documentation.d.ts 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979
  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. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module BABYLON {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module BABYLON {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module BABYLON {
  409. /**
  410. * Interface used to define the mechanism to get data from the network
  411. */
  412. export interface IWebRequest {
  413. /**
  414. * Returns client's response url
  415. */
  416. responseURL: string;
  417. /**
  418. * Returns client's status
  419. */
  420. status: number;
  421. /**
  422. * Returns client's status as a text
  423. */
  424. statusText: string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  430. */
  431. export class WebRequest implements IWebRequest {
  432. private _xhr;
  433. /**
  434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  435. * i.e. when loading files, where the server/service expects an Authorization header
  436. */
  437. static CustomRequestHeaders: {
  438. [key: string]: string;
  439. };
  440. /**
  441. * Add callback functions in this array to update all the requests before they get sent to the network
  442. */
  443. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  444. private _injectCustomRequestHeaders;
  445. /**
  446. * Gets or sets a function to be called when loading progress changes
  447. */
  448. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  449. /**
  450. * Returns client's state
  451. */
  452. readonly readyState: number;
  453. /**
  454. * Returns client's status
  455. */
  456. readonly status: number;
  457. /**
  458. * Returns client's status as a text
  459. */
  460. readonly statusText: string;
  461. /**
  462. * Returns client's response
  463. */
  464. readonly response: any;
  465. /**
  466. * Returns client's response url
  467. */
  468. readonly responseURL: string;
  469. /**
  470. * Returns client's response as text
  471. */
  472. readonly responseText: string;
  473. /**
  474. * Gets or sets the expected response type
  475. */
  476. responseType: XMLHttpRequestResponseType;
  477. /** @hidden */
  478. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  479. /** @hidden */
  480. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  481. /**
  482. * Cancels any network activity
  483. */
  484. abort(): void;
  485. /**
  486. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  487. * @param body defines an optional request body
  488. */
  489. send(body?: Document | BodyInit | null): void;
  490. /**
  491. * Sets the request method, request URL
  492. * @param method defines the method to use (GET, POST, etc..)
  493. * @param url defines the url to connect with
  494. */
  495. open(method: string, url: string): void;
  496. /**
  497. * Sets the value of a request header.
  498. * @param name The name of the header whose value is to be set
  499. * @param value The value to set as the body of the header
  500. */
  501. setRequestHeader(name: string, value: string): void;
  502. /**
  503. * Get the string containing the text of a particular header's value.
  504. * @param name The name of the header
  505. * @returns The string containing the text of the given header name
  506. */
  507. getResponseHeader(name: string): Nullable<string>;
  508. }
  509. }
  510. declare module BABYLON {
  511. /**
  512. * File request interface
  513. */
  514. export interface IFileRequest {
  515. /**
  516. * Raised when the request is complete (success or error).
  517. */
  518. onCompleteObservable: Observable<IFileRequest>;
  519. /**
  520. * Aborts the request for a file.
  521. */
  522. abort: () => void;
  523. }
  524. }
  525. declare module BABYLON {
  526. /**
  527. * Define options used to create a render target texture
  528. */
  529. export class RenderTargetCreationOptions {
  530. /**
  531. * Specifies is mipmaps must be generated
  532. */
  533. generateMipMaps?: boolean;
  534. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  535. generateDepthBuffer?: boolean;
  536. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  537. generateStencilBuffer?: boolean;
  538. /** Defines texture type (int by default) */
  539. type?: number;
  540. /** Defines sampling mode (trilinear by default) */
  541. samplingMode?: number;
  542. /** Defines format (RGBA by default) */
  543. format?: number;
  544. }
  545. }
  546. declare module BABYLON {
  547. /**
  548. * @hidden
  549. **/
  550. export class _TimeToken {
  551. _startTimeQuery: Nullable<WebGLQuery>;
  552. _endTimeQuery: Nullable<WebGLQuery>;
  553. _timeElapsedQuery: Nullable<WebGLQuery>;
  554. _timeElapsedQueryEnded: boolean;
  555. }
  556. }
  557. declare module BABYLON {
  558. /** Defines the cross module used constants to avoid circular dependncies */
  559. export class Constants {
  560. /** Defines that alpha blending is disabled */
  561. static readonly ALPHA_DISABLE: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  563. static readonly ALPHA_ADD: number;
  564. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  565. static readonly ALPHA_COMBINE: number;
  566. /** Defines that alpha blending to DEST - SRC * DEST */
  567. static readonly ALPHA_SUBTRACT: number;
  568. /** Defines that alpha blending to SRC * DEST */
  569. static readonly ALPHA_MULTIPLY: number;
  570. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  571. static readonly ALPHA_MAXIMIZED: number;
  572. /** Defines that alpha blending to SRC + DEST */
  573. static readonly ALPHA_ONEONE: number;
  574. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  575. static readonly ALPHA_PREMULTIPLIED: number;
  576. /**
  577. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  578. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  579. */
  580. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  581. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  582. static readonly ALPHA_INTERPOLATE: number;
  583. /**
  584. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  585. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  586. */
  587. static readonly ALPHA_SCREENMODE: number;
  588. /**
  589. * Defines that alpha blending to SRC + DST
  590. * Alpha will be set to SRC ALPHA + DST ALPHA
  591. */
  592. static readonly ALPHA_ONEONE_ONEONE: number;
  593. /**
  594. * Defines that alpha blending to SRC * DST ALPHA + DST
  595. * Alpha will be set to 0
  596. */
  597. static readonly ALPHA_ALPHATOCOLOR: number;
  598. /**
  599. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  600. */
  601. static readonly ALPHA_REVERSEONEMINUS: number;
  602. /**
  603. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  604. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  605. */
  606. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  607. /**
  608. * Defines that alpha blending to SRC + DST
  609. * Alpha will be set to SRC ALPHA
  610. */
  611. static readonly ALPHA_ONEONE_ONEZERO: number;
  612. /** Defines that alpha blending equation a SUM */
  613. static readonly ALPHA_EQUATION_ADD: number;
  614. /** Defines that alpha blending equation a SUBSTRACTION */
  615. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  616. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  617. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  618. /** Defines that alpha blending equation a MAX operation */
  619. static readonly ALPHA_EQUATION_MAX: number;
  620. /** Defines that alpha blending equation a MIN operation */
  621. static readonly ALPHA_EQUATION_MIN: number;
  622. /**
  623. * Defines that alpha blending equation a DARKEN operation:
  624. * It takes the min of the src and sums the alpha channels.
  625. */
  626. static readonly ALPHA_EQUATION_DARKEN: number;
  627. /** Defines that the ressource is not delayed*/
  628. static readonly DELAYLOADSTATE_NONE: number;
  629. /** Defines that the ressource was successfully delay loaded */
  630. static readonly DELAYLOADSTATE_LOADED: number;
  631. /** Defines that the ressource is currently delay loading */
  632. static readonly DELAYLOADSTATE_LOADING: number;
  633. /** Defines that the ressource is delayed and has not started loading */
  634. static readonly DELAYLOADSTATE_NOTLOADED: number;
  635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  636. static readonly NEVER: number;
  637. /** 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 */
  638. static readonly ALWAYS: number;
  639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  640. static readonly LESS: number;
  641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  642. static readonly EQUAL: number;
  643. /** 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 */
  644. static readonly LEQUAL: number;
  645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  646. static readonly GREATER: number;
  647. /** 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 */
  648. static readonly GEQUAL: number;
  649. /** 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 */
  650. static readonly NOTEQUAL: number;
  651. /** Passed to stencilOperation to specify that stencil value must be kept */
  652. static readonly KEEP: number;
  653. /** Passed to stencilOperation to specify that stencil value must be replaced */
  654. static readonly REPLACE: number;
  655. /** Passed to stencilOperation to specify that stencil value must be incremented */
  656. static readonly INCR: number;
  657. /** Passed to stencilOperation to specify that stencil value must be decremented */
  658. static readonly DECR: number;
  659. /** Passed to stencilOperation to specify that stencil value must be inverted */
  660. static readonly INVERT: number;
  661. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  662. static readonly INCR_WRAP: number;
  663. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  664. static readonly DECR_WRAP: number;
  665. /** Texture is not repeating outside of 0..1 UVs */
  666. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  667. /** Texture is repeating outside of 0..1 UVs */
  668. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  669. /** Texture is repeating and mirrored */
  670. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  671. /** ALPHA */
  672. static readonly TEXTUREFORMAT_ALPHA: number;
  673. /** LUMINANCE */
  674. static readonly TEXTUREFORMAT_LUMINANCE: number;
  675. /** LUMINANCE_ALPHA */
  676. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  677. /** RGB */
  678. static readonly TEXTUREFORMAT_RGB: number;
  679. /** RGBA */
  680. static readonly TEXTUREFORMAT_RGBA: number;
  681. /** RED */
  682. static readonly TEXTUREFORMAT_RED: number;
  683. /** RED (2nd reference) */
  684. static readonly TEXTUREFORMAT_R: number;
  685. /** RG */
  686. static readonly TEXTUREFORMAT_RG: number;
  687. /** RED_INTEGER */
  688. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  689. /** RED_INTEGER (2nd reference) */
  690. static readonly TEXTUREFORMAT_R_INTEGER: number;
  691. /** RG_INTEGER */
  692. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  693. /** RGB_INTEGER */
  694. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  695. /** RGBA_INTEGER */
  696. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  697. /** UNSIGNED_BYTE */
  698. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  699. /** UNSIGNED_BYTE (2nd reference) */
  700. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  701. /** FLOAT */
  702. static readonly TEXTURETYPE_FLOAT: number;
  703. /** HALF_FLOAT */
  704. static readonly TEXTURETYPE_HALF_FLOAT: number;
  705. /** BYTE */
  706. static readonly TEXTURETYPE_BYTE: number;
  707. /** SHORT */
  708. static readonly TEXTURETYPE_SHORT: number;
  709. /** UNSIGNED_SHORT */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  711. /** INT */
  712. static readonly TEXTURETYPE_INT: number;
  713. /** UNSIGNED_INT */
  714. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  715. /** UNSIGNED_SHORT_4_4_4_4 */
  716. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  717. /** UNSIGNED_SHORT_5_5_5_1 */
  718. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  719. /** UNSIGNED_SHORT_5_6_5 */
  720. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  721. /** UNSIGNED_INT_2_10_10_10_REV */
  722. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  723. /** UNSIGNED_INT_24_8 */
  724. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  725. /** UNSIGNED_INT_10F_11F_11F_REV */
  726. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  727. /** UNSIGNED_INT_5_9_9_9_REV */
  728. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  729. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  730. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  731. /** nearest is mag = nearest and min = nearest and mip = linear */
  732. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  733. /** Bilinear is mag = linear and min = linear and mip = nearest */
  734. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  735. /** Trilinear is mag = linear and min = linear and mip = linear */
  736. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  737. /** nearest is mag = nearest and min = nearest and mip = linear */
  738. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  739. /** Bilinear is mag = linear and min = linear and mip = nearest */
  740. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  741. /** Trilinear is mag = linear and min = linear and mip = linear */
  742. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  743. /** mag = nearest and min = nearest and mip = nearest */
  744. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  745. /** mag = nearest and min = linear and mip = nearest */
  746. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  747. /** mag = nearest and min = linear and mip = linear */
  748. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  749. /** mag = nearest and min = linear and mip = none */
  750. static readonly TEXTURE_NEAREST_LINEAR: number;
  751. /** mag = nearest and min = nearest and mip = none */
  752. static readonly TEXTURE_NEAREST_NEAREST: number;
  753. /** mag = linear and min = nearest and mip = nearest */
  754. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  755. /** mag = linear and min = nearest and mip = linear */
  756. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  757. /** mag = linear and min = linear and mip = none */
  758. static readonly TEXTURE_LINEAR_LINEAR: number;
  759. /** mag = linear and min = nearest and mip = none */
  760. static readonly TEXTURE_LINEAR_NEAREST: number;
  761. /** Explicit coordinates mode */
  762. static readonly TEXTURE_EXPLICIT_MODE: number;
  763. /** Spherical coordinates mode */
  764. static readonly TEXTURE_SPHERICAL_MODE: number;
  765. /** Planar coordinates mode */
  766. static readonly TEXTURE_PLANAR_MODE: number;
  767. /** Cubic coordinates mode */
  768. static readonly TEXTURE_CUBIC_MODE: number;
  769. /** Projection coordinates mode */
  770. static readonly TEXTURE_PROJECTION_MODE: number;
  771. /** Skybox coordinates mode */
  772. static readonly TEXTURE_SKYBOX_MODE: number;
  773. /** Inverse Cubic coordinates mode */
  774. static readonly TEXTURE_INVCUBIC_MODE: number;
  775. /** Equirectangular coordinates mode */
  776. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  777. /** Equirectangular Fixed coordinates mode */
  778. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  779. /** Equirectangular Fixed Mirrored coordinates mode */
  780. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  781. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  782. static readonly SCALEMODE_FLOOR: number;
  783. /** Defines that texture rescaling will look for the nearest power of 2 size */
  784. static readonly SCALEMODE_NEAREST: number;
  785. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  786. static readonly SCALEMODE_CEILING: number;
  787. /**
  788. * The dirty texture flag value
  789. */
  790. static readonly MATERIAL_TextureDirtyFlag: number;
  791. /**
  792. * The dirty light flag value
  793. */
  794. static readonly MATERIAL_LightDirtyFlag: number;
  795. /**
  796. * The dirty fresnel flag value
  797. */
  798. static readonly MATERIAL_FresnelDirtyFlag: number;
  799. /**
  800. * The dirty attribute flag value
  801. */
  802. static readonly MATERIAL_AttributesDirtyFlag: number;
  803. /**
  804. * The dirty misc flag value
  805. */
  806. static readonly MATERIAL_MiscDirtyFlag: number;
  807. /**
  808. * The all dirty flag value
  809. */
  810. static readonly MATERIAL_AllDirtyFlag: number;
  811. /**
  812. * Returns the triangle fill mode
  813. */
  814. static readonly MATERIAL_TriangleFillMode: number;
  815. /**
  816. * Returns the wireframe mode
  817. */
  818. static readonly MATERIAL_WireFrameFillMode: number;
  819. /**
  820. * Returns the point fill mode
  821. */
  822. static readonly MATERIAL_PointFillMode: number;
  823. /**
  824. * Returns the point list draw mode
  825. */
  826. static readonly MATERIAL_PointListDrawMode: number;
  827. /**
  828. * Returns the line list draw mode
  829. */
  830. static readonly MATERIAL_LineListDrawMode: number;
  831. /**
  832. * Returns the line loop draw mode
  833. */
  834. static readonly MATERIAL_LineLoopDrawMode: number;
  835. /**
  836. * Returns the line strip draw mode
  837. */
  838. static readonly MATERIAL_LineStripDrawMode: number;
  839. /**
  840. * Returns the triangle strip draw mode
  841. */
  842. static readonly MATERIAL_TriangleStripDrawMode: number;
  843. /**
  844. * Returns the triangle fan draw mode
  845. */
  846. static readonly MATERIAL_TriangleFanDrawMode: number;
  847. /**
  848. * Stores the clock-wise side orientation
  849. */
  850. static readonly MATERIAL_ClockWiseSideOrientation: number;
  851. /**
  852. * Stores the counter clock-wise side orientation
  853. */
  854. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  855. /**
  856. * Nothing
  857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  858. */
  859. static readonly ACTION_NothingTrigger: number;
  860. /**
  861. * On pick
  862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  863. */
  864. static readonly ACTION_OnPickTrigger: number;
  865. /**
  866. * On left pick
  867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  868. */
  869. static readonly ACTION_OnLeftPickTrigger: number;
  870. /**
  871. * On right pick
  872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  873. */
  874. static readonly ACTION_OnRightPickTrigger: number;
  875. /**
  876. * On center pick
  877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  878. */
  879. static readonly ACTION_OnCenterPickTrigger: number;
  880. /**
  881. * On pick down
  882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  883. */
  884. static readonly ACTION_OnPickDownTrigger: number;
  885. /**
  886. * On double pick
  887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  888. */
  889. static readonly ACTION_OnDoublePickTrigger: number;
  890. /**
  891. * On pick up
  892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  893. */
  894. static readonly ACTION_OnPickUpTrigger: number;
  895. /**
  896. * On pick out.
  897. * This trigger will only be raised if you also declared a OnPickDown
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickOutTrigger: number;
  901. /**
  902. * On long press
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLongPressTrigger: number;
  906. /**
  907. * On pointer over
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnPointerOverTrigger: number;
  911. /**
  912. * On pointer out
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnPointerOutTrigger: number;
  916. /**
  917. * On every frame
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnEveryFrameTrigger: number;
  921. /**
  922. * On intersection enter
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnIntersectionEnterTrigger: number;
  926. /**
  927. * On intersection exit
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnIntersectionExitTrigger: number;
  931. /**
  932. * On key down
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnKeyDownTrigger: number;
  936. /**
  937. * On key up
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnKeyUpTrigger: number;
  941. /**
  942. * Billboard mode will only apply to Y axis
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  945. /**
  946. * Billboard mode will apply to all axes
  947. */
  948. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  949. /**
  950. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  951. */
  952. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  953. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  954. * Test order :
  955. * Is the bounding sphere outside the frustum ?
  956. * If not, are the bounding box vertices outside the frustum ?
  957. * It not, then the cullable object is in the frustum.
  958. */
  959. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  960. /** Culling strategy : Bounding Sphere Only.
  961. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  962. * It's also less accurate than the standard because some not visible objects can still be selected.
  963. * Test : is the bounding sphere outside the frustum ?
  964. * If not, then the cullable object is in the frustum.
  965. */
  966. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  967. /** Culling strategy : Optimistic Inclusion.
  968. * This in an inclusion test first, then the standard exclusion test.
  969. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  970. * 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.
  971. * Anyway, it's as accurate as the standard strategy.
  972. * Test :
  973. * Is the cullable object bounding sphere center in the frustum ?
  974. * If not, apply the default culling strategy.
  975. */
  976. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  977. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  978. * This in an inclusion test first, then the bounding sphere only exclusion test.
  979. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  980. * 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.
  981. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  982. * Test :
  983. * Is the cullable object bounding sphere center in the frustum ?
  984. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  985. */
  986. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  987. /**
  988. * No logging while loading
  989. */
  990. static readonly SCENELOADER_NO_LOGGING: number;
  991. /**
  992. * Minimal logging while loading
  993. */
  994. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  995. /**
  996. * Summary logging while loading
  997. */
  998. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  999. /**
  1000. * Detailled logging while loading
  1001. */
  1002. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1003. }
  1004. }
  1005. declare module BABYLON {
  1006. /**
  1007. * This represents the required contract to create a new type of texture loader.
  1008. */
  1009. export interface IInternalTextureLoader {
  1010. /**
  1011. * Defines wether the loader supports cascade loading the different faces.
  1012. */
  1013. supportCascades: boolean;
  1014. /**
  1015. * This returns if the loader support the current file information.
  1016. * @param extension defines the file extension of the file being loaded
  1017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1018. * @param fallback defines the fallback internal texture if any
  1019. * @param isBase64 defines whether the texture is encoded as a base64
  1020. * @param isBuffer defines whether the texture data are stored as a buffer
  1021. * @returns true if the loader can load the specified file
  1022. */
  1023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1024. /**
  1025. * Transform the url before loading if required.
  1026. * @param rootUrl the url of the texture
  1027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1028. * @returns the transformed texture
  1029. */
  1030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1031. /**
  1032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1033. * @param rootUrl the url of the texture
  1034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1035. * @returns the fallback texture
  1036. */
  1037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1038. /**
  1039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1040. * @param data contains the texture data
  1041. * @param texture defines the BabylonJS internal texture
  1042. * @param createPolynomials will be true if polynomials have been requested
  1043. * @param onLoad defines the callback to trigger once the texture is ready
  1044. * @param onError defines the callback to trigger in case of error
  1045. */
  1046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1047. /**
  1048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1049. * @param data contains the texture data
  1050. * @param texture defines the BabylonJS internal texture
  1051. * @param callback defines the method to call once ready to upload
  1052. */
  1053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1054. }
  1055. }
  1056. declare module BABYLON {
  1057. /**
  1058. * Class used to store and describe the pipeline context associated with an effect
  1059. */
  1060. export interface IPipelineContext {
  1061. /**
  1062. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1063. */
  1064. isAsync: boolean;
  1065. /**
  1066. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1067. */
  1068. isReady: boolean;
  1069. /** @hidden */
  1070. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1071. }
  1072. }
  1073. declare module BABYLON {
  1074. /**
  1075. * Class used to store gfx data (like WebGLBuffer)
  1076. */
  1077. export class DataBuffer {
  1078. /**
  1079. * Gets or sets the number of objects referencing this buffer
  1080. */
  1081. references: number;
  1082. /** Gets or sets the size of the underlying buffer */
  1083. capacity: number;
  1084. /**
  1085. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1086. */
  1087. is32Bits: boolean;
  1088. /**
  1089. * Gets the underlying buffer
  1090. */
  1091. readonly underlyingResource: any;
  1092. }
  1093. }
  1094. declare module BABYLON {
  1095. /** @hidden */
  1096. export interface IShaderProcessor {
  1097. attributeProcessor?: (attribute: string) => string;
  1098. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1099. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1100. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1101. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1102. lineProcessor?: (line: string, isFragment: boolean) => string;
  1103. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1104. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1105. }
  1106. }
  1107. declare module BABYLON {
  1108. /** @hidden */
  1109. export interface ProcessingOptions {
  1110. defines: string[];
  1111. indexParameters: any;
  1112. isFragment: boolean;
  1113. shouldUseHighPrecisionShader: boolean;
  1114. supportsUniformBuffers: boolean;
  1115. shadersRepository: string;
  1116. includesShadersStore: {
  1117. [key: string]: string;
  1118. };
  1119. processor?: IShaderProcessor;
  1120. version: string;
  1121. platformName: string;
  1122. lookForClosingBracketForUniformBuffer?: boolean;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Helper to manipulate strings
  1128. */
  1129. export class StringTools {
  1130. /**
  1131. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1132. * @param str Source string
  1133. * @param suffix Suffix to search for in the source string
  1134. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1135. */
  1136. static EndsWith(str: string, suffix: string): boolean;
  1137. /**
  1138. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1139. * @param str Source string
  1140. * @param suffix Suffix to search for in the source string
  1141. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1142. */
  1143. static StartsWith(str: string, suffix: string): boolean;
  1144. /**
  1145. * Decodes a buffer into a string
  1146. * @param buffer The buffer to decode
  1147. * @returns The decoded string
  1148. */
  1149. static Decode(buffer: Uint8Array | Uint16Array): string;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. readonly currentLine: string;
  1173. readonly canRead: boolean;
  1174. lines: string[];
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderCodeTestNode extends ShaderCodeNode {
  1196. testExpression: ShaderDefineExpression;
  1197. isValid(preprocessors: {
  1198. [key: string]: string;
  1199. }): boolean;
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1205. define: string;
  1206. not: boolean;
  1207. constructor(define: string, not?: boolean);
  1208. isTrue(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1226. leftOperand: ShaderDefineExpression;
  1227. rightOperand: ShaderDefineExpression;
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module BABYLON {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module BABYLON {
  1297. /**
  1298. * Class used to define a retry strategy when error happens while loading assets
  1299. */
  1300. export class RetryStrategy {
  1301. /**
  1302. * Function used to defines an exponential back off strategy
  1303. * @param maxRetries defines the maximum number of retries (3 by default)
  1304. * @param baseInterval defines the interval between retries
  1305. * @returns the strategy function to use
  1306. */
  1307. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1308. }
  1309. }
  1310. declare module BABYLON {
  1311. /**
  1312. * @ignore
  1313. * Application error to support additional information when loading a file
  1314. */
  1315. export abstract class BaseError extends Error {
  1316. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1317. }
  1318. }
  1319. declare module BABYLON {
  1320. /** @ignore */
  1321. export class LoadFileError extends BaseError {
  1322. request?: WebRequest;
  1323. file?: File;
  1324. /**
  1325. * Creates a new LoadFileError
  1326. * @param message defines the message of the error
  1327. * @param request defines the optional web request
  1328. * @param file defines the optional file
  1329. */
  1330. constructor(message: string, object?: WebRequest | File);
  1331. }
  1332. /** @ignore */
  1333. export class RequestFileError extends BaseError {
  1334. request: WebRequest;
  1335. /**
  1336. * Creates a new LoadFileError
  1337. * @param message defines the message of the error
  1338. * @param request defines the optional web request
  1339. */
  1340. constructor(message: string, request: WebRequest);
  1341. }
  1342. /** @ignore */
  1343. export class ReadFileError extends BaseError {
  1344. file: File;
  1345. /**
  1346. * Creates a new ReadFileError
  1347. * @param message defines the message of the error
  1348. * @param file defines the optional file
  1349. */
  1350. constructor(message: string, file: File);
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export class FileTools {
  1356. /**
  1357. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1358. */
  1359. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1360. /**
  1361. * Gets or sets the base URL to use to load assets
  1362. */
  1363. static BaseUrl: string;
  1364. /**
  1365. * Default behaviour for cors in the application.
  1366. * It can be a string if the expected behavior is identical in the entire app.
  1367. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1368. */
  1369. static CorsBehavior: string | ((url: string | string[]) => string);
  1370. /**
  1371. * Gets or sets a function used to pre-process url before using them to load assets
  1372. */
  1373. static PreprocessUrl: (url: string) => string;
  1374. /**
  1375. * Removes unwanted characters from an url
  1376. * @param url defines the url to clean
  1377. * @returns the cleaned url
  1378. */
  1379. private static _CleanUrl;
  1380. /**
  1381. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1382. * @param url define the url we are trying
  1383. * @param element define the dom element where to configure the cors policy
  1384. */
  1385. static SetCorsBehavior(url: string | string[], element: {
  1386. crossOrigin: string | null;
  1387. }): void;
  1388. private static _ArrayBufferToBase64;
  1389. /**
  1390. * Loads an image as an HTMLImageElement.
  1391. * @param input url string, ArrayBuffer, or Blob to load
  1392. * @param onLoad callback called when the image successfully loads
  1393. * @param onError callback called when the image fails to load
  1394. * @param offlineProvider offline provider for caching
  1395. * @param mimeType optional mime type
  1396. * @returns the HTMLImageElement of the loaded image
  1397. */
  1398. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1399. /**
  1400. * Reads a file from a File object
  1401. * @param file defines the file to load
  1402. * @param onSuccess defines the callback to call when data is loaded
  1403. * @param onProgress defines the callback to call during loading process
  1404. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1405. * @param onError defines the callback to call when an error occurs
  1406. * @returns a file request object
  1407. */
  1408. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1409. /**
  1410. * Loads a file from a url
  1411. * @param url url to load
  1412. * @param onSuccess callback called when the file successfully loads
  1413. * @param onProgress callback called while file is loading (if the server supports this mode)
  1414. * @param offlineProvider defines the offline provider for caching
  1415. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1416. * @param onError callback called when the file fails to load
  1417. * @returns a file request object
  1418. */
  1419. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1426. * @param onError callback called when the file fails to load
  1427. * @param onOpened callback called when the web request is opened
  1428. * @returns a file request object
  1429. */
  1430. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1431. /**
  1432. * Checks if the loaded document was accessed via `file:`-Protocol.
  1433. * @returns boolean
  1434. */
  1435. static IsFileURL(): boolean;
  1436. }
  1437. }
  1438. declare module BABYLON {
  1439. /** @hidden */
  1440. export class ShaderProcessor {
  1441. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1442. private static _ProcessPrecision;
  1443. private static _ExtractOperation;
  1444. private static _BuildSubExpression;
  1445. private static _BuildExpression;
  1446. private static _MoveCursorWithinIf;
  1447. private static _MoveCursor;
  1448. private static _EvaluatePreProcessors;
  1449. private static _PreparePreProcessors;
  1450. private static _ProcessShaderConversion;
  1451. private static _ProcessIncludes;
  1452. }
  1453. }
  1454. declare module BABYLON {
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IColor4Like {
  1459. r: float;
  1460. g: float;
  1461. b: float;
  1462. a: float;
  1463. }
  1464. /**
  1465. * @hidden
  1466. */
  1467. export interface IColor3Like {
  1468. r: float;
  1469. g: float;
  1470. b: float;
  1471. }
  1472. /**
  1473. * @hidden
  1474. */
  1475. export interface IVector4Like {
  1476. x: float;
  1477. y: float;
  1478. z: float;
  1479. w: float;
  1480. }
  1481. /**
  1482. * @hidden
  1483. */
  1484. export interface IVector3Like {
  1485. x: float;
  1486. y: float;
  1487. z: float;
  1488. }
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IVector2Like {
  1493. x: float;
  1494. y: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IMatrixLike {
  1500. toArray(): DeepImmutable<Float32Array>;
  1501. updateFlag: int;
  1502. }
  1503. /**
  1504. * @hidden
  1505. */
  1506. export interface IViewportLike {
  1507. x: float;
  1508. y: float;
  1509. width: float;
  1510. height: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IPlaneLike {
  1516. normal: IVector3Like;
  1517. d: float;
  1518. normalize(): void;
  1519. }
  1520. }
  1521. declare module BABYLON {
  1522. /**
  1523. * Interface used to define common properties for effect fallbacks
  1524. */
  1525. export interface IEffectFallbacks {
  1526. /**
  1527. * Removes the defines that should be removed when falling back.
  1528. * @param currentDefines defines the current define statements for the shader.
  1529. * @param effect defines the current effect we try to compile
  1530. * @returns The resulting defines with defines of the current rank removed.
  1531. */
  1532. reduce(currentDefines: string, effect: Effect): string;
  1533. /**
  1534. * Removes the fallback from the bound mesh.
  1535. */
  1536. unBindMesh(): void;
  1537. /**
  1538. * Checks to see if more fallbacks are still availible.
  1539. */
  1540. hasMoreFallbacks: boolean;
  1541. }
  1542. }
  1543. declare module BABYLON {
  1544. /**
  1545. * Class used to evalaute queries containing `and` and `or` operators
  1546. */
  1547. export class AndOrNotEvaluator {
  1548. /**
  1549. * Evaluate a query
  1550. * @param query defines the query to evaluate
  1551. * @param evaluateCallback defines the callback used to filter result
  1552. * @returns true if the query matches
  1553. */
  1554. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1555. private static _HandleParenthesisContent;
  1556. private static _SimplifyNegation;
  1557. }
  1558. }
  1559. declare module BABYLON {
  1560. /**
  1561. * Class used to store custom tags
  1562. */
  1563. export class Tags {
  1564. /**
  1565. * Adds support for tags on the given object
  1566. * @param obj defines the object to use
  1567. */
  1568. static EnableFor(obj: any): void;
  1569. /**
  1570. * Removes tags support
  1571. * @param obj defines the object to use
  1572. */
  1573. static DisableFor(obj: any): void;
  1574. /**
  1575. * Gets a boolean indicating if the given object has tags
  1576. * @param obj defines the object to use
  1577. * @returns a boolean
  1578. */
  1579. static HasTags(obj: any): boolean;
  1580. /**
  1581. * Gets the tags available on a given object
  1582. * @param obj defines the object to use
  1583. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1584. * @returns the tags
  1585. */
  1586. static GetTags(obj: any, asString?: boolean): any;
  1587. /**
  1588. * Adds tags to an object
  1589. * @param obj defines the object to use
  1590. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1591. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1592. */
  1593. static AddTagsTo(obj: any, tagsString: string): void;
  1594. /**
  1595. * @hidden
  1596. */
  1597. static _AddTagTo(obj: any, tag: string): void;
  1598. /**
  1599. * Removes specific tags from a specific object
  1600. * @param obj defines the object to use
  1601. * @param tagsString defines the tags to remove
  1602. */
  1603. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _RemoveTagFrom(obj: any, tag: string): void;
  1608. /**
  1609. * Defines if tags hosted on an object match a given query
  1610. * @param obj defines the object to use
  1611. * @param tagsQuery defines the tag query
  1612. * @returns a boolean
  1613. */
  1614. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /**
  1619. * Scalar computation library
  1620. */
  1621. export class Scalar {
  1622. /**
  1623. * Two pi constants convenient for computation.
  1624. */
  1625. static TwoPi: number;
  1626. /**
  1627. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1628. * @param a number
  1629. * @param b number
  1630. * @param epsilon (default = 1.401298E-45)
  1631. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1632. */
  1633. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1634. /**
  1635. * Returns a string : the upper case translation of the number i to hexadecimal.
  1636. * @param i number
  1637. * @returns the upper case translation of the number i to hexadecimal.
  1638. */
  1639. static ToHex(i: number): string;
  1640. /**
  1641. * Returns -1 if value is negative and +1 is value is positive.
  1642. * @param value the value
  1643. * @returns the value itself if it's equal to zero.
  1644. */
  1645. static Sign(value: number): number;
  1646. /**
  1647. * Returns the value itself if it's between min and max.
  1648. * Returns min if the value is lower than min.
  1649. * Returns max if the value is greater than max.
  1650. * @param value the value to clmap
  1651. * @param min the min value to clamp to (default: 0)
  1652. * @param max the max value to clamp to (default: 1)
  1653. * @returns the clamped value
  1654. */
  1655. static Clamp(value: number, min?: number, max?: number): number;
  1656. /**
  1657. * the log2 of value.
  1658. * @param value the value to compute log2 of
  1659. * @returns the log2 of value.
  1660. */
  1661. static Log2(value: number): number;
  1662. /**
  1663. * Loops the value, so that it is never larger than length and never smaller than 0.
  1664. *
  1665. * This is similar to the modulo operator but it works with floating point numbers.
  1666. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1667. * With t = 5 and length = 2.5, the result would be 0.0.
  1668. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1669. * @param value the value
  1670. * @param length the length
  1671. * @returns the looped value
  1672. */
  1673. static Repeat(value: number, length: number): number;
  1674. /**
  1675. * Normalize the value between 0.0 and 1.0 using min and max values
  1676. * @param value value to normalize
  1677. * @param min max to normalize between
  1678. * @param max min to normalize between
  1679. * @returns the normalized value
  1680. */
  1681. static Normalize(value: number, min: number, max: number): number;
  1682. /**
  1683. * Denormalize the value from 0.0 and 1.0 using min and max values
  1684. * @param normalized value to denormalize
  1685. * @param min max to denormalize between
  1686. * @param max min to denormalize between
  1687. * @returns the denormalized value
  1688. */
  1689. static Denormalize(normalized: number, min: number, max: number): number;
  1690. /**
  1691. * Calculates the shortest difference between two given angles given in degrees.
  1692. * @param current current angle in degrees
  1693. * @param target target angle in degrees
  1694. * @returns the delta
  1695. */
  1696. static DeltaAngle(current: number, target: number): number;
  1697. /**
  1698. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1699. * @param tx value
  1700. * @param length length
  1701. * @returns The returned value will move back and forth between 0 and length
  1702. */
  1703. static PingPong(tx: number, length: number): number;
  1704. /**
  1705. * Interpolates between min and max with smoothing at the limits.
  1706. *
  1707. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1708. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1709. * @param from from
  1710. * @param to to
  1711. * @param tx value
  1712. * @returns the smooth stepped value
  1713. */
  1714. static SmoothStep(from: number, to: number, tx: number): number;
  1715. /**
  1716. * Moves a value current towards target.
  1717. *
  1718. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1719. * Negative values of maxDelta pushes the value away from target.
  1720. * @param current current value
  1721. * @param target target value
  1722. * @param maxDelta max distance to move
  1723. * @returns resulting value
  1724. */
  1725. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1726. /**
  1727. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1728. *
  1729. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1730. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1731. * @param current current value
  1732. * @param target target value
  1733. * @param maxDelta max distance to move
  1734. * @returns resulting angle
  1735. */
  1736. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1737. /**
  1738. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1739. * @param start start value
  1740. * @param end target value
  1741. * @param amount amount to lerp between
  1742. * @returns the lerped value
  1743. */
  1744. static Lerp(start: number, end: number, amount: number): number;
  1745. /**
  1746. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1747. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1748. * @param start start value
  1749. * @param end target value
  1750. * @param amount amount to lerp between
  1751. * @returns the lerped value
  1752. */
  1753. static LerpAngle(start: number, end: number, amount: number): number;
  1754. /**
  1755. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1756. * @param a start value
  1757. * @param b target value
  1758. * @param value value between a and b
  1759. * @returns the inverseLerp value
  1760. */
  1761. static InverseLerp(a: number, b: number, value: number): number;
  1762. /**
  1763. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1764. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1765. * @param value1 spline value
  1766. * @param tangent1 spline value
  1767. * @param value2 spline value
  1768. * @param tangent2 spline value
  1769. * @param amount input value
  1770. * @returns hermite result
  1771. */
  1772. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1773. /**
  1774. * Returns a random float number between and min and max values
  1775. * @param min min value of random
  1776. * @param max max value of random
  1777. * @returns random value
  1778. */
  1779. static RandomRange(min: number, max: number): number;
  1780. /**
  1781. * This function returns percentage of a number in a given range.
  1782. *
  1783. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1784. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1785. * @param number to convert to percentage
  1786. * @param min min range
  1787. * @param max max range
  1788. * @returns the percentage
  1789. */
  1790. static RangeToPercent(number: number, min: number, max: number): number;
  1791. /**
  1792. * This function returns number that corresponds to the percentage in a given range.
  1793. *
  1794. * PercentToRange(0.34,0,100) will return 34.
  1795. * @param percent to convert to number
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the number
  1799. */
  1800. static PercentToRange(percent: number, min: number, max: number): number;
  1801. /**
  1802. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1803. * @param angle The angle to normalize in radian.
  1804. * @return The converted angle.
  1805. */
  1806. static NormalizeRadians(angle: number): number;
  1807. }
  1808. }
  1809. declare module BABYLON {
  1810. /**
  1811. * Constant used to convert a value to gamma space
  1812. * @ignorenaming
  1813. */
  1814. export const ToGammaSpace: number;
  1815. /**
  1816. * Constant used to convert a value to linear space
  1817. * @ignorenaming
  1818. */
  1819. export const ToLinearSpace = 2.2;
  1820. /**
  1821. * Constant used to define the minimal number value in Babylon.js
  1822. * @ignorenaming
  1823. */
  1824. let Epsilon: number;
  1825. }
  1826. declare module BABYLON {
  1827. /**
  1828. * Class used to represent a viewport on screen
  1829. */
  1830. export class Viewport {
  1831. /** viewport left coordinate */
  1832. x: number;
  1833. /** viewport top coordinate */
  1834. y: number;
  1835. /**viewport width */
  1836. width: number;
  1837. /** viewport height */
  1838. height: number;
  1839. /**
  1840. * Creates a Viewport object located at (x, y) and sized (width, height)
  1841. * @param x defines viewport left coordinate
  1842. * @param y defines viewport top coordinate
  1843. * @param width defines the viewport width
  1844. * @param height defines the viewport height
  1845. */
  1846. constructor(
  1847. /** viewport left coordinate */
  1848. x: number,
  1849. /** viewport top coordinate */
  1850. y: number,
  1851. /**viewport width */
  1852. width: number,
  1853. /** viewport height */
  1854. height: number);
  1855. /**
  1856. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1857. * @param renderWidth defines the rendering width
  1858. * @param renderHeight defines the rendering height
  1859. * @returns a new Viewport
  1860. */
  1861. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1862. /**
  1863. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1864. * @param renderWidth defines the rendering width
  1865. * @param renderHeight defines the rendering height
  1866. * @param ref defines the target viewport
  1867. * @returns the current viewport
  1868. */
  1869. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1870. /**
  1871. * Returns a new Viewport copied from the current one
  1872. * @returns a new Viewport
  1873. */
  1874. clone(): Viewport;
  1875. }
  1876. }
  1877. declare module BABYLON {
  1878. /**
  1879. * Class containing a set of static utilities functions for arrays.
  1880. */
  1881. export class ArrayTools {
  1882. /**
  1883. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1884. * @param size the number of element to construct and put in the array
  1885. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1886. * @returns a new array filled with new objects
  1887. */
  1888. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1889. }
  1890. }
  1891. declare module BABYLON {
  1892. /**
  1893. * Class representing a vector containing 2 coordinates
  1894. */
  1895. export class Vector2 {
  1896. /** defines the first coordinate */
  1897. x: number;
  1898. /** defines the second coordinate */
  1899. y: number;
  1900. /**
  1901. * Creates a new Vector2 from the given x and y coordinates
  1902. * @param x defines the first coordinate
  1903. * @param y defines the second coordinate
  1904. */
  1905. constructor(
  1906. /** defines the first coordinate */
  1907. x?: number,
  1908. /** defines the second coordinate */
  1909. y?: number);
  1910. /**
  1911. * Gets a string with the Vector2 coordinates
  1912. * @returns a string with the Vector2 coordinates
  1913. */
  1914. toString(): string;
  1915. /**
  1916. * Gets class name
  1917. * @returns the string "Vector2"
  1918. */
  1919. getClassName(): string;
  1920. /**
  1921. * Gets current vector hash code
  1922. * @returns the Vector2 hash code as a number
  1923. */
  1924. getHashCode(): number;
  1925. /**
  1926. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1927. * @param array defines the source array
  1928. * @param index defines the offset in source array
  1929. * @returns the current Vector2
  1930. */
  1931. toArray(array: FloatArray, index?: number): Vector2;
  1932. /**
  1933. * Copy the current vector to an array
  1934. * @returns a new array with 2 elements: the Vector2 coordinates.
  1935. */
  1936. asArray(): number[];
  1937. /**
  1938. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1939. * @param source defines the source Vector2
  1940. * @returns the current updated Vector2
  1941. */
  1942. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1943. /**
  1944. * Sets the Vector2 coordinates with the given floats
  1945. * @param x defines the first coordinate
  1946. * @param y defines the second coordinate
  1947. * @returns the current updated Vector2
  1948. */
  1949. copyFromFloats(x: number, y: number): Vector2;
  1950. /**
  1951. * Sets the Vector2 coordinates with the given floats
  1952. * @param x defines the first coordinate
  1953. * @param y defines the second coordinate
  1954. * @returns the current updated Vector2
  1955. */
  1956. set(x: number, y: number): Vector2;
  1957. /**
  1958. * Add another vector with the current one
  1959. * @param otherVector defines the other vector
  1960. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1961. */
  1962. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1963. /**
  1964. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1965. * @param otherVector defines the other vector
  1966. * @param result defines the target vector
  1967. * @returns the unmodified current Vector2
  1968. */
  1969. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1970. /**
  1971. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1972. * @param otherVector defines the other vector
  1973. * @returns the current updated Vector2
  1974. */
  1975. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1976. /**
  1977. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns a new Vector2
  1980. */
  1981. addVector3(otherVector: Vector3): Vector2;
  1982. /**
  1983. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1984. * @param otherVector defines the other vector
  1985. * @returns a new Vector2
  1986. */
  1987. subtract(otherVector: Vector2): Vector2;
  1988. /**
  1989. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1990. * @param otherVector defines the other vector
  1991. * @param result defines the target vector
  1992. * @returns the unmodified current Vector2
  1993. */
  1994. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1995. /**
  1996. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1997. * @param otherVector defines the other vector
  1998. * @returns the current updated Vector2
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Multiplies in place the current Vector2 coordinates by the given ones
  2003. * @param otherVector defines the other vector
  2004. * @returns the current updated Vector2
  2005. */
  2006. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2007. /**
  2008. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2009. * @param otherVector defines the other vector
  2010. * @returns a new Vector2
  2011. */
  2012. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2013. /**
  2014. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2015. * @param otherVector defines the other vector
  2016. * @param result defines the target vector
  2017. * @returns the unmodified current Vector2
  2018. */
  2019. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2020. /**
  2021. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2022. * @param x defines the first coordinate
  2023. * @param y defines the second coordinate
  2024. * @returns a new Vector2
  2025. */
  2026. multiplyByFloats(x: number, y: number): Vector2;
  2027. /**
  2028. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2029. * @param otherVector defines the other vector
  2030. * @returns a new Vector2
  2031. */
  2032. divide(otherVector: Vector2): Vector2;
  2033. /**
  2034. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2035. * @param otherVector defines the other vector
  2036. * @param result defines the target vector
  2037. * @returns the unmodified current Vector2
  2038. */
  2039. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2040. /**
  2041. * Divides the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Gets a new Vector2 with current Vector2 negated coordinates
  2048. * @returns a new Vector2
  2049. */
  2050. negate(): Vector2;
  2051. /**
  2052. * Multiply the Vector2 coordinates by scale
  2053. * @param scale defines the scaling factor
  2054. * @returns the current updated Vector2
  2055. */
  2056. scaleInPlace(scale: number): Vector2;
  2057. /**
  2058. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2059. * @param scale defines the scaling factor
  2060. * @returns a new Vector2
  2061. */
  2062. scale(scale: number): Vector2;
  2063. /**
  2064. * Scale the current Vector2 values by a factor to a given Vector2
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector2 object where to store the result
  2067. * @returns the unmodified current Vector2
  2068. */
  2069. scaleToRef(scale: number, result: Vector2): Vector2;
  2070. /**
  2071. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2072. * @param scale defines the scale factor
  2073. * @param result defines the Vector2 object where to store the result
  2074. * @returns the unmodified current Vector2
  2075. */
  2076. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2077. /**
  2078. * Gets a boolean if two vectors are equals
  2079. * @param otherVector defines the other vector
  2080. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2081. */
  2082. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2083. /**
  2084. * Gets a boolean if two vectors are equals (using an epsilon value)
  2085. * @param otherVector defines the other vector
  2086. * @param epsilon defines the minimal distance to consider equality
  2087. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2088. */
  2089. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2090. /**
  2091. * Gets a new Vector2 from current Vector2 floored values
  2092. * @returns a new Vector2
  2093. */
  2094. floor(): Vector2;
  2095. /**
  2096. * Gets a new Vector2 from current Vector2 floored values
  2097. * @returns a new Vector2
  2098. */
  2099. fract(): Vector2;
  2100. /**
  2101. * Gets the length of the vector
  2102. * @returns the vector length (float)
  2103. */
  2104. length(): number;
  2105. /**
  2106. * Gets the vector squared length
  2107. * @returns the vector squared length (float)
  2108. */
  2109. lengthSquared(): number;
  2110. /**
  2111. * Normalize the vector
  2112. * @returns the current updated Vector2
  2113. */
  2114. normalize(): Vector2;
  2115. /**
  2116. * Gets a new Vector2 copied from the Vector2
  2117. * @returns a new Vector2
  2118. */
  2119. clone(): Vector2;
  2120. /**
  2121. * Gets a new Vector2(0, 0)
  2122. * @returns a new Vector2
  2123. */
  2124. static Zero(): Vector2;
  2125. /**
  2126. * Gets a new Vector2(1, 1)
  2127. * @returns a new Vector2
  2128. */
  2129. static One(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 set from the given index element of the given array
  2132. * @param array defines the data source
  2133. * @param offset defines the offset in the data source
  2134. * @returns a new Vector2
  2135. */
  2136. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2137. /**
  2138. * Sets "result" from the given index element of the given array
  2139. * @param array defines the data source
  2140. * @param offset defines the offset in the data source
  2141. * @param result defines the target vector
  2142. */
  2143. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2144. /**
  2145. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2146. * @param value1 defines 1st point of control
  2147. * @param value2 defines 2nd point of control
  2148. * @param value3 defines 3rd point of control
  2149. * @param value4 defines 4th point of control
  2150. * @param amount defines the interpolation factor
  2151. * @returns a new Vector2
  2152. */
  2153. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2154. /**
  2155. * 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".
  2156. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2157. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2158. * @param value defines the value to clamp
  2159. * @param min defines the lower limit
  2160. * @param max defines the upper limit
  2161. * @returns a new Vector2
  2162. */
  2163. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2166. * @param value1 defines the 1st control point
  2167. * @param tangent1 defines the outgoing tangent
  2168. * @param value2 defines the 2nd control point
  2169. * @param tangent2 defines the incoming tangent
  2170. * @param amount defines the interpolation factor
  2171. * @returns a new Vector2
  2172. */
  2173. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2174. /**
  2175. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2176. * @param start defines the start vector
  2177. * @param end defines the end vector
  2178. * @param amount defines the interpolation factor
  2179. * @returns a new Vector2
  2180. */
  2181. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2182. /**
  2183. * Gets the dot product of the vector "left" and the vector "right"
  2184. * @param left defines first vector
  2185. * @param right defines second vector
  2186. * @returns the dot product (float)
  2187. */
  2188. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2189. /**
  2190. * Returns a new Vector2 equal to the normalized given vector
  2191. * @param vector defines the vector to normalize
  2192. * @returns a new Vector2
  2193. */
  2194. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2195. /**
  2196. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2197. * @param left defines 1st vector
  2198. * @param right defines 2nd vector
  2199. * @returns a new Vector2
  2200. */
  2201. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2204. * @param left defines 1st vector
  2205. * @param right defines 2nd vector
  2206. * @returns a new Vector2
  2207. */
  2208. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2209. /**
  2210. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2211. * @param vector defines the vector to transform
  2212. * @param transformation defines the matrix to apply
  2213. * @returns a new Vector2
  2214. */
  2215. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2216. /**
  2217. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2218. * @param vector defines the vector to transform
  2219. * @param transformation defines the matrix to apply
  2220. * @param result defines the target vector
  2221. */
  2222. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2223. /**
  2224. * Determines if a given vector is included in a triangle
  2225. * @param p defines the vector to test
  2226. * @param p0 defines 1st triangle point
  2227. * @param p1 defines 2nd triangle point
  2228. * @param p2 defines 3rd triangle point
  2229. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2230. */
  2231. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2232. /**
  2233. * Gets the distance between the vectors "value1" and "value2"
  2234. * @param value1 defines first vector
  2235. * @param value2 defines second vector
  2236. * @returns the distance between vectors
  2237. */
  2238. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns the squared distance between the vectors "value1" and "value2"
  2241. * @param value1 defines first vector
  2242. * @param value2 defines second vector
  2243. * @returns the squared distance between vectors
  2244. */
  2245. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2246. /**
  2247. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2248. * @param value1 defines first vector
  2249. * @param value2 defines second vector
  2250. * @returns a new Vector2
  2251. */
  2252. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2255. * @param p defines the middle point
  2256. * @param segA defines one point of the segment
  2257. * @param segB defines the other point of the segment
  2258. * @returns the shortest distance
  2259. */
  2260. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2261. }
  2262. /**
  2263. * Classed used to store (x,y,z) vector representation
  2264. * A Vector3 is the main object used in 3D geometry
  2265. * It can represent etiher the coordinates of a point the space, either a direction
  2266. * Reminder: js uses a left handed forward facing system
  2267. */
  2268. export class Vector3 {
  2269. /**
  2270. * Defines the first coordinates (on X axis)
  2271. */
  2272. x: number;
  2273. /**
  2274. * Defines the second coordinates (on Y axis)
  2275. */
  2276. y: number;
  2277. /**
  2278. * Defines the third coordinates (on Z axis)
  2279. */
  2280. z: number;
  2281. private static _UpReadOnly;
  2282. private static _ZeroReadOnly;
  2283. /**
  2284. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2285. * @param x defines the first coordinates (on X axis)
  2286. * @param y defines the second coordinates (on Y axis)
  2287. * @param z defines the third coordinates (on Z axis)
  2288. */
  2289. constructor(
  2290. /**
  2291. * Defines the first coordinates (on X axis)
  2292. */
  2293. x?: number,
  2294. /**
  2295. * Defines the second coordinates (on Y axis)
  2296. */
  2297. y?: number,
  2298. /**
  2299. * Defines the third coordinates (on Z axis)
  2300. */
  2301. z?: number);
  2302. /**
  2303. * Creates a string representation of the Vector3
  2304. * @returns a string with the Vector3 coordinates.
  2305. */
  2306. toString(): string;
  2307. /**
  2308. * Gets the class name
  2309. * @returns the string "Vector3"
  2310. */
  2311. getClassName(): string;
  2312. /**
  2313. * Creates the Vector3 hash code
  2314. * @returns a number which tends to be unique between Vector3 instances
  2315. */
  2316. getHashCode(): number;
  2317. /**
  2318. * Creates an array containing three elements : the coordinates of the Vector3
  2319. * @returns a new array of numbers
  2320. */
  2321. asArray(): number[];
  2322. /**
  2323. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2324. * @param array defines the destination array
  2325. * @param index defines the offset in the destination array
  2326. * @returns the current Vector3
  2327. */
  2328. toArray(array: FloatArray, index?: number): Vector3;
  2329. /**
  2330. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2331. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2332. */
  2333. toQuaternion(): Quaternion;
  2334. /**
  2335. * Adds the given vector to the current Vector3
  2336. * @param otherVector defines the second operand
  2337. * @returns the current updated Vector3
  2338. */
  2339. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2340. /**
  2341. * Adds the given coordinates to the current Vector3
  2342. * @param x defines the x coordinate of the operand
  2343. * @param y defines the y coordinate of the operand
  2344. * @param z defines the z coordinate of the operand
  2345. * @returns the current updated Vector3
  2346. */
  2347. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2348. /**
  2349. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2350. * @param otherVector defines the second operand
  2351. * @returns the resulting Vector3
  2352. */
  2353. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2356. * @param otherVector defines the second operand
  2357. * @param result defines the Vector3 object where to store the result
  2358. * @returns the current Vector3
  2359. */
  2360. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2361. /**
  2362. * Subtract the given vector from the current Vector3
  2363. * @param otherVector defines the second operand
  2364. * @returns the current updated Vector3
  2365. */
  2366. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2367. /**
  2368. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2369. * @param otherVector defines the second operand
  2370. * @returns the resulting Vector3
  2371. */
  2372. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2375. * @param otherVector defines the second operand
  2376. * @param result defines the Vector3 object where to store the result
  2377. * @returns the current Vector3
  2378. */
  2379. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2380. /**
  2381. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2382. * @param x defines the x coordinate of the operand
  2383. * @param y defines the y coordinate of the operand
  2384. * @param z defines the z coordinate of the operand
  2385. * @returns the resulting Vector3
  2386. */
  2387. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2388. /**
  2389. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2390. * @param x defines the x coordinate of the operand
  2391. * @param y defines the y coordinate of the operand
  2392. * @param z defines the z coordinate of the operand
  2393. * @param result defines the Vector3 object where to store the result
  2394. * @returns the current Vector3
  2395. */
  2396. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2397. /**
  2398. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2399. * @returns a new Vector3
  2400. */
  2401. negate(): Vector3;
  2402. /**
  2403. * Multiplies the Vector3 coordinates by the float "scale"
  2404. * @param scale defines the multiplier factor
  2405. * @returns the current updated Vector3
  2406. */
  2407. scaleInPlace(scale: number): Vector3;
  2408. /**
  2409. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2410. * @param scale defines the multiplier factor
  2411. * @returns a new Vector3
  2412. */
  2413. scale(scale: number): Vector3;
  2414. /**
  2415. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2416. * @param scale defines the multiplier factor
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. scaleToRef(scale: number, result: Vector3): Vector3;
  2421. /**
  2422. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2423. * @param scale defines the scale factor
  2424. * @param result defines the Vector3 object where to store the result
  2425. * @returns the unmodified current Vector3
  2426. */
  2427. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2428. /**
  2429. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2430. * @param otherVector defines the second operand
  2431. * @returns true if both vectors are equals
  2432. */
  2433. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2434. /**
  2435. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2436. * @param otherVector defines the second operand
  2437. * @param epsilon defines the minimal distance to define values as equals
  2438. * @returns true if both vectors are distant less than epsilon
  2439. */
  2440. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2441. /**
  2442. * Returns true if the current Vector3 coordinates equals the given floats
  2443. * @param x defines the x coordinate of the operand
  2444. * @param y defines the y coordinate of the operand
  2445. * @param z defines the z coordinate of the operand
  2446. * @returns true if both vectors are equals
  2447. */
  2448. equalsToFloats(x: number, y: number, z: number): boolean;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the given ones
  2451. * @param otherVector defines the second operand
  2452. * @returns the current updated Vector3
  2453. */
  2454. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2455. /**
  2456. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2457. * @param otherVector defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2463. * @param otherVector defines the second operand
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the current Vector3
  2466. */
  2467. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2468. /**
  2469. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2470. * @param x defines the x coordinate of the operand
  2471. * @param y defines the y coordinate of the operand
  2472. * @param z defines the z coordinate of the operand
  2473. * @returns the new Vector3
  2474. */
  2475. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2476. /**
  2477. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2478. * @param otherVector defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2484. * @param otherVector defines the second operand
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2489. /**
  2490. * Divides the current Vector3 coordinates by the given ones.
  2491. * @param otherVector defines the second operand
  2492. * @returns the current updated Vector3
  2493. */
  2494. divideInPlace(otherVector: Vector3): Vector3;
  2495. /**
  2496. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2497. * @param other defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2503. * @param other defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2509. * @param x defines the x coordinate of the operand
  2510. * @param y defines the y coordinate of the operand
  2511. * @param z defines the z coordinate of the operand
  2512. * @returns the current updated Vector3
  2513. */
  2514. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2515. /**
  2516. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2517. * @param x defines the x coordinate of the operand
  2518. * @param y defines the y coordinate of the operand
  2519. * @param z defines the z coordinate of the operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2523. /**
  2524. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2525. * Check if is non uniform within a certain amount of decimal places to account for this
  2526. * @param epsilon the amount the values can differ
  2527. * @returns if the the vector is non uniform to a certain number of decimal places
  2528. */
  2529. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2530. /**
  2531. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2532. */
  2533. readonly isNonUniform: boolean;
  2534. /**
  2535. * Gets a new Vector3 from current Vector3 floored values
  2536. * @returns a new Vector3
  2537. */
  2538. floor(): Vector3;
  2539. /**
  2540. * Gets a new Vector3 from current Vector3 floored values
  2541. * @returns a new Vector3
  2542. */
  2543. fract(): Vector3;
  2544. /**
  2545. * Gets the length of the Vector3
  2546. * @returns the length of the Vector3
  2547. */
  2548. length(): number;
  2549. /**
  2550. * Gets the squared length of the Vector3
  2551. * @returns squared length of the Vector3
  2552. */
  2553. lengthSquared(): number;
  2554. /**
  2555. * Normalize the current Vector3.
  2556. * Please note that this is an in place operation.
  2557. * @returns the current updated Vector3
  2558. */
  2559. normalize(): Vector3;
  2560. /**
  2561. * Reorders the x y z properties of the vector in place
  2562. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2563. * @returns the current updated vector
  2564. */
  2565. reorderInPlace(order: string): this;
  2566. /**
  2567. * Rotates the vector around 0,0,0 by a quaternion
  2568. * @param quaternion the rotation quaternion
  2569. * @param result vector to store the result
  2570. * @returns the resulting vector
  2571. */
  2572. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2573. /**
  2574. * Rotates a vector around a given point
  2575. * @param quaternion the rotation quaternion
  2576. * @param point the point to rotate around
  2577. * @param result vector to store the result
  2578. * @returns the resulting vector
  2579. */
  2580. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2581. /**
  2582. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2583. * The cross product is then orthogonal to both current and "other"
  2584. * @param other defines the right operand
  2585. * @returns the cross product
  2586. */
  2587. cross(other: Vector3): Vector3;
  2588. /**
  2589. * Normalize the current Vector3 with the given input length.
  2590. * Please note that this is an in place operation.
  2591. * @param len the length of the vector
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalizeFromLength(len: number): Vector3;
  2595. /**
  2596. * Normalize the current Vector3 to a new vector
  2597. * @returns the new Vector3
  2598. */
  2599. normalizeToNew(): Vector3;
  2600. /**
  2601. * Normalize the current Vector3 to the reference
  2602. * @param reference define the Vector3 to update
  2603. * @returns the updated Vector3
  2604. */
  2605. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2606. /**
  2607. * Creates a new Vector3 copied from the current Vector3
  2608. * @returns the new Vector3
  2609. */
  2610. clone(): Vector3;
  2611. /**
  2612. * Copies the given vector coordinates to the current Vector3 ones
  2613. * @param source defines the source Vector3
  2614. * @returns the current updated Vector3
  2615. */
  2616. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2617. /**
  2618. * Copies the given floats to the current Vector3 coordinates
  2619. * @param x defines the x coordinate of the operand
  2620. * @param y defines the y coordinate of the operand
  2621. * @param z defines the z coordinate of the operand
  2622. * @returns the current updated Vector3
  2623. */
  2624. copyFromFloats(x: number, y: number, z: number): Vector3;
  2625. /**
  2626. * Copies the given floats to the current Vector3 coordinates
  2627. * @param x defines the x coordinate of the operand
  2628. * @param y defines the y coordinate of the operand
  2629. * @param z defines the z coordinate of the operand
  2630. * @returns the current updated Vector3
  2631. */
  2632. set(x: number, y: number, z: number): Vector3;
  2633. /**
  2634. * Copies the given float to the current Vector3 coordinates
  2635. * @param v defines the x, y and z coordinates of the operand
  2636. * @returns the current updated Vector3
  2637. */
  2638. setAll(v: number): Vector3;
  2639. /**
  2640. * Get the clip factor between two vectors
  2641. * @param vector0 defines the first operand
  2642. * @param vector1 defines the second operand
  2643. * @param axis defines the axis to use
  2644. * @param size defines the size along the axis
  2645. * @returns the clip factor
  2646. */
  2647. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2648. /**
  2649. * Get angle between two vectors
  2650. * @param vector0 angle between vector0 and vector1
  2651. * @param vector1 angle between vector0 and vector1
  2652. * @param normal direction of the normal
  2653. * @return the angle between vector0 and vector1
  2654. */
  2655. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2656. /**
  2657. * Returns a new Vector3 set from the index "offset" of the given array
  2658. * @param array defines the source array
  2659. * @param offset defines the offset in the source array
  2660. * @returns the new Vector3
  2661. */
  2662. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2663. /**
  2664. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2665. * This function is deprecated. Use FromArray instead
  2666. * @param array defines the source array
  2667. * @param offset defines the offset in the source array
  2668. * @returns the new Vector3
  2669. */
  2670. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2671. /**
  2672. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2673. * @param array defines the source array
  2674. * @param offset defines the offset in the source array
  2675. * @param result defines the Vector3 where to store the result
  2676. */
  2677. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2678. /**
  2679. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2680. * This function is deprecated. Use FromArrayToRef instead.
  2681. * @param array defines the source array
  2682. * @param offset defines the offset in the source array
  2683. * @param result defines the Vector3 where to store the result
  2684. */
  2685. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2686. /**
  2687. * Sets the given vector "result" with the given floats.
  2688. * @param x defines the x coordinate of the source
  2689. * @param y defines the y coordinate of the source
  2690. * @param z defines the z coordinate of the source
  2691. * @param result defines the Vector3 where to store the result
  2692. */
  2693. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2694. /**
  2695. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2696. * @returns a new empty Vector3
  2697. */
  2698. static Zero(): Vector3;
  2699. /**
  2700. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2701. * @returns a new unit Vector3
  2702. */
  2703. static One(): Vector3;
  2704. /**
  2705. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2706. * @returns a new up Vector3
  2707. */
  2708. static Up(): Vector3;
  2709. /**
  2710. * Gets a up Vector3 that must not be updated
  2711. */
  2712. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2713. /**
  2714. * Gets a zero Vector3 that must not be updated
  2715. */
  2716. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2717. /**
  2718. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2719. * @returns a new down Vector3
  2720. */
  2721. static Down(): Vector3;
  2722. /**
  2723. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2724. * @returns a new forward Vector3
  2725. */
  2726. static Forward(): Vector3;
  2727. /**
  2728. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2729. * @returns a new forward Vector3
  2730. */
  2731. static Backward(): Vector3;
  2732. /**
  2733. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2734. * @returns a new right Vector3
  2735. */
  2736. static Right(): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2739. * @returns a new left Vector3
  2740. */
  2741. static Left(): Vector3;
  2742. /**
  2743. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2744. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2745. * @param vector defines the Vector3 to transform
  2746. * @param transformation defines the transformation matrix
  2747. * @returns the transformed Vector3
  2748. */
  2749. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2750. /**
  2751. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2752. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2753. * @param vector defines the Vector3 to transform
  2754. * @param transformation defines the transformation matrix
  2755. * @param result defines the Vector3 where to store the result
  2756. */
  2757. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2758. /**
  2759. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2760. * This method computes tranformed coordinates only, not transformed direction vectors
  2761. * @param x define the x coordinate of the source vector
  2762. * @param y define the y coordinate of the source vector
  2763. * @param z define the z coordinate of the source vector
  2764. * @param transformation defines the transformation matrix
  2765. * @param result defines the Vector3 where to store the result
  2766. */
  2767. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2768. /**
  2769. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2770. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2771. * @param vector defines the Vector3 to transform
  2772. * @param transformation defines the transformation matrix
  2773. * @returns the new Vector3
  2774. */
  2775. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2776. /**
  2777. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2778. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2779. * @param vector defines the Vector3 to transform
  2780. * @param transformation defines the transformation matrix
  2781. * @param result defines the Vector3 where to store the result
  2782. */
  2783. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2784. /**
  2785. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2786. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2787. * @param x define the x coordinate of the source vector
  2788. * @param y define the y coordinate of the source vector
  2789. * @param z define the z coordinate of the source vector
  2790. * @param transformation defines the transformation matrix
  2791. * @param result defines the Vector3 where to store the result
  2792. */
  2793. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2794. /**
  2795. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2796. * @param value1 defines the first control point
  2797. * @param value2 defines the second control point
  2798. * @param value3 defines the third control point
  2799. * @param value4 defines the fourth control point
  2800. * @param amount defines the amount on the spline to use
  2801. * @returns the new Vector3
  2802. */
  2803. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2804. /**
  2805. * 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"
  2806. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2807. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2808. * @param value defines the current value
  2809. * @param min defines the lower range value
  2810. * @param max defines the upper range value
  2811. * @returns the new Vector3
  2812. */
  2813. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * 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"
  2816. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2817. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2818. * @param value defines the current value
  2819. * @param min defines the lower range value
  2820. * @param max defines the upper range value
  2821. * @param result defines the Vector3 where to store the result
  2822. */
  2823. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2824. /**
  2825. * Checks if a given vector is inside a specific range
  2826. * @param v defines the vector to test
  2827. * @param min defines the minimum range
  2828. * @param max defines the maximum range
  2829. */
  2830. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2833. * @param value1 defines the first control point
  2834. * @param tangent1 defines the first tangent vector
  2835. * @param value2 defines the second control point
  2836. * @param tangent2 defines the second tangent vector
  2837. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2838. * @returns the new Vector3
  2839. */
  2840. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2843. * @param start defines the start value
  2844. * @param end defines the end value
  2845. * @param amount max defines amount between both (between 0 and 1)
  2846. * @returns the new Vector3
  2847. */
  2848. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2851. * @param start defines the start value
  2852. * @param end defines the end value
  2853. * @param amount max defines amount between both (between 0 and 1)
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2857. /**
  2858. * Returns the dot product (float) between the vectors "left" and "right"
  2859. * @param left defines the left operand
  2860. * @param right defines the right operand
  2861. * @returns the dot product
  2862. */
  2863. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2864. /**
  2865. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2866. * The cross product is then orthogonal to both "left" and "right"
  2867. * @param left defines the left operand
  2868. * @param right defines the right operand
  2869. * @returns the cross product
  2870. */
  2871. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2872. /**
  2873. * Sets the given vector "result" with the cross product of "left" and "right"
  2874. * The cross product is then orthogonal to both "left" and "right"
  2875. * @param left defines the left operand
  2876. * @param right defines the right operand
  2877. * @param result defines the Vector3 where to store the result
  2878. */
  2879. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2880. /**
  2881. * Returns a new Vector3 as the normalization of the given vector
  2882. * @param vector defines the Vector3 to normalize
  2883. * @returns the new Vector3
  2884. */
  2885. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the normalization of the given first vector
  2888. * @param vector defines the Vector3 to normalize
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2892. /**
  2893. * Project a Vector3 onto screen space
  2894. * @param vector defines the Vector3 to project
  2895. * @param world defines the world matrix to use
  2896. * @param transform defines the transform (view x projection) matrix to use
  2897. * @param viewport defines the screen viewport to use
  2898. * @returns the new Vector3
  2899. */
  2900. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2901. /** @hidden */
  2902. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2903. /**
  2904. * Unproject from screen space to object space
  2905. * @param source defines the screen space Vector3 to use
  2906. * @param viewportWidth defines the current width of the viewport
  2907. * @param viewportHeight defines the current height of the viewport
  2908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2909. * @param transform defines the transform (view x projection) matrix to use
  2910. * @returns the new Vector3
  2911. */
  2912. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2913. /**
  2914. * Unproject from screen space to object space
  2915. * @param source defines the screen space Vector3 to use
  2916. * @param viewportWidth defines the current width of the viewport
  2917. * @param viewportHeight defines the current height of the viewport
  2918. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2919. * @param view defines the view matrix to use
  2920. * @param projection defines the projection matrix to use
  2921. * @returns the new Vector3
  2922. */
  2923. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2924. /**
  2925. * Unproject from screen space to object space
  2926. * @param source defines the screen space Vector3 to use
  2927. * @param viewportWidth defines the current width of the viewport
  2928. * @param viewportHeight defines the current height of the viewport
  2929. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2930. * @param view defines the view matrix to use
  2931. * @param projection defines the projection matrix to use
  2932. * @param result defines the Vector3 where to store the result
  2933. */
  2934. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2935. /**
  2936. * Unproject from screen space to object space
  2937. * @param sourceX defines the screen space x coordinate to use
  2938. * @param sourceY defines the screen space y coordinate to use
  2939. * @param sourceZ defines the screen space z coordinate to use
  2940. * @param viewportWidth defines the current width of the viewport
  2941. * @param viewportHeight defines the current height of the viewport
  2942. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2943. * @param view defines the view matrix to use
  2944. * @param projection defines the projection matrix to use
  2945. * @param result defines the Vector3 where to store the result
  2946. */
  2947. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2948. /**
  2949. * Gets the minimal coordinate values between two Vector3
  2950. * @param left defines the first operand
  2951. * @param right defines the second operand
  2952. * @returns the new Vector3
  2953. */
  2954. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2955. /**
  2956. * Gets the maximal coordinate values between two Vector3
  2957. * @param left defines the first operand
  2958. * @param right defines the second operand
  2959. * @returns the new Vector3
  2960. */
  2961. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2962. /**
  2963. * Returns the distance between the vectors "value1" and "value2"
  2964. * @param value1 defines the first operand
  2965. * @param value2 defines the second operand
  2966. * @returns the distance
  2967. */
  2968. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2969. /**
  2970. * Returns the squared distance between the vectors "value1" and "value2"
  2971. * @param value1 defines the first operand
  2972. * @param value2 defines the second operand
  2973. * @returns the squared distance
  2974. */
  2975. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2976. /**
  2977. * Returns a new Vector3 located at the center between "value1" and "value2"
  2978. * @param value1 defines the first operand
  2979. * @param value2 defines the second operand
  2980. * @returns the new Vector3
  2981. */
  2982. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2985. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2986. * to something in order to rotate it from its local system to the given target system
  2987. * Note: axis1, axis2 and axis3 are normalized during this operation
  2988. * @param axis1 defines the first axis
  2989. * @param axis2 defines the second axis
  2990. * @param axis3 defines the third axis
  2991. * @returns a new Vector3
  2992. */
  2993. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2996. * @param axis1 defines the first axis
  2997. * @param axis2 defines the second axis
  2998. * @param axis3 defines the third axis
  2999. * @param ref defines the Vector3 where to store the result
  3000. */
  3001. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3002. }
  3003. /**
  3004. * Vector4 class created for EulerAngle class conversion to Quaternion
  3005. */
  3006. export class Vector4 {
  3007. /** x value of the vector */
  3008. x: number;
  3009. /** y value of the vector */
  3010. y: number;
  3011. /** z value of the vector */
  3012. z: number;
  3013. /** w value of the vector */
  3014. w: number;
  3015. /**
  3016. * Creates a Vector4 object from the given floats.
  3017. * @param x x value of the vector
  3018. * @param y y value of the vector
  3019. * @param z z value of the vector
  3020. * @param w w value of the vector
  3021. */
  3022. constructor(
  3023. /** x value of the vector */
  3024. x: number,
  3025. /** y value of the vector */
  3026. y: number,
  3027. /** z value of the vector */
  3028. z: number,
  3029. /** w value of the vector */
  3030. w: number);
  3031. /**
  3032. * Returns the string with the Vector4 coordinates.
  3033. * @returns a string containing all the vector values
  3034. */
  3035. toString(): string;
  3036. /**
  3037. * Returns the string "Vector4".
  3038. * @returns "Vector4"
  3039. */
  3040. getClassName(): string;
  3041. /**
  3042. * Returns the Vector4 hash code.
  3043. * @returns a unique hash code
  3044. */
  3045. getHashCode(): number;
  3046. /**
  3047. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3048. * @returns the resulting array
  3049. */
  3050. asArray(): number[];
  3051. /**
  3052. * Populates the given array from the given index with the Vector4 coordinates.
  3053. * @param array array to populate
  3054. * @param index index of the array to start at (default: 0)
  3055. * @returns the Vector4.
  3056. */
  3057. toArray(array: FloatArray, index?: number): Vector4;
  3058. /**
  3059. * Adds the given vector to the current Vector4.
  3060. * @param otherVector the vector to add
  3061. * @returns the updated Vector4.
  3062. */
  3063. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3064. /**
  3065. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3066. * @param otherVector the vector to add
  3067. * @returns the resulting vector
  3068. */
  3069. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3070. /**
  3071. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3072. * @param otherVector the vector to add
  3073. * @param result the vector to store the result
  3074. * @returns the current Vector4.
  3075. */
  3076. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3077. /**
  3078. * Subtract in place the given vector from the current Vector4.
  3079. * @param otherVector the vector to subtract
  3080. * @returns the updated Vector4.
  3081. */
  3082. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3083. /**
  3084. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3085. * @param otherVector the vector to add
  3086. * @returns the new vector with the result
  3087. */
  3088. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3089. /**
  3090. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3091. * @param otherVector the vector to subtract
  3092. * @param result the vector to store the result
  3093. * @returns the current Vector4.
  3094. */
  3095. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3096. /**
  3097. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3098. */
  3099. /**
  3100. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3101. * @param x value to subtract
  3102. * @param y value to subtract
  3103. * @param z value to subtract
  3104. * @param w value to subtract
  3105. * @returns new vector containing the result
  3106. */
  3107. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3108. /**
  3109. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3110. * @param x value to subtract
  3111. * @param y value to subtract
  3112. * @param z value to subtract
  3113. * @param w value to subtract
  3114. * @param result the vector to store the result in
  3115. * @returns the current Vector4.
  3116. */
  3117. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3118. /**
  3119. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3120. * @returns a new vector with the negated values
  3121. */
  3122. negate(): Vector4;
  3123. /**
  3124. * Multiplies the current Vector4 coordinates by scale (float).
  3125. * @param scale the number to scale with
  3126. * @returns the updated Vector4.
  3127. */
  3128. scaleInPlace(scale: number): Vector4;
  3129. /**
  3130. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3131. * @param scale the number to scale with
  3132. * @returns a new vector with the result
  3133. */
  3134. scale(scale: number): Vector4;
  3135. /**
  3136. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3137. * @param scale the number to scale with
  3138. * @param result a vector to store the result in
  3139. * @returns the current Vector4.
  3140. */
  3141. scaleToRef(scale: number, result: Vector4): Vector4;
  3142. /**
  3143. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3144. * @param scale defines the scale factor
  3145. * @param result defines the Vector4 object where to store the result
  3146. * @returns the unmodified current Vector4
  3147. */
  3148. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3149. /**
  3150. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3151. * @param otherVector the vector to compare against
  3152. * @returns true if they are equal
  3153. */
  3154. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3155. /**
  3156. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3157. * @param otherVector vector to compare against
  3158. * @param epsilon (Default: very small number)
  3159. * @returns true if they are equal
  3160. */
  3161. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3162. /**
  3163. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3164. * @param x x value to compare against
  3165. * @param y y value to compare against
  3166. * @param z z value to compare against
  3167. * @param w w value to compare against
  3168. * @returns true if equal
  3169. */
  3170. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3171. /**
  3172. * Multiplies in place the current Vector4 by the given one.
  3173. * @param otherVector vector to multiple with
  3174. * @returns the updated Vector4.
  3175. */
  3176. multiplyInPlace(otherVector: Vector4): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3179. * @param otherVector vector to multiple with
  3180. * @returns resulting new vector
  3181. */
  3182. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3183. /**
  3184. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3185. * @param otherVector vector to multiple with
  3186. * @param result vector to store the result
  3187. * @returns the current Vector4.
  3188. */
  3189. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3192. * @param x x value multiply with
  3193. * @param y y value multiply with
  3194. * @param z z value multiply with
  3195. * @param w w value multiply with
  3196. * @returns resulting new vector
  3197. */
  3198. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3199. /**
  3200. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3201. * @param otherVector vector to devide with
  3202. * @returns resulting new vector
  3203. */
  3204. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3205. /**
  3206. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3207. * @param otherVector vector to devide with
  3208. * @param result vector to store the result
  3209. * @returns the current Vector4.
  3210. */
  3211. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3212. /**
  3213. * Divides the current Vector3 coordinates by the given ones.
  3214. * @param otherVector vector to devide with
  3215. * @returns the updated Vector3.
  3216. */
  3217. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3220. * @param other defines the second operand
  3221. * @returns the current updated Vector4
  3222. */
  3223. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3224. /**
  3225. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3226. * @param other defines the second operand
  3227. * @returns the current updated Vector4
  3228. */
  3229. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3230. /**
  3231. * Gets a new Vector4 from current Vector4 floored values
  3232. * @returns a new Vector4
  3233. */
  3234. floor(): Vector4;
  3235. /**
  3236. * Gets a new Vector4 from current Vector3 floored values
  3237. * @returns a new Vector4
  3238. */
  3239. fract(): Vector4;
  3240. /**
  3241. * Returns the Vector4 length (float).
  3242. * @returns the length
  3243. */
  3244. length(): number;
  3245. /**
  3246. * Returns the Vector4 squared length (float).
  3247. * @returns the length squared
  3248. */
  3249. lengthSquared(): number;
  3250. /**
  3251. * Normalizes in place the Vector4.
  3252. * @returns the updated Vector4.
  3253. */
  3254. normalize(): Vector4;
  3255. /**
  3256. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3257. * @returns this converted to a new vector3
  3258. */
  3259. toVector3(): Vector3;
  3260. /**
  3261. * Returns a new Vector4 copied from the current one.
  3262. * @returns the new cloned vector
  3263. */
  3264. clone(): Vector4;
  3265. /**
  3266. * Updates the current Vector4 with the given one coordinates.
  3267. * @param source the source vector to copy from
  3268. * @returns the updated Vector4.
  3269. */
  3270. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3271. /**
  3272. * Updates the current Vector4 coordinates with the given floats.
  3273. * @param x float to copy from
  3274. * @param y float to copy from
  3275. * @param z float to copy from
  3276. * @param w float to copy from
  3277. * @returns the updated Vector4.
  3278. */
  3279. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3280. /**
  3281. * Updates the current Vector4 coordinates with the given floats.
  3282. * @param x float to set from
  3283. * @param y float to set from
  3284. * @param z float to set from
  3285. * @param w float to set from
  3286. * @returns the updated Vector4.
  3287. */
  3288. set(x: number, y: number, z: number, w: number): Vector4;
  3289. /**
  3290. * Copies the given float to the current Vector3 coordinates
  3291. * @param v defines the x, y, z and w coordinates of the operand
  3292. * @returns the current updated Vector3
  3293. */
  3294. setAll(v: number): Vector4;
  3295. /**
  3296. * Returns a new Vector4 set from the starting index of the given array.
  3297. * @param array the array to pull values from
  3298. * @param offset the offset into the array to start at
  3299. * @returns the new vector
  3300. */
  3301. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3302. /**
  3303. * Updates the given vector "result" from the starting index of the given array.
  3304. * @param array the array to pull values from
  3305. * @param offset the offset into the array to start at
  3306. * @param result the vector to store the result in
  3307. */
  3308. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3309. /**
  3310. * Updates the given vector "result" from the starting index of the given Float32Array.
  3311. * @param array the array to pull values from
  3312. * @param offset the offset into the array to start at
  3313. * @param result the vector to store the result in
  3314. */
  3315. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3316. /**
  3317. * Updates the given vector "result" coordinates from the given floats.
  3318. * @param x float to set from
  3319. * @param y float to set from
  3320. * @param z float to set from
  3321. * @param w float to set from
  3322. * @param result the vector to the floats in
  3323. */
  3324. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3325. /**
  3326. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3327. * @returns the new vector
  3328. */
  3329. static Zero(): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3332. * @returns the new vector
  3333. */
  3334. static One(): Vector4;
  3335. /**
  3336. * Returns a new normalized Vector4 from the given one.
  3337. * @param vector the vector to normalize
  3338. * @returns the vector
  3339. */
  3340. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3341. /**
  3342. * Updates the given vector "result" from the normalization of the given one.
  3343. * @param vector the vector to normalize
  3344. * @param result the vector to store the result in
  3345. */
  3346. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3347. /**
  3348. * Returns a vector with the minimum values from the left and right vectors
  3349. * @param left left vector to minimize
  3350. * @param right right vector to minimize
  3351. * @returns a new vector with the minimum of the left and right vector values
  3352. */
  3353. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3354. /**
  3355. * Returns a vector with the maximum values from the left and right vectors
  3356. * @param left left vector to maximize
  3357. * @param right right vector to maximize
  3358. * @returns a new vector with the maximum of the left and right vector values
  3359. */
  3360. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3361. /**
  3362. * Returns the distance (float) between the vectors "value1" and "value2".
  3363. * @param value1 value to calulate the distance between
  3364. * @param value2 value to calulate the distance between
  3365. * @return the distance between the two vectors
  3366. */
  3367. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3368. /**
  3369. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3370. * @param value1 value to calulate the distance between
  3371. * @param value2 value to calulate the distance between
  3372. * @return the distance between the two vectors squared
  3373. */
  3374. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3375. /**
  3376. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3377. * @param value1 value to calulate the center between
  3378. * @param value2 value to calulate the center between
  3379. * @return the center between the two vectors
  3380. */
  3381. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3382. /**
  3383. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3384. * This methods computes transformed normalized direction vectors only.
  3385. * @param vector the vector to transform
  3386. * @param transformation the transformation matrix to apply
  3387. * @returns the new vector
  3388. */
  3389. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3390. /**
  3391. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3392. * This methods computes transformed normalized direction vectors only.
  3393. * @param vector the vector to transform
  3394. * @param transformation the transformation matrix to apply
  3395. * @param result the vector to store the result in
  3396. */
  3397. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3398. /**
  3399. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3400. * This methods computes transformed normalized direction vectors only.
  3401. * @param x value to transform
  3402. * @param y value to transform
  3403. * @param z value to transform
  3404. * @param w value to transform
  3405. * @param transformation the transformation matrix to apply
  3406. * @param result the vector to store the results in
  3407. */
  3408. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3409. /**
  3410. * Creates a new Vector4 from a Vector3
  3411. * @param source defines the source data
  3412. * @param w defines the 4th component (default is 0)
  3413. * @returns a new Vector4
  3414. */
  3415. static FromVector3(source: Vector3, w?: number): Vector4;
  3416. }
  3417. /**
  3418. * Class used to store quaternion data
  3419. * @see https://en.wikipedia.org/wiki/Quaternion
  3420. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3421. */
  3422. export class Quaternion {
  3423. /** defines the first component (0 by default) */
  3424. x: number;
  3425. /** defines the second component (0 by default) */
  3426. y: number;
  3427. /** defines the third component (0 by default) */
  3428. z: number;
  3429. /** defines the fourth component (1.0 by default) */
  3430. w: number;
  3431. /**
  3432. * Creates a new Quaternion from the given floats
  3433. * @param x defines the first component (0 by default)
  3434. * @param y defines the second component (0 by default)
  3435. * @param z defines the third component (0 by default)
  3436. * @param w defines the fourth component (1.0 by default)
  3437. */
  3438. constructor(
  3439. /** defines the first component (0 by default) */
  3440. x?: number,
  3441. /** defines the second component (0 by default) */
  3442. y?: number,
  3443. /** defines the third component (0 by default) */
  3444. z?: number,
  3445. /** defines the fourth component (1.0 by default) */
  3446. w?: number);
  3447. /**
  3448. * Gets a string representation for the current quaternion
  3449. * @returns a string with the Quaternion coordinates
  3450. */
  3451. toString(): string;
  3452. /**
  3453. * Gets the class name of the quaternion
  3454. * @returns the string "Quaternion"
  3455. */
  3456. getClassName(): string;
  3457. /**
  3458. * Gets a hash code for this quaternion
  3459. * @returns the quaternion hash code
  3460. */
  3461. getHashCode(): number;
  3462. /**
  3463. * Copy the quaternion to an array
  3464. * @returns a new array populated with 4 elements from the quaternion coordinates
  3465. */
  3466. asArray(): number[];
  3467. /**
  3468. * Check if two quaternions are equals
  3469. * @param otherQuaternion defines the second operand
  3470. * @return true if the current quaternion and the given one coordinates are strictly equals
  3471. */
  3472. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3473. /**
  3474. * Clone the current quaternion
  3475. * @returns a new quaternion copied from the current one
  3476. */
  3477. clone(): Quaternion;
  3478. /**
  3479. * Copy a quaternion to the current one
  3480. * @param other defines the other quaternion
  3481. * @returns the updated current quaternion
  3482. */
  3483. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3484. /**
  3485. * Updates the current quaternion with the given float coordinates
  3486. * @param x defines the x coordinate
  3487. * @param y defines the y coordinate
  3488. * @param z defines the z coordinate
  3489. * @param w defines the w coordinate
  3490. * @returns the updated current quaternion
  3491. */
  3492. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3493. /**
  3494. * Updates the current quaternion from the given float coordinates
  3495. * @param x defines the x coordinate
  3496. * @param y defines the y coordinate
  3497. * @param z defines the z coordinate
  3498. * @param w defines the w coordinate
  3499. * @returns the updated current quaternion
  3500. */
  3501. set(x: number, y: number, z: number, w: number): Quaternion;
  3502. /**
  3503. * Adds two quaternions
  3504. * @param other defines the second operand
  3505. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3506. */
  3507. add(other: DeepImmutable<Quaternion>): Quaternion;
  3508. /**
  3509. * Add a quaternion to the current one
  3510. * @param other defines the quaternion to add
  3511. * @returns the current quaternion
  3512. */
  3513. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3514. /**
  3515. * Subtract two quaternions
  3516. * @param other defines the second operand
  3517. * @returns a new quaternion as the subtraction result of the given one from the current one
  3518. */
  3519. subtract(other: Quaternion): Quaternion;
  3520. /**
  3521. * Multiplies the current quaternion by a scale factor
  3522. * @param value defines the scale factor
  3523. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3524. */
  3525. scale(value: number): Quaternion;
  3526. /**
  3527. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3528. * @param scale defines the scale factor
  3529. * @param result defines the Quaternion object where to store the result
  3530. * @returns the unmodified current quaternion
  3531. */
  3532. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3533. /**
  3534. * Multiplies in place the current quaternion by a scale factor
  3535. * @param value defines the scale factor
  3536. * @returns the current modified quaternion
  3537. */
  3538. scaleInPlace(value: number): Quaternion;
  3539. /**
  3540. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3541. * @param scale defines the scale factor
  3542. * @param result defines the Quaternion object where to store the result
  3543. * @returns the unmodified current quaternion
  3544. */
  3545. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3546. /**
  3547. * Multiplies two quaternions
  3548. * @param q1 defines the second operand
  3549. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3550. */
  3551. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3554. * @param q1 defines the second operand
  3555. * @param result defines the target quaternion
  3556. * @returns the current quaternion
  3557. */
  3558. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3559. /**
  3560. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3561. * @param q1 defines the second operand
  3562. * @returns the currentupdated quaternion
  3563. */
  3564. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3565. /**
  3566. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3567. * @param ref defines the target quaternion
  3568. * @returns the current quaternion
  3569. */
  3570. conjugateToRef(ref: Quaternion): Quaternion;
  3571. /**
  3572. * Conjugates in place (1-q) the current quaternion
  3573. * @returns the current updated quaternion
  3574. */
  3575. conjugateInPlace(): Quaternion;
  3576. /**
  3577. * Conjugates in place (1-q) the current quaternion
  3578. * @returns a new quaternion
  3579. */
  3580. conjugate(): Quaternion;
  3581. /**
  3582. * Gets length of current quaternion
  3583. * @returns the quaternion length (float)
  3584. */
  3585. length(): number;
  3586. /**
  3587. * Normalize in place the current quaternion
  3588. * @returns the current updated quaternion
  3589. */
  3590. normalize(): Quaternion;
  3591. /**
  3592. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3593. * @param order is a reserved parameter and is ignore for now
  3594. * @returns a new Vector3 containing the Euler angles
  3595. */
  3596. toEulerAngles(order?: string): Vector3;
  3597. /**
  3598. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3599. * @param result defines the vector which will be filled with the Euler angles
  3600. * @param order is a reserved parameter and is ignore for now
  3601. * @returns the current unchanged quaternion
  3602. */
  3603. toEulerAnglesToRef(result: Vector3): Quaternion;
  3604. /**
  3605. * Updates the given rotation matrix with the current quaternion values
  3606. * @param result defines the target matrix
  3607. * @returns the current unchanged quaternion
  3608. */
  3609. toRotationMatrix(result: Matrix): Quaternion;
  3610. /**
  3611. * Updates the current quaternion from the given rotation matrix values
  3612. * @param matrix defines the source matrix
  3613. * @returns the current updated quaternion
  3614. */
  3615. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3616. /**
  3617. * Creates a new quaternion from a rotation matrix
  3618. * @param matrix defines the source matrix
  3619. * @returns a new quaternion created from the given rotation matrix values
  3620. */
  3621. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3622. /**
  3623. * Updates the given quaternion with the given rotation matrix values
  3624. * @param matrix defines the source matrix
  3625. * @param result defines the target quaternion
  3626. */
  3627. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3628. /**
  3629. * Returns the dot product (float) between the quaternions "left" and "right"
  3630. * @param left defines the left operand
  3631. * @param right defines the right operand
  3632. * @returns the dot product
  3633. */
  3634. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3635. /**
  3636. * Checks if the two quaternions are close to each other
  3637. * @param quat0 defines the first quaternion to check
  3638. * @param quat1 defines the second quaternion to check
  3639. * @returns true if the two quaternions are close to each other
  3640. */
  3641. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3642. /**
  3643. * Creates an empty quaternion
  3644. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3645. */
  3646. static Zero(): Quaternion;
  3647. /**
  3648. * Inverse a given quaternion
  3649. * @param q defines the source quaternion
  3650. * @returns a new quaternion as the inverted current quaternion
  3651. */
  3652. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3653. /**
  3654. * Inverse a given quaternion
  3655. * @param q defines the source quaternion
  3656. * @param result the quaternion the result will be stored in
  3657. * @returns the result quaternion
  3658. */
  3659. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3660. /**
  3661. * Creates an identity quaternion
  3662. * @returns the identity quaternion
  3663. */
  3664. static Identity(): Quaternion;
  3665. /**
  3666. * Gets a boolean indicating if the given quaternion is identity
  3667. * @param quaternion defines the quaternion to check
  3668. * @returns true if the quaternion is identity
  3669. */
  3670. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3671. /**
  3672. * Creates a quaternion from a rotation around an axis
  3673. * @param axis defines the axis to use
  3674. * @param angle defines the angle to use
  3675. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3676. */
  3677. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3678. /**
  3679. * Creates a rotation around an axis and stores it into the given quaternion
  3680. * @param axis defines the axis to use
  3681. * @param angle defines the angle to use
  3682. * @param result defines the target quaternion
  3683. * @returns the target quaternion
  3684. */
  3685. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from data stored into an array
  3688. * @param array defines the data source
  3689. * @param offset defines the offset in the source array where the data starts
  3690. * @returns a new quaternion
  3691. */
  3692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3693. /**
  3694. * Create a quaternion from Euler rotation angles
  3695. * @param x Pitch
  3696. * @param y Yaw
  3697. * @param z Roll
  3698. * @returns the new Quaternion
  3699. */
  3700. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3701. /**
  3702. * Updates a quaternion from Euler rotation angles
  3703. * @param x Pitch
  3704. * @param y Yaw
  3705. * @param z Roll
  3706. * @param result the quaternion to store the result
  3707. * @returns the updated quaternion
  3708. */
  3709. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3710. /**
  3711. * Create a quaternion from Euler rotation vector
  3712. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3713. * @returns the new Quaternion
  3714. */
  3715. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3716. /**
  3717. * Updates a quaternion from Euler rotation vector
  3718. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3719. * @param result the quaternion to store the result
  3720. * @returns the updated quaternion
  3721. */
  3722. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3723. /**
  3724. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3725. * @param yaw defines the rotation around Y axis
  3726. * @param pitch defines the rotation around X axis
  3727. * @param roll defines the rotation around Z axis
  3728. * @returns the new quaternion
  3729. */
  3730. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3731. /**
  3732. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3733. * @param yaw defines the rotation around Y axis
  3734. * @param pitch defines the rotation around X axis
  3735. * @param roll defines the rotation around Z axis
  3736. * @param result defines the target quaternion
  3737. */
  3738. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3739. /**
  3740. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3741. * @param alpha defines the rotation around first axis
  3742. * @param beta defines the rotation around second axis
  3743. * @param gamma defines the rotation around third axis
  3744. * @returns the new quaternion
  3745. */
  3746. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3747. /**
  3748. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3749. * @param alpha defines the rotation around first axis
  3750. * @param beta defines the rotation around second axis
  3751. * @param gamma defines the rotation around third axis
  3752. * @param result defines the target quaternion
  3753. */
  3754. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3755. /**
  3756. * 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)
  3757. * @param axis1 defines the first axis
  3758. * @param axis2 defines the second axis
  3759. * @param axis3 defines the third axis
  3760. * @returns the new quaternion
  3761. */
  3762. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3763. /**
  3764. * 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
  3765. * @param axis1 defines the first axis
  3766. * @param axis2 defines the second axis
  3767. * @param axis3 defines the third axis
  3768. * @param ref defines the target quaternion
  3769. */
  3770. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3771. /**
  3772. * Interpolates between two quaternions
  3773. * @param left defines first quaternion
  3774. * @param right defines second quaternion
  3775. * @param amount defines the gradient to use
  3776. * @returns the new interpolated quaternion
  3777. */
  3778. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3779. /**
  3780. * Interpolates between two quaternions and stores it into a target quaternion
  3781. * @param left defines first quaternion
  3782. * @param right defines second quaternion
  3783. * @param amount defines the gradient to use
  3784. * @param result defines the target quaternion
  3785. */
  3786. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3787. /**
  3788. * Interpolate between two quaternions using Hermite interpolation
  3789. * @param value1 defines first quaternion
  3790. * @param tangent1 defines the incoming tangent
  3791. * @param value2 defines second quaternion
  3792. * @param tangent2 defines the outgoing tangent
  3793. * @param amount defines the target quaternion
  3794. * @returns the new interpolated quaternion
  3795. */
  3796. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3797. }
  3798. /**
  3799. * Class used to store matrix data (4x4)
  3800. */
  3801. export class Matrix {
  3802. private static _updateFlagSeed;
  3803. private static _identityReadOnly;
  3804. private _isIdentity;
  3805. private _isIdentityDirty;
  3806. private _isIdentity3x2;
  3807. private _isIdentity3x2Dirty;
  3808. /**
  3809. * Gets the update flag of the matrix which is an unique number for the matrix.
  3810. * It will be incremented every time the matrix data change.
  3811. * You can use it to speed the comparison between two versions of the same matrix.
  3812. */
  3813. updateFlag: number;
  3814. private readonly _m;
  3815. /**
  3816. * Gets the internal data of the matrix
  3817. */
  3818. readonly m: DeepImmutable<Float32Array>;
  3819. /** @hidden */
  3820. _markAsUpdated(): void;
  3821. /** @hidden */
  3822. private _updateIdentityStatus;
  3823. /**
  3824. * Creates an empty matrix (filled with zeros)
  3825. */
  3826. constructor();
  3827. /**
  3828. * Check if the current matrix is identity
  3829. * @returns true is the matrix is the identity matrix
  3830. */
  3831. isIdentity(): boolean;
  3832. /**
  3833. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3834. * @returns true is the matrix is the identity matrix
  3835. */
  3836. isIdentityAs3x2(): boolean;
  3837. /**
  3838. * Gets the determinant of the matrix
  3839. * @returns the matrix determinant
  3840. */
  3841. determinant(): number;
  3842. /**
  3843. * Returns the matrix as a Float32Array
  3844. * @returns the matrix underlying array
  3845. */
  3846. toArray(): DeepImmutable<Float32Array>;
  3847. /**
  3848. * Returns the matrix as a Float32Array
  3849. * @returns the matrix underlying array.
  3850. */
  3851. asArray(): DeepImmutable<Float32Array>;
  3852. /**
  3853. * Inverts the current matrix in place
  3854. * @returns the current inverted matrix
  3855. */
  3856. invert(): Matrix;
  3857. /**
  3858. * Sets all the matrix elements to zero
  3859. * @returns the current matrix
  3860. */
  3861. reset(): Matrix;
  3862. /**
  3863. * Adds the current matrix with a second one
  3864. * @param other defines the matrix to add
  3865. * @returns a new matrix as the addition of the current matrix and the given one
  3866. */
  3867. add(other: DeepImmutable<Matrix>): Matrix;
  3868. /**
  3869. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3870. * @param other defines the matrix to add
  3871. * @param result defines the target matrix
  3872. * @returns the current matrix
  3873. */
  3874. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3875. /**
  3876. * Adds in place the given matrix to the current matrix
  3877. * @param other defines the second operand
  3878. * @returns the current updated matrix
  3879. */
  3880. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3881. /**
  3882. * Sets the given matrix to the current inverted Matrix
  3883. * @param other defines the target matrix
  3884. * @returns the unmodified current matrix
  3885. */
  3886. invertToRef(other: Matrix): Matrix;
  3887. /**
  3888. * add a value at the specified position in the current Matrix
  3889. * @param index the index of the value within the matrix. between 0 and 15.
  3890. * @param value the value to be added
  3891. * @returns the current updated matrix
  3892. */
  3893. addAtIndex(index: number, value: number): Matrix;
  3894. /**
  3895. * mutiply the specified position in the current Matrix by a value
  3896. * @param index the index of the value within the matrix. between 0 and 15.
  3897. * @param value the value to be added
  3898. * @returns the current updated matrix
  3899. */
  3900. multiplyAtIndex(index: number, value: number): Matrix;
  3901. /**
  3902. * Inserts the translation vector (using 3 floats) in the current matrix
  3903. * @param x defines the 1st component of the translation
  3904. * @param y defines the 2nd component of the translation
  3905. * @param z defines the 3rd component of the translation
  3906. * @returns the current updated matrix
  3907. */
  3908. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3909. /**
  3910. * Adds the translation vector (using 3 floats) in the current matrix
  3911. * @param x defines the 1st component of the translation
  3912. * @param y defines the 2nd component of the translation
  3913. * @param z defines the 3rd component of the translation
  3914. * @returns the current updated matrix
  3915. */
  3916. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3917. /**
  3918. * Inserts the translation vector in the current matrix
  3919. * @param vector3 defines the translation to insert
  3920. * @returns the current updated matrix
  3921. */
  3922. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3923. /**
  3924. * Gets the translation value of the current matrix
  3925. * @returns a new Vector3 as the extracted translation from the matrix
  3926. */
  3927. getTranslation(): Vector3;
  3928. /**
  3929. * Fill a Vector3 with the extracted translation from the matrix
  3930. * @param result defines the Vector3 where to store the translation
  3931. * @returns the current matrix
  3932. */
  3933. getTranslationToRef(result: Vector3): Matrix;
  3934. /**
  3935. * Remove rotation and scaling part from the matrix
  3936. * @returns the updated matrix
  3937. */
  3938. removeRotationAndScaling(): Matrix;
  3939. /**
  3940. * Multiply two matrices
  3941. * @param other defines the second operand
  3942. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3943. */
  3944. multiply(other: DeepImmutable<Matrix>): Matrix;
  3945. /**
  3946. * Copy the current matrix from the given one
  3947. * @param other defines the source matrix
  3948. * @returns the current updated matrix
  3949. */
  3950. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Populates the given array from the starting index with the current matrix values
  3953. * @param array defines the target array
  3954. * @param offset defines the offset in the target array where to start storing values
  3955. * @returns the current matrix
  3956. */
  3957. copyToArray(array: Float32Array, offset?: number): Matrix;
  3958. /**
  3959. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3960. * @param other defines the second operand
  3961. * @param result defines the matrix where to store the multiplication
  3962. * @returns the current matrix
  3963. */
  3964. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3965. /**
  3966. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3967. * @param other defines the second operand
  3968. * @param result defines the array where to store the multiplication
  3969. * @param offset defines the offset in the target array where to start storing values
  3970. * @returns the current matrix
  3971. */
  3972. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3973. /**
  3974. * Check equality between this matrix and a second one
  3975. * @param value defines the second matrix to compare
  3976. * @returns true is the current matrix and the given one values are strictly equal
  3977. */
  3978. equals(value: DeepImmutable<Matrix>): boolean;
  3979. /**
  3980. * Clone the current matrix
  3981. * @returns a new matrix from the current matrix
  3982. */
  3983. clone(): Matrix;
  3984. /**
  3985. * Returns the name of the current matrix class
  3986. * @returns the string "Matrix"
  3987. */
  3988. getClassName(): string;
  3989. /**
  3990. * Gets the hash code of the current matrix
  3991. * @returns the hash code
  3992. */
  3993. getHashCode(): number;
  3994. /**
  3995. * Decomposes the current Matrix into a translation, rotation and scaling components
  3996. * @param scale defines the scale vector3 given as a reference to update
  3997. * @param rotation defines the rotation quaternion given as a reference to update
  3998. * @param translation defines the translation vector3 given as a reference to update
  3999. * @returns true if operation was successful
  4000. */
  4001. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4002. /**
  4003. * Gets specific row of the matrix
  4004. * @param index defines the number of the row to get
  4005. * @returns the index-th row of the current matrix as a new Vector4
  4006. */
  4007. getRow(index: number): Nullable<Vector4>;
  4008. /**
  4009. * Sets the index-th row of the current matrix to the vector4 values
  4010. * @param index defines the number of the row to set
  4011. * @param row defines the target vector4
  4012. * @returns the updated current matrix
  4013. */
  4014. setRow(index: number, row: Vector4): Matrix;
  4015. /**
  4016. * Compute the transpose of the matrix
  4017. * @returns the new transposed matrix
  4018. */
  4019. transpose(): Matrix;
  4020. /**
  4021. * Compute the transpose of the matrix and store it in a given matrix
  4022. * @param result defines the target matrix
  4023. * @returns the current matrix
  4024. */
  4025. transposeToRef(result: Matrix): Matrix;
  4026. /**
  4027. * Sets the index-th row of the current matrix with the given 4 x float values
  4028. * @param index defines the row index
  4029. * @param x defines the x component to set
  4030. * @param y defines the y component to set
  4031. * @param z defines the z component to set
  4032. * @param w defines the w component to set
  4033. * @returns the updated current matrix
  4034. */
  4035. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4036. /**
  4037. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4038. * @param scale defines the scale factor
  4039. * @returns a new matrix
  4040. */
  4041. scale(scale: number): Matrix;
  4042. /**
  4043. * Scale the current matrix values by a factor to a given result matrix
  4044. * @param scale defines the scale factor
  4045. * @param result defines the matrix to store the result
  4046. * @returns the current matrix
  4047. */
  4048. scaleToRef(scale: number, result: Matrix): Matrix;
  4049. /**
  4050. * Scale the current matrix values by a factor and add the result to a given matrix
  4051. * @param scale defines the scale factor
  4052. * @param result defines the Matrix to store the result
  4053. * @returns the current matrix
  4054. */
  4055. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4056. /**
  4057. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4058. * @param ref matrix to store the result
  4059. */
  4060. toNormalMatrix(ref: Matrix): void;
  4061. /**
  4062. * Gets only rotation part of the current matrix
  4063. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4064. */
  4065. getRotationMatrix(): Matrix;
  4066. /**
  4067. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4068. * @param result defines the target matrix to store data to
  4069. * @returns the current matrix
  4070. */
  4071. getRotationMatrixToRef(result: Matrix): Matrix;
  4072. /**
  4073. * Toggles model matrix from being right handed to left handed in place and vice versa
  4074. */
  4075. toggleModelMatrixHandInPlace(): void;
  4076. /**
  4077. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4078. */
  4079. toggleProjectionMatrixHandInPlace(): void;
  4080. /**
  4081. * Creates a matrix from an array
  4082. * @param array defines the source array
  4083. * @param offset defines an offset in the source array
  4084. * @returns a new Matrix set from the starting index of the given array
  4085. */
  4086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4087. /**
  4088. * Copy the content of an array into a given matrix
  4089. * @param array defines the source array
  4090. * @param offset defines an offset in the source array
  4091. * @param result defines the target matrix
  4092. */
  4093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4094. /**
  4095. * Stores an array into a matrix after having multiplied each component by a given factor
  4096. * @param array defines the source array
  4097. * @param offset defines the offset in the source array
  4098. * @param scale defines the scaling factor
  4099. * @param result defines the target matrix
  4100. */
  4101. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4102. /**
  4103. * Gets an identity matrix that must not be updated
  4104. */
  4105. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4106. /**
  4107. * Stores a list of values (16) inside a given matrix
  4108. * @param initialM11 defines 1st value of 1st row
  4109. * @param initialM12 defines 2nd value of 1st row
  4110. * @param initialM13 defines 3rd value of 1st row
  4111. * @param initialM14 defines 4th value of 1st row
  4112. * @param initialM21 defines 1st value of 2nd row
  4113. * @param initialM22 defines 2nd value of 2nd row
  4114. * @param initialM23 defines 3rd value of 2nd row
  4115. * @param initialM24 defines 4th value of 2nd row
  4116. * @param initialM31 defines 1st value of 3rd row
  4117. * @param initialM32 defines 2nd value of 3rd row
  4118. * @param initialM33 defines 3rd value of 3rd row
  4119. * @param initialM34 defines 4th value of 3rd row
  4120. * @param initialM41 defines 1st value of 4th row
  4121. * @param initialM42 defines 2nd value of 4th row
  4122. * @param initialM43 defines 3rd value of 4th row
  4123. * @param initialM44 defines 4th value of 4th row
  4124. * @param result defines the target matrix
  4125. */
  4126. 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;
  4127. /**
  4128. * Creates new matrix from a list of values (16)
  4129. * @param initialM11 defines 1st value of 1st row
  4130. * @param initialM12 defines 2nd value of 1st row
  4131. * @param initialM13 defines 3rd value of 1st row
  4132. * @param initialM14 defines 4th value of 1st row
  4133. * @param initialM21 defines 1st value of 2nd row
  4134. * @param initialM22 defines 2nd value of 2nd row
  4135. * @param initialM23 defines 3rd value of 2nd row
  4136. * @param initialM24 defines 4th value of 2nd row
  4137. * @param initialM31 defines 1st value of 3rd row
  4138. * @param initialM32 defines 2nd value of 3rd row
  4139. * @param initialM33 defines 3rd value of 3rd row
  4140. * @param initialM34 defines 4th value of 3rd row
  4141. * @param initialM41 defines 1st value of 4th row
  4142. * @param initialM42 defines 2nd value of 4th row
  4143. * @param initialM43 defines 3rd value of 4th row
  4144. * @param initialM44 defines 4th value of 4th row
  4145. * @returns the new matrix
  4146. */
  4147. 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;
  4148. /**
  4149. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4150. * @param scale defines the scale vector3
  4151. * @param rotation defines the rotation quaternion
  4152. * @param translation defines the translation vector3
  4153. * @returns a new matrix
  4154. */
  4155. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4156. /**
  4157. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4158. * @param scale defines the scale vector3
  4159. * @param rotation defines the rotation quaternion
  4160. * @param translation defines the translation vector3
  4161. * @param result defines the target matrix
  4162. */
  4163. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4164. /**
  4165. * Creates a new identity matrix
  4166. * @returns a new identity matrix
  4167. */
  4168. static Identity(): Matrix;
  4169. /**
  4170. * Creates a new identity matrix and stores the result in a given matrix
  4171. * @param result defines the target matrix
  4172. */
  4173. static IdentityToRef(result: Matrix): void;
  4174. /**
  4175. * Creates a new zero matrix
  4176. * @returns a new zero matrix
  4177. */
  4178. static Zero(): Matrix;
  4179. /**
  4180. * Creates a new rotation matrix for "angle" radians around the X axis
  4181. * @param angle defines the angle (in radians) to use
  4182. * @return the new matrix
  4183. */
  4184. static RotationX(angle: number): Matrix;
  4185. /**
  4186. * Creates a new matrix as the invert of a given matrix
  4187. * @param source defines the source matrix
  4188. * @returns the new matrix
  4189. */
  4190. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4191. /**
  4192. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4193. * @param angle defines the angle (in radians) to use
  4194. * @param result defines the target matrix
  4195. */
  4196. static RotationXToRef(angle: number, result: Matrix): void;
  4197. /**
  4198. * Creates a new rotation matrix for "angle" radians around the Y axis
  4199. * @param angle defines the angle (in radians) to use
  4200. * @return the new matrix
  4201. */
  4202. static RotationY(angle: number): Matrix;
  4203. /**
  4204. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4205. * @param angle defines the angle (in radians) to use
  4206. * @param result defines the target matrix
  4207. */
  4208. static RotationYToRef(angle: number, result: Matrix): void;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the Z axis
  4211. * @param angle defines the angle (in radians) to use
  4212. * @return the new matrix
  4213. */
  4214. static RotationZ(angle: number): Matrix;
  4215. /**
  4216. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4217. * @param angle defines the angle (in radians) to use
  4218. * @param result defines the target matrix
  4219. */
  4220. static RotationZToRef(angle: number, result: Matrix): void;
  4221. /**
  4222. * Creates a new rotation matrix for "angle" radians around the given axis
  4223. * @param axis defines the axis to use
  4224. * @param angle defines the angle (in radians) to use
  4225. * @return the new matrix
  4226. */
  4227. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4228. /**
  4229. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4230. * @param axis defines the axis to use
  4231. * @param angle defines the angle (in radians) to use
  4232. * @param result defines the target matrix
  4233. */
  4234. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4235. /**
  4236. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4237. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4238. * @param from defines the vector to align
  4239. * @param to defines the vector to align to
  4240. * @param result defines the target matrix
  4241. */
  4242. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4243. /**
  4244. * Creates a rotation matrix
  4245. * @param yaw defines the yaw angle in radians (Y axis)
  4246. * @param pitch defines the pitch angle in radians (X axis)
  4247. * @param roll defines the roll angle in radians (X axis)
  4248. * @returns the new rotation matrix
  4249. */
  4250. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4251. /**
  4252. * Creates a rotation matrix and stores it in a given matrix
  4253. * @param yaw defines the yaw angle in radians (Y axis)
  4254. * @param pitch defines the pitch angle in radians (X axis)
  4255. * @param roll defines the roll angle in radians (X axis)
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4259. /**
  4260. * Creates a scaling matrix
  4261. * @param x defines the scale factor on X axis
  4262. * @param y defines the scale factor on Y axis
  4263. * @param z defines the scale factor on Z axis
  4264. * @returns the new matrix
  4265. */
  4266. static Scaling(x: number, y: number, z: number): Matrix;
  4267. /**
  4268. * Creates a scaling matrix and stores it in a given matrix
  4269. * @param x defines the scale factor on X axis
  4270. * @param y defines the scale factor on Y axis
  4271. * @param z defines the scale factor on Z axis
  4272. * @param result defines the target matrix
  4273. */
  4274. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4275. /**
  4276. * Creates a translation matrix
  4277. * @param x defines the translation on X axis
  4278. * @param y defines the translation on Y axis
  4279. * @param z defines the translationon Z axis
  4280. * @returns the new matrix
  4281. */
  4282. static Translation(x: number, y: number, z: number): Matrix;
  4283. /**
  4284. * Creates a translation matrix and stores it in a given matrix
  4285. * @param x defines the translation on X axis
  4286. * @param y defines the translation on Y axis
  4287. * @param z defines the translationon Z axis
  4288. * @param result defines the target matrix
  4289. */
  4290. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4291. /**
  4292. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4293. * @param startValue defines the start value
  4294. * @param endValue defines the end value
  4295. * @param gradient defines the gradient factor
  4296. * @returns the new matrix
  4297. */
  4298. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4299. /**
  4300. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4301. * @param startValue defines the start value
  4302. * @param endValue defines the end value
  4303. * @param gradient defines the gradient factor
  4304. * @param result defines the Matrix object where to store data
  4305. */
  4306. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4307. /**
  4308. * Builds a new matrix whose values are computed by:
  4309. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4310. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4311. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4312. * @param startValue defines the first matrix
  4313. * @param endValue defines the second matrix
  4314. * @param gradient defines the gradient between the two matrices
  4315. * @returns the new matrix
  4316. */
  4317. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4318. /**
  4319. * Update a matrix to values which are computed by:
  4320. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4321. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4322. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4323. * @param startValue defines the first matrix
  4324. * @param endValue defines the second matrix
  4325. * @param gradient defines the gradient between the two matrices
  4326. * @param result defines the target matrix
  4327. */
  4328. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4329. /**
  4330. * 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"
  4331. * This function works in left handed mode
  4332. * @param eye defines the final position of the entity
  4333. * @param target defines where the entity should look at
  4334. * @param up defines the up vector for the entity
  4335. * @returns the new matrix
  4336. */
  4337. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4338. /**
  4339. * 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".
  4340. * This function works in left handed mode
  4341. * @param eye defines the final position of the entity
  4342. * @param target defines where the entity should look at
  4343. * @param up defines the up vector for the entity
  4344. * @param result defines the target matrix
  4345. */
  4346. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4347. /**
  4348. * 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"
  4349. * This function works in right handed mode
  4350. * @param eye defines the final position of the entity
  4351. * @param target defines where the entity should look at
  4352. * @param up defines the up vector for the entity
  4353. * @returns the new matrix
  4354. */
  4355. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4356. /**
  4357. * 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".
  4358. * This function works in right handed mode
  4359. * @param eye defines the final position of the entity
  4360. * @param target defines where the entity should look at
  4361. * @param up defines the up vector for the entity
  4362. * @param result defines the target matrix
  4363. */
  4364. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4365. /**
  4366. * Create a left-handed orthographic projection matrix
  4367. * @param width defines the viewport width
  4368. * @param height defines the viewport height
  4369. * @param znear defines the near clip plane
  4370. * @param zfar defines the far clip plane
  4371. * @returns a new matrix as a left-handed orthographic projection matrix
  4372. */
  4373. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4374. /**
  4375. * Store a left-handed orthographic projection to a given matrix
  4376. * @param width defines the viewport width
  4377. * @param height defines the viewport height
  4378. * @param znear defines the near clip plane
  4379. * @param zfar defines the far clip plane
  4380. * @param result defines the target matrix
  4381. */
  4382. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4383. /**
  4384. * Create a left-handed orthographic projection matrix
  4385. * @param left defines the viewport left coordinate
  4386. * @param right defines the viewport right coordinate
  4387. * @param bottom defines the viewport bottom coordinate
  4388. * @param top defines the viewport top coordinate
  4389. * @param znear defines the near clip plane
  4390. * @param zfar defines the far clip plane
  4391. * @returns a new matrix as a left-handed orthographic projection matrix
  4392. */
  4393. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4394. /**
  4395. * Stores a left-handed orthographic projection into a given matrix
  4396. * @param left defines the viewport left coordinate
  4397. * @param right defines the viewport right coordinate
  4398. * @param bottom defines the viewport bottom coordinate
  4399. * @param top defines the viewport top coordinate
  4400. * @param znear defines the near clip plane
  4401. * @param zfar defines the far clip plane
  4402. * @param result defines the target matrix
  4403. */
  4404. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4405. /**
  4406. * Creates a right-handed orthographic projection matrix
  4407. * @param left defines the viewport left coordinate
  4408. * @param right defines the viewport right coordinate
  4409. * @param bottom defines the viewport bottom coordinate
  4410. * @param top defines the viewport top coordinate
  4411. * @param znear defines the near clip plane
  4412. * @param zfar defines the far clip plane
  4413. * @returns a new matrix as a right-handed orthographic projection matrix
  4414. */
  4415. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4416. /**
  4417. * Stores a right-handed orthographic projection into a given matrix
  4418. * @param left defines the viewport left coordinate
  4419. * @param right defines the viewport right coordinate
  4420. * @param bottom defines the viewport bottom coordinate
  4421. * @param top defines the viewport top coordinate
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @param result defines the target matrix
  4425. */
  4426. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4427. /**
  4428. * Creates a left-handed perspective projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed perspective projection matrix
  4434. */
  4435. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Creates a left-handed perspective projection matrix
  4438. * @param fov defines the horizontal field of view
  4439. * @param aspect defines the aspect ratio
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @returns a new matrix as a left-handed perspective projection matrix
  4443. */
  4444. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4445. /**
  4446. * Stores a left-handed perspective projection into a given matrix
  4447. * @param fov defines the horizontal field of view
  4448. * @param aspect defines the aspect ratio
  4449. * @param znear defines the near clip plane
  4450. * @param zfar defines the far clip plane
  4451. * @param result defines the target matrix
  4452. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4453. */
  4454. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4455. /**
  4456. * Creates a right-handed perspective projection matrix
  4457. * @param fov defines the horizontal field of view
  4458. * @param aspect defines the aspect ratio
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a right-handed perspective projection matrix
  4462. */
  4463. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a right-handed perspective projection into a given matrix
  4466. * @param fov defines the horizontal field of view
  4467. * @param aspect defines the aspect ratio
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4472. */
  4473. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4474. /**
  4475. * Stores a perspective projection for WebVR info a given matrix
  4476. * @param fov defines the field of view
  4477. * @param znear defines the near clip plane
  4478. * @param zfar defines the far clip plane
  4479. * @param result defines the target matrix
  4480. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4481. */
  4482. static PerspectiveFovWebVRToRef(fov: {
  4483. upDegrees: number;
  4484. downDegrees: number;
  4485. leftDegrees: number;
  4486. rightDegrees: number;
  4487. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4488. /**
  4489. * Computes a complete transformation matrix
  4490. * @param viewport defines the viewport to use
  4491. * @param world defines the world matrix
  4492. * @param view defines the view matrix
  4493. * @param projection defines the projection matrix
  4494. * @param zmin defines the near clip plane
  4495. * @param zmax defines the far clip plane
  4496. * @returns the transformation matrix
  4497. */
  4498. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4499. /**
  4500. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4501. * @param matrix defines the matrix to use
  4502. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4503. */
  4504. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4505. /**
  4506. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4507. * @param matrix defines the matrix to use
  4508. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4509. */
  4510. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4511. /**
  4512. * Compute the transpose of a given matrix
  4513. * @param matrix defines the matrix to transpose
  4514. * @returns the new matrix
  4515. */
  4516. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4517. /**
  4518. * Compute the transpose of a matrix and store it in a target matrix
  4519. * @param matrix defines the matrix to transpose
  4520. * @param result defines the target matrix
  4521. */
  4522. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4523. /**
  4524. * Computes a reflection matrix from a plane
  4525. * @param plane defines the reflection plane
  4526. * @returns a new matrix
  4527. */
  4528. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4529. /**
  4530. * Computes a reflection matrix from a plane
  4531. * @param plane defines the reflection plane
  4532. * @param result defines the target matrix
  4533. */
  4534. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4535. /**
  4536. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4537. * @param xaxis defines the value of the 1st axis
  4538. * @param yaxis defines the value of the 2nd axis
  4539. * @param zaxis defines the value of the 3rd axis
  4540. * @param result defines the target matrix
  4541. */
  4542. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4543. /**
  4544. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4545. * @param quat defines the quaternion to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4549. }
  4550. /**
  4551. * @hidden
  4552. */
  4553. export class TmpVectors {
  4554. static Vector2: Vector2[];
  4555. static Vector3: Vector3[];
  4556. static Vector4: Vector4[];
  4557. static Quaternion: Quaternion[];
  4558. static Matrix: Matrix[];
  4559. }
  4560. }
  4561. declare module BABYLON {
  4562. /**
  4563. * Defines potential orientation for back face culling
  4564. */
  4565. export enum Orientation {
  4566. /**
  4567. * Clockwise
  4568. */
  4569. CW = 0,
  4570. /** Counter clockwise */
  4571. CCW = 1
  4572. }
  4573. /** Class used to represent a Bezier curve */
  4574. export class BezierCurve {
  4575. /**
  4576. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4577. * @param t defines the time
  4578. * @param x1 defines the left coordinate on X axis
  4579. * @param y1 defines the left coordinate on Y axis
  4580. * @param x2 defines the right coordinate on X axis
  4581. * @param y2 defines the right coordinate on Y axis
  4582. * @returns the interpolated value
  4583. */
  4584. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4585. }
  4586. /**
  4587. * Defines angle representation
  4588. */
  4589. export class Angle {
  4590. private _radians;
  4591. /**
  4592. * Creates an Angle object of "radians" radians (float).
  4593. * @param radians the angle in radians
  4594. */
  4595. constructor(radians: number);
  4596. /**
  4597. * Get value in degrees
  4598. * @returns the Angle value in degrees (float)
  4599. */
  4600. degrees(): number;
  4601. /**
  4602. * Get value in radians
  4603. * @returns the Angle value in radians (float)
  4604. */
  4605. radians(): number;
  4606. /**
  4607. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4608. * @param a defines first vector
  4609. * @param b defines second vector
  4610. * @returns a new Angle
  4611. */
  4612. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4613. /**
  4614. * Gets a new Angle object from the given float in radians
  4615. * @param radians defines the angle value in radians
  4616. * @returns a new Angle
  4617. */
  4618. static FromRadians(radians: number): Angle;
  4619. /**
  4620. * Gets a new Angle object from the given float in degrees
  4621. * @param degrees defines the angle value in degrees
  4622. * @returns a new Angle
  4623. */
  4624. static FromDegrees(degrees: number): Angle;
  4625. }
  4626. /**
  4627. * This represents an arc in a 2d space.
  4628. */
  4629. export class Arc2 {
  4630. /** Defines the start point of the arc */
  4631. startPoint: Vector2;
  4632. /** Defines the mid point of the arc */
  4633. midPoint: Vector2;
  4634. /** Defines the end point of the arc */
  4635. endPoint: Vector2;
  4636. /**
  4637. * Defines the center point of the arc.
  4638. */
  4639. centerPoint: Vector2;
  4640. /**
  4641. * Defines the radius of the arc.
  4642. */
  4643. radius: number;
  4644. /**
  4645. * Defines the angle of the arc (from mid point to end point).
  4646. */
  4647. angle: Angle;
  4648. /**
  4649. * Defines the start angle of the arc (from start point to middle point).
  4650. */
  4651. startAngle: Angle;
  4652. /**
  4653. * Defines the orientation of the arc (clock wise/counter clock wise).
  4654. */
  4655. orientation: Orientation;
  4656. /**
  4657. * Creates an Arc object from the three given points : start, middle and end.
  4658. * @param startPoint Defines the start point of the arc
  4659. * @param midPoint Defines the midlle point of the arc
  4660. * @param endPoint Defines the end point of the arc
  4661. */
  4662. constructor(
  4663. /** Defines the start point of the arc */
  4664. startPoint: Vector2,
  4665. /** Defines the mid point of the arc */
  4666. midPoint: Vector2,
  4667. /** Defines the end point of the arc */
  4668. endPoint: Vector2);
  4669. }
  4670. /**
  4671. * Represents a 2D path made up of multiple 2D points
  4672. */
  4673. export class Path2 {
  4674. private _points;
  4675. private _length;
  4676. /**
  4677. * If the path start and end point are the same
  4678. */
  4679. closed: boolean;
  4680. /**
  4681. * Creates a Path2 object from the starting 2D coordinates x and y.
  4682. * @param x the starting points x value
  4683. * @param y the starting points y value
  4684. */
  4685. constructor(x: number, y: number);
  4686. /**
  4687. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4688. * @param x the added points x value
  4689. * @param y the added points y value
  4690. * @returns the updated Path2.
  4691. */
  4692. addLineTo(x: number, y: number): Path2;
  4693. /**
  4694. * 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.
  4695. * @param midX middle point x value
  4696. * @param midY middle point y value
  4697. * @param endX end point x value
  4698. * @param endY end point y value
  4699. * @param numberOfSegments (default: 36)
  4700. * @returns the updated Path2.
  4701. */
  4702. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4703. /**
  4704. * Closes the Path2.
  4705. * @returns the Path2.
  4706. */
  4707. close(): Path2;
  4708. /**
  4709. * Gets the sum of the distance between each sequential point in the path
  4710. * @returns the Path2 total length (float).
  4711. */
  4712. length(): number;
  4713. /**
  4714. * Gets the points which construct the path
  4715. * @returns the Path2 internal array of points.
  4716. */
  4717. getPoints(): Vector2[];
  4718. /**
  4719. * Retreives the point at the distance aways from the starting point
  4720. * @param normalizedLengthPosition the length along the path to retreive the point from
  4721. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4722. */
  4723. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4724. /**
  4725. * Creates a new path starting from an x and y position
  4726. * @param x starting x value
  4727. * @param y starting y value
  4728. * @returns a new Path2 starting at the coordinates (x, y).
  4729. */
  4730. static StartingAt(x: number, y: number): Path2;
  4731. }
  4732. /**
  4733. * Represents a 3D path made up of multiple 3D points
  4734. */
  4735. export class Path3D {
  4736. /**
  4737. * an array of Vector3, the curve axis of the Path3D
  4738. */
  4739. path: Vector3[];
  4740. private _curve;
  4741. private _distances;
  4742. private _tangents;
  4743. private _normals;
  4744. private _binormals;
  4745. private _raw;
  4746. /**
  4747. * new Path3D(path, normal, raw)
  4748. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4749. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4750. * @param path an array of Vector3, the curve axis of the Path3D
  4751. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4752. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4753. */
  4754. constructor(
  4755. /**
  4756. * an array of Vector3, the curve axis of the Path3D
  4757. */
  4758. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4759. /**
  4760. * Returns the Path3D array of successive Vector3 designing its curve.
  4761. * @returns the Path3D array of successive Vector3 designing its curve.
  4762. */
  4763. getCurve(): Vector3[];
  4764. /**
  4765. * Returns an array populated with tangent vectors on each Path3D curve point.
  4766. * @returns an array populated with tangent vectors on each Path3D curve point.
  4767. */
  4768. getTangents(): Vector3[];
  4769. /**
  4770. * Returns an array populated with normal vectors on each Path3D curve point.
  4771. * @returns an array populated with normal vectors on each Path3D curve point.
  4772. */
  4773. getNormals(): Vector3[];
  4774. /**
  4775. * Returns an array populated with binormal vectors on each Path3D curve point.
  4776. * @returns an array populated with binormal vectors on each Path3D curve point.
  4777. */
  4778. getBinormals(): Vector3[];
  4779. /**
  4780. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4781. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4782. */
  4783. getDistances(): number[];
  4784. /**
  4785. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4786. * @param path path which all values are copied into the curves points
  4787. * @param firstNormal which should be projected onto the curve
  4788. * @returns the same object updated.
  4789. */
  4790. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4791. private _compute;
  4792. private _getFirstNonNullVector;
  4793. private _getLastNonNullVector;
  4794. private _normalVector;
  4795. }
  4796. /**
  4797. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4798. * A Curve3 is designed from a series of successive Vector3.
  4799. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4800. */
  4801. export class Curve3 {
  4802. private _points;
  4803. private _length;
  4804. /**
  4805. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4806. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4807. * @param v1 (Vector3) the control point
  4808. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4809. * @param nbPoints (integer) the wanted number of points in the curve
  4810. * @returns the created Curve3
  4811. */
  4812. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4813. /**
  4814. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4815. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4816. * @param v1 (Vector3) the first control point
  4817. * @param v2 (Vector3) the second control point
  4818. * @param v3 (Vector3) the end point of the Cubic Bezier
  4819. * @param nbPoints (integer) the wanted number of points in the curve
  4820. * @returns the created Curve3
  4821. */
  4822. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4823. /**
  4824. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4825. * @param p1 (Vector3) the origin point of the Hermite Spline
  4826. * @param t1 (Vector3) the tangent vector at the origin point
  4827. * @param p2 (Vector3) the end point of the Hermite Spline
  4828. * @param t2 (Vector3) the tangent vector at the end point
  4829. * @param nbPoints (integer) the wanted number of points in the curve
  4830. * @returns the created Curve3
  4831. */
  4832. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4833. /**
  4834. * Returns a Curve3 object along a CatmullRom Spline curve :
  4835. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4836. * @param nbPoints (integer) the wanted number of points between each curve control points
  4837. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4838. * @returns the created Curve3
  4839. */
  4840. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4841. /**
  4842. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4843. * A Curve3 is designed from a series of successive Vector3.
  4844. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4845. * @param points points which make up the curve
  4846. */
  4847. constructor(points: Vector3[]);
  4848. /**
  4849. * @returns the Curve3 stored array of successive Vector3
  4850. */
  4851. getPoints(): Vector3[];
  4852. /**
  4853. * @returns the computed length (float) of the curve.
  4854. */
  4855. length(): number;
  4856. /**
  4857. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4858. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4859. * curveA and curveB keep unchanged.
  4860. * @param curve the curve to continue from this curve
  4861. * @returns the newly constructed curve
  4862. */
  4863. continue(curve: DeepImmutable<Curve3>): Curve3;
  4864. private _computeLength;
  4865. }
  4866. }
  4867. declare module BABYLON {
  4868. /**
  4869. * This represents the main contract an easing function should follow.
  4870. * Easing functions are used throughout the animation system.
  4871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4872. */
  4873. export interface IEasingFunction {
  4874. /**
  4875. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4876. * of the easing function.
  4877. * The link below provides some of the most common examples of easing functions.
  4878. * @see https://easings.net/
  4879. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4880. * @returns the corresponding value on the curve defined by the easing function
  4881. */
  4882. ease(gradient: number): number;
  4883. }
  4884. /**
  4885. * Base class used for every default easing function.
  4886. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4887. */
  4888. export class EasingFunction implements IEasingFunction {
  4889. /**
  4890. * Interpolation follows the mathematical formula associated with the easing function.
  4891. */
  4892. static readonly EASINGMODE_EASEIN: number;
  4893. /**
  4894. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4895. */
  4896. static readonly EASINGMODE_EASEOUT: number;
  4897. /**
  4898. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4899. */
  4900. static readonly EASINGMODE_EASEINOUT: number;
  4901. private _easingMode;
  4902. /**
  4903. * Sets the easing mode of the current function.
  4904. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4905. */
  4906. setEasingMode(easingMode: number): void;
  4907. /**
  4908. * Gets the current easing mode.
  4909. * @returns the easing mode
  4910. */
  4911. getEasingMode(): number;
  4912. /**
  4913. * @hidden
  4914. */
  4915. easeInCore(gradient: number): number;
  4916. /**
  4917. * Given an input gradient between 0 and 1, this returns the corresponding value
  4918. * of the easing function.
  4919. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4920. * @returns the corresponding value on the curve defined by the easing function
  4921. */
  4922. ease(gradient: number): number;
  4923. }
  4924. /**
  4925. * Easing function with a circle shape (see link below).
  4926. * @see https://easings.net/#easeInCirc
  4927. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4928. */
  4929. export class CircleEase extends EasingFunction implements IEasingFunction {
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a ease back shape (see link below).
  4935. * @see https://easings.net/#easeInBack
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class BackEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the amplitude of the function */
  4940. amplitude: number;
  4941. /**
  4942. * Instantiates a back ease easing
  4943. * @see https://easings.net/#easeInBack
  4944. * @param amplitude Defines the amplitude of the function
  4945. */
  4946. constructor(
  4947. /** Defines the amplitude of the function */
  4948. amplitude?: number);
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a bouncing shape (see link below).
  4954. * @see https://easings.net/#easeInBounce
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. export class BounceEase extends EasingFunction implements IEasingFunction {
  4958. /** Defines the number of bounces */
  4959. bounces: number;
  4960. /** Defines the amplitude of the bounce */
  4961. bounciness: number;
  4962. /**
  4963. * Instantiates a bounce easing
  4964. * @see https://easings.net/#easeInBounce
  4965. * @param bounces Defines the number of bounces
  4966. * @param bounciness Defines the amplitude of the bounce
  4967. */
  4968. constructor(
  4969. /** Defines the number of bounces */
  4970. bounces?: number,
  4971. /** Defines the amplitude of the bounce */
  4972. bounciness?: number);
  4973. /** @hidden */
  4974. easeInCore(gradient: number): number;
  4975. }
  4976. /**
  4977. * Easing function with a power of 3 shape (see link below).
  4978. * @see https://easings.net/#easeInCubic
  4979. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4980. */
  4981. export class CubicEase extends EasingFunction implements IEasingFunction {
  4982. /** @hidden */
  4983. easeInCore(gradient: number): number;
  4984. }
  4985. /**
  4986. * Easing function with an elastic shape (see link below).
  4987. * @see https://easings.net/#easeInElastic
  4988. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4989. */
  4990. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4991. /** Defines the number of oscillations*/
  4992. oscillations: number;
  4993. /** Defines the amplitude of the oscillations*/
  4994. springiness: number;
  4995. /**
  4996. * Instantiates an elastic easing function
  4997. * @see https://easings.net/#easeInElastic
  4998. * @param oscillations Defines the number of oscillations
  4999. * @param springiness Defines the amplitude of the oscillations
  5000. */
  5001. constructor(
  5002. /** Defines the number of oscillations*/
  5003. oscillations?: number,
  5004. /** Defines the amplitude of the oscillations*/
  5005. springiness?: number);
  5006. /** @hidden */
  5007. easeInCore(gradient: number): number;
  5008. }
  5009. /**
  5010. * Easing function with an exponential shape (see link below).
  5011. * @see https://easings.net/#easeInExpo
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5015. /** Defines the exponent of the function */
  5016. exponent: number;
  5017. /**
  5018. * Instantiates an exponential easing function
  5019. * @see https://easings.net/#easeInExpo
  5020. * @param exponent Defines the exponent of the function
  5021. */
  5022. constructor(
  5023. /** Defines the exponent of the function */
  5024. exponent?: number);
  5025. /** @hidden */
  5026. easeInCore(gradient: number): number;
  5027. }
  5028. /**
  5029. * Easing function with a power shape (see link below).
  5030. * @see https://easings.net/#easeInQuad
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class PowerEase extends EasingFunction implements IEasingFunction {
  5034. /** Defines the power of the function */
  5035. power: number;
  5036. /**
  5037. * Instantiates an power base easing function
  5038. * @see https://easings.net/#easeInQuad
  5039. * @param power Defines the power of the function
  5040. */
  5041. constructor(
  5042. /** Defines the power of the function */
  5043. power?: number);
  5044. /** @hidden */
  5045. easeInCore(gradient: number): number;
  5046. }
  5047. /**
  5048. * Easing function with a power of 2 shape (see link below).
  5049. * @see https://easings.net/#easeInQuad
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5053. /** @hidden */
  5054. easeInCore(gradient: number): number;
  5055. }
  5056. /**
  5057. * Easing function with a power of 4 shape (see link below).
  5058. * @see https://easings.net/#easeInQuart
  5059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5060. */
  5061. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power of 5 shape (see link below).
  5067. * @see https://easings.net/#easeInQuint
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5071. /** @hidden */
  5072. easeInCore(gradient: number): number;
  5073. }
  5074. /**
  5075. * Easing function with a sin shape (see link below).
  5076. * @see https://easings.net/#easeInSine
  5077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5078. */
  5079. export class SineEase extends EasingFunction implements IEasingFunction {
  5080. /** @hidden */
  5081. easeInCore(gradient: number): number;
  5082. }
  5083. /**
  5084. * Easing function with a bezier shape (see link below).
  5085. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5086. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5087. */
  5088. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5089. /** Defines the x component of the start tangent in the bezier curve */
  5090. x1: number;
  5091. /** Defines the y component of the start tangent in the bezier curve */
  5092. y1: number;
  5093. /** Defines the x component of the end tangent in the bezier curve */
  5094. x2: number;
  5095. /** Defines the y component of the end tangent in the bezier curve */
  5096. y2: number;
  5097. /**
  5098. * Instantiates a bezier function
  5099. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5100. * @param x1 Defines the x component of the start tangent in the bezier curve
  5101. * @param y1 Defines the y component of the start tangent in the bezier curve
  5102. * @param x2 Defines the x component of the end tangent in the bezier curve
  5103. * @param y2 Defines the y component of the end tangent in the bezier curve
  5104. */
  5105. constructor(
  5106. /** Defines the x component of the start tangent in the bezier curve */
  5107. x1?: number,
  5108. /** Defines the y component of the start tangent in the bezier curve */
  5109. y1?: number,
  5110. /** Defines the x component of the end tangent in the bezier curve */
  5111. x2?: number,
  5112. /** Defines the y component of the end tangent in the bezier curve */
  5113. y2?: number);
  5114. /** @hidden */
  5115. easeInCore(gradient: number): number;
  5116. }
  5117. }
  5118. declare module BABYLON {
  5119. /**
  5120. * Class used to hold a RBG color
  5121. */
  5122. export class Color3 {
  5123. /**
  5124. * Defines the red component (between 0 and 1, default is 0)
  5125. */
  5126. r: number;
  5127. /**
  5128. * Defines the green component (between 0 and 1, default is 0)
  5129. */
  5130. g: number;
  5131. /**
  5132. * Defines the blue component (between 0 and 1, default is 0)
  5133. */
  5134. b: number;
  5135. /**
  5136. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5137. * @param r defines the red component (between 0 and 1, default is 0)
  5138. * @param g defines the green component (between 0 and 1, default is 0)
  5139. * @param b defines the blue component (between 0 and 1, default is 0)
  5140. */
  5141. constructor(
  5142. /**
  5143. * Defines the red component (between 0 and 1, default is 0)
  5144. */
  5145. r?: number,
  5146. /**
  5147. * Defines the green component (between 0 and 1, default is 0)
  5148. */
  5149. g?: number,
  5150. /**
  5151. * Defines the blue component (between 0 and 1, default is 0)
  5152. */
  5153. b?: number);
  5154. /**
  5155. * Creates a string with the Color3 current values
  5156. * @returns the string representation of the Color3 object
  5157. */
  5158. toString(): string;
  5159. /**
  5160. * Returns the string "Color3"
  5161. * @returns "Color3"
  5162. */
  5163. getClassName(): string;
  5164. /**
  5165. * Compute the Color3 hash code
  5166. * @returns an unique number that can be used to hash Color3 objects
  5167. */
  5168. getHashCode(): number;
  5169. /**
  5170. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5171. * @param array defines the array where to store the r,g,b components
  5172. * @param index defines an optional index in the target array to define where to start storing values
  5173. * @returns the current Color3 object
  5174. */
  5175. toArray(array: FloatArray, index?: number): Color3;
  5176. /**
  5177. * Returns a new Color4 object from the current Color3 and the given alpha
  5178. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5179. * @returns a new Color4 object
  5180. */
  5181. toColor4(alpha?: number): Color4;
  5182. /**
  5183. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5184. * @returns the new array
  5185. */
  5186. asArray(): number[];
  5187. /**
  5188. * Returns the luminance value
  5189. * @returns a float value
  5190. */
  5191. toLuminance(): number;
  5192. /**
  5193. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5194. * @param otherColor defines the second operand
  5195. * @returns the new Color3 object
  5196. */
  5197. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5198. /**
  5199. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5200. * @param otherColor defines the second operand
  5201. * @param result defines the Color3 object where to store the result
  5202. * @returns the current Color3
  5203. */
  5204. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5205. /**
  5206. * Determines equality between Color3 objects
  5207. * @param otherColor defines the second operand
  5208. * @returns true if the rgb values are equal to the given ones
  5209. */
  5210. equals(otherColor: DeepImmutable<Color3>): boolean;
  5211. /**
  5212. * Determines equality between the current Color3 object and a set of r,b,g values
  5213. * @param r defines the red component to check
  5214. * @param g defines the green component to check
  5215. * @param b defines the blue component to check
  5216. * @returns true if the rgb values are equal to the given ones
  5217. */
  5218. equalsFloats(r: number, g: number, b: number): boolean;
  5219. /**
  5220. * Multiplies in place each rgb value by scale
  5221. * @param scale defines the scaling factor
  5222. * @returns the updated Color3
  5223. */
  5224. scale(scale: number): Color3;
  5225. /**
  5226. * Multiplies the rgb values by scale and stores the result into "result"
  5227. * @param scale defines the scaling factor
  5228. * @param result defines the Color3 object where to store the result
  5229. * @returns the unmodified current Color3
  5230. */
  5231. scaleToRef(scale: number, result: Color3): Color3;
  5232. /**
  5233. * Scale the current Color3 values by a factor and add the result to a given Color3
  5234. * @param scale defines the scale factor
  5235. * @param result defines color to store the result into
  5236. * @returns the unmodified current Color3
  5237. */
  5238. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5239. /**
  5240. * Clamps the rgb values by the min and max values and stores the result into "result"
  5241. * @param min defines minimum clamping value (default is 0)
  5242. * @param max defines maximum clamping value (default is 1)
  5243. * @param result defines color to store the result into
  5244. * @returns the original Color3
  5245. */
  5246. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5247. /**
  5248. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5249. * @param otherColor defines the second operand
  5250. * @returns the new Color3
  5251. */
  5252. add(otherColor: DeepImmutable<Color3>): Color3;
  5253. /**
  5254. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5255. * @param otherColor defines the second operand
  5256. * @param result defines Color3 object to store the result into
  5257. * @returns the unmodified current Color3
  5258. */
  5259. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5260. /**
  5261. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5262. * @param otherColor defines the second operand
  5263. * @returns the new Color3
  5264. */
  5265. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5266. /**
  5267. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5268. * @param otherColor defines the second operand
  5269. * @param result defines Color3 object to store the result into
  5270. * @returns the unmodified current Color3
  5271. */
  5272. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5273. /**
  5274. * Copy the current object
  5275. * @returns a new Color3 copied the current one
  5276. */
  5277. clone(): Color3;
  5278. /**
  5279. * Copies the rgb values from the source in the current Color3
  5280. * @param source defines the source Color3 object
  5281. * @returns the updated Color3 object
  5282. */
  5283. copyFrom(source: DeepImmutable<Color3>): Color3;
  5284. /**
  5285. * Updates the Color3 rgb values from the given floats
  5286. * @param r defines the red component to read from
  5287. * @param g defines the green component to read from
  5288. * @param b defines the blue component to read from
  5289. * @returns the current Color3 object
  5290. */
  5291. copyFromFloats(r: number, g: number, b: number): Color3;
  5292. /**
  5293. * Updates the Color3 rgb values from the given floats
  5294. * @param r defines the red component to read from
  5295. * @param g defines the green component to read from
  5296. * @param b defines the blue component to read from
  5297. * @returns the current Color3 object
  5298. */
  5299. set(r: number, g: number, b: number): Color3;
  5300. /**
  5301. * Compute the Color3 hexadecimal code as a string
  5302. * @returns a string containing the hexadecimal representation of the Color3 object
  5303. */
  5304. toHexString(): string;
  5305. /**
  5306. * Computes a new Color3 converted from the current one to linear space
  5307. * @returns a new Color3 object
  5308. */
  5309. toLinearSpace(): Color3;
  5310. /**
  5311. * Converts current color in rgb space to HSV values
  5312. * @returns a new color3 representing the HSV values
  5313. */
  5314. toHSV(): Color3;
  5315. /**
  5316. * Converts current color in rgb space to HSV values
  5317. * @param result defines the Color3 where to store the HSV values
  5318. */
  5319. toHSVToRef(result: Color3): void;
  5320. /**
  5321. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5322. * @param convertedColor defines the Color3 object where to store the linear space version
  5323. * @returns the unmodified Color3
  5324. */
  5325. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5326. /**
  5327. * Computes a new Color3 converted from the current one to gamma space
  5328. * @returns a new Color3 object
  5329. */
  5330. toGammaSpace(): Color3;
  5331. /**
  5332. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5333. * @param convertedColor defines the Color3 object where to store the gamma space version
  5334. * @returns the unmodified Color3
  5335. */
  5336. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5337. private static _BlackReadOnly;
  5338. /**
  5339. * Convert Hue, saturation and value to a Color3 (RGB)
  5340. * @param hue defines the hue
  5341. * @param saturation defines the saturation
  5342. * @param value defines the value
  5343. * @param result defines the Color3 where to store the RGB values
  5344. */
  5345. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5346. /**
  5347. * Creates a new Color3 from the string containing valid hexadecimal values
  5348. * @param hex defines a string containing valid hexadecimal values
  5349. * @returns a new Color3 object
  5350. */
  5351. static FromHexString(hex: string): Color3;
  5352. /**
  5353. * Creates a new Color3 from the starting index of the given array
  5354. * @param array defines the source array
  5355. * @param offset defines an offset in the source array
  5356. * @returns a new Color3 object
  5357. */
  5358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5359. /**
  5360. * Creates a new Color3 from integer values (< 256)
  5361. * @param r defines the red component to read from (value between 0 and 255)
  5362. * @param g defines the green component to read from (value between 0 and 255)
  5363. * @param b defines the blue component to read from (value between 0 and 255)
  5364. * @returns a new Color3 object
  5365. */
  5366. static FromInts(r: number, g: number, b: number): Color3;
  5367. /**
  5368. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5369. * @param start defines the start Color3 value
  5370. * @param end defines the end Color3 value
  5371. * @param amount defines the gradient value between start and end
  5372. * @returns a new Color3 object
  5373. */
  5374. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5375. /**
  5376. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5377. * @param left defines the start value
  5378. * @param right defines the end value
  5379. * @param amount defines the gradient factor
  5380. * @param result defines the Color3 object where to store the result
  5381. */
  5382. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5383. /**
  5384. * Returns a Color3 value containing a red color
  5385. * @returns a new Color3 object
  5386. */
  5387. static Red(): Color3;
  5388. /**
  5389. * Returns a Color3 value containing a green color
  5390. * @returns a new Color3 object
  5391. */
  5392. static Green(): Color3;
  5393. /**
  5394. * Returns a Color3 value containing a blue color
  5395. * @returns a new Color3 object
  5396. */
  5397. static Blue(): Color3;
  5398. /**
  5399. * Returns a Color3 value containing a black color
  5400. * @returns a new Color3 object
  5401. */
  5402. static Black(): Color3;
  5403. /**
  5404. * Gets a Color3 value containing a black color that must not be updated
  5405. */
  5406. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5407. /**
  5408. * Returns a Color3 value containing a white color
  5409. * @returns a new Color3 object
  5410. */
  5411. static White(): Color3;
  5412. /**
  5413. * Returns a Color3 value containing a purple color
  5414. * @returns a new Color3 object
  5415. */
  5416. static Purple(): Color3;
  5417. /**
  5418. * Returns a Color3 value containing a magenta color
  5419. * @returns a new Color3 object
  5420. */
  5421. static Magenta(): Color3;
  5422. /**
  5423. * Returns a Color3 value containing a yellow color
  5424. * @returns a new Color3 object
  5425. */
  5426. static Yellow(): Color3;
  5427. /**
  5428. * Returns a Color3 value containing a gray color
  5429. * @returns a new Color3 object
  5430. */
  5431. static Gray(): Color3;
  5432. /**
  5433. * Returns a Color3 value containing a teal color
  5434. * @returns a new Color3 object
  5435. */
  5436. static Teal(): Color3;
  5437. /**
  5438. * Returns a Color3 value containing a random color
  5439. * @returns a new Color3 object
  5440. */
  5441. static Random(): Color3;
  5442. }
  5443. /**
  5444. * Class used to hold a RBGA color
  5445. */
  5446. export class Color4 {
  5447. /**
  5448. * Defines the red component (between 0 and 1, default is 0)
  5449. */
  5450. r: number;
  5451. /**
  5452. * Defines the green component (between 0 and 1, default is 0)
  5453. */
  5454. g: number;
  5455. /**
  5456. * Defines the blue component (between 0 and 1, default is 0)
  5457. */
  5458. b: number;
  5459. /**
  5460. * Defines the alpha component (between 0 and 1, default is 1)
  5461. */
  5462. a: number;
  5463. /**
  5464. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5465. * @param r defines the red component (between 0 and 1, default is 0)
  5466. * @param g defines the green component (between 0 and 1, default is 0)
  5467. * @param b defines the blue component (between 0 and 1, default is 0)
  5468. * @param a defines the alpha component (between 0 and 1, default is 1)
  5469. */
  5470. constructor(
  5471. /**
  5472. * Defines the red component (between 0 and 1, default is 0)
  5473. */
  5474. r?: number,
  5475. /**
  5476. * Defines the green component (between 0 and 1, default is 0)
  5477. */
  5478. g?: number,
  5479. /**
  5480. * Defines the blue component (between 0 and 1, default is 0)
  5481. */
  5482. b?: number,
  5483. /**
  5484. * Defines the alpha component (between 0 and 1, default is 1)
  5485. */
  5486. a?: number);
  5487. /**
  5488. * Adds in place the given Color4 values to the current Color4 object
  5489. * @param right defines the second operand
  5490. * @returns the current updated Color4 object
  5491. */
  5492. addInPlace(right: DeepImmutable<Color4>): Color4;
  5493. /**
  5494. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5495. * @returns the new array
  5496. */
  5497. asArray(): number[];
  5498. /**
  5499. * Stores from the starting index in the given array the Color4 successive values
  5500. * @param array defines the array where to store the r,g,b components
  5501. * @param index defines an optional index in the target array to define where to start storing values
  5502. * @returns the current Color4 object
  5503. */
  5504. toArray(array: number[], index?: number): Color4;
  5505. /**
  5506. * Determines equality between Color4 objects
  5507. * @param otherColor defines the second operand
  5508. * @returns true if the rgba values are equal to the given ones
  5509. */
  5510. equals(otherColor: DeepImmutable<Color4>): boolean;
  5511. /**
  5512. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5513. * @param right defines the second operand
  5514. * @returns a new Color4 object
  5515. */
  5516. add(right: DeepImmutable<Color4>): Color4;
  5517. /**
  5518. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5519. * @param right defines the second operand
  5520. * @returns a new Color4 object
  5521. */
  5522. subtract(right: DeepImmutable<Color4>): Color4;
  5523. /**
  5524. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5525. * @param right defines the second operand
  5526. * @param result defines the Color4 object where to store the result
  5527. * @returns the current Color4 object
  5528. */
  5529. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5530. /**
  5531. * Creates a new Color4 with the current Color4 values multiplied by scale
  5532. * @param scale defines the scaling factor to apply
  5533. * @returns a new Color4 object
  5534. */
  5535. scale(scale: number): Color4;
  5536. /**
  5537. * Multiplies the current Color4 values by scale and stores the result in "result"
  5538. * @param scale defines the scaling factor to apply
  5539. * @param result defines the Color4 object where to store the result
  5540. * @returns the current unmodified Color4
  5541. */
  5542. scaleToRef(scale: number, result: Color4): Color4;
  5543. /**
  5544. * Scale the current Color4 values by a factor and add the result to a given Color4
  5545. * @param scale defines the scale factor
  5546. * @param result defines the Color4 object where to store the result
  5547. * @returns the unmodified current Color4
  5548. */
  5549. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5550. /**
  5551. * Clamps the rgb values by the min and max values and stores the result into "result"
  5552. * @param min defines minimum clamping value (default is 0)
  5553. * @param max defines maximum clamping value (default is 1)
  5554. * @param result defines color to store the result into.
  5555. * @returns the cuurent Color4
  5556. */
  5557. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5558. /**
  5559. * Multipy an Color4 value by another and return a new Color4 object
  5560. * @param color defines the Color4 value to multiply by
  5561. * @returns a new Color4 object
  5562. */
  5563. multiply(color: Color4): Color4;
  5564. /**
  5565. * Multipy a Color4 value by another and push the result in a reference value
  5566. * @param color defines the Color4 value to multiply by
  5567. * @param result defines the Color4 to fill the result in
  5568. * @returns the result Color4
  5569. */
  5570. multiplyToRef(color: Color4, result: Color4): Color4;
  5571. /**
  5572. * Creates a string with the Color4 current values
  5573. * @returns the string representation of the Color4 object
  5574. */
  5575. toString(): string;
  5576. /**
  5577. * Returns the string "Color4"
  5578. * @returns "Color4"
  5579. */
  5580. getClassName(): string;
  5581. /**
  5582. * Compute the Color4 hash code
  5583. * @returns an unique number that can be used to hash Color4 objects
  5584. */
  5585. getHashCode(): number;
  5586. /**
  5587. * Creates a new Color4 copied from the current one
  5588. * @returns a new Color4 object
  5589. */
  5590. clone(): Color4;
  5591. /**
  5592. * Copies the given Color4 values into the current one
  5593. * @param source defines the source Color4 object
  5594. * @returns the current updated Color4 object
  5595. */
  5596. copyFrom(source: Color4): Color4;
  5597. /**
  5598. * Copies the given float values into the current one
  5599. * @param r defines the red component to read from
  5600. * @param g defines the green component to read from
  5601. * @param b defines the blue component to read from
  5602. * @param a defines the alpha component to read from
  5603. * @returns the current updated Color4 object
  5604. */
  5605. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5606. /**
  5607. * Copies the given float values into the current one
  5608. * @param r defines the red component to read from
  5609. * @param g defines the green component to read from
  5610. * @param b defines the blue component to read from
  5611. * @param a defines the alpha component to read from
  5612. * @returns the current updated Color4 object
  5613. */
  5614. set(r: number, g: number, b: number, a: number): Color4;
  5615. /**
  5616. * Compute the Color4 hexadecimal code as a string
  5617. * @returns a string containing the hexadecimal representation of the Color4 object
  5618. */
  5619. toHexString(): string;
  5620. /**
  5621. * Computes a new Color4 converted from the current one to linear space
  5622. * @returns a new Color4 object
  5623. */
  5624. toLinearSpace(): Color4;
  5625. /**
  5626. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5627. * @param convertedColor defines the Color4 object where to store the linear space version
  5628. * @returns the unmodified Color4
  5629. */
  5630. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5631. /**
  5632. * Computes a new Color4 converted from the current one to gamma space
  5633. * @returns a new Color4 object
  5634. */
  5635. toGammaSpace(): Color4;
  5636. /**
  5637. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5638. * @param convertedColor defines the Color4 object where to store the gamma space version
  5639. * @returns the unmodified Color4
  5640. */
  5641. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5642. /**
  5643. * Creates a new Color4 from the string containing valid hexadecimal values
  5644. * @param hex defines a string containing valid hexadecimal values
  5645. * @returns a new Color4 object
  5646. */
  5647. static FromHexString(hex: string): Color4;
  5648. /**
  5649. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5650. * @param left defines the start value
  5651. * @param right defines the end value
  5652. * @param amount defines the gradient factor
  5653. * @returns a new Color4 object
  5654. */
  5655. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5656. /**
  5657. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5658. * @param left defines the start value
  5659. * @param right defines the end value
  5660. * @param amount defines the gradient factor
  5661. * @param result defines the Color4 object where to store data
  5662. */
  5663. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5664. /**
  5665. * Creates a new Color4 from a Color3 and an alpha value
  5666. * @param color3 defines the source Color3 to read from
  5667. * @param alpha defines the alpha component (1.0 by default)
  5668. * @returns a new Color4 object
  5669. */
  5670. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5671. /**
  5672. * Creates a new Color4 from the starting index element of the given array
  5673. * @param array defines the source array to read from
  5674. * @param offset defines the offset in the source array
  5675. * @returns a new Color4 object
  5676. */
  5677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5678. /**
  5679. * Creates a new Color3 from integer values (< 256)
  5680. * @param r defines the red component to read from (value between 0 and 255)
  5681. * @param g defines the green component to read from (value between 0 and 255)
  5682. * @param b defines the blue component to read from (value between 0 and 255)
  5683. * @param a defines the alpha component to read from (value between 0 and 255)
  5684. * @returns a new Color3 object
  5685. */
  5686. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5687. /**
  5688. * Check the content of a given array and convert it to an array containing RGBA data
  5689. * If the original array was already containing count * 4 values then it is returned directly
  5690. * @param colors defines the array to check
  5691. * @param count defines the number of RGBA data to expect
  5692. * @returns an array containing count * 4 values (RGBA)
  5693. */
  5694. static CheckColors4(colors: number[], count: number): number[];
  5695. }
  5696. /**
  5697. * @hidden
  5698. */
  5699. export class TmpColors {
  5700. static Color3: Color3[];
  5701. static Color4: Color4[];
  5702. }
  5703. }
  5704. declare module BABYLON {
  5705. /**
  5706. * Defines an interface which represents an animation key frame
  5707. */
  5708. export interface IAnimationKey {
  5709. /**
  5710. * Frame of the key frame
  5711. */
  5712. frame: number;
  5713. /**
  5714. * Value at the specifies key frame
  5715. */
  5716. value: any;
  5717. /**
  5718. * The input tangent for the cubic hermite spline
  5719. */
  5720. inTangent?: any;
  5721. /**
  5722. * The output tangent for the cubic hermite spline
  5723. */
  5724. outTangent?: any;
  5725. /**
  5726. * The animation interpolation type
  5727. */
  5728. interpolation?: AnimationKeyInterpolation;
  5729. }
  5730. /**
  5731. * Enum for the animation key frame interpolation type
  5732. */
  5733. export enum AnimationKeyInterpolation {
  5734. /**
  5735. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5736. */
  5737. STEP = 1
  5738. }
  5739. }
  5740. declare module BABYLON {
  5741. /**
  5742. * Represents the range of an animation
  5743. */
  5744. export class AnimationRange {
  5745. /**The name of the animation range**/
  5746. name: string;
  5747. /**The starting frame of the animation */
  5748. from: number;
  5749. /**The ending frame of the animation*/
  5750. to: number;
  5751. /**
  5752. * Initializes the range of an animation
  5753. * @param name The name of the animation range
  5754. * @param from The starting frame of the animation
  5755. * @param to The ending frame of the animation
  5756. */
  5757. constructor(
  5758. /**The name of the animation range**/
  5759. name: string,
  5760. /**The starting frame of the animation */
  5761. from: number,
  5762. /**The ending frame of the animation*/
  5763. to: number);
  5764. /**
  5765. * Makes a copy of the animation range
  5766. * @returns A copy of the animation range
  5767. */
  5768. clone(): AnimationRange;
  5769. }
  5770. }
  5771. declare module BABYLON {
  5772. /**
  5773. * Composed of a frame, and an action function
  5774. */
  5775. export class AnimationEvent {
  5776. /** The frame for which the event is triggered **/
  5777. frame: number;
  5778. /** The event to perform when triggered **/
  5779. action: (currentFrame: number) => void;
  5780. /** Specifies if the event should be triggered only once**/
  5781. onlyOnce?: boolean | undefined;
  5782. /**
  5783. * Specifies if the animation event is done
  5784. */
  5785. isDone: boolean;
  5786. /**
  5787. * Initializes the animation event
  5788. * @param frame The frame for which the event is triggered
  5789. * @param action The event to perform when triggered
  5790. * @param onlyOnce Specifies if the event should be triggered only once
  5791. */
  5792. constructor(
  5793. /** The frame for which the event is triggered **/
  5794. frame: number,
  5795. /** The event to perform when triggered **/
  5796. action: (currentFrame: number) => void,
  5797. /** Specifies if the event should be triggered only once**/
  5798. onlyOnce?: boolean | undefined);
  5799. /** @hidden */
  5800. _clone(): AnimationEvent;
  5801. }
  5802. }
  5803. declare module BABYLON {
  5804. /**
  5805. * Interface used to define a behavior
  5806. */
  5807. export interface Behavior<T> {
  5808. /** gets or sets behavior's name */
  5809. name: string;
  5810. /**
  5811. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5812. */
  5813. init(): void;
  5814. /**
  5815. * Called when the behavior is attached to a target
  5816. * @param target defines the target where the behavior is attached to
  5817. */
  5818. attach(target: T): void;
  5819. /**
  5820. * Called when the behavior is detached from its target
  5821. */
  5822. detach(): void;
  5823. }
  5824. /**
  5825. * Interface implemented by classes supporting behaviors
  5826. */
  5827. export interface IBehaviorAware<T> {
  5828. /**
  5829. * Attach a behavior
  5830. * @param behavior defines the behavior to attach
  5831. * @returns the current host
  5832. */
  5833. addBehavior(behavior: Behavior<T>): T;
  5834. /**
  5835. * Remove a behavior from the current object
  5836. * @param behavior defines the behavior to detach
  5837. * @returns the current host
  5838. */
  5839. removeBehavior(behavior: Behavior<T>): T;
  5840. /**
  5841. * Gets a behavior using its name to search
  5842. * @param name defines the name to search
  5843. * @returns the behavior or null if not found
  5844. */
  5845. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5846. }
  5847. }
  5848. declare module BABYLON {
  5849. /**
  5850. * Defines an array and its length.
  5851. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5852. */
  5853. export interface ISmartArrayLike<T> {
  5854. /**
  5855. * The data of the array.
  5856. */
  5857. data: Array<T>;
  5858. /**
  5859. * The active length of the array.
  5860. */
  5861. length: number;
  5862. }
  5863. /**
  5864. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5865. */
  5866. export class SmartArray<T> implements ISmartArrayLike<T> {
  5867. /**
  5868. * The full set of data from the array.
  5869. */
  5870. data: Array<T>;
  5871. /**
  5872. * The active length of the array.
  5873. */
  5874. length: number;
  5875. protected _id: number;
  5876. /**
  5877. * Instantiates a Smart Array.
  5878. * @param capacity defines the default capacity of the array.
  5879. */
  5880. constructor(capacity: number);
  5881. /**
  5882. * Pushes a value at the end of the active data.
  5883. * @param value defines the object to push in the array.
  5884. */
  5885. push(value: T): void;
  5886. /**
  5887. * Iterates over the active data and apply the lambda to them.
  5888. * @param func defines the action to apply on each value.
  5889. */
  5890. forEach(func: (content: T) => void): void;
  5891. /**
  5892. * Sorts the full sets of data.
  5893. * @param compareFn defines the comparison function to apply.
  5894. */
  5895. sort(compareFn: (a: T, b: T) => number): void;
  5896. /**
  5897. * Resets the active data to an empty array.
  5898. */
  5899. reset(): void;
  5900. /**
  5901. * Releases all the data from the array as well as the array.
  5902. */
  5903. dispose(): void;
  5904. /**
  5905. * Concats the active data with a given array.
  5906. * @param array defines the data to concatenate with.
  5907. */
  5908. concat(array: any): void;
  5909. /**
  5910. * Returns the position of a value in the active data.
  5911. * @param value defines the value to find the index for
  5912. * @returns the index if found in the active data otherwise -1
  5913. */
  5914. indexOf(value: T): number;
  5915. /**
  5916. * Returns whether an element is part of the active data.
  5917. * @param value defines the value to look for
  5918. * @returns true if found in the active data otherwise false
  5919. */
  5920. contains(value: T): boolean;
  5921. private static _GlobalId;
  5922. }
  5923. /**
  5924. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5925. * The data in this array can only be present once
  5926. */
  5927. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5928. private _duplicateId;
  5929. /**
  5930. * Pushes a value at the end of the active data.
  5931. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5932. * @param value defines the object to push in the array.
  5933. */
  5934. push(value: T): void;
  5935. /**
  5936. * Pushes a value at the end of the active data.
  5937. * If the data is already present, it won t be added again
  5938. * @param value defines the object to push in the array.
  5939. * @returns true if added false if it was already present
  5940. */
  5941. pushNoDuplicate(value: T): boolean;
  5942. /**
  5943. * Resets the active data to an empty array.
  5944. */
  5945. reset(): void;
  5946. /**
  5947. * Concats the active data with a given array.
  5948. * This ensures no dupplicate will be present in the result.
  5949. * @param array defines the data to concatenate with.
  5950. */
  5951. concatWithNoDuplicate(array: any): void;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * @ignore
  5957. * This is a list of all the different input types that are available in the application.
  5958. * Fo instance: ArcRotateCameraGamepadInput...
  5959. */
  5960. export var CameraInputTypes: {};
  5961. /**
  5962. * This is the contract to implement in order to create a new input class.
  5963. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5964. */
  5965. export interface ICameraInput<TCamera extends Camera> {
  5966. /**
  5967. * Defines the camera the input is attached to.
  5968. */
  5969. camera: Nullable<TCamera>;
  5970. /**
  5971. * Gets the class name of the current intput.
  5972. * @returns the class name
  5973. */
  5974. getClassName(): string;
  5975. /**
  5976. * Get the friendly name associated with the input class.
  5977. * @returns the input friendly name
  5978. */
  5979. getSimpleName(): string;
  5980. /**
  5981. * Attach the input controls to a specific dom element to get the input from.
  5982. * @param element Defines the element the controls should be listened from
  5983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5984. */
  5985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5986. /**
  5987. * Detach the current controls from the specified dom element.
  5988. * @param element Defines the element to stop listening the inputs from
  5989. */
  5990. detachControl(element: Nullable<HTMLElement>): void;
  5991. /**
  5992. * Update the current camera state depending on the inputs that have been used this frame.
  5993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5994. */
  5995. checkInputs?: () => void;
  5996. }
  5997. /**
  5998. * Represents a map of input types to input instance or input index to input instance.
  5999. */
  6000. export interface CameraInputsMap<TCamera extends Camera> {
  6001. /**
  6002. * Accessor to the input by input type.
  6003. */
  6004. [name: string]: ICameraInput<TCamera>;
  6005. /**
  6006. * Accessor to the input by input index.
  6007. */
  6008. [idx: number]: ICameraInput<TCamera>;
  6009. }
  6010. /**
  6011. * This represents the input manager used within a camera.
  6012. * It helps dealing with all the different kind of input attached to a camera.
  6013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6014. */
  6015. export class CameraInputsManager<TCamera extends Camera> {
  6016. /**
  6017. * Defines the list of inputs attahed to the camera.
  6018. */
  6019. attached: CameraInputsMap<TCamera>;
  6020. /**
  6021. * Defines the dom element the camera is collecting inputs from.
  6022. * This is null if the controls have not been attached.
  6023. */
  6024. attachedElement: Nullable<HTMLElement>;
  6025. /**
  6026. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6027. */
  6028. noPreventDefault: boolean;
  6029. /**
  6030. * Defined the camera the input manager belongs to.
  6031. */
  6032. camera: TCamera;
  6033. /**
  6034. * Update the current camera state depending on the inputs that have been used this frame.
  6035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6036. */
  6037. checkInputs: () => void;
  6038. /**
  6039. * Instantiate a new Camera Input Manager.
  6040. * @param camera Defines the camera the input manager blongs to
  6041. */
  6042. constructor(camera: TCamera);
  6043. /**
  6044. * Add an input method to a camera
  6045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6046. * @param input camera input method
  6047. */
  6048. add(input: ICameraInput<TCamera>): void;
  6049. /**
  6050. * Remove a specific input method from a camera
  6051. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6052. * @param inputToRemove camera input method
  6053. */
  6054. remove(inputToRemove: ICameraInput<TCamera>): void;
  6055. /**
  6056. * Remove a specific input type from a camera
  6057. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6058. * @param inputType the type of the input to remove
  6059. */
  6060. removeByType(inputType: string): void;
  6061. private _addCheckInputs;
  6062. /**
  6063. * Attach the input controls to the currently attached dom element to listen the events from.
  6064. * @param input Defines the input to attach
  6065. */
  6066. attachInput(input: ICameraInput<TCamera>): void;
  6067. /**
  6068. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6069. * @param element Defines the dom element to collect the events from
  6070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6071. */
  6072. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6073. /**
  6074. * Detach the current manager inputs controls from a specific dom element.
  6075. * @param element Defines the dom element to collect the events from
  6076. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6077. */
  6078. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6079. /**
  6080. * Rebuild the dynamic inputCheck function from the current list of
  6081. * defined inputs in the manager.
  6082. */
  6083. rebuildInputCheck(): void;
  6084. /**
  6085. * Remove all attached input methods from a camera
  6086. */
  6087. clear(): void;
  6088. /**
  6089. * Serialize the current input manager attached to a camera.
  6090. * This ensures than once parsed,
  6091. * the input associated to the camera will be identical to the current ones
  6092. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6093. */
  6094. serialize(serializedCamera: any): void;
  6095. /**
  6096. * Parses an input manager serialized JSON to restore the previous list of inputs
  6097. * and states associated to a camera.
  6098. * @param parsedCamera Defines the JSON to parse
  6099. */
  6100. parse(parsedCamera: any): void;
  6101. }
  6102. }
  6103. declare module BABYLON {
  6104. /**
  6105. * Class used to store data that will be store in GPU memory
  6106. */
  6107. export class Buffer {
  6108. private _engine;
  6109. private _buffer;
  6110. /** @hidden */
  6111. _data: Nullable<DataArray>;
  6112. private _updatable;
  6113. private _instanced;
  6114. private _divisor;
  6115. /**
  6116. * Gets the byte stride.
  6117. */
  6118. readonly byteStride: number;
  6119. /**
  6120. * Constructor
  6121. * @param engine the engine
  6122. * @param data the data to use for this buffer
  6123. * @param updatable whether the data is updatable
  6124. * @param stride the stride (optional)
  6125. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6126. * @param instanced whether the buffer is instanced (optional)
  6127. * @param useBytes set to true if the stride in in bytes (optional)
  6128. * @param divisor sets an optional divisor for instances (1 by default)
  6129. */
  6130. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6131. /**
  6132. * Create a new VertexBuffer based on the current buffer
  6133. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6134. * @param offset defines offset in the buffer (0 by default)
  6135. * @param size defines the size in floats of attributes (position is 3 for instance)
  6136. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6137. * @param instanced defines if the vertex buffer contains indexed data
  6138. * @param useBytes defines if the offset and stride are in bytes *
  6139. * @param divisor sets an optional divisor for instances (1 by default)
  6140. * @returns the new vertex buffer
  6141. */
  6142. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6143. /**
  6144. * Gets a boolean indicating if the Buffer is updatable?
  6145. * @returns true if the buffer is updatable
  6146. */
  6147. isUpdatable(): boolean;
  6148. /**
  6149. * Gets current buffer's data
  6150. * @returns a DataArray or null
  6151. */
  6152. getData(): Nullable<DataArray>;
  6153. /**
  6154. * Gets underlying native buffer
  6155. * @returns underlying native buffer
  6156. */
  6157. getBuffer(): Nullable<DataBuffer>;
  6158. /**
  6159. * Gets the stride in float32 units (i.e. byte stride / 4).
  6160. * May not be an integer if the byte stride is not divisible by 4.
  6161. * DEPRECATED. Use byteStride instead.
  6162. * @returns the stride in float32 units
  6163. */
  6164. getStrideSize(): number;
  6165. /**
  6166. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6167. * @param data defines the data to store
  6168. */
  6169. create(data?: Nullable<DataArray>): void;
  6170. /** @hidden */
  6171. _rebuild(): void;
  6172. /**
  6173. * Update current buffer data
  6174. * @param data defines the data to store
  6175. */
  6176. update(data: DataArray): void;
  6177. /**
  6178. * Updates the data directly.
  6179. * @param data the new data
  6180. * @param offset the new offset
  6181. * @param vertexCount the vertex count (optional)
  6182. * @param useBytes set to true if the offset is in bytes
  6183. */
  6184. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6185. /**
  6186. * Release all resources
  6187. */
  6188. dispose(): void;
  6189. }
  6190. /**
  6191. * Specialized buffer used to store vertex data
  6192. */
  6193. export class VertexBuffer {
  6194. /** @hidden */
  6195. _buffer: Buffer;
  6196. private _kind;
  6197. private _size;
  6198. private _ownsBuffer;
  6199. private _instanced;
  6200. private _instanceDivisor;
  6201. /**
  6202. * The byte type.
  6203. */
  6204. static readonly BYTE: number;
  6205. /**
  6206. * The unsigned byte type.
  6207. */
  6208. static readonly UNSIGNED_BYTE: number;
  6209. /**
  6210. * The short type.
  6211. */
  6212. static readonly SHORT: number;
  6213. /**
  6214. * The unsigned short type.
  6215. */
  6216. static readonly UNSIGNED_SHORT: number;
  6217. /**
  6218. * The integer type.
  6219. */
  6220. static readonly INT: number;
  6221. /**
  6222. * The unsigned integer type.
  6223. */
  6224. static readonly UNSIGNED_INT: number;
  6225. /**
  6226. * The float type.
  6227. */
  6228. static readonly FLOAT: number;
  6229. /**
  6230. * Gets or sets the instance divisor when in instanced mode
  6231. */
  6232. instanceDivisor: number;
  6233. /**
  6234. * Gets the byte stride.
  6235. */
  6236. readonly byteStride: number;
  6237. /**
  6238. * Gets the byte offset.
  6239. */
  6240. readonly byteOffset: number;
  6241. /**
  6242. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6243. */
  6244. readonly normalized: boolean;
  6245. /**
  6246. * Gets the data type of each component in the array.
  6247. */
  6248. readonly type: number;
  6249. /**
  6250. * Constructor
  6251. * @param engine the engine
  6252. * @param data the data to use for this vertex buffer
  6253. * @param kind the vertex buffer kind
  6254. * @param updatable whether the data is updatable
  6255. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6256. * @param stride the stride (optional)
  6257. * @param instanced whether the buffer is instanced (optional)
  6258. * @param offset the offset of the data (optional)
  6259. * @param size the number of components (optional)
  6260. * @param type the type of the component (optional)
  6261. * @param normalized whether the data contains normalized data (optional)
  6262. * @param useBytes set to true if stride and offset are in bytes (optional)
  6263. * @param divisor defines the instance divisor to use (1 by default)
  6264. */
  6265. 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, divisor?: number);
  6266. /** @hidden */
  6267. _rebuild(): void;
  6268. /**
  6269. * Returns the kind of the VertexBuffer (string)
  6270. * @returns a string
  6271. */
  6272. getKind(): string;
  6273. /**
  6274. * Gets a boolean indicating if the VertexBuffer is updatable?
  6275. * @returns true if the buffer is updatable
  6276. */
  6277. isUpdatable(): boolean;
  6278. /**
  6279. * Gets current buffer's data
  6280. * @returns a DataArray or null
  6281. */
  6282. getData(): Nullable<DataArray>;
  6283. /**
  6284. * Gets underlying native buffer
  6285. * @returns underlying native buffer
  6286. */
  6287. getBuffer(): Nullable<DataBuffer>;
  6288. /**
  6289. * Gets the stride in float32 units (i.e. byte stride / 4).
  6290. * May not be an integer if the byte stride is not divisible by 4.
  6291. * DEPRECATED. Use byteStride instead.
  6292. * @returns the stride in float32 units
  6293. */
  6294. getStrideSize(): number;
  6295. /**
  6296. * Returns the offset as a multiple of the type byte length.
  6297. * DEPRECATED. Use byteOffset instead.
  6298. * @returns the offset in bytes
  6299. */
  6300. getOffset(): number;
  6301. /**
  6302. * Returns the number of components per vertex attribute (integer)
  6303. * @returns the size in float
  6304. */
  6305. getSize(): number;
  6306. /**
  6307. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6308. * @returns true if this buffer is instanced
  6309. */
  6310. getIsInstanced(): boolean;
  6311. /**
  6312. * Returns the instancing divisor, zero for non-instanced (integer).
  6313. * @returns a number
  6314. */
  6315. getInstanceDivisor(): number;
  6316. /**
  6317. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6318. * @param data defines the data to store
  6319. */
  6320. create(data?: DataArray): void;
  6321. /**
  6322. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6323. * This function will create a new buffer if the current one is not updatable
  6324. * @param data defines the data to store
  6325. */
  6326. update(data: DataArray): void;
  6327. /**
  6328. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6329. * Returns the directly updated WebGLBuffer.
  6330. * @param data the new data
  6331. * @param offset the new offset
  6332. * @param useBytes set to true if the offset is in bytes
  6333. */
  6334. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6335. /**
  6336. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6337. */
  6338. dispose(): void;
  6339. /**
  6340. * Enumerates each value of this vertex buffer as numbers.
  6341. * @param count the number of values to enumerate
  6342. * @param callback the callback function called for each value
  6343. */
  6344. forEach(count: number, callback: (value: number, index: number) => void): void;
  6345. /**
  6346. * Positions
  6347. */
  6348. static readonly PositionKind: string;
  6349. /**
  6350. * Normals
  6351. */
  6352. static readonly NormalKind: string;
  6353. /**
  6354. * Tangents
  6355. */
  6356. static readonly TangentKind: string;
  6357. /**
  6358. * Texture coordinates
  6359. */
  6360. static readonly UVKind: string;
  6361. /**
  6362. * Texture coordinates 2
  6363. */
  6364. static readonly UV2Kind: string;
  6365. /**
  6366. * Texture coordinates 3
  6367. */
  6368. static readonly UV3Kind: string;
  6369. /**
  6370. * Texture coordinates 4
  6371. */
  6372. static readonly UV4Kind: string;
  6373. /**
  6374. * Texture coordinates 5
  6375. */
  6376. static readonly UV5Kind: string;
  6377. /**
  6378. * Texture coordinates 6
  6379. */
  6380. static readonly UV6Kind: string;
  6381. /**
  6382. * Colors
  6383. */
  6384. static readonly ColorKind: string;
  6385. /**
  6386. * Matrix indices (for bones)
  6387. */
  6388. static readonly MatricesIndicesKind: string;
  6389. /**
  6390. * Matrix weights (for bones)
  6391. */
  6392. static readonly MatricesWeightsKind: string;
  6393. /**
  6394. * Additional matrix indices (for bones)
  6395. */
  6396. static readonly MatricesIndicesExtraKind: string;
  6397. /**
  6398. * Additional matrix weights (for bones)
  6399. */
  6400. static readonly MatricesWeightsExtraKind: string;
  6401. /**
  6402. * Deduces the stride given a kind.
  6403. * @param kind The kind string to deduce
  6404. * @returns The deduced stride
  6405. */
  6406. static DeduceStride(kind: string): number;
  6407. /**
  6408. * Gets the byte length of the given type.
  6409. * @param type the type
  6410. * @returns the number of bytes
  6411. */
  6412. static GetTypeByteLength(type: number): number;
  6413. /**
  6414. * Enumerates each value of the given parameters as numbers.
  6415. * @param data the data to enumerate
  6416. * @param byteOffset the byte offset of the data
  6417. * @param byteStride the byte stride of the data
  6418. * @param componentCount the number of components per element
  6419. * @param componentType the type of the component
  6420. * @param count the number of values to enumerate
  6421. * @param normalized whether the data is normalized
  6422. * @param callback the callback function called for each value
  6423. */
  6424. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6425. private static _GetFloatValue;
  6426. }
  6427. }
  6428. declare module BABYLON {
  6429. /**
  6430. * @hidden
  6431. */
  6432. export class IntersectionInfo {
  6433. bu: Nullable<number>;
  6434. bv: Nullable<number>;
  6435. distance: number;
  6436. faceId: number;
  6437. subMeshId: number;
  6438. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6439. }
  6440. }
  6441. declare module BABYLON {
  6442. /**
  6443. * Represens a plane by the equation ax + by + cz + d = 0
  6444. */
  6445. export class Plane {
  6446. private static _TmpMatrix;
  6447. /**
  6448. * Normal of the plane (a,b,c)
  6449. */
  6450. normal: Vector3;
  6451. /**
  6452. * d component of the plane
  6453. */
  6454. d: number;
  6455. /**
  6456. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6457. * @param a a component of the plane
  6458. * @param b b component of the plane
  6459. * @param c c component of the plane
  6460. * @param d d component of the plane
  6461. */
  6462. constructor(a: number, b: number, c: number, d: number);
  6463. /**
  6464. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6465. */
  6466. asArray(): number[];
  6467. /**
  6468. * @returns a new plane copied from the current Plane.
  6469. */
  6470. clone(): Plane;
  6471. /**
  6472. * @returns the string "Plane".
  6473. */
  6474. getClassName(): string;
  6475. /**
  6476. * @returns the Plane hash code.
  6477. */
  6478. getHashCode(): number;
  6479. /**
  6480. * Normalize the current Plane in place.
  6481. * @returns the updated Plane.
  6482. */
  6483. normalize(): Plane;
  6484. /**
  6485. * Applies a transformation the plane and returns the result
  6486. * @param transformation the transformation matrix to be applied to the plane
  6487. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6488. */
  6489. transform(transformation: DeepImmutable<Matrix>): Plane;
  6490. /**
  6491. * Calcualtte the dot product between the point and the plane normal
  6492. * @param point point to calculate the dot product with
  6493. * @returns the dot product (float) of the point coordinates and the plane normal.
  6494. */
  6495. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6496. /**
  6497. * Updates the current Plane from the plane defined by the three given points.
  6498. * @param point1 one of the points used to contruct the plane
  6499. * @param point2 one of the points used to contruct the plane
  6500. * @param point3 one of the points used to contruct the plane
  6501. * @returns the updated Plane.
  6502. */
  6503. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6504. /**
  6505. * Checks if the plane is facing a given direction
  6506. * @param direction the direction to check if the plane is facing
  6507. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6508. * @returns True is the vector "direction" is the same side than the plane normal.
  6509. */
  6510. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6511. /**
  6512. * Calculates the distance to a point
  6513. * @param point point to calculate distance to
  6514. * @returns the signed distance (float) from the given point to the Plane.
  6515. */
  6516. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6517. /**
  6518. * Creates a plane from an array
  6519. * @param array the array to create a plane from
  6520. * @returns a new Plane from the given array.
  6521. */
  6522. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6523. /**
  6524. * Creates a plane from three points
  6525. * @param point1 point used to create the plane
  6526. * @param point2 point used to create the plane
  6527. * @param point3 point used to create the plane
  6528. * @returns a new Plane defined by the three given points.
  6529. */
  6530. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6531. /**
  6532. * Creates a plane from an origin point and a normal
  6533. * @param origin origin of the plane to be constructed
  6534. * @param normal normal of the plane to be constructed
  6535. * @returns a new Plane the normal vector to this plane at the given origin point.
  6536. * Note : the vector "normal" is updated because normalized.
  6537. */
  6538. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6539. /**
  6540. * Calculates the distance from a plane and a point
  6541. * @param origin origin of the plane to be constructed
  6542. * @param normal normal of the plane to be constructed
  6543. * @param point point to calculate distance to
  6544. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6545. */
  6546. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6547. }
  6548. }
  6549. declare module BABYLON {
  6550. /**
  6551. * Class used to store bounding sphere information
  6552. */
  6553. export class BoundingSphere {
  6554. /**
  6555. * Gets the center of the bounding sphere in local space
  6556. */
  6557. readonly center: Vector3;
  6558. /**
  6559. * Radius of the bounding sphere in local space
  6560. */
  6561. radius: number;
  6562. /**
  6563. * Gets the center of the bounding sphere in world space
  6564. */
  6565. readonly centerWorld: Vector3;
  6566. /**
  6567. * Radius of the bounding sphere in world space
  6568. */
  6569. radiusWorld: number;
  6570. /**
  6571. * Gets the minimum vector in local space
  6572. */
  6573. readonly minimum: Vector3;
  6574. /**
  6575. * Gets the maximum vector in local space
  6576. */
  6577. readonly maximum: Vector3;
  6578. private _worldMatrix;
  6579. private static readonly TmpVector3;
  6580. /**
  6581. * Creates a new bounding sphere
  6582. * @param min defines the minimum vector (in local space)
  6583. * @param max defines the maximum vector (in local space)
  6584. * @param worldMatrix defines the new world matrix
  6585. */
  6586. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6587. /**
  6588. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6589. * @param min defines the new minimum vector (in local space)
  6590. * @param max defines the new maximum vector (in local space)
  6591. * @param worldMatrix defines the new world matrix
  6592. */
  6593. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6594. /**
  6595. * Scale the current bounding sphere by applying a scale factor
  6596. * @param factor defines the scale factor to apply
  6597. * @returns the current bounding box
  6598. */
  6599. scale(factor: number): BoundingSphere;
  6600. /**
  6601. * Gets the world matrix of the bounding box
  6602. * @returns a matrix
  6603. */
  6604. getWorldMatrix(): DeepImmutable<Matrix>;
  6605. /** @hidden */
  6606. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6607. /**
  6608. * Tests if the bounding sphere is intersecting the frustum planes
  6609. * @param frustumPlanes defines the frustum planes to test
  6610. * @returns true if there is an intersection
  6611. */
  6612. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6613. /**
  6614. * Tests if the bounding sphere center is in between the frustum planes.
  6615. * Used for optimistic fast inclusion.
  6616. * @param frustumPlanes defines the frustum planes to test
  6617. * @returns true if the sphere center is in between the frustum planes
  6618. */
  6619. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6620. /**
  6621. * Tests if a point is inside the bounding sphere
  6622. * @param point defines the point to test
  6623. * @returns true if the point is inside the bounding sphere
  6624. */
  6625. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6626. /**
  6627. * Checks if two sphere intersct
  6628. * @param sphere0 sphere 0
  6629. * @param sphere1 sphere 1
  6630. * @returns true if the speres intersect
  6631. */
  6632. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6633. }
  6634. }
  6635. declare module BABYLON {
  6636. /**
  6637. * Class used to store bounding box information
  6638. */
  6639. export class BoundingBox implements ICullable {
  6640. /**
  6641. * Gets the 8 vectors representing the bounding box in local space
  6642. */
  6643. readonly vectors: Vector3[];
  6644. /**
  6645. * Gets the center of the bounding box in local space
  6646. */
  6647. readonly center: Vector3;
  6648. /**
  6649. * Gets the center of the bounding box in world space
  6650. */
  6651. readonly centerWorld: Vector3;
  6652. /**
  6653. * Gets the extend size in local space
  6654. */
  6655. readonly extendSize: Vector3;
  6656. /**
  6657. * Gets the extend size in world space
  6658. */
  6659. readonly extendSizeWorld: Vector3;
  6660. /**
  6661. * Gets the OBB (object bounding box) directions
  6662. */
  6663. readonly directions: Vector3[];
  6664. /**
  6665. * Gets the 8 vectors representing the bounding box in world space
  6666. */
  6667. readonly vectorsWorld: Vector3[];
  6668. /**
  6669. * Gets the minimum vector in world space
  6670. */
  6671. readonly minimumWorld: Vector3;
  6672. /**
  6673. * Gets the maximum vector in world space
  6674. */
  6675. readonly maximumWorld: Vector3;
  6676. /**
  6677. * Gets the minimum vector in local space
  6678. */
  6679. readonly minimum: Vector3;
  6680. /**
  6681. * Gets the maximum vector in local space
  6682. */
  6683. readonly maximum: Vector3;
  6684. private _worldMatrix;
  6685. private static readonly TmpVector3;
  6686. /**
  6687. * @hidden
  6688. */
  6689. _tag: number;
  6690. /**
  6691. * Creates a new bounding box
  6692. * @param min defines the minimum vector (in local space)
  6693. * @param max defines the maximum vector (in local space)
  6694. * @param worldMatrix defines the new world matrix
  6695. */
  6696. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6697. /**
  6698. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6699. * @param min defines the new minimum vector (in local space)
  6700. * @param max defines the new maximum vector (in local space)
  6701. * @param worldMatrix defines the new world matrix
  6702. */
  6703. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6704. /**
  6705. * Scale the current bounding box by applying a scale factor
  6706. * @param factor defines the scale factor to apply
  6707. * @returns the current bounding box
  6708. */
  6709. scale(factor: number): BoundingBox;
  6710. /**
  6711. * Gets the world matrix of the bounding box
  6712. * @returns a matrix
  6713. */
  6714. getWorldMatrix(): DeepImmutable<Matrix>;
  6715. /** @hidden */
  6716. _update(world: DeepImmutable<Matrix>): void;
  6717. /**
  6718. * Tests if the bounding box is intersecting the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an intersection
  6721. */
  6722. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if the bounding box is entirely inside the frustum planes
  6725. * @param frustumPlanes defines the frustum planes to test
  6726. * @returns true if there is an inclusion
  6727. */
  6728. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6729. /**
  6730. * Tests if a point is inside the bounding box
  6731. * @param point defines the point to test
  6732. * @returns true if the point is inside the bounding box
  6733. */
  6734. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a bounding sphere
  6737. * @param sphere defines the sphere to test
  6738. * @returns true if there is an intersection
  6739. */
  6740. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6741. /**
  6742. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6743. * @param min defines the min vector to use
  6744. * @param max defines the max vector to use
  6745. * @returns true if there is an intersection
  6746. */
  6747. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6748. /**
  6749. * Tests if two bounding boxes are intersections
  6750. * @param box0 defines the first box to test
  6751. * @param box1 defines the second box to test
  6752. * @returns true if there is an intersection
  6753. */
  6754. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6755. /**
  6756. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6757. * @param minPoint defines the minimum vector of the bounding box
  6758. * @param maxPoint defines the maximum vector of the bounding box
  6759. * @param sphereCenter defines the sphere center
  6760. * @param sphereRadius defines the sphere radius
  6761. * @returns true if there is an intersection
  6762. */
  6763. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6764. /**
  6765. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6766. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @return true if there is an inclusion
  6769. */
  6770. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6773. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @return true if there is an intersection
  6776. */
  6777. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. }
  6779. }
  6780. declare module BABYLON {
  6781. /** @hidden */
  6782. export class Collider {
  6783. /** Define if a collision was found */
  6784. collisionFound: boolean;
  6785. /**
  6786. * Define last intersection point in local space
  6787. */
  6788. intersectionPoint: Vector3;
  6789. /**
  6790. * Define last collided mesh
  6791. */
  6792. collidedMesh: Nullable<AbstractMesh>;
  6793. private _collisionPoint;
  6794. private _planeIntersectionPoint;
  6795. private _tempVector;
  6796. private _tempVector2;
  6797. private _tempVector3;
  6798. private _tempVector4;
  6799. private _edge;
  6800. private _baseToVertex;
  6801. private _destinationPoint;
  6802. private _slidePlaneNormal;
  6803. private _displacementVector;
  6804. /** @hidden */
  6805. _radius: Vector3;
  6806. /** @hidden */
  6807. _retry: number;
  6808. private _velocity;
  6809. private _basePoint;
  6810. private _epsilon;
  6811. /** @hidden */
  6812. _velocityWorldLength: number;
  6813. /** @hidden */
  6814. _basePointWorld: Vector3;
  6815. private _velocityWorld;
  6816. private _normalizedVelocity;
  6817. /** @hidden */
  6818. _initialVelocity: Vector3;
  6819. /** @hidden */
  6820. _initialPosition: Vector3;
  6821. private _nearestDistance;
  6822. private _collisionMask;
  6823. collisionMask: number;
  6824. /**
  6825. * Gets the plane normal used to compute the sliding response (in local space)
  6826. */
  6827. readonly slidePlaneNormal: Vector3;
  6828. /** @hidden */
  6829. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6830. /** @hidden */
  6831. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6832. /** @hidden */
  6833. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6834. /** @hidden */
  6835. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6838. /** @hidden */
  6839. _getResponse(pos: Vector3, vel: Vector3): void;
  6840. }
  6841. }
  6842. declare module BABYLON {
  6843. /**
  6844. * Interface for cullable objects
  6845. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6846. */
  6847. export interface ICullable {
  6848. /**
  6849. * Checks if the object or part of the object is in the frustum
  6850. * @param frustumPlanes Camera near/planes
  6851. * @returns true if the object is in frustum otherwise false
  6852. */
  6853. isInFrustum(frustumPlanes: Plane[]): boolean;
  6854. /**
  6855. * Checks if a cullable object (mesh...) is in the camera frustum
  6856. * Unlike isInFrustum this cheks the full bounding box
  6857. * @param frustumPlanes Camera near/planes
  6858. * @returns true if the object is in frustum otherwise false
  6859. */
  6860. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6861. }
  6862. /**
  6863. * Info for a bounding data of a mesh
  6864. */
  6865. export class BoundingInfo implements ICullable {
  6866. /**
  6867. * Bounding box for the mesh
  6868. */
  6869. readonly boundingBox: BoundingBox;
  6870. /**
  6871. * Bounding sphere for the mesh
  6872. */
  6873. readonly boundingSphere: BoundingSphere;
  6874. private _isLocked;
  6875. private static readonly TmpVector3;
  6876. /**
  6877. * Constructs bounding info
  6878. * @param minimum min vector of the bounding box/sphere
  6879. * @param maximum max vector of the bounding box/sphere
  6880. * @param worldMatrix defines the new world matrix
  6881. */
  6882. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6883. /**
  6884. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6885. * @param min defines the new minimum vector (in local space)
  6886. * @param max defines the new maximum vector (in local space)
  6887. * @param worldMatrix defines the new world matrix
  6888. */
  6889. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * min vector of the bounding box/sphere
  6892. */
  6893. readonly minimum: Vector3;
  6894. /**
  6895. * max vector of the bounding box/sphere
  6896. */
  6897. readonly maximum: Vector3;
  6898. /**
  6899. * If the info is locked and won't be updated to avoid perf overhead
  6900. */
  6901. isLocked: boolean;
  6902. /**
  6903. * Updates the bounding sphere and box
  6904. * @param world world matrix to be used to update
  6905. */
  6906. update(world: DeepImmutable<Matrix>): void;
  6907. /**
  6908. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6909. * @param center New center of the bounding info
  6910. * @param extend New extend of the bounding info
  6911. * @returns the current bounding info
  6912. */
  6913. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6914. /**
  6915. * Scale the current bounding info by applying a scale factor
  6916. * @param factor defines the scale factor to apply
  6917. * @returns the current bounding info
  6918. */
  6919. scale(factor: number): BoundingInfo;
  6920. /**
  6921. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6922. * @param frustumPlanes defines the frustum to test
  6923. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6924. * @returns true if the bounding info is in the frustum planes
  6925. */
  6926. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6927. /**
  6928. * Gets the world distance between the min and max points of the bounding box
  6929. */
  6930. readonly diagonalLength: number;
  6931. /**
  6932. * Checks if a cullable object (mesh...) is in the camera frustum
  6933. * Unlike isInFrustum this cheks the full bounding box
  6934. * @param frustumPlanes Camera near/planes
  6935. * @returns true if the object is in frustum otherwise false
  6936. */
  6937. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /** @hidden */
  6939. _checkCollision(collider: Collider): boolean;
  6940. /**
  6941. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6942. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6943. * @param point the point to check intersection with
  6944. * @returns if the point intersects
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6949. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6950. * @param boundingInfo the bounding info to check intersection with
  6951. * @param precise if the intersection should be done using OBB
  6952. * @returns if the bounding info intersects
  6953. */
  6954. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6955. }
  6956. }
  6957. declare module BABYLON {
  6958. /**
  6959. * Extracts minimum and maximum values from a list of indexed positions
  6960. * @param positions defines the positions to use
  6961. * @param indices defines the indices to the positions
  6962. * @param indexStart defines the start index
  6963. * @param indexCount defines the end index
  6964. * @param bias defines bias value to add to the result
  6965. * @return minimum and maximum values
  6966. */
  6967. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6968. minimum: Vector3;
  6969. maximum: Vector3;
  6970. };
  6971. /**
  6972. * Extracts minimum and maximum values from a list of positions
  6973. * @param positions defines the positions to use
  6974. * @param start defines the start index in the positions array
  6975. * @param count defines the number of positions to handle
  6976. * @param bias defines bias value to add to the result
  6977. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6978. * @return minimum and maximum values
  6979. */
  6980. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6981. minimum: Vector3;
  6982. maximum: Vector3;
  6983. };
  6984. }
  6985. declare module BABYLON {
  6986. /** @hidden */
  6987. export class WebGLDataBuffer extends DataBuffer {
  6988. private _buffer;
  6989. constructor(resource: WebGLBuffer);
  6990. readonly underlyingResource: any;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /** @hidden */
  6995. export class WebGLPipelineContext implements IPipelineContext {
  6996. engine: ThinEngine;
  6997. program: Nullable<WebGLProgram>;
  6998. context?: WebGLRenderingContext;
  6999. vertexShader?: WebGLShader;
  7000. fragmentShader?: WebGLShader;
  7001. isParallelCompiled: boolean;
  7002. onCompiled?: () => void;
  7003. transformFeedback?: WebGLTransformFeedback | null;
  7004. readonly isAsync: boolean;
  7005. readonly isReady: boolean;
  7006. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7007. }
  7008. }
  7009. declare module BABYLON {
  7010. interface ThinEngine {
  7011. /**
  7012. * Create an uniform buffer
  7013. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7014. * @param elements defines the content of the uniform buffer
  7015. * @returns the webGL uniform buffer
  7016. */
  7017. createUniformBuffer(elements: FloatArray): DataBuffer;
  7018. /**
  7019. * Create a dynamic uniform buffer
  7020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7021. * @param elements defines the content of the uniform buffer
  7022. * @returns the webGL uniform buffer
  7023. */
  7024. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7025. /**
  7026. * Update an existing uniform buffer
  7027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7028. * @param uniformBuffer defines the target uniform buffer
  7029. * @param elements defines the content to update
  7030. * @param offset defines the offset in the uniform buffer where update should start
  7031. * @param count defines the size of the data to update
  7032. */
  7033. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7034. /**
  7035. * Bind an uniform buffer to the current webGL context
  7036. * @param buffer defines the buffer to bind
  7037. */
  7038. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7039. /**
  7040. * Bind a buffer to the current webGL context at a given location
  7041. * @param buffer defines the buffer to bind
  7042. * @param location defines the index where to bind the buffer
  7043. */
  7044. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7045. /**
  7046. * Bind a specific block at a given index in a specific shader program
  7047. * @param pipelineContext defines the pipeline context to use
  7048. * @param blockName defines the block name
  7049. * @param index defines the index where to bind the block
  7050. */
  7051. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7052. }
  7053. }
  7054. declare module BABYLON {
  7055. /**
  7056. * Uniform buffer objects.
  7057. *
  7058. * Handles blocks of uniform on the GPU.
  7059. *
  7060. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7061. *
  7062. * For more information, please refer to :
  7063. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7064. */
  7065. export class UniformBuffer {
  7066. private _engine;
  7067. private _buffer;
  7068. private _data;
  7069. private _bufferData;
  7070. private _dynamic?;
  7071. private _uniformLocations;
  7072. private _uniformSizes;
  7073. private _uniformLocationPointer;
  7074. private _needSync;
  7075. private _noUBO;
  7076. private _currentEffect;
  7077. /** @hidden */
  7078. _alreadyBound: boolean;
  7079. private static _MAX_UNIFORM_SIZE;
  7080. private static _tempBuffer;
  7081. /**
  7082. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7083. * This is dynamic to allow compat with webgl 1 and 2.
  7084. * You will need to pass the name of the uniform as well as the value.
  7085. */
  7086. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7087. /**
  7088. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7089. * This is dynamic to allow compat with webgl 1 and 2.
  7090. * You will need to pass the name of the uniform as well as the value.
  7091. */
  7092. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7093. /**
  7094. * Lambda to Update a single float in a uniform buffer.
  7095. * This is dynamic to allow compat with webgl 1 and 2.
  7096. * You will need to pass the name of the uniform as well as the value.
  7097. */
  7098. updateFloat: (name: string, x: number) => void;
  7099. /**
  7100. * Lambda to Update a vec2 of float in a uniform buffer.
  7101. * This is dynamic to allow compat with webgl 1 and 2.
  7102. * You will need to pass the name of the uniform as well as the value.
  7103. */
  7104. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7105. /**
  7106. * Lambda to Update a vec3 of float in a uniform buffer.
  7107. * This is dynamic to allow compat with webgl 1 and 2.
  7108. * You will need to pass the name of the uniform as well as the value.
  7109. */
  7110. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7111. /**
  7112. * Lambda to Update a vec4 of float in a uniform buffer.
  7113. * This is dynamic to allow compat with webgl 1 and 2.
  7114. * You will need to pass the name of the uniform as well as the value.
  7115. */
  7116. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7117. /**
  7118. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7119. * This is dynamic to allow compat with webgl 1 and 2.
  7120. * You will need to pass the name of the uniform as well as the value.
  7121. */
  7122. updateMatrix: (name: string, mat: Matrix) => void;
  7123. /**
  7124. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7125. * This is dynamic to allow compat with webgl 1 and 2.
  7126. * You will need to pass the name of the uniform as well as the value.
  7127. */
  7128. updateVector3: (name: string, vector: Vector3) => void;
  7129. /**
  7130. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7131. * This is dynamic to allow compat with webgl 1 and 2.
  7132. * You will need to pass the name of the uniform as well as the value.
  7133. */
  7134. updateVector4: (name: string, vector: Vector4) => void;
  7135. /**
  7136. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7137. * This is dynamic to allow compat with webgl 1 and 2.
  7138. * You will need to pass the name of the uniform as well as the value.
  7139. */
  7140. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7141. /**
  7142. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7143. * This is dynamic to allow compat with webgl 1 and 2.
  7144. * You will need to pass the name of the uniform as well as the value.
  7145. */
  7146. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7147. /**
  7148. * Instantiates a new Uniform buffer objects.
  7149. *
  7150. * Handles blocks of uniform on the GPU.
  7151. *
  7152. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7153. *
  7154. * For more information, please refer to :
  7155. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7156. * @param engine Define the engine the buffer is associated with
  7157. * @param data Define the data contained in the buffer
  7158. * @param dynamic Define if the buffer is updatable
  7159. */
  7160. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7161. /**
  7162. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7163. * or just falling back on setUniformXXX calls.
  7164. */
  7165. readonly useUbo: boolean;
  7166. /**
  7167. * Indicates if the WebGL underlying uniform buffer is in sync
  7168. * with the javascript cache data.
  7169. */
  7170. readonly isSync: boolean;
  7171. /**
  7172. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7173. * Also, a dynamic UniformBuffer will disable cache verification and always
  7174. * update the underlying WebGL uniform buffer to the GPU.
  7175. * @returns if Dynamic, otherwise false
  7176. */
  7177. isDynamic(): boolean;
  7178. /**
  7179. * The data cache on JS side.
  7180. * @returns the underlying data as a float array
  7181. */
  7182. getData(): Float32Array;
  7183. /**
  7184. * The underlying WebGL Uniform buffer.
  7185. * @returns the webgl buffer
  7186. */
  7187. getBuffer(): Nullable<DataBuffer>;
  7188. /**
  7189. * std140 layout specifies how to align data within an UBO structure.
  7190. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7191. * for specs.
  7192. */
  7193. private _fillAlignment;
  7194. /**
  7195. * Adds an uniform in the buffer.
  7196. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7197. * for the layout to be correct !
  7198. * @param name Name of the uniform, as used in the uniform block in the shader.
  7199. * @param size Data size, or data directly.
  7200. */
  7201. addUniform(name: string, size: number | number[]): void;
  7202. /**
  7203. * Adds a Matrix 4x4 to the uniform buffer.
  7204. * @param name Name of the uniform, as used in the uniform block in the shader.
  7205. * @param mat A 4x4 matrix.
  7206. */
  7207. addMatrix(name: string, mat: Matrix): void;
  7208. /**
  7209. * Adds a vec2 to the uniform buffer.
  7210. * @param name Name of the uniform, as used in the uniform block in the shader.
  7211. * @param x Define the x component value of the vec2
  7212. * @param y Define the y component value of the vec2
  7213. */
  7214. addFloat2(name: string, x: number, y: number): void;
  7215. /**
  7216. * Adds a vec3 to the uniform buffer.
  7217. * @param name Name of the uniform, as used in the uniform block in the shader.
  7218. * @param x Define the x component value of the vec3
  7219. * @param y Define the y component value of the vec3
  7220. * @param z Define the z component value of the vec3
  7221. */
  7222. addFloat3(name: string, x: number, y: number, z: number): void;
  7223. /**
  7224. * Adds a vec3 to the uniform buffer.
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param color Define the vec3 from a Color
  7227. */
  7228. addColor3(name: string, color: Color3): void;
  7229. /**
  7230. * Adds a vec4 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param color Define the rgb components from a Color
  7233. * @param alpha Define the a component of the vec4
  7234. */
  7235. addColor4(name: string, color: Color3, alpha: number): void;
  7236. /**
  7237. * Adds a vec3 to the uniform buffer.
  7238. * @param name Name of the uniform, as used in the uniform block in the shader.
  7239. * @param vector Define the vec3 components from a Vector
  7240. */
  7241. addVector3(name: string, vector: Vector3): void;
  7242. /**
  7243. * Adds a Matrix 3x3 to the uniform buffer.
  7244. * @param name Name of the uniform, as used in the uniform block in the shader.
  7245. */
  7246. addMatrix3x3(name: string): void;
  7247. /**
  7248. * Adds a Matrix 2x2 to the uniform buffer.
  7249. * @param name Name of the uniform, as used in the uniform block in the shader.
  7250. */
  7251. addMatrix2x2(name: string): void;
  7252. /**
  7253. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7254. */
  7255. create(): void;
  7256. /** @hidden */
  7257. _rebuild(): void;
  7258. /**
  7259. * Updates the WebGL Uniform Buffer on the GPU.
  7260. * If the `dynamic` flag is set to true, no cache comparison is done.
  7261. * Otherwise, the buffer will be updated only if the cache differs.
  7262. */
  7263. update(): void;
  7264. /**
  7265. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7266. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7267. * @param data Define the flattened data
  7268. * @param size Define the size of the data.
  7269. */
  7270. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7271. private _valueCache;
  7272. private _cacheMatrix;
  7273. private _updateMatrix3x3ForUniform;
  7274. private _updateMatrix3x3ForEffect;
  7275. private _updateMatrix2x2ForEffect;
  7276. private _updateMatrix2x2ForUniform;
  7277. private _updateFloatForEffect;
  7278. private _updateFloatForUniform;
  7279. private _updateFloat2ForEffect;
  7280. private _updateFloat2ForUniform;
  7281. private _updateFloat3ForEffect;
  7282. private _updateFloat3ForUniform;
  7283. private _updateFloat4ForEffect;
  7284. private _updateFloat4ForUniform;
  7285. private _updateMatrixForEffect;
  7286. private _updateMatrixForUniform;
  7287. private _updateVector3ForEffect;
  7288. private _updateVector3ForUniform;
  7289. private _updateVector4ForEffect;
  7290. private _updateVector4ForUniform;
  7291. private _updateColor3ForEffect;
  7292. private _updateColor3ForUniform;
  7293. private _updateColor4ForEffect;
  7294. private _updateColor4ForUniform;
  7295. /**
  7296. * Sets a sampler uniform on the effect.
  7297. * @param name Define the name of the sampler.
  7298. * @param texture Define the texture to set in the sampler
  7299. */
  7300. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7301. /**
  7302. * Directly updates the value of the uniform in the cache AND on the GPU.
  7303. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7304. * @param data Define the flattened data
  7305. */
  7306. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7307. /**
  7308. * Binds this uniform buffer to an effect.
  7309. * @param effect Define the effect to bind the buffer to
  7310. * @param name Name of the uniform block in the shader.
  7311. */
  7312. bindToEffect(effect: Effect, name: string): void;
  7313. /**
  7314. * Disposes the uniform buffer.
  7315. */
  7316. dispose(): void;
  7317. }
  7318. }
  7319. declare module BABYLON {
  7320. /**
  7321. * Enum that determines the text-wrapping mode to use.
  7322. */
  7323. export enum InspectableType {
  7324. /**
  7325. * Checkbox for booleans
  7326. */
  7327. Checkbox = 0,
  7328. /**
  7329. * Sliders for numbers
  7330. */
  7331. Slider = 1,
  7332. /**
  7333. * Vector3
  7334. */
  7335. Vector3 = 2,
  7336. /**
  7337. * Quaternions
  7338. */
  7339. Quaternion = 3,
  7340. /**
  7341. * Color3
  7342. */
  7343. Color3 = 4,
  7344. /**
  7345. * String
  7346. */
  7347. String = 5
  7348. }
  7349. /**
  7350. * Interface used to define custom inspectable properties.
  7351. * This interface is used by the inspector to display custom property grids
  7352. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7353. */
  7354. export interface IInspectable {
  7355. /**
  7356. * Gets the label to display
  7357. */
  7358. label: string;
  7359. /**
  7360. * Gets the name of the property to edit
  7361. */
  7362. propertyName: string;
  7363. /**
  7364. * Gets the type of the editor to use
  7365. */
  7366. type: InspectableType;
  7367. /**
  7368. * Gets the minimum value of the property when using in "slider" mode
  7369. */
  7370. min?: number;
  7371. /**
  7372. * Gets the maximum value of the property when using in "slider" mode
  7373. */
  7374. max?: number;
  7375. /**
  7376. * Gets the setp to use when using in "slider" mode
  7377. */
  7378. step?: number;
  7379. }
  7380. }
  7381. declare module BABYLON {
  7382. /**
  7383. * Class used to provide helper for timing
  7384. */
  7385. export class TimingTools {
  7386. /**
  7387. * Polyfill for setImmediate
  7388. * @param action defines the action to execute after the current execution block
  7389. */
  7390. static SetImmediate(action: () => void): void;
  7391. }
  7392. }
  7393. declare module BABYLON {
  7394. /**
  7395. * Class used to enable instatition of objects by class name
  7396. */
  7397. export class InstantiationTools {
  7398. /**
  7399. * Use this object to register external classes like custom textures or material
  7400. * to allow the laoders to instantiate them
  7401. */
  7402. static RegisteredExternalClasses: {
  7403. [key: string]: Object;
  7404. };
  7405. /**
  7406. * Tries to instantiate a new object from a given class name
  7407. * @param className defines the class name to instantiate
  7408. * @returns the new object or null if the system was not able to do the instantiation
  7409. */
  7410. static Instantiate(className: string): any;
  7411. }
  7412. }
  7413. declare module BABYLON {
  7414. /**
  7415. * Define options used to create a depth texture
  7416. */
  7417. export class DepthTextureCreationOptions {
  7418. /** Specifies whether or not a stencil should be allocated in the texture */
  7419. generateStencil?: boolean;
  7420. /** Specifies whether or not bilinear filtering is enable on the texture */
  7421. bilinearFiltering?: boolean;
  7422. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7423. comparisonFunction?: number;
  7424. /** Specifies if the created texture is a cube texture */
  7425. isCube?: boolean;
  7426. }
  7427. }
  7428. declare module BABYLON {
  7429. interface ThinEngine {
  7430. /**
  7431. * Creates a depth stencil cube texture.
  7432. * This is only available in WebGL 2.
  7433. * @param size The size of face edge in the cube texture.
  7434. * @param options The options defining the cube texture.
  7435. * @returns The cube texture
  7436. */
  7437. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7438. /**
  7439. * Creates a cube texture
  7440. * @param rootUrl defines the url where the files to load is located
  7441. * @param scene defines the current scene
  7442. * @param files defines the list of files to load (1 per face)
  7443. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7444. * @param onLoad defines an optional callback raised when the texture is loaded
  7445. * @param onError defines an optional callback raised if there is an issue to load the texture
  7446. * @param format defines the format of the data
  7447. * @param forcedExtension defines the extension to use to pick the right loader
  7448. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7449. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7450. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7451. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7452. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7453. * @returns the cube texture as an InternalTexture
  7454. */
  7455. 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;
  7456. /**
  7457. * Creates a cube texture
  7458. * @param rootUrl defines the url where the files to load is located
  7459. * @param scene defines the current scene
  7460. * @param files defines the list of files to load (1 per face)
  7461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7462. * @param onLoad defines an optional callback raised when the texture is loaded
  7463. * @param onError defines an optional callback raised if there is an issue to load the texture
  7464. * @param format defines the format of the data
  7465. * @param forcedExtension defines the extension to use to pick the right loader
  7466. * @returns the cube texture as an InternalTexture
  7467. */
  7468. 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;
  7469. /**
  7470. * Creates a cube texture
  7471. * @param rootUrl defines the url where the files to load is located
  7472. * @param scene defines the current scene
  7473. * @param files defines the list of files to load (1 per face)
  7474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7475. * @param onLoad defines an optional callback raised when the texture is loaded
  7476. * @param onError defines an optional callback raised if there is an issue to load the texture
  7477. * @param format defines the format of the data
  7478. * @param forcedExtension defines the extension to use to pick the right loader
  7479. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7482. * @returns the cube texture as an InternalTexture
  7483. */
  7484. 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;
  7485. /** @hidden */
  7486. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7487. /** @hidden */
  7488. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7489. /** @hidden */
  7490. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7491. /** @hidden */
  7492. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Class for creating a cube texture
  7498. */
  7499. export class CubeTexture extends BaseTexture {
  7500. private _delayedOnLoad;
  7501. /**
  7502. * The url of the texture
  7503. */
  7504. url: string;
  7505. /**
  7506. * Gets or sets the center of the bounding box associated with the cube texture.
  7507. * It must define where the camera used to render the texture was set
  7508. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7509. */
  7510. boundingBoxPosition: Vector3;
  7511. private _boundingBoxSize;
  7512. /**
  7513. * Gets or sets the size of the bounding box associated with the cube texture
  7514. * When defined, the cubemap will switch to local mode
  7515. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7516. * @example https://www.babylonjs-playground.com/#RNASML
  7517. */
  7518. /**
  7519. * Returns the bounding box size
  7520. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7521. */
  7522. boundingBoxSize: Vector3;
  7523. protected _rotationY: number;
  7524. /**
  7525. * Sets texture matrix rotation angle around Y axis in radians.
  7526. */
  7527. /**
  7528. * Gets texture matrix rotation angle around Y axis radians.
  7529. */
  7530. rotationY: number;
  7531. /**
  7532. * Are mip maps generated for this texture or not.
  7533. */
  7534. readonly noMipmap: boolean;
  7535. private _noMipmap;
  7536. private _files;
  7537. protected _forcedExtension: Nullable<string>;
  7538. private _extensions;
  7539. private _textureMatrix;
  7540. private _format;
  7541. private _createPolynomials;
  7542. /** @hidden */
  7543. _prefiltered: boolean;
  7544. /**
  7545. * Creates a cube texture from an array of image urls
  7546. * @param files defines an array of image urls
  7547. * @param scene defines the hosting scene
  7548. * @param noMipmap specifies if mip maps are not used
  7549. * @returns a cube texture
  7550. */
  7551. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7552. /**
  7553. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7554. * @param url defines the url of the prefiltered texture
  7555. * @param scene defines the scene the texture is attached to
  7556. * @param forcedExtension defines the extension of the file if different from the url
  7557. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7558. * @return the prefiltered texture
  7559. */
  7560. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7561. /**
  7562. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7563. * as prefiltered data.
  7564. * @param rootUrl defines the url of the texture or the root name of the six images
  7565. * @param scene defines the scene the texture is attached to
  7566. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7567. * @param noMipmap defines if mipmaps should be created or not
  7568. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7569. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7570. * @param onError defines a callback triggered in case of error during load
  7571. * @param format defines the internal format to use for the texture once loaded
  7572. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7573. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7574. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7577. * @return the cube texture
  7578. */
  7579. 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);
  7580. /**
  7581. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7582. */
  7583. readonly isPrefiltered: boolean;
  7584. /**
  7585. * Get the current class name of the texture useful for serialization or dynamic coding.
  7586. * @returns "CubeTexture"
  7587. */
  7588. getClassName(): string;
  7589. /**
  7590. * Update the url (and optional buffer) of this texture if url was null during construction.
  7591. * @param url the url of the texture
  7592. * @param forcedExtension defines the extension to use
  7593. * @param onLoad callback called when the texture is loaded (defaults to null)
  7594. */
  7595. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7596. /**
  7597. * Delays loading of the cube texture
  7598. * @param forcedExtension defines the extension to use
  7599. */
  7600. delayLoad(forcedExtension?: string): void;
  7601. /**
  7602. * Returns the reflection texture matrix
  7603. * @returns the reflection texture matrix
  7604. */
  7605. getReflectionTextureMatrix(): Matrix;
  7606. /**
  7607. * Sets the reflection texture matrix
  7608. * @param value Reflection texture matrix
  7609. */
  7610. setReflectionTextureMatrix(value: Matrix): void;
  7611. /**
  7612. * Parses text to create a cube texture
  7613. * @param parsedTexture define the serialized text to read from
  7614. * @param scene defines the hosting scene
  7615. * @param rootUrl defines the root url of the cube texture
  7616. * @returns a cube texture
  7617. */
  7618. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7619. /**
  7620. * Makes a clone, or deep copy, of the cube texture
  7621. * @returns a new cube texture
  7622. */
  7623. clone(): CubeTexture;
  7624. }
  7625. }
  7626. declare module BABYLON {
  7627. /**
  7628. * Manages the defines for the Material
  7629. */
  7630. export class MaterialDefines {
  7631. /** @hidden */
  7632. protected _keys: string[];
  7633. private _isDirty;
  7634. /** @hidden */
  7635. _renderId: number;
  7636. /** @hidden */
  7637. _areLightsDirty: boolean;
  7638. /** @hidden */
  7639. _areLightsDisposed: boolean;
  7640. /** @hidden */
  7641. _areAttributesDirty: boolean;
  7642. /** @hidden */
  7643. _areTexturesDirty: boolean;
  7644. /** @hidden */
  7645. _areFresnelDirty: boolean;
  7646. /** @hidden */
  7647. _areMiscDirty: boolean;
  7648. /** @hidden */
  7649. _areImageProcessingDirty: boolean;
  7650. /** @hidden */
  7651. _normals: boolean;
  7652. /** @hidden */
  7653. _uvs: boolean;
  7654. /** @hidden */
  7655. _needNormals: boolean;
  7656. /** @hidden */
  7657. _needUVs: boolean;
  7658. [id: string]: any;
  7659. /**
  7660. * Specifies if the material needs to be re-calculated
  7661. */
  7662. readonly isDirty: boolean;
  7663. /**
  7664. * Marks the material to indicate that it has been re-calculated
  7665. */
  7666. markAsProcessed(): void;
  7667. /**
  7668. * Marks the material to indicate that it needs to be re-calculated
  7669. */
  7670. markAsUnprocessed(): void;
  7671. /**
  7672. * Marks the material to indicate all of its defines need to be re-calculated
  7673. */
  7674. markAllAsDirty(): void;
  7675. /**
  7676. * Marks the material to indicate that image processing needs to be re-calculated
  7677. */
  7678. markAsImageProcessingDirty(): void;
  7679. /**
  7680. * Marks the material to indicate the lights need to be re-calculated
  7681. * @param disposed Defines whether the light is dirty due to dispose or not
  7682. */
  7683. markAsLightDirty(disposed?: boolean): void;
  7684. /**
  7685. * Marks the attribute state as changed
  7686. */
  7687. markAsAttributesDirty(): void;
  7688. /**
  7689. * Marks the texture state as changed
  7690. */
  7691. markAsTexturesDirty(): void;
  7692. /**
  7693. * Marks the fresnel state as changed
  7694. */
  7695. markAsFresnelDirty(): void;
  7696. /**
  7697. * Marks the misc state as changed
  7698. */
  7699. markAsMiscDirty(): void;
  7700. /**
  7701. * Rebuilds the material defines
  7702. */
  7703. rebuild(): void;
  7704. /**
  7705. * Specifies if two material defines are equal
  7706. * @param other - A material define instance to compare to
  7707. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7708. */
  7709. isEqual(other: MaterialDefines): boolean;
  7710. /**
  7711. * Clones this instance's defines to another instance
  7712. * @param other - material defines to clone values to
  7713. */
  7714. cloneTo(other: MaterialDefines): void;
  7715. /**
  7716. * Resets the material define values
  7717. */
  7718. reset(): void;
  7719. /**
  7720. * Converts the material define values to a string
  7721. * @returns - String of material define information
  7722. */
  7723. toString(): string;
  7724. }
  7725. }
  7726. declare module BABYLON {
  7727. /**
  7728. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7729. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7730. * 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;
  7731. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7732. */
  7733. export class ColorCurves {
  7734. private _dirty;
  7735. private _tempColor;
  7736. private _globalCurve;
  7737. private _highlightsCurve;
  7738. private _midtonesCurve;
  7739. private _shadowsCurve;
  7740. private _positiveCurve;
  7741. private _negativeCurve;
  7742. private _globalHue;
  7743. private _globalDensity;
  7744. private _globalSaturation;
  7745. private _globalExposure;
  7746. /**
  7747. * Gets the global Hue value.
  7748. * 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).
  7749. */
  7750. /**
  7751. * Sets the global Hue value.
  7752. * 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).
  7753. */
  7754. globalHue: number;
  7755. /**
  7756. * Gets the global Density value.
  7757. * 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.
  7758. * Values less than zero provide a filter of opposite hue.
  7759. */
  7760. /**
  7761. * Sets the global Density value.
  7762. * 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.
  7763. * Values less than zero provide a filter of opposite hue.
  7764. */
  7765. globalDensity: number;
  7766. /**
  7767. * Gets the global Saturation value.
  7768. * 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.
  7769. */
  7770. /**
  7771. * Sets the global Saturation value.
  7772. * 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.
  7773. */
  7774. globalSaturation: number;
  7775. /**
  7776. * Gets the global Exposure value.
  7777. * 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.
  7778. */
  7779. /**
  7780. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  7782. */
  7783. globalExposure: number;
  7784. private _highlightsHue;
  7785. private _highlightsDensity;
  7786. private _highlightsSaturation;
  7787. private _highlightsExposure;
  7788. /**
  7789. * Gets the highlights Hue value.
  7790. * 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).
  7791. */
  7792. /**
  7793. * Sets the highlights Hue value.
  7794. * 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).
  7795. */
  7796. highlightsHue: number;
  7797. /**
  7798. * Gets the highlights Density value.
  7799. * 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.
  7800. * Values less than zero provide a filter of opposite hue.
  7801. */
  7802. /**
  7803. * Sets the highlights Density value.
  7804. * 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.
  7805. * Values less than zero provide a filter of opposite hue.
  7806. */
  7807. highlightsDensity: number;
  7808. /**
  7809. * Gets the highlights Saturation value.
  7810. * 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.
  7811. */
  7812. /**
  7813. * Sets the highlights Saturation value.
  7814. * 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.
  7815. */
  7816. highlightsSaturation: number;
  7817. /**
  7818. * Gets the highlights Exposure value.
  7819. * 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.
  7820. */
  7821. /**
  7822. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  7824. */
  7825. highlightsExposure: number;
  7826. private _midtonesHue;
  7827. private _midtonesDensity;
  7828. private _midtonesSaturation;
  7829. private _midtonesExposure;
  7830. /**
  7831. * Gets the midtones Hue value.
  7832. * 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).
  7833. */
  7834. /**
  7835. * Sets the midtones Hue value.
  7836. * 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).
  7837. */
  7838. midtonesHue: number;
  7839. /**
  7840. * Gets the midtones Density value.
  7841. * 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.
  7842. * Values less than zero provide a filter of opposite hue.
  7843. */
  7844. /**
  7845. * Sets the midtones Density value.
  7846. * 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.
  7847. * Values less than zero provide a filter of opposite hue.
  7848. */
  7849. midtonesDensity: number;
  7850. /**
  7851. * Gets the midtones Saturation value.
  7852. * 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.
  7853. */
  7854. /**
  7855. * Sets the midtones Saturation value.
  7856. * 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.
  7857. */
  7858. midtonesSaturation: number;
  7859. /**
  7860. * Gets the midtones Exposure value.
  7861. * 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.
  7862. */
  7863. /**
  7864. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  7866. */
  7867. midtonesExposure: number;
  7868. private _shadowsHue;
  7869. private _shadowsDensity;
  7870. private _shadowsSaturation;
  7871. private _shadowsExposure;
  7872. /**
  7873. * Gets the shadows Hue value.
  7874. * 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).
  7875. */
  7876. /**
  7877. * Sets the shadows Hue value.
  7878. * 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).
  7879. */
  7880. shadowsHue: number;
  7881. /**
  7882. * Gets the shadows Density value.
  7883. * 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.
  7884. * Values less than zero provide a filter of opposite hue.
  7885. */
  7886. /**
  7887. * Sets the shadows Density value.
  7888. * 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.
  7889. * Values less than zero provide a filter of opposite hue.
  7890. */
  7891. shadowsDensity: number;
  7892. /**
  7893. * Gets the shadows Saturation value.
  7894. * 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.
  7895. */
  7896. /**
  7897. * Sets the shadows Saturation value.
  7898. * 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.
  7899. */
  7900. shadowsSaturation: number;
  7901. /**
  7902. * Gets the shadows Exposure value.
  7903. * 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.
  7904. */
  7905. /**
  7906. * Sets the shadows Exposure value.
  7907. * 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.
  7908. */
  7909. shadowsExposure: number;
  7910. /**
  7911. * Returns the class name
  7912. * @returns The class name
  7913. */
  7914. getClassName(): string;
  7915. /**
  7916. * Binds the color curves to the shader.
  7917. * @param colorCurves The color curve to bind
  7918. * @param effect The effect to bind to
  7919. * @param positiveUniform The positive uniform shader parameter
  7920. * @param neutralUniform The neutral uniform shader parameter
  7921. * @param negativeUniform The negative uniform shader parameter
  7922. */
  7923. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7924. /**
  7925. * Prepare the list of uniforms associated with the ColorCurves effects.
  7926. * @param uniformsList The list of uniforms used in the effect
  7927. */
  7928. static PrepareUniforms(uniformsList: string[]): void;
  7929. /**
  7930. * Returns color grading data based on a hue, density, saturation and exposure value.
  7931. * @param filterHue The hue of the color filter.
  7932. * @param filterDensity The density of the color filter.
  7933. * @param saturation The saturation.
  7934. * @param exposure The exposure.
  7935. * @param result The result data container.
  7936. */
  7937. private getColorGradingDataToRef;
  7938. /**
  7939. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7940. * @param value The input slider value in range [-100,100].
  7941. * @returns Adjusted value.
  7942. */
  7943. private static applyColorGradingSliderNonlinear;
  7944. /**
  7945. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7946. * @param hue The hue (H) input.
  7947. * @param saturation The saturation (S) input.
  7948. * @param brightness The brightness (B) input.
  7949. * @result An RGBA color represented as Vector4.
  7950. */
  7951. private static fromHSBToRef;
  7952. /**
  7953. * Returns a value clamped between min and max
  7954. * @param value The value to clamp
  7955. * @param min The minimum of value
  7956. * @param max The maximum of value
  7957. * @returns The clamped value.
  7958. */
  7959. private static clamp;
  7960. /**
  7961. * Clones the current color curve instance.
  7962. * @return The cloned curves
  7963. */
  7964. clone(): ColorCurves;
  7965. /**
  7966. * Serializes the current color curve instance to a json representation.
  7967. * @return a JSON representation
  7968. */
  7969. serialize(): any;
  7970. /**
  7971. * Parses the color curve from a json representation.
  7972. * @param source the JSON source to parse
  7973. * @return The parsed curves
  7974. */
  7975. static Parse(source: any): ColorCurves;
  7976. }
  7977. }
  7978. declare module BABYLON {
  7979. /**
  7980. * Interface to follow in your material defines to integrate easily the
  7981. * Image proccessing functions.
  7982. * @hidden
  7983. */
  7984. export interface IImageProcessingConfigurationDefines {
  7985. IMAGEPROCESSING: boolean;
  7986. VIGNETTE: boolean;
  7987. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7988. VIGNETTEBLENDMODEOPAQUE: boolean;
  7989. TONEMAPPING: boolean;
  7990. TONEMAPPING_ACES: boolean;
  7991. CONTRAST: boolean;
  7992. EXPOSURE: boolean;
  7993. COLORCURVES: boolean;
  7994. COLORGRADING: boolean;
  7995. COLORGRADING3D: boolean;
  7996. SAMPLER3DGREENDEPTH: boolean;
  7997. SAMPLER3DBGRMAP: boolean;
  7998. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7999. }
  8000. /**
  8001. * @hidden
  8002. */
  8003. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8004. IMAGEPROCESSING: boolean;
  8005. VIGNETTE: boolean;
  8006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8007. VIGNETTEBLENDMODEOPAQUE: boolean;
  8008. TONEMAPPING: boolean;
  8009. TONEMAPPING_ACES: boolean;
  8010. CONTRAST: boolean;
  8011. COLORCURVES: boolean;
  8012. COLORGRADING: boolean;
  8013. COLORGRADING3D: boolean;
  8014. SAMPLER3DGREENDEPTH: boolean;
  8015. SAMPLER3DBGRMAP: boolean;
  8016. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8017. EXPOSURE: boolean;
  8018. constructor();
  8019. }
  8020. /**
  8021. * This groups together the common properties used for image processing either in direct forward pass
  8022. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8023. * or not.
  8024. */
  8025. export class ImageProcessingConfiguration {
  8026. /**
  8027. * Default tone mapping applied in BabylonJS.
  8028. */
  8029. static readonly TONEMAPPING_STANDARD: number;
  8030. /**
  8031. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8032. * to other engines rendering to increase portability.
  8033. */
  8034. static readonly TONEMAPPING_ACES: number;
  8035. /**
  8036. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8037. */
  8038. colorCurves: Nullable<ColorCurves>;
  8039. private _colorCurvesEnabled;
  8040. /**
  8041. * Gets wether the color curves effect is enabled.
  8042. */
  8043. /**
  8044. * Sets wether the color curves effect is enabled.
  8045. */
  8046. colorCurvesEnabled: boolean;
  8047. private _colorGradingTexture;
  8048. /**
  8049. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8050. */
  8051. /**
  8052. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8053. */
  8054. colorGradingTexture: Nullable<BaseTexture>;
  8055. private _colorGradingEnabled;
  8056. /**
  8057. * Gets wether the color grading effect is enabled.
  8058. */
  8059. /**
  8060. * Sets wether the color grading effect is enabled.
  8061. */
  8062. colorGradingEnabled: boolean;
  8063. private _colorGradingWithGreenDepth;
  8064. /**
  8065. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8066. */
  8067. /**
  8068. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8069. */
  8070. colorGradingWithGreenDepth: boolean;
  8071. private _colorGradingBGR;
  8072. /**
  8073. * Gets wether the color grading texture contains BGR values.
  8074. */
  8075. /**
  8076. * Sets wether the color grading texture contains BGR values.
  8077. */
  8078. colorGradingBGR: boolean;
  8079. /** @hidden */
  8080. _exposure: number;
  8081. /**
  8082. * Gets the Exposure used in the effect.
  8083. */
  8084. /**
  8085. * Sets the Exposure used in the effect.
  8086. */
  8087. exposure: number;
  8088. private _toneMappingEnabled;
  8089. /**
  8090. * Gets wether the tone mapping effect is enabled.
  8091. */
  8092. /**
  8093. * Sets wether the tone mapping effect is enabled.
  8094. */
  8095. toneMappingEnabled: boolean;
  8096. private _toneMappingType;
  8097. /**
  8098. * Gets the type of tone mapping effect.
  8099. */
  8100. /**
  8101. * Sets the type of tone mapping effect used in BabylonJS.
  8102. */
  8103. toneMappingType: number;
  8104. protected _contrast: number;
  8105. /**
  8106. * Gets the contrast used in the effect.
  8107. */
  8108. /**
  8109. * Sets the contrast used in the effect.
  8110. */
  8111. contrast: number;
  8112. /**
  8113. * Vignette stretch size.
  8114. */
  8115. vignetteStretch: number;
  8116. /**
  8117. * Vignette centre X Offset.
  8118. */
  8119. vignetteCentreX: number;
  8120. /**
  8121. * Vignette centre Y Offset.
  8122. */
  8123. vignetteCentreY: number;
  8124. /**
  8125. * Vignette weight or intensity of the vignette effect.
  8126. */
  8127. vignetteWeight: number;
  8128. /**
  8129. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8130. * if vignetteEnabled is set to true.
  8131. */
  8132. vignetteColor: Color4;
  8133. /**
  8134. * Camera field of view used by the Vignette effect.
  8135. */
  8136. vignetteCameraFov: number;
  8137. private _vignetteBlendMode;
  8138. /**
  8139. * Gets the vignette blend mode allowing different kind of effect.
  8140. */
  8141. /**
  8142. * Sets the vignette blend mode allowing different kind of effect.
  8143. */
  8144. vignetteBlendMode: number;
  8145. private _vignetteEnabled;
  8146. /**
  8147. * Gets wether the vignette effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the vignette effect is enabled.
  8151. */
  8152. vignetteEnabled: boolean;
  8153. private _applyByPostProcess;
  8154. /**
  8155. * Gets wether the image processing is applied through a post process or not.
  8156. */
  8157. /**
  8158. * Sets wether the image processing is applied through a post process or not.
  8159. */
  8160. applyByPostProcess: boolean;
  8161. private _isEnabled;
  8162. /**
  8163. * Gets wether the image processing is enabled or not.
  8164. */
  8165. /**
  8166. * Sets wether the image processing is enabled or not.
  8167. */
  8168. isEnabled: boolean;
  8169. /**
  8170. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8171. */
  8172. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8173. /**
  8174. * Method called each time the image processing information changes requires to recompile the effect.
  8175. */
  8176. protected _updateParameters(): void;
  8177. /**
  8178. * Gets the current class name.
  8179. * @return "ImageProcessingConfiguration"
  8180. */
  8181. getClassName(): string;
  8182. /**
  8183. * Prepare the list of uniforms associated with the Image Processing effects.
  8184. * @param uniforms The list of uniforms used in the effect
  8185. * @param defines the list of defines currently in use
  8186. */
  8187. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8188. /**
  8189. * Prepare the list of samplers associated with the Image Processing effects.
  8190. * @param samplersList The list of uniforms used in the effect
  8191. * @param defines the list of defines currently in use
  8192. */
  8193. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8194. /**
  8195. * Prepare the list of defines associated to the shader.
  8196. * @param defines the list of defines to complete
  8197. * @param forPostProcess Define if we are currently in post process mode or not
  8198. */
  8199. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8200. /**
  8201. * Returns true if all the image processing information are ready.
  8202. * @returns True if ready, otherwise, false
  8203. */
  8204. isReady(): boolean;
  8205. /**
  8206. * Binds the image processing to the shader.
  8207. * @param effect The effect to bind to
  8208. * @param aspectRatio Define the current aspect ratio of the effect
  8209. */
  8210. bind(effect: Effect, aspectRatio?: number): void;
  8211. /**
  8212. * Clones the current image processing instance.
  8213. * @return The cloned image processing
  8214. */
  8215. clone(): ImageProcessingConfiguration;
  8216. /**
  8217. * Serializes the current image processing instance to a json representation.
  8218. * @return a JSON representation
  8219. */
  8220. serialize(): any;
  8221. /**
  8222. * Parses the image processing from a json representation.
  8223. * @param source the JSON source to parse
  8224. * @return The parsed image processing
  8225. */
  8226. static Parse(source: any): ImageProcessingConfiguration;
  8227. private static _VIGNETTEMODE_MULTIPLY;
  8228. private static _VIGNETTEMODE_OPAQUE;
  8229. /**
  8230. * Used to apply the vignette as a mix with the pixel color.
  8231. */
  8232. static readonly VIGNETTEMODE_MULTIPLY: number;
  8233. /**
  8234. * Used to apply the vignette as a replacement of the pixel color.
  8235. */
  8236. static readonly VIGNETTEMODE_OPAQUE: number;
  8237. }
  8238. }
  8239. declare module BABYLON {
  8240. /** @hidden */
  8241. export var postprocessVertexShader: {
  8242. name: string;
  8243. shader: string;
  8244. };
  8245. }
  8246. declare module BABYLON {
  8247. interface ThinEngine {
  8248. /**
  8249. * Creates a new render target texture
  8250. * @param size defines the size of the texture
  8251. * @param options defines the options used to create the texture
  8252. * @returns a new render target texture stored in an InternalTexture
  8253. */
  8254. createRenderTargetTexture(size: number | {
  8255. width: number;
  8256. height: number;
  8257. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8258. }
  8259. }
  8260. declare module BABYLON {
  8261. /** Defines supported spaces */
  8262. export enum Space {
  8263. /** Local (object) space */
  8264. LOCAL = 0,
  8265. /** World space */
  8266. WORLD = 1,
  8267. /** Bone space */
  8268. BONE = 2
  8269. }
  8270. /** Defines the 3 main axes */
  8271. export class Axis {
  8272. /** X axis */
  8273. static X: Vector3;
  8274. /** Y axis */
  8275. static Y: Vector3;
  8276. /** Z axis */
  8277. static Z: Vector3;
  8278. }
  8279. }
  8280. declare module BABYLON {
  8281. /**
  8282. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8283. * This is the base of the follow, arc rotate cameras and Free camera
  8284. * @see http://doc.babylonjs.com/features/cameras
  8285. */
  8286. export class TargetCamera extends Camera {
  8287. private static _RigCamTransformMatrix;
  8288. private static _TargetTransformMatrix;
  8289. private static _TargetFocalPoint;
  8290. /**
  8291. * Define the current direction the camera is moving to
  8292. */
  8293. cameraDirection: Vector3;
  8294. /**
  8295. * Define the current rotation the camera is rotating to
  8296. */
  8297. cameraRotation: Vector2;
  8298. /**
  8299. * When set, the up vector of the camera will be updated by the rotation of the camera
  8300. */
  8301. updateUpVectorFromRotation: boolean;
  8302. private _tmpQuaternion;
  8303. /**
  8304. * Define the current rotation of the camera
  8305. */
  8306. rotation: Vector3;
  8307. /**
  8308. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8309. */
  8310. rotationQuaternion: Quaternion;
  8311. /**
  8312. * Define the current speed of the camera
  8313. */
  8314. speed: number;
  8315. /**
  8316. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8317. * around all axis.
  8318. */
  8319. noRotationConstraint: boolean;
  8320. /**
  8321. * Define the current target of the camera as an object or a position.
  8322. */
  8323. lockedTarget: any;
  8324. /** @hidden */
  8325. _currentTarget: Vector3;
  8326. /** @hidden */
  8327. _initialFocalDistance: number;
  8328. /** @hidden */
  8329. _viewMatrix: Matrix;
  8330. /** @hidden */
  8331. _camMatrix: Matrix;
  8332. /** @hidden */
  8333. _cameraTransformMatrix: Matrix;
  8334. /** @hidden */
  8335. _cameraRotationMatrix: Matrix;
  8336. /** @hidden */
  8337. _referencePoint: Vector3;
  8338. /** @hidden */
  8339. _transformedReferencePoint: Vector3;
  8340. protected _globalCurrentTarget: Vector3;
  8341. protected _globalCurrentUpVector: Vector3;
  8342. /** @hidden */
  8343. _reset: () => void;
  8344. private _defaultUp;
  8345. /**
  8346. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8347. * This is the base of the follow, arc rotate cameras and Free camera
  8348. * @see http://doc.babylonjs.com/features/cameras
  8349. * @param name Defines the name of the camera in the scene
  8350. * @param position Defines the start position of the camera in the scene
  8351. * @param scene Defines the scene the camera belongs to
  8352. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8353. */
  8354. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8355. /**
  8356. * Gets the position in front of the camera at a given distance.
  8357. * @param distance The distance from the camera we want the position to be
  8358. * @returns the position
  8359. */
  8360. getFrontPosition(distance: number): Vector3;
  8361. /** @hidden */
  8362. _getLockedTargetPosition(): Nullable<Vector3>;
  8363. private _storedPosition;
  8364. private _storedRotation;
  8365. private _storedRotationQuaternion;
  8366. /**
  8367. * Store current camera state of the camera (fov, position, rotation, etc..)
  8368. * @returns the camera
  8369. */
  8370. storeState(): Camera;
  8371. /**
  8372. * Restored camera state. You must call storeState() first
  8373. * @returns whether it was successful or not
  8374. * @hidden
  8375. */
  8376. _restoreStateValues(): boolean;
  8377. /** @hidden */
  8378. _initCache(): void;
  8379. /** @hidden */
  8380. _updateCache(ignoreParentClass?: boolean): void;
  8381. /** @hidden */
  8382. _isSynchronizedViewMatrix(): boolean;
  8383. /** @hidden */
  8384. _computeLocalCameraSpeed(): number;
  8385. /**
  8386. * Defines the target the camera should look at.
  8387. * @param target Defines the new target as a Vector or a mesh
  8388. */
  8389. setTarget(target: Vector3): void;
  8390. /**
  8391. * Return the current target position of the camera. This value is expressed in local space.
  8392. * @returns the target position
  8393. */
  8394. getTarget(): Vector3;
  8395. /** @hidden */
  8396. _decideIfNeedsToMove(): boolean;
  8397. /** @hidden */
  8398. _updatePosition(): void;
  8399. /** @hidden */
  8400. _checkInputs(): void;
  8401. protected _updateCameraRotationMatrix(): void;
  8402. /**
  8403. * 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)
  8404. * @returns the current camera
  8405. */
  8406. private _rotateUpVectorWithCameraRotationMatrix;
  8407. private _cachedRotationZ;
  8408. private _cachedQuaternionRotationZ;
  8409. /** @hidden */
  8410. _getViewMatrix(): Matrix;
  8411. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8412. /**
  8413. * @hidden
  8414. */
  8415. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8416. /**
  8417. * @hidden
  8418. */
  8419. _updateRigCameras(): void;
  8420. private _getRigCamPositionAndTarget;
  8421. /**
  8422. * Gets the current object class name.
  8423. * @return the class name
  8424. */
  8425. getClassName(): string;
  8426. }
  8427. }
  8428. declare module BABYLON {
  8429. /**
  8430. * Gather the list of keyboard event types as constants.
  8431. */
  8432. export class KeyboardEventTypes {
  8433. /**
  8434. * The keydown event is fired when a key becomes active (pressed).
  8435. */
  8436. static readonly KEYDOWN: number;
  8437. /**
  8438. * The keyup event is fired when a key has been released.
  8439. */
  8440. static readonly KEYUP: number;
  8441. }
  8442. /**
  8443. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8444. */
  8445. export class KeyboardInfo {
  8446. /**
  8447. * Defines the type of event (KeyboardEventTypes)
  8448. */
  8449. type: number;
  8450. /**
  8451. * Defines the related dom event
  8452. */
  8453. event: KeyboardEvent;
  8454. /**
  8455. * Instantiates a new keyboard info.
  8456. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8457. * @param type Defines the type of event (KeyboardEventTypes)
  8458. * @param event Defines the related dom event
  8459. */
  8460. constructor(
  8461. /**
  8462. * Defines the type of event (KeyboardEventTypes)
  8463. */
  8464. type: number,
  8465. /**
  8466. * Defines the related dom event
  8467. */
  8468. event: KeyboardEvent);
  8469. }
  8470. /**
  8471. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8472. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8473. */
  8474. export class KeyboardInfoPre extends KeyboardInfo {
  8475. /**
  8476. * Defines the type of event (KeyboardEventTypes)
  8477. */
  8478. type: number;
  8479. /**
  8480. * Defines the related dom event
  8481. */
  8482. event: KeyboardEvent;
  8483. /**
  8484. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8485. */
  8486. skipOnPointerObservable: boolean;
  8487. /**
  8488. * Instantiates a new keyboard pre info.
  8489. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8490. * @param type Defines the type of event (KeyboardEventTypes)
  8491. * @param event Defines the related dom event
  8492. */
  8493. constructor(
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number,
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent);
  8502. }
  8503. }
  8504. declare module BABYLON {
  8505. /**
  8506. * Manage the keyboard inputs to control the movement of a free camera.
  8507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8508. */
  8509. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8510. /**
  8511. * Defines the camera the input is attached to.
  8512. */
  8513. camera: FreeCamera;
  8514. /**
  8515. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8516. */
  8517. keysUp: number[];
  8518. /**
  8519. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8520. */
  8521. keysDown: number[];
  8522. /**
  8523. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8524. */
  8525. keysLeft: number[];
  8526. /**
  8527. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8528. */
  8529. keysRight: number[];
  8530. private _keys;
  8531. private _onCanvasBlurObserver;
  8532. private _onKeyboardObserver;
  8533. private _engine;
  8534. private _scene;
  8535. /**
  8536. * Attach the input controls to a specific dom element to get the input from.
  8537. * @param element Defines the element the controls should be listened from
  8538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8539. */
  8540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8541. /**
  8542. * Detach the current controls from the specified dom element.
  8543. * @param element Defines the element to stop listening the inputs from
  8544. */
  8545. detachControl(element: Nullable<HTMLElement>): void;
  8546. /**
  8547. * Update the current camera state depending on the inputs that have been used this frame.
  8548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8549. */
  8550. checkInputs(): void;
  8551. /**
  8552. * Gets the class name of the current intput.
  8553. * @returns the class name
  8554. */
  8555. getClassName(): string;
  8556. /** @hidden */
  8557. _onLostFocus(): void;
  8558. /**
  8559. * Get the friendly name associated with the input class.
  8560. * @returns the input friendly name
  8561. */
  8562. getSimpleName(): string;
  8563. }
  8564. }
  8565. declare module BABYLON {
  8566. /**
  8567. * Interface describing all the common properties and methods a shadow light needs to implement.
  8568. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8569. * as well as binding the different shadow properties to the effects.
  8570. */
  8571. export interface IShadowLight extends Light {
  8572. /**
  8573. * The light id in the scene (used in scene.findLighById for instance)
  8574. */
  8575. id: string;
  8576. /**
  8577. * The position the shdow will be casted from.
  8578. */
  8579. position: Vector3;
  8580. /**
  8581. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8582. */
  8583. direction: Vector3;
  8584. /**
  8585. * The transformed position. Position of the light in world space taking parenting in account.
  8586. */
  8587. transformedPosition: Vector3;
  8588. /**
  8589. * The transformed direction. Direction of the light in world space taking parenting in account.
  8590. */
  8591. transformedDirection: Vector3;
  8592. /**
  8593. * The friendly name of the light in the scene.
  8594. */
  8595. name: string;
  8596. /**
  8597. * Defines the shadow projection clipping minimum z value.
  8598. */
  8599. shadowMinZ: number;
  8600. /**
  8601. * Defines the shadow projection clipping maximum z value.
  8602. */
  8603. shadowMaxZ: number;
  8604. /**
  8605. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8606. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8607. */
  8608. computeTransformedInformation(): boolean;
  8609. /**
  8610. * Gets the scene the light belongs to.
  8611. * @returns The scene
  8612. */
  8613. getScene(): Scene;
  8614. /**
  8615. * Callback defining a custom Projection Matrix Builder.
  8616. * This can be used to override the default projection matrix computation.
  8617. */
  8618. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8619. /**
  8620. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8621. * @param matrix The materix to updated with the projection information
  8622. * @param viewMatrix The transform matrix of the light
  8623. * @param renderList The list of mesh to render in the map
  8624. * @returns The current light
  8625. */
  8626. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8627. /**
  8628. * Gets the current depth scale used in ESM.
  8629. * @returns The scale
  8630. */
  8631. getDepthScale(): number;
  8632. /**
  8633. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8634. * @returns true if a cube texture needs to be use
  8635. */
  8636. needCube(): boolean;
  8637. /**
  8638. * Detects if the projection matrix requires to be recomputed this frame.
  8639. * @returns true if it requires to be recomputed otherwise, false.
  8640. */
  8641. needProjectionMatrixCompute(): boolean;
  8642. /**
  8643. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8644. */
  8645. forceProjectionMatrixCompute(): void;
  8646. /**
  8647. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8648. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8649. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8650. */
  8651. getShadowDirection(faceIndex?: number): Vector3;
  8652. /**
  8653. * Gets the minZ used for shadow according to both the scene and the light.
  8654. * @param activeCamera The camera we are returning the min for
  8655. * @returns the depth min z
  8656. */
  8657. getDepthMinZ(activeCamera: Camera): number;
  8658. /**
  8659. * Gets the maxZ used for shadow according to both the scene and the light.
  8660. * @param activeCamera The camera we are returning the max for
  8661. * @returns the depth max z
  8662. */
  8663. getDepthMaxZ(activeCamera: Camera): number;
  8664. }
  8665. /**
  8666. * Base implementation IShadowLight
  8667. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8668. */
  8669. export abstract class ShadowLight extends Light implements IShadowLight {
  8670. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8671. protected _position: Vector3;
  8672. protected _setPosition(value: Vector3): void;
  8673. /**
  8674. * Sets the position the shadow will be casted from. Also use as the light position for both
  8675. * point and spot lights.
  8676. */
  8677. /**
  8678. * Sets the position the shadow will be casted from. Also use as the light position for both
  8679. * point and spot lights.
  8680. */
  8681. position: Vector3;
  8682. protected _direction: Vector3;
  8683. protected _setDirection(value: Vector3): void;
  8684. /**
  8685. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8686. * Also use as the light direction on spot and directional lights.
  8687. */
  8688. /**
  8689. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8690. * Also use as the light direction on spot and directional lights.
  8691. */
  8692. direction: Vector3;
  8693. private _shadowMinZ;
  8694. /**
  8695. * Gets the shadow projection clipping minimum z value.
  8696. */
  8697. /**
  8698. * Sets the shadow projection clipping minimum z value.
  8699. */
  8700. shadowMinZ: number;
  8701. private _shadowMaxZ;
  8702. /**
  8703. * Sets the shadow projection clipping maximum z value.
  8704. */
  8705. /**
  8706. * Gets the shadow projection clipping maximum z value.
  8707. */
  8708. shadowMaxZ: number;
  8709. /**
  8710. * Callback defining a custom Projection Matrix Builder.
  8711. * This can be used to override the default projection matrix computation.
  8712. */
  8713. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8714. /**
  8715. * The transformed position. Position of the light in world space taking parenting in account.
  8716. */
  8717. transformedPosition: Vector3;
  8718. /**
  8719. * The transformed direction. Direction of the light in world space taking parenting in account.
  8720. */
  8721. transformedDirection: Vector3;
  8722. private _needProjectionMatrixCompute;
  8723. /**
  8724. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8725. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8726. */
  8727. computeTransformedInformation(): boolean;
  8728. /**
  8729. * Return the depth scale used for the shadow map.
  8730. * @returns the depth scale.
  8731. */
  8732. getDepthScale(): number;
  8733. /**
  8734. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8735. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8736. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8737. */
  8738. getShadowDirection(faceIndex?: number): Vector3;
  8739. /**
  8740. * Returns the ShadowLight absolute position in the World.
  8741. * @returns the position vector in world space
  8742. */
  8743. getAbsolutePosition(): Vector3;
  8744. /**
  8745. * Sets the ShadowLight direction toward the passed target.
  8746. * @param target The point to target in local space
  8747. * @returns the updated ShadowLight direction
  8748. */
  8749. setDirectionToTarget(target: Vector3): Vector3;
  8750. /**
  8751. * Returns the light rotation in euler definition.
  8752. * @returns the x y z rotation in local space.
  8753. */
  8754. getRotation(): Vector3;
  8755. /**
  8756. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8757. * @returns true if a cube texture needs to be use
  8758. */
  8759. needCube(): boolean;
  8760. /**
  8761. * Detects if the projection matrix requires to be recomputed this frame.
  8762. * @returns true if it requires to be recomputed otherwise, false.
  8763. */
  8764. needProjectionMatrixCompute(): boolean;
  8765. /**
  8766. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8767. */
  8768. forceProjectionMatrixCompute(): void;
  8769. /** @hidden */
  8770. _initCache(): void;
  8771. /** @hidden */
  8772. _isSynchronized(): boolean;
  8773. /**
  8774. * Computes the world matrix of the node
  8775. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8776. * @returns the world matrix
  8777. */
  8778. computeWorldMatrix(force?: boolean): Matrix;
  8779. /**
  8780. * Gets the minZ used for shadow according to both the scene and the light.
  8781. * @param activeCamera The camera we are returning the min for
  8782. * @returns the depth min z
  8783. */
  8784. getDepthMinZ(activeCamera: Camera): number;
  8785. /**
  8786. * Gets the maxZ used for shadow according to both the scene and the light.
  8787. * @param activeCamera The camera we are returning the max for
  8788. * @returns the depth max z
  8789. */
  8790. getDepthMaxZ(activeCamera: Camera): number;
  8791. /**
  8792. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8793. * @param matrix The materix to updated with the projection information
  8794. * @param viewMatrix The transform matrix of the light
  8795. * @param renderList The list of mesh to render in the map
  8796. * @returns The current light
  8797. */
  8798. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8799. }
  8800. }
  8801. declare module BABYLON {
  8802. /**
  8803. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8804. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8805. */
  8806. export class EffectFallbacks implements IEffectFallbacks {
  8807. private _defines;
  8808. private _currentRank;
  8809. private _maxRank;
  8810. private _mesh;
  8811. /**
  8812. * Removes the fallback from the bound mesh.
  8813. */
  8814. unBindMesh(): void;
  8815. /**
  8816. * Adds a fallback on the specified property.
  8817. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8818. * @param define The name of the define in the shader
  8819. */
  8820. addFallback(rank: number, define: string): void;
  8821. /**
  8822. * Sets the mesh to use CPU skinning when needing to fallback.
  8823. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8824. * @param mesh The mesh to use the fallbacks.
  8825. */
  8826. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8827. /**
  8828. * Checks to see if more fallbacks are still availible.
  8829. */
  8830. readonly hasMoreFallbacks: boolean;
  8831. /**
  8832. * Removes the defines that should be removed when falling back.
  8833. * @param currentDefines defines the current define statements for the shader.
  8834. * @param effect defines the current effect we try to compile
  8835. * @returns The resulting defines with defines of the current rank removed.
  8836. */
  8837. reduce(currentDefines: string, effect: Effect): string;
  8838. }
  8839. }
  8840. declare module BABYLON {
  8841. /**
  8842. * "Static Class" containing the most commonly used helper while dealing with material for
  8843. * rendering purpose.
  8844. *
  8845. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8846. *
  8847. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8848. */
  8849. export class MaterialHelper {
  8850. /**
  8851. * Bind the current view position to an effect.
  8852. * @param effect The effect to be bound
  8853. * @param scene The scene the eyes position is used from
  8854. */
  8855. static BindEyePosition(effect: Effect, scene: Scene): void;
  8856. /**
  8857. * Helps preparing the defines values about the UVs in used in the effect.
  8858. * UVs are shared as much as we can accross channels in the shaders.
  8859. * @param texture The texture we are preparing the UVs for
  8860. * @param defines The defines to update
  8861. * @param key The channel key "diffuse", "specular"... used in the shader
  8862. */
  8863. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8864. /**
  8865. * Binds a texture matrix value to its corrsponding uniform
  8866. * @param texture The texture to bind the matrix for
  8867. * @param uniformBuffer The uniform buffer receivin the data
  8868. * @param key The channel key "diffuse", "specular"... used in the shader
  8869. */
  8870. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8871. /**
  8872. * Gets the current status of the fog (should it be enabled?)
  8873. * @param mesh defines the mesh to evaluate for fog support
  8874. * @param scene defines the hosting scene
  8875. * @returns true if fog must be enabled
  8876. */
  8877. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8878. /**
  8879. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8880. * @param mesh defines the current mesh
  8881. * @param scene defines the current scene
  8882. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8883. * @param pointsCloud defines if point cloud rendering has to be turned on
  8884. * @param fogEnabled defines if fog has to be turned on
  8885. * @param alphaTest defines if alpha testing has to be turned on
  8886. * @param defines defines the current list of defines
  8887. */
  8888. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8889. /**
  8890. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8891. * @param scene defines the current scene
  8892. * @param engine defines the current engine
  8893. * @param defines specifies the list of active defines
  8894. * @param useInstances defines if instances have to be turned on
  8895. * @param useClipPlane defines if clip plane have to be turned on
  8896. */
  8897. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8898. /**
  8899. * Prepares the defines for bones
  8900. * @param mesh The mesh containing the geometry data we will draw
  8901. * @param defines The defines to update
  8902. */
  8903. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8904. /**
  8905. * Prepares the defines for morph targets
  8906. * @param mesh The mesh containing the geometry data we will draw
  8907. * @param defines The defines to update
  8908. */
  8909. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8910. /**
  8911. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8912. * @param mesh The mesh containing the geometry data we will draw
  8913. * @param defines The defines to update
  8914. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8915. * @param useBones Precise whether bones should be used or not (override mesh info)
  8916. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8917. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8918. * @returns false if defines are considered not dirty and have not been checked
  8919. */
  8920. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8921. /**
  8922. * Prepares the defines related to multiview
  8923. * @param scene The scene we are intending to draw
  8924. * @param defines The defines to update
  8925. */
  8926. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8927. /**
  8928. * Prepares the defines related to the light information passed in parameter
  8929. * @param scene The scene we are intending to draw
  8930. * @param mesh The mesh the effect is compiling for
  8931. * @param light The light the effect is compiling for
  8932. * @param lightIndex The index of the light
  8933. * @param defines The defines to update
  8934. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8935. * @param state Defines the current state regarding what is needed (normals, etc...)
  8936. */
  8937. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8938. needNormals: boolean;
  8939. needRebuild: boolean;
  8940. shadowEnabled: boolean;
  8941. specularEnabled: boolean;
  8942. lightmapMode: boolean;
  8943. }): void;
  8944. /**
  8945. * Prepares the defines related to the light information passed in parameter
  8946. * @param scene The scene we are intending to draw
  8947. * @param mesh The mesh the effect is compiling for
  8948. * @param defines The defines to update
  8949. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8950. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8951. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8952. * @returns true if normals will be required for the rest of the effect
  8953. */
  8954. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8955. /**
  8956. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8957. * @param lightIndex defines the light index
  8958. * @param uniformsList The uniform list
  8959. * @param samplersList The sampler list
  8960. * @param projectedLightTexture defines if projected texture must be used
  8961. * @param uniformBuffersList defines an optional list of uniform buffers
  8962. */
  8963. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8964. /**
  8965. * Prepares the uniforms and samplers list to be used in the effect
  8966. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8967. * @param samplersList The sampler list
  8968. * @param defines The defines helping in the list generation
  8969. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8970. */
  8971. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8972. /**
  8973. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8974. * @param defines The defines to update while falling back
  8975. * @param fallbacks The authorized effect fallbacks
  8976. * @param maxSimultaneousLights The maximum number of lights allowed
  8977. * @param rank the current rank of the Effect
  8978. * @returns The newly affected rank
  8979. */
  8980. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8981. private static _TmpMorphInfluencers;
  8982. /**
  8983. * Prepares the list of attributes required for morph targets according to the effect defines.
  8984. * @param attribs The current list of supported attribs
  8985. * @param mesh The mesh to prepare the morph targets attributes for
  8986. * @param influencers The number of influencers
  8987. */
  8988. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8989. /**
  8990. * Prepares the list of attributes required for morph targets according to the effect defines.
  8991. * @param attribs The current list of supported attribs
  8992. * @param mesh The mesh to prepare the morph targets attributes for
  8993. * @param defines The current Defines of the effect
  8994. */
  8995. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8996. /**
  8997. * Prepares the list of attributes required for bones according to the effect defines.
  8998. * @param attribs The current list of supported attribs
  8999. * @param mesh The mesh to prepare the bones attributes for
  9000. * @param defines The current Defines of the effect
  9001. * @param fallbacks The current efffect fallback strategy
  9002. */
  9003. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9004. /**
  9005. * Check and prepare the list of attributes required for instances according to the effect defines.
  9006. * @param attribs The current list of supported attribs
  9007. * @param defines The current MaterialDefines of the effect
  9008. */
  9009. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9010. /**
  9011. * Add the list of attributes required for instances to the attribs array.
  9012. * @param attribs The current list of supported attribs
  9013. */
  9014. static PushAttributesForInstances(attribs: string[]): void;
  9015. /**
  9016. * Binds the light information to the effect.
  9017. * @param light The light containing the generator
  9018. * @param effect The effect we are binding the data to
  9019. * @param lightIndex The light index in the effect used to render
  9020. */
  9021. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9022. /**
  9023. * Binds the lights information from the scene to the effect for the given mesh.
  9024. * @param light Light to bind
  9025. * @param lightIndex Light index
  9026. * @param scene The scene where the light belongs to
  9027. * @param effect The effect we are binding the data to
  9028. * @param useSpecular Defines if specular is supported
  9029. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9030. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9031. */
  9032. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9033. /**
  9034. * Binds the lights information from the scene to the effect for the given mesh.
  9035. * @param scene The scene the lights belongs to
  9036. * @param mesh The mesh we are binding the information to render
  9037. * @param effect The effect we are binding the data to
  9038. * @param defines The generated defines for the effect
  9039. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9040. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9041. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9042. */
  9043. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9044. private static _tempFogColor;
  9045. /**
  9046. * Binds the fog information from the scene to the effect for the given mesh.
  9047. * @param scene The scene the lights belongs to
  9048. * @param mesh The mesh we are binding the information to render
  9049. * @param effect The effect we are binding the data to
  9050. * @param linearSpace Defines if the fog effect is applied in linear space
  9051. */
  9052. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9053. /**
  9054. * Binds the bones information from the mesh to the effect.
  9055. * @param mesh The mesh we are binding the information to render
  9056. * @param effect The effect we are binding the data to
  9057. */
  9058. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9059. /**
  9060. * Binds the morph targets information from the mesh to the effect.
  9061. * @param abstractMesh The mesh we are binding the information to render
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9065. /**
  9066. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9067. * @param defines The generated defines used in the effect
  9068. * @param effect The effect we are binding the data to
  9069. * @param scene The scene we are willing to render with logarithmic scale for
  9070. */
  9071. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9072. /**
  9073. * Binds the clip plane information from the scene to the effect.
  9074. * @param scene The scene the clip plane information are extracted from
  9075. * @param effect The effect we are binding the data to
  9076. */
  9077. static BindClipPlane(effect: Effect, scene: Scene): void;
  9078. }
  9079. }
  9080. declare module BABYLON {
  9081. /** @hidden */
  9082. export var packingFunctions: {
  9083. name: string;
  9084. shader: string;
  9085. };
  9086. }
  9087. declare module BABYLON {
  9088. /** @hidden */
  9089. export var shadowMapPixelShader: {
  9090. name: string;
  9091. shader: string;
  9092. };
  9093. }
  9094. declare module BABYLON {
  9095. /** @hidden */
  9096. export var bonesDeclaration: {
  9097. name: string;
  9098. shader: string;
  9099. };
  9100. }
  9101. declare module BABYLON {
  9102. /** @hidden */
  9103. export var morphTargetsVertexGlobalDeclaration: {
  9104. name: string;
  9105. shader: string;
  9106. };
  9107. }
  9108. declare module BABYLON {
  9109. /** @hidden */
  9110. export var morphTargetsVertexDeclaration: {
  9111. name: string;
  9112. shader: string;
  9113. };
  9114. }
  9115. declare module BABYLON {
  9116. /** @hidden */
  9117. export var instancesDeclaration: {
  9118. name: string;
  9119. shader: string;
  9120. };
  9121. }
  9122. declare module BABYLON {
  9123. /** @hidden */
  9124. export var helperFunctions: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module BABYLON {
  9130. /** @hidden */
  9131. export var morphTargetsVertex: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module BABYLON {
  9137. /** @hidden */
  9138. export var instancesVertex: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module BABYLON {
  9144. /** @hidden */
  9145. export var bonesVertex: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module BABYLON {
  9151. /** @hidden */
  9152. export var shadowMapVertexShader: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module BABYLON {
  9158. /** @hidden */
  9159. export var depthBoxBlurPixelShader: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module BABYLON {
  9165. /**
  9166. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9167. */
  9168. export interface ICustomShaderOptions {
  9169. /**
  9170. * Gets or sets the custom shader name to use
  9171. */
  9172. shaderName: string;
  9173. /**
  9174. * The list of attribute names used in the shader
  9175. */
  9176. attributes?: string[];
  9177. /**
  9178. * The list of unifrom names used in the shader
  9179. */
  9180. uniforms?: string[];
  9181. /**
  9182. * The list of sampler names used in the shader
  9183. */
  9184. samplers?: string[];
  9185. /**
  9186. * The list of defines used in the shader
  9187. */
  9188. defines?: string[];
  9189. }
  9190. /**
  9191. * Interface to implement to create a shadow generator compatible with BJS.
  9192. */
  9193. export interface IShadowGenerator {
  9194. /**
  9195. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9196. * @returns The render target texture if present otherwise, null
  9197. */
  9198. getShadowMap(): Nullable<RenderTargetTexture>;
  9199. /**
  9200. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9201. * @returns The render target texture if the shadow map is present otherwise, null
  9202. */
  9203. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9204. /**
  9205. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9206. * @param subMesh The submesh we want to render in the shadow map
  9207. * @param useInstances Defines wether will draw in the map using instances
  9208. * @returns true if ready otherwise, false
  9209. */
  9210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9211. /**
  9212. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9213. * @param defines Defines of the material we want to update
  9214. * @param lightIndex Index of the light in the enabled light list of the material
  9215. */
  9216. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9217. /**
  9218. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9219. * defined in the generator but impacting the effect).
  9220. * It implies the unifroms available on the materials are the standard BJS ones.
  9221. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9222. * @param effect The effect we are binfing the information for
  9223. */
  9224. bindShadowLight(lightIndex: string, effect: Effect): void;
  9225. /**
  9226. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9227. * (eq to shadow prjection matrix * light transform matrix)
  9228. * @returns The transform matrix used to create the shadow map
  9229. */
  9230. getTransformMatrix(): Matrix;
  9231. /**
  9232. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9233. * Cube and 2D textures for instance.
  9234. */
  9235. recreateShadowMap(): void;
  9236. /**
  9237. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9238. * @param onCompiled Callback triggered at the and of the effects compilation
  9239. * @param options Sets of optional options forcing the compilation with different modes
  9240. */
  9241. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9242. useInstances: boolean;
  9243. }>): void;
  9244. /**
  9245. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9246. * @param options Sets of optional options forcing the compilation with different modes
  9247. * @returns A promise that resolves when the compilation completes
  9248. */
  9249. forceCompilationAsync(options?: Partial<{
  9250. useInstances: boolean;
  9251. }>): Promise<void>;
  9252. /**
  9253. * Serializes the shadow generator setup to a json object.
  9254. * @returns The serialized JSON object
  9255. */
  9256. serialize(): any;
  9257. /**
  9258. * Disposes the Shadow map and related Textures and effects.
  9259. */
  9260. dispose(): void;
  9261. }
  9262. /**
  9263. * Default implementation IShadowGenerator.
  9264. * This is the main object responsible of generating shadows in the framework.
  9265. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9266. */
  9267. export class ShadowGenerator implements IShadowGenerator {
  9268. /**
  9269. * Shadow generator mode None: no filtering applied.
  9270. */
  9271. static readonly FILTER_NONE: number;
  9272. /**
  9273. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9274. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9275. */
  9276. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9277. /**
  9278. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9279. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9280. */
  9281. static readonly FILTER_POISSONSAMPLING: number;
  9282. /**
  9283. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9284. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9285. */
  9286. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9287. /**
  9288. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9289. * edge artifacts on steep falloff.
  9290. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9291. */
  9292. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9293. /**
  9294. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9295. * edge artifacts on steep falloff.
  9296. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9297. */
  9298. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9299. /**
  9300. * Shadow generator mode PCF: Percentage Closer Filtering
  9301. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9302. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9303. */
  9304. static readonly FILTER_PCF: number;
  9305. /**
  9306. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9307. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9308. * Contact Hardening
  9309. */
  9310. static readonly FILTER_PCSS: number;
  9311. /**
  9312. * Reserved for PCF and PCSS
  9313. * Highest Quality.
  9314. *
  9315. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9316. *
  9317. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9318. */
  9319. static readonly QUALITY_HIGH: number;
  9320. /**
  9321. * Reserved for PCF and PCSS
  9322. * Good tradeoff for quality/perf cross devices
  9323. *
  9324. * Execute PCF on a 3*3 kernel.
  9325. *
  9326. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9327. */
  9328. static readonly QUALITY_MEDIUM: number;
  9329. /**
  9330. * Reserved for PCF and PCSS
  9331. * The lowest quality but the fastest.
  9332. *
  9333. * Execute PCF on a 1*1 kernel.
  9334. *
  9335. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9336. */
  9337. static readonly QUALITY_LOW: number;
  9338. /** Gets or sets the custom shader name to use */
  9339. customShaderOptions: ICustomShaderOptions;
  9340. /**
  9341. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9342. */
  9343. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9344. /**
  9345. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9346. */
  9347. onAfterShadowMapRenderObservable: Observable<Effect>;
  9348. /**
  9349. * Observable triggered before a mesh is rendered in the shadow map.
  9350. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9351. */
  9352. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9353. /**
  9354. * Observable triggered after a mesh is rendered in the shadow map.
  9355. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9356. */
  9357. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9358. private _bias;
  9359. /**
  9360. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9361. */
  9362. /**
  9363. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9364. */
  9365. bias: number;
  9366. private _normalBias;
  9367. /**
  9368. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9369. */
  9370. /**
  9371. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9372. */
  9373. normalBias: number;
  9374. private _blurBoxOffset;
  9375. /**
  9376. * Gets the blur box offset: offset applied during the blur pass.
  9377. * Only useful if useKernelBlur = false
  9378. */
  9379. /**
  9380. * Sets the blur box offset: offset applied during the blur pass.
  9381. * Only useful if useKernelBlur = false
  9382. */
  9383. blurBoxOffset: number;
  9384. private _blurScale;
  9385. /**
  9386. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9387. * 2 means half of the size.
  9388. */
  9389. /**
  9390. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9391. * 2 means half of the size.
  9392. */
  9393. blurScale: number;
  9394. private _blurKernel;
  9395. /**
  9396. * Gets the blur kernel: kernel size of the blur pass.
  9397. * Only useful if useKernelBlur = true
  9398. */
  9399. /**
  9400. * Sets the blur kernel: kernel size of the blur pass.
  9401. * Only useful if useKernelBlur = true
  9402. */
  9403. blurKernel: number;
  9404. private _useKernelBlur;
  9405. /**
  9406. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9407. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9408. */
  9409. /**
  9410. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9411. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9412. */
  9413. useKernelBlur: boolean;
  9414. private _depthScale;
  9415. /**
  9416. * Gets the depth scale used in ESM mode.
  9417. */
  9418. /**
  9419. * Sets the depth scale used in ESM mode.
  9420. * This can override the scale stored on the light.
  9421. */
  9422. depthScale: number;
  9423. private _filter;
  9424. /**
  9425. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9426. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9427. */
  9428. /**
  9429. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9430. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9431. */
  9432. filter: number;
  9433. /**
  9434. * Gets if the current filter is set to Poisson Sampling.
  9435. */
  9436. /**
  9437. * Sets the current filter to Poisson Sampling.
  9438. */
  9439. usePoissonSampling: boolean;
  9440. /**
  9441. * Gets if the current filter is set to ESM.
  9442. */
  9443. /**
  9444. * Sets the current filter is to ESM.
  9445. */
  9446. useExponentialShadowMap: boolean;
  9447. /**
  9448. * Gets if the current filter is set to filtered ESM.
  9449. */
  9450. /**
  9451. * Gets if the current filter is set to filtered ESM.
  9452. */
  9453. useBlurExponentialShadowMap: boolean;
  9454. /**
  9455. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9456. * exponential to prevent steep falloff artifacts).
  9457. */
  9458. /**
  9459. * Sets the current filter to "close ESM" (using the inverse of the
  9460. * exponential to prevent steep falloff artifacts).
  9461. */
  9462. useCloseExponentialShadowMap: boolean;
  9463. /**
  9464. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9465. * exponential to prevent steep falloff artifacts).
  9466. */
  9467. /**
  9468. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9469. * exponential to prevent steep falloff artifacts).
  9470. */
  9471. useBlurCloseExponentialShadowMap: boolean;
  9472. /**
  9473. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9474. */
  9475. /**
  9476. * Sets the current filter to "PCF" (percentage closer filtering).
  9477. */
  9478. usePercentageCloserFiltering: boolean;
  9479. private _filteringQuality;
  9480. /**
  9481. * Gets the PCF or PCSS Quality.
  9482. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9483. */
  9484. /**
  9485. * Sets the PCF or PCSS Quality.
  9486. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9487. */
  9488. filteringQuality: number;
  9489. /**
  9490. * Gets if the current filter is set to "PCSS" (contact hardening).
  9491. */
  9492. /**
  9493. * Sets the current filter to "PCSS" (contact hardening).
  9494. */
  9495. useContactHardeningShadow: boolean;
  9496. private _contactHardeningLightSizeUVRatio;
  9497. /**
  9498. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9499. * Using a ratio helps keeping shape stability independently of the map size.
  9500. *
  9501. * It does not account for the light projection as it was having too much
  9502. * instability during the light setup or during light position changes.
  9503. *
  9504. * Only valid if useContactHardeningShadow is true.
  9505. */
  9506. /**
  9507. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9508. * Using a ratio helps keeping shape stability independently of the map size.
  9509. *
  9510. * It does not account for the light projection as it was having too much
  9511. * instability during the light setup or during light position changes.
  9512. *
  9513. * Only valid if useContactHardeningShadow is true.
  9514. */
  9515. contactHardeningLightSizeUVRatio: number;
  9516. private _darkness;
  9517. /** Gets or sets the actual darkness of a shadow */
  9518. darkness: number;
  9519. /**
  9520. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9521. * 0 means strongest and 1 would means no shadow.
  9522. * @returns the darkness.
  9523. */
  9524. getDarkness(): number;
  9525. /**
  9526. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9527. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9528. * @returns the shadow generator allowing fluent coding.
  9529. */
  9530. setDarkness(darkness: number): ShadowGenerator;
  9531. private _transparencyShadow;
  9532. /** Gets or sets the ability to have transparent shadow */
  9533. transparencyShadow: boolean;
  9534. /**
  9535. * Sets the ability to have transparent shadow (boolean).
  9536. * @param transparent True if transparent else False
  9537. * @returns the shadow generator allowing fluent coding
  9538. */
  9539. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9540. private _shadowMap;
  9541. private _shadowMap2;
  9542. /**
  9543. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9544. * @returns The render target texture if present otherwise, null
  9545. */
  9546. getShadowMap(): Nullable<RenderTargetTexture>;
  9547. /**
  9548. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9549. * @returns The render target texture if the shadow map is present otherwise, null
  9550. */
  9551. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9552. /**
  9553. * Gets the class name of that object
  9554. * @returns "ShadowGenerator"
  9555. */
  9556. getClassName(): string;
  9557. /**
  9558. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9559. * @param mesh Mesh to add
  9560. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9561. * @returns the Shadow Generator itself
  9562. */
  9563. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9564. /**
  9565. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9566. * @param mesh Mesh to remove
  9567. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9568. * @returns the Shadow Generator itself
  9569. */
  9570. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9571. /**
  9572. * Controls the extent to which the shadows fade out at the edge of the frustum
  9573. * Used only by directionals and spots
  9574. */
  9575. frustumEdgeFalloff: number;
  9576. private _light;
  9577. /**
  9578. * Returns the associated light object.
  9579. * @returns the light generating the shadow
  9580. */
  9581. getLight(): IShadowLight;
  9582. /**
  9583. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9584. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9585. * It might on the other hand introduce peter panning.
  9586. */
  9587. forceBackFacesOnly: boolean;
  9588. private _scene;
  9589. private _lightDirection;
  9590. private _effect;
  9591. private _viewMatrix;
  9592. private _projectionMatrix;
  9593. private _transformMatrix;
  9594. private _cachedPosition;
  9595. private _cachedDirection;
  9596. private _cachedDefines;
  9597. private _currentRenderID;
  9598. private _boxBlurPostprocess;
  9599. private _kernelBlurXPostprocess;
  9600. private _kernelBlurYPostprocess;
  9601. private _blurPostProcesses;
  9602. private _mapSize;
  9603. private _currentFaceIndex;
  9604. private _currentFaceIndexCache;
  9605. private _textureType;
  9606. private _defaultTextureMatrix;
  9607. private _storedUniqueId;
  9608. /** @hidden */
  9609. static _SceneComponentInitialization: (scene: Scene) => void;
  9610. /**
  9611. * Creates a ShadowGenerator object.
  9612. * A ShadowGenerator is the required tool to use the shadows.
  9613. * Each light casting shadows needs to use its own ShadowGenerator.
  9614. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9615. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9616. * @param light The light object generating the shadows.
  9617. * @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.
  9618. */
  9619. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9620. private _initializeGenerator;
  9621. private _initializeShadowMap;
  9622. private _initializeBlurRTTAndPostProcesses;
  9623. private _renderForShadowMap;
  9624. private _renderSubMeshForShadowMap;
  9625. private _applyFilterValues;
  9626. /**
  9627. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9628. * @param onCompiled Callback triggered at the and of the effects compilation
  9629. * @param options Sets of optional options forcing the compilation with different modes
  9630. */
  9631. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9632. useInstances: boolean;
  9633. }>): void;
  9634. /**
  9635. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9636. * @param options Sets of optional options forcing the compilation with different modes
  9637. * @returns A promise that resolves when the compilation completes
  9638. */
  9639. forceCompilationAsync(options?: Partial<{
  9640. useInstances: boolean;
  9641. }>): Promise<void>;
  9642. /**
  9643. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9644. * @param subMesh The submesh we want to render in the shadow map
  9645. * @param useInstances Defines wether will draw in the map using instances
  9646. * @returns true if ready otherwise, false
  9647. */
  9648. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9649. /**
  9650. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9651. * @param defines Defines of the material we want to update
  9652. * @param lightIndex Index of the light in the enabled light list of the material
  9653. */
  9654. prepareDefines(defines: any, lightIndex: number): void;
  9655. /**
  9656. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9657. * defined in the generator but impacting the effect).
  9658. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9659. * @param effect The effect we are binfing the information for
  9660. */
  9661. bindShadowLight(lightIndex: string, effect: Effect): void;
  9662. /**
  9663. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9664. * (eq to shadow prjection matrix * light transform matrix)
  9665. * @returns The transform matrix used to create the shadow map
  9666. */
  9667. getTransformMatrix(): Matrix;
  9668. /**
  9669. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9670. * Cube and 2D textures for instance.
  9671. */
  9672. recreateShadowMap(): void;
  9673. private _disposeBlurPostProcesses;
  9674. private _disposeRTTandPostProcesses;
  9675. /**
  9676. * Disposes the ShadowGenerator.
  9677. * Returns nothing.
  9678. */
  9679. dispose(): void;
  9680. /**
  9681. * Serializes the shadow generator setup to a json object.
  9682. * @returns The serialized JSON object
  9683. */
  9684. serialize(): any;
  9685. /**
  9686. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9687. * @param parsedShadowGenerator The JSON object to parse
  9688. * @param scene The scene to create the shadow map for
  9689. * @returns The parsed shadow generator
  9690. */
  9691. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9692. }
  9693. }
  9694. declare module BABYLON {
  9695. /**
  9696. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9697. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9698. * 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.
  9699. */
  9700. export abstract class Light extends Node {
  9701. /**
  9702. * Falloff Default: light is falling off following the material specification:
  9703. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9704. */
  9705. static readonly FALLOFF_DEFAULT: number;
  9706. /**
  9707. * Falloff Physical: light is falling off following the inverse squared distance law.
  9708. */
  9709. static readonly FALLOFF_PHYSICAL: number;
  9710. /**
  9711. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9712. * to enhance interoperability with other engines.
  9713. */
  9714. static readonly FALLOFF_GLTF: number;
  9715. /**
  9716. * Falloff Standard: light is falling off like in the standard material
  9717. * to enhance interoperability with other materials.
  9718. */
  9719. static readonly FALLOFF_STANDARD: number;
  9720. /**
  9721. * If every light affecting the material is in this lightmapMode,
  9722. * material.lightmapTexture adds or multiplies
  9723. * (depends on material.useLightmapAsShadowmap)
  9724. * after every other light calculations.
  9725. */
  9726. static readonly LIGHTMAP_DEFAULT: number;
  9727. /**
  9728. * material.lightmapTexture as only diffuse lighting from this light
  9729. * adds only specular lighting from this light
  9730. * adds dynamic shadows
  9731. */
  9732. static readonly LIGHTMAP_SPECULAR: number;
  9733. /**
  9734. * material.lightmapTexture as only lighting
  9735. * no light calculation from this light
  9736. * only adds dynamic shadows from this light
  9737. */
  9738. static readonly LIGHTMAP_SHADOWSONLY: number;
  9739. /**
  9740. * Each light type uses the default quantity according to its type:
  9741. * point/spot lights use luminous intensity
  9742. * directional lights use illuminance
  9743. */
  9744. static readonly INTENSITYMODE_AUTOMATIC: number;
  9745. /**
  9746. * lumen (lm)
  9747. */
  9748. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9749. /**
  9750. * candela (lm/sr)
  9751. */
  9752. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9753. /**
  9754. * lux (lm/m^2)
  9755. */
  9756. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9757. /**
  9758. * nit (cd/m^2)
  9759. */
  9760. static readonly INTENSITYMODE_LUMINANCE: number;
  9761. /**
  9762. * Light type const id of the point light.
  9763. */
  9764. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9765. /**
  9766. * Light type const id of the directional light.
  9767. */
  9768. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9769. /**
  9770. * Light type const id of the spot light.
  9771. */
  9772. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9773. /**
  9774. * Light type const id of the hemispheric light.
  9775. */
  9776. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9777. /**
  9778. * Diffuse gives the basic color to an object.
  9779. */
  9780. diffuse: Color3;
  9781. /**
  9782. * Specular produces a highlight color on an object.
  9783. * Note: This is note affecting PBR materials.
  9784. */
  9785. specular: Color3;
  9786. /**
  9787. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9788. * falling off base on range or angle.
  9789. * This can be set to any values in Light.FALLOFF_x.
  9790. *
  9791. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9792. * other types of materials.
  9793. */
  9794. falloffType: number;
  9795. /**
  9796. * Strength of the light.
  9797. * Note: By default it is define in the framework own unit.
  9798. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9799. */
  9800. intensity: number;
  9801. private _range;
  9802. protected _inverseSquaredRange: number;
  9803. /**
  9804. * Defines how far from the source the light is impacting in scene units.
  9805. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9806. */
  9807. /**
  9808. * Defines how far from the source the light is impacting in scene units.
  9809. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9810. */
  9811. range: number;
  9812. /**
  9813. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9814. * of light.
  9815. */
  9816. private _photometricScale;
  9817. private _intensityMode;
  9818. /**
  9819. * Gets the photometric scale used to interpret the intensity.
  9820. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9821. */
  9822. /**
  9823. * Sets the photometric scale used to interpret the intensity.
  9824. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9825. */
  9826. intensityMode: number;
  9827. private _radius;
  9828. /**
  9829. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9830. */
  9831. /**
  9832. * sets the light radius used by PBR Materials to simulate soft area lights.
  9833. */
  9834. radius: number;
  9835. private _renderPriority;
  9836. /**
  9837. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9838. * exceeding the number allowed of the materials.
  9839. */
  9840. renderPriority: number;
  9841. private _shadowEnabled;
  9842. /**
  9843. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9844. * the current shadow generator.
  9845. */
  9846. /**
  9847. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9848. * the current shadow generator.
  9849. */
  9850. shadowEnabled: boolean;
  9851. private _includedOnlyMeshes;
  9852. /**
  9853. * Gets the only meshes impacted by this light.
  9854. */
  9855. /**
  9856. * Sets the only meshes impacted by this light.
  9857. */
  9858. includedOnlyMeshes: AbstractMesh[];
  9859. private _excludedMeshes;
  9860. /**
  9861. * Gets the meshes not impacted by this light.
  9862. */
  9863. /**
  9864. * Sets the meshes not impacted by this light.
  9865. */
  9866. excludedMeshes: AbstractMesh[];
  9867. private _excludeWithLayerMask;
  9868. /**
  9869. * Gets the layer id use to find what meshes are not impacted by the light.
  9870. * Inactive if 0
  9871. */
  9872. /**
  9873. * Sets the layer id use to find what meshes are not impacted by the light.
  9874. * Inactive if 0
  9875. */
  9876. excludeWithLayerMask: number;
  9877. private _includeOnlyWithLayerMask;
  9878. /**
  9879. * Gets the layer id use to find what meshes are impacted by the light.
  9880. * Inactive if 0
  9881. */
  9882. /**
  9883. * Sets the layer id use to find what meshes are impacted by the light.
  9884. * Inactive if 0
  9885. */
  9886. includeOnlyWithLayerMask: number;
  9887. private _lightmapMode;
  9888. /**
  9889. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9890. */
  9891. /**
  9892. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9893. */
  9894. lightmapMode: number;
  9895. /**
  9896. * Shadow generator associted to the light.
  9897. * @hidden Internal use only.
  9898. */
  9899. _shadowGenerator: Nullable<IShadowGenerator>;
  9900. /**
  9901. * @hidden Internal use only.
  9902. */
  9903. _excludedMeshesIds: string[];
  9904. /**
  9905. * @hidden Internal use only.
  9906. */
  9907. _includedOnlyMeshesIds: string[];
  9908. /**
  9909. * The current light unifom buffer.
  9910. * @hidden Internal use only.
  9911. */
  9912. _uniformBuffer: UniformBuffer;
  9913. /** @hidden */
  9914. _renderId: number;
  9915. /**
  9916. * Creates a Light object in the scene.
  9917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9918. * @param name The firendly name of the light
  9919. * @param scene The scene the light belongs too
  9920. */
  9921. constructor(name: string, scene: Scene);
  9922. protected abstract _buildUniformLayout(): void;
  9923. /**
  9924. * Sets the passed Effect "effect" with the Light information.
  9925. * @param effect The effect to update
  9926. * @param lightIndex The index of the light in the effect to update
  9927. * @returns The light
  9928. */
  9929. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9930. /**
  9931. * Sets the passed Effect "effect" with the Light information.
  9932. * @param effect The effect to update
  9933. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9934. * @returns The light
  9935. */
  9936. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9937. /**
  9938. * Returns the string "Light".
  9939. * @returns the class name
  9940. */
  9941. getClassName(): string;
  9942. /** @hidden */
  9943. readonly _isLight: boolean;
  9944. /**
  9945. * Converts the light information to a readable string for debug purpose.
  9946. * @param fullDetails Supports for multiple levels of logging within scene loading
  9947. * @returns the human readable light info
  9948. */
  9949. toString(fullDetails?: boolean): string;
  9950. /** @hidden */
  9951. protected _syncParentEnabledState(): void;
  9952. /**
  9953. * Set the enabled state of this node.
  9954. * @param value - the new enabled state
  9955. */
  9956. setEnabled(value: boolean): void;
  9957. /**
  9958. * Returns the Light associated shadow generator if any.
  9959. * @return the associated shadow generator.
  9960. */
  9961. getShadowGenerator(): Nullable<IShadowGenerator>;
  9962. /**
  9963. * Returns a Vector3, the absolute light position in the World.
  9964. * @returns the world space position of the light
  9965. */
  9966. getAbsolutePosition(): Vector3;
  9967. /**
  9968. * Specifies if the light will affect the passed mesh.
  9969. * @param mesh The mesh to test against the light
  9970. * @return true the mesh is affected otherwise, false.
  9971. */
  9972. canAffectMesh(mesh: AbstractMesh): boolean;
  9973. /**
  9974. * Sort function to order lights for rendering.
  9975. * @param a First Light object to compare to second.
  9976. * @param b Second Light object to compare first.
  9977. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9978. */
  9979. static CompareLightsPriority(a: Light, b: Light): number;
  9980. /**
  9981. * Releases resources associated with this node.
  9982. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9983. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9984. */
  9985. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9986. /**
  9987. * Returns the light type ID (integer).
  9988. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9989. */
  9990. getTypeID(): number;
  9991. /**
  9992. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9993. * @returns the scaled intensity in intensity mode unit
  9994. */
  9995. getScaledIntensity(): number;
  9996. /**
  9997. * Returns a new Light object, named "name", from the current one.
  9998. * @param name The name of the cloned light
  9999. * @returns the new created light
  10000. */
  10001. clone(name: string): Nullable<Light>;
  10002. /**
  10003. * Serializes the current light into a Serialization object.
  10004. * @returns the serialized object.
  10005. */
  10006. serialize(): any;
  10007. /**
  10008. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10009. * This new light is named "name" and added to the passed scene.
  10010. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10011. * @param name The friendly name of the light
  10012. * @param scene The scene the new light will belong to
  10013. * @returns the constructor function
  10014. */
  10015. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10016. /**
  10017. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10018. * @param parsedLight The JSON representation of the light
  10019. * @param scene The scene to create the parsed light in
  10020. * @returns the created light after parsing
  10021. */
  10022. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10023. private _hookArrayForExcluded;
  10024. private _hookArrayForIncludedOnly;
  10025. private _resyncMeshes;
  10026. /**
  10027. * Forces the meshes to update their light related information in their rendering used effects
  10028. * @hidden Internal Use Only
  10029. */
  10030. _markMeshesAsLightDirty(): void;
  10031. /**
  10032. * Recomputes the cached photometric scale if needed.
  10033. */
  10034. private _computePhotometricScale;
  10035. /**
  10036. * Returns the Photometric Scale according to the light type and intensity mode.
  10037. */
  10038. private _getPhotometricScale;
  10039. /**
  10040. * Reorder the light in the scene according to their defined priority.
  10041. * @hidden Internal Use Only
  10042. */
  10043. _reorderLightsInScene(): void;
  10044. /**
  10045. * Prepares the list of defines specific to the light type.
  10046. * @param defines the list of defines
  10047. * @param lightIndex defines the index of the light for the effect
  10048. */
  10049. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10050. }
  10051. }
  10052. declare module BABYLON {
  10053. /**
  10054. * Interface used to define Action
  10055. */
  10056. export interface IAction {
  10057. /**
  10058. * Trigger for the action
  10059. */
  10060. trigger: number;
  10061. /** Options of the trigger */
  10062. triggerOptions: any;
  10063. /**
  10064. * Gets the trigger parameters
  10065. * @returns the trigger parameters
  10066. */
  10067. getTriggerParameter(): any;
  10068. /**
  10069. * Internal only - executes current action event
  10070. * @hidden
  10071. */
  10072. _executeCurrent(evt?: ActionEvent): void;
  10073. /**
  10074. * Serialize placeholder for child classes
  10075. * @param parent of child
  10076. * @returns the serialized object
  10077. */
  10078. serialize(parent: any): any;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. _prepare(): void;
  10084. /**
  10085. * Internal only - manager for action
  10086. * @hidden
  10087. */
  10088. _actionManager: AbstractActionManager;
  10089. /**
  10090. * Adds action to chain of actions, may be a DoNothingAction
  10091. * @param action defines the next action to execute
  10092. * @returns The action passed in
  10093. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10094. */
  10095. then(action: IAction): IAction;
  10096. }
  10097. /**
  10098. * The action to be carried out following a trigger
  10099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10100. */
  10101. export class Action implements IAction {
  10102. /** the trigger, with or without parameters, for the action */
  10103. triggerOptions: any;
  10104. /**
  10105. * Trigger for the action
  10106. */
  10107. trigger: number;
  10108. /**
  10109. * Internal only - manager for action
  10110. * @hidden
  10111. */
  10112. _actionManager: ActionManager;
  10113. private _nextActiveAction;
  10114. private _child;
  10115. private _condition?;
  10116. private _triggerParameter;
  10117. /**
  10118. * An event triggered prior to action being executed.
  10119. */
  10120. onBeforeExecuteObservable: Observable<Action>;
  10121. /**
  10122. * Creates a new Action
  10123. * @param triggerOptions the trigger, with or without parameters, for the action
  10124. * @param condition an optional determinant of action
  10125. */
  10126. constructor(
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any, condition?: Condition);
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. _prepare(): void;
  10134. /**
  10135. * Gets the trigger parameters
  10136. * @returns the trigger parameters
  10137. */
  10138. getTriggerParameter(): any;
  10139. /**
  10140. * Internal only - executes current action event
  10141. * @hidden
  10142. */
  10143. _executeCurrent(evt?: ActionEvent): void;
  10144. /**
  10145. * Execute placeholder for child classes
  10146. * @param evt optional action event
  10147. */
  10148. execute(evt?: ActionEvent): void;
  10149. /**
  10150. * Skips to next active action
  10151. */
  10152. skipToNextActiveAction(): void;
  10153. /**
  10154. * Adds action to chain of actions, may be a DoNothingAction
  10155. * @param action defines the next action to execute
  10156. * @returns The action passed in
  10157. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10158. */
  10159. then(action: Action): Action;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getProperty(propertyPath: string): string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _getEffectiveTarget(target: any, propertyPath: string): any;
  10170. /**
  10171. * Serialize placeholder for child classes
  10172. * @param parent of child
  10173. * @returns the serialized object
  10174. */
  10175. serialize(parent: any): any;
  10176. /**
  10177. * Internal only called by serialize
  10178. * @hidden
  10179. */
  10180. protected _serialize(serializedAction: any, parent?: any): any;
  10181. /**
  10182. * Internal only
  10183. * @hidden
  10184. */
  10185. static _SerializeValueAsString: (value: any) => string;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. static _GetTargetProperty: (target: Node | Scene) => {
  10191. name: string;
  10192. targetType: string;
  10193. value: string;
  10194. };
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * A Condition applied to an Action
  10200. */
  10201. export class Condition {
  10202. /**
  10203. * Internal only - manager for action
  10204. * @hidden
  10205. */
  10206. _actionManager: ActionManager;
  10207. /**
  10208. * Internal only
  10209. * @hidden
  10210. */
  10211. _evaluationId: number;
  10212. /**
  10213. * Internal only
  10214. * @hidden
  10215. */
  10216. _currentResult: boolean;
  10217. /**
  10218. * Creates a new Condition
  10219. * @param actionManager the manager of the action the condition is applied to
  10220. */
  10221. constructor(actionManager: ActionManager);
  10222. /**
  10223. * Check if the current condition is valid
  10224. * @returns a boolean
  10225. */
  10226. isValid(): boolean;
  10227. /**
  10228. * Internal only
  10229. * @hidden
  10230. */
  10231. _getProperty(propertyPath: string): string;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. _getEffectiveTarget(target: any, propertyPath: string): any;
  10237. /**
  10238. * Serialize placeholder for child classes
  10239. * @returns the serialized object
  10240. */
  10241. serialize(): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. protected _serialize(serializedCondition: any): any;
  10247. }
  10248. /**
  10249. * Defines specific conditional operators as extensions of Condition
  10250. */
  10251. export class ValueCondition extends Condition {
  10252. /** path to specify the property of the target the conditional operator uses */
  10253. propertyPath: string;
  10254. /** the value compared by the conditional operator against the current value of the property */
  10255. value: any;
  10256. /** the conditional operator, default ValueCondition.IsEqual */
  10257. operator: number;
  10258. /**
  10259. * Internal only
  10260. * @hidden
  10261. */
  10262. private static _IsEqual;
  10263. /**
  10264. * Internal only
  10265. * @hidden
  10266. */
  10267. private static _IsDifferent;
  10268. /**
  10269. * Internal only
  10270. * @hidden
  10271. */
  10272. private static _IsGreater;
  10273. /**
  10274. * Internal only
  10275. * @hidden
  10276. */
  10277. private static _IsLesser;
  10278. /**
  10279. * returns the number for IsEqual
  10280. */
  10281. static readonly IsEqual: number;
  10282. /**
  10283. * Returns the number for IsDifferent
  10284. */
  10285. static readonly IsDifferent: number;
  10286. /**
  10287. * Returns the number for IsGreater
  10288. */
  10289. static readonly IsGreater: number;
  10290. /**
  10291. * Returns the number for IsLesser
  10292. */
  10293. static readonly IsLesser: number;
  10294. /**
  10295. * Internal only The action manager for the condition
  10296. * @hidden
  10297. */
  10298. _actionManager: ActionManager;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. private _target;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. private _effectiveTarget;
  10309. /**
  10310. * Internal only
  10311. * @hidden
  10312. */
  10313. private _property;
  10314. /**
  10315. * Creates a new ValueCondition
  10316. * @param actionManager manager for the action the condition applies to
  10317. * @param target for the action
  10318. * @param propertyPath path to specify the property of the target the conditional operator uses
  10319. * @param value the value compared by the conditional operator against the current value of the property
  10320. * @param operator the conditional operator, default ValueCondition.IsEqual
  10321. */
  10322. constructor(actionManager: ActionManager, target: any,
  10323. /** path to specify the property of the target the conditional operator uses */
  10324. propertyPath: string,
  10325. /** the value compared by the conditional operator against the current value of the property */
  10326. value: any,
  10327. /** the conditional operator, default ValueCondition.IsEqual */
  10328. operator?: number);
  10329. /**
  10330. * Compares the given value with the property value for the specified conditional operator
  10331. * @returns the result of the comparison
  10332. */
  10333. isValid(): boolean;
  10334. /**
  10335. * Serialize the ValueCondition into a JSON compatible object
  10336. * @returns serialization object
  10337. */
  10338. serialize(): any;
  10339. /**
  10340. * Gets the name of the conditional operator for the ValueCondition
  10341. * @param operator the conditional operator
  10342. * @returns the name
  10343. */
  10344. static GetOperatorName(operator: number): string;
  10345. }
  10346. /**
  10347. * Defines a predicate condition as an extension of Condition
  10348. */
  10349. export class PredicateCondition extends Condition {
  10350. /** defines the predicate function used to validate the condition */
  10351. predicate: () => boolean;
  10352. /**
  10353. * Internal only - manager for action
  10354. * @hidden
  10355. */
  10356. _actionManager: ActionManager;
  10357. /**
  10358. * Creates a new PredicateCondition
  10359. * @param actionManager manager for the action the condition applies to
  10360. * @param predicate defines the predicate function used to validate the condition
  10361. */
  10362. constructor(actionManager: ActionManager,
  10363. /** defines the predicate function used to validate the condition */
  10364. predicate: () => boolean);
  10365. /**
  10366. * @returns the validity of the predicate condition
  10367. */
  10368. isValid(): boolean;
  10369. }
  10370. /**
  10371. * Defines a state condition as an extension of Condition
  10372. */
  10373. export class StateCondition extends Condition {
  10374. /** Value to compare with target state */
  10375. value: string;
  10376. /**
  10377. * Internal only - manager for action
  10378. * @hidden
  10379. */
  10380. _actionManager: ActionManager;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. private _target;
  10386. /**
  10387. * Creates a new StateCondition
  10388. * @param actionManager manager for the action the condition applies to
  10389. * @param target of the condition
  10390. * @param value to compare with target state
  10391. */
  10392. constructor(actionManager: ActionManager, target: any,
  10393. /** Value to compare with target state */
  10394. value: string);
  10395. /**
  10396. * Gets a boolean indicating if the current condition is met
  10397. * @returns the validity of the state
  10398. */
  10399. isValid(): boolean;
  10400. /**
  10401. * Serialize the StateCondition into a JSON compatible object
  10402. * @returns serialization object
  10403. */
  10404. serialize(): any;
  10405. }
  10406. }
  10407. declare module BABYLON {
  10408. /**
  10409. * This defines an action responsible to toggle a boolean once triggered.
  10410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10411. */
  10412. export class SwitchBooleanAction extends Action {
  10413. /**
  10414. * The path to the boolean property in the target object
  10415. */
  10416. propertyPath: string;
  10417. private _target;
  10418. private _effectiveTarget;
  10419. private _property;
  10420. /**
  10421. * Instantiate the action
  10422. * @param triggerOptions defines the trigger options
  10423. * @param target defines the object containing the boolean
  10424. * @param propertyPath defines the path to the boolean property in the target object
  10425. * @param condition defines the trigger related conditions
  10426. */
  10427. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10428. /** @hidden */
  10429. _prepare(): void;
  10430. /**
  10431. * Execute the action toggle the boolean value.
  10432. */
  10433. execute(): void;
  10434. /**
  10435. * Serializes the actions and its related information.
  10436. * @param parent defines the object to serialize in
  10437. * @returns the serialized object
  10438. */
  10439. serialize(parent: any): any;
  10440. }
  10441. /**
  10442. * This defines an action responsible to set a the state field of the target
  10443. * to a desired value once triggered.
  10444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10445. */
  10446. export class SetStateAction extends Action {
  10447. /**
  10448. * The value to store in the state field.
  10449. */
  10450. value: string;
  10451. private _target;
  10452. /**
  10453. * Instantiate the action
  10454. * @param triggerOptions defines the trigger options
  10455. * @param target defines the object containing the state property
  10456. * @param value defines the value to store in the state field
  10457. * @param condition defines the trigger related conditions
  10458. */
  10459. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10460. /**
  10461. * Execute the action and store the value on the target state property.
  10462. */
  10463. execute(): void;
  10464. /**
  10465. * Serializes the actions and its related information.
  10466. * @param parent defines the object to serialize in
  10467. * @returns the serialized object
  10468. */
  10469. serialize(parent: any): any;
  10470. }
  10471. /**
  10472. * This defines an action responsible to set a property of the target
  10473. * to a desired value once triggered.
  10474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10475. */
  10476. export class SetValueAction extends Action {
  10477. /**
  10478. * The path of the property to set in the target.
  10479. */
  10480. propertyPath: string;
  10481. /**
  10482. * The value to set in the property
  10483. */
  10484. value: any;
  10485. private _target;
  10486. private _effectiveTarget;
  10487. private _property;
  10488. /**
  10489. * Instantiate the action
  10490. * @param triggerOptions defines the trigger options
  10491. * @param target defines the object containing the property
  10492. * @param propertyPath defines the path of the property to set in the target
  10493. * @param value defines the value to set in the property
  10494. * @param condition defines the trigger related conditions
  10495. */
  10496. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10497. /** @hidden */
  10498. _prepare(): void;
  10499. /**
  10500. * Execute the action and set the targetted property to the desired value.
  10501. */
  10502. execute(): void;
  10503. /**
  10504. * Serializes the actions and its related information.
  10505. * @param parent defines the object to serialize in
  10506. * @returns the serialized object
  10507. */
  10508. serialize(parent: any): any;
  10509. }
  10510. /**
  10511. * This defines an action responsible to increment the target value
  10512. * to a desired value once triggered.
  10513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10514. */
  10515. export class IncrementValueAction extends Action {
  10516. /**
  10517. * The path of the property to increment in the target.
  10518. */
  10519. propertyPath: string;
  10520. /**
  10521. * The value we should increment the property by.
  10522. */
  10523. value: any;
  10524. private _target;
  10525. private _effectiveTarget;
  10526. private _property;
  10527. /**
  10528. * Instantiate the action
  10529. * @param triggerOptions defines the trigger options
  10530. * @param target defines the object containing the property
  10531. * @param propertyPath defines the path of the property to increment in the target
  10532. * @param value defines the value value we should increment the property by
  10533. * @param condition defines the trigger related conditions
  10534. */
  10535. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10536. /** @hidden */
  10537. _prepare(): void;
  10538. /**
  10539. * Execute the action and increment the target of the value amount.
  10540. */
  10541. execute(): void;
  10542. /**
  10543. * Serializes the actions and its related information.
  10544. * @param parent defines the object to serialize in
  10545. * @returns the serialized object
  10546. */
  10547. serialize(parent: any): any;
  10548. }
  10549. /**
  10550. * This defines an action responsible to start an animation once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class PlayAnimationAction extends Action {
  10554. /**
  10555. * Where the animation should start (animation frame)
  10556. */
  10557. from: number;
  10558. /**
  10559. * Where the animation should stop (animation frame)
  10560. */
  10561. to: number;
  10562. /**
  10563. * Define if the animation should loop or stop after the first play.
  10564. */
  10565. loop?: boolean;
  10566. private _target;
  10567. /**
  10568. * Instantiate the action
  10569. * @param triggerOptions defines the trigger options
  10570. * @param target defines the target animation or animation name
  10571. * @param from defines from where the animation should start (animation frame)
  10572. * @param end defines where the animation should stop (animation frame)
  10573. * @param loop defines if the animation should loop or stop after the first play
  10574. * @param condition defines the trigger related conditions
  10575. */
  10576. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10577. /** @hidden */
  10578. _prepare(): void;
  10579. /**
  10580. * Execute the action and play the animation.
  10581. */
  10582. execute(): void;
  10583. /**
  10584. * Serializes the actions and its related information.
  10585. * @param parent defines the object to serialize in
  10586. * @returns the serialized object
  10587. */
  10588. serialize(parent: any): any;
  10589. }
  10590. /**
  10591. * This defines an action responsible to stop an animation once triggered.
  10592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10593. */
  10594. export class StopAnimationAction extends Action {
  10595. private _target;
  10596. /**
  10597. * Instantiate the action
  10598. * @param triggerOptions defines the trigger options
  10599. * @param target defines the target animation or animation name
  10600. * @param condition defines the trigger related conditions
  10601. */
  10602. constructor(triggerOptions: any, target: any, condition?: Condition);
  10603. /** @hidden */
  10604. _prepare(): void;
  10605. /**
  10606. * Execute the action and stop the animation.
  10607. */
  10608. execute(): void;
  10609. /**
  10610. * Serializes the actions and its related information.
  10611. * @param parent defines the object to serialize in
  10612. * @returns the serialized object
  10613. */
  10614. serialize(parent: any): any;
  10615. }
  10616. /**
  10617. * This defines an action responsible that does nothing once triggered.
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10619. */
  10620. export class DoNothingAction extends Action {
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param condition defines the trigger related conditions
  10625. */
  10626. constructor(triggerOptions?: any, condition?: Condition);
  10627. /**
  10628. * Execute the action and do nothing.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to trigger several actions once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class CombineAction extends Action {
  10643. /**
  10644. * The list of aggregated animations to run.
  10645. */
  10646. children: Action[];
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param children defines the list of aggregated animations to run
  10651. * @param condition defines the trigger related conditions
  10652. */
  10653. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10654. /** @hidden */
  10655. _prepare(): void;
  10656. /**
  10657. * Execute the action and executes all the aggregated actions.
  10658. */
  10659. execute(evt: ActionEvent): void;
  10660. /**
  10661. * Serializes the actions and its related information.
  10662. * @param parent defines the object to serialize in
  10663. * @returns the serialized object
  10664. */
  10665. serialize(parent: any): any;
  10666. }
  10667. /**
  10668. * This defines an action responsible to run code (external event) once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class ExecuteCodeAction extends Action {
  10672. /**
  10673. * The callback function to run.
  10674. */
  10675. func: (evt: ActionEvent) => void;
  10676. /**
  10677. * Instantiate the action
  10678. * @param triggerOptions defines the trigger options
  10679. * @param func defines the callback function to run
  10680. * @param condition defines the trigger related conditions
  10681. */
  10682. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10683. /**
  10684. * Execute the action and run the attached code.
  10685. */
  10686. execute(evt: ActionEvent): void;
  10687. }
  10688. /**
  10689. * This defines an action responsible to set the parent property of the target once triggered.
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10691. */
  10692. export class SetParentAction extends Action {
  10693. private _parent;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target containing the parent property
  10699. * @param parent defines from where the animation should start (animation frame)
  10700. * @param condition defines the trigger related conditions
  10701. */
  10702. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10703. /** @hidden */
  10704. _prepare(): void;
  10705. /**
  10706. * Execute the action and set the parent property.
  10707. */
  10708. execute(): void;
  10709. /**
  10710. * Serializes the actions and its related information.
  10711. * @param parent defines the object to serialize in
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. }
  10716. }
  10717. declare module BABYLON {
  10718. /**
  10719. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10720. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10722. */
  10723. export class ActionManager extends AbstractActionManager {
  10724. /**
  10725. * Nothing
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10727. */
  10728. static readonly NothingTrigger: number;
  10729. /**
  10730. * On pick
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10732. */
  10733. static readonly OnPickTrigger: number;
  10734. /**
  10735. * On left pick
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10737. */
  10738. static readonly OnLeftPickTrigger: number;
  10739. /**
  10740. * On right pick
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10742. */
  10743. static readonly OnRightPickTrigger: number;
  10744. /**
  10745. * On center pick
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10747. */
  10748. static readonly OnCenterPickTrigger: number;
  10749. /**
  10750. * On pick down
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly OnPickDownTrigger: number;
  10754. /**
  10755. * On double pick
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnDoublePickTrigger: number;
  10759. /**
  10760. * On pick up
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnPickUpTrigger: number;
  10764. /**
  10765. * On pick out.
  10766. * This trigger will only be raised if you also declared a OnPickDown
  10767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10768. */
  10769. static readonly OnPickOutTrigger: number;
  10770. /**
  10771. * On long press
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10773. */
  10774. static readonly OnLongPressTrigger: number;
  10775. /**
  10776. * On pointer over
  10777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10778. */
  10779. static readonly OnPointerOverTrigger: number;
  10780. /**
  10781. * On pointer out
  10782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10783. */
  10784. static readonly OnPointerOutTrigger: number;
  10785. /**
  10786. * On every frame
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10788. */
  10789. static readonly OnEveryFrameTrigger: number;
  10790. /**
  10791. * On intersection enter
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10793. */
  10794. static readonly OnIntersectionEnterTrigger: number;
  10795. /**
  10796. * On intersection exit
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly OnIntersectionExitTrigger: number;
  10800. /**
  10801. * On key down
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnKeyDownTrigger: number;
  10805. /**
  10806. * On key up
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnKeyUpTrigger: number;
  10810. private _scene;
  10811. /**
  10812. * Creates a new action manager
  10813. * @param scene defines the hosting scene
  10814. */
  10815. constructor(scene: Scene);
  10816. /**
  10817. * Releases all associated resources
  10818. */
  10819. dispose(): void;
  10820. /**
  10821. * Gets hosting scene
  10822. * @returns the hosting scene
  10823. */
  10824. getScene(): Scene;
  10825. /**
  10826. * Does this action manager handles actions of any of the given triggers
  10827. * @param triggers defines the triggers to be tested
  10828. * @return a boolean indicating whether one (or more) of the triggers is handled
  10829. */
  10830. hasSpecificTriggers(triggers: number[]): boolean;
  10831. /**
  10832. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10833. * speed.
  10834. * @param triggerA defines the trigger to be tested
  10835. * @param triggerB defines the trigger to be tested
  10836. * @return a boolean indicating whether one (or more) of the triggers is handled
  10837. */
  10838. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10839. /**
  10840. * Does this action manager handles actions of a given trigger
  10841. * @param trigger defines the trigger to be tested
  10842. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10843. * @return whether the trigger is handled
  10844. */
  10845. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10846. /**
  10847. * Does this action manager has pointer triggers
  10848. */
  10849. readonly hasPointerTriggers: boolean;
  10850. /**
  10851. * Does this action manager has pick triggers
  10852. */
  10853. readonly hasPickTriggers: boolean;
  10854. /**
  10855. * Registers an action to this action manager
  10856. * @param action defines the action to be registered
  10857. * @return the action amended (prepared) after registration
  10858. */
  10859. registerAction(action: IAction): Nullable<IAction>;
  10860. /**
  10861. * Unregisters an action to this action manager
  10862. * @param action defines the action to be unregistered
  10863. * @return a boolean indicating whether the action has been unregistered
  10864. */
  10865. unregisterAction(action: IAction): Boolean;
  10866. /**
  10867. * Process a specific trigger
  10868. * @param trigger defines the trigger to process
  10869. * @param evt defines the event details to be processed
  10870. */
  10871. processTrigger(trigger: number, evt?: IActionEvent): void;
  10872. /** @hidden */
  10873. _getEffectiveTarget(target: any, propertyPath: string): any;
  10874. /** @hidden */
  10875. _getProperty(propertyPath: string): string;
  10876. /**
  10877. * Serialize this manager to a JSON object
  10878. * @param name defines the property name to store this manager
  10879. * @returns a JSON representation of this manager
  10880. */
  10881. serialize(name: string): any;
  10882. /**
  10883. * Creates a new ActionManager from a JSON data
  10884. * @param parsedActions defines the JSON data to read from
  10885. * @param object defines the hosting mesh
  10886. * @param scene defines the hosting scene
  10887. */
  10888. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10889. /**
  10890. * Get a trigger name by index
  10891. * @param trigger defines the trigger index
  10892. * @returns a trigger name
  10893. */
  10894. static GetTriggerName(trigger: number): string;
  10895. }
  10896. }
  10897. declare module BABYLON {
  10898. /**
  10899. * Class representing a ray with position and direction
  10900. */
  10901. export class Ray {
  10902. /** origin point */
  10903. origin: Vector3;
  10904. /** direction */
  10905. direction: Vector3;
  10906. /** length of the ray */
  10907. length: number;
  10908. private static readonly TmpVector3;
  10909. private _tmpRay;
  10910. /**
  10911. * Creates a new ray
  10912. * @param origin origin point
  10913. * @param direction direction
  10914. * @param length length of the ray
  10915. */
  10916. constructor(
  10917. /** origin point */
  10918. origin: Vector3,
  10919. /** direction */
  10920. direction: Vector3,
  10921. /** length of the ray */
  10922. length?: number);
  10923. /**
  10924. * Checks if the ray intersects a box
  10925. * @param minimum bound of the box
  10926. * @param maximum bound of the box
  10927. * @param intersectionTreshold extra extend to be added to the box in all direction
  10928. * @returns if the box was hit
  10929. */
  10930. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10931. /**
  10932. * Checks if the ray intersects a box
  10933. * @param box the bounding box to check
  10934. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10935. * @returns if the box was hit
  10936. */
  10937. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10938. /**
  10939. * If the ray hits a sphere
  10940. * @param sphere the bounding sphere to check
  10941. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10942. * @returns true if it hits the sphere
  10943. */
  10944. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10945. /**
  10946. * If the ray hits a triange
  10947. * @param vertex0 triangle vertex
  10948. * @param vertex1 triangle vertex
  10949. * @param vertex2 triangle vertex
  10950. * @returns intersection information if hit
  10951. */
  10952. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10953. /**
  10954. * Checks if ray intersects a plane
  10955. * @param plane the plane to check
  10956. * @returns the distance away it was hit
  10957. */
  10958. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10959. /**
  10960. * Calculate the intercept of a ray on a given axis
  10961. * @param axis to check 'x' | 'y' | 'z'
  10962. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10963. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10964. */
  10965. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10966. /**
  10967. * Checks if ray intersects a mesh
  10968. * @param mesh the mesh to check
  10969. * @param fastCheck if only the bounding box should checked
  10970. * @returns picking info of the intersecton
  10971. */
  10972. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10973. /**
  10974. * Checks if ray intersects a mesh
  10975. * @param meshes the meshes to check
  10976. * @param fastCheck if only the bounding box should checked
  10977. * @param results array to store result in
  10978. * @returns Array of picking infos
  10979. */
  10980. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10981. private _comparePickingInfo;
  10982. private static smallnum;
  10983. private static rayl;
  10984. /**
  10985. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10986. * @param sega the first point of the segment to test the intersection against
  10987. * @param segb the second point of the segment to test the intersection against
  10988. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10989. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10990. */
  10991. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10992. /**
  10993. * Update the ray from viewport position
  10994. * @param x position
  10995. * @param y y position
  10996. * @param viewportWidth viewport width
  10997. * @param viewportHeight viewport height
  10998. * @param world world matrix
  10999. * @param view view matrix
  11000. * @param projection projection matrix
  11001. * @returns this ray updated
  11002. */
  11003. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11004. /**
  11005. * Creates a ray with origin and direction of 0,0,0
  11006. * @returns the new ray
  11007. */
  11008. static Zero(): Ray;
  11009. /**
  11010. * Creates a new ray from screen space and viewport
  11011. * @param x position
  11012. * @param y y position
  11013. * @param viewportWidth viewport width
  11014. * @param viewportHeight viewport height
  11015. * @param world world matrix
  11016. * @param view view matrix
  11017. * @param projection projection matrix
  11018. * @returns new ray
  11019. */
  11020. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11021. /**
  11022. * 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
  11023. * transformed to the given world matrix.
  11024. * @param origin The origin point
  11025. * @param end The end point
  11026. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11027. * @returns the new ray
  11028. */
  11029. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11030. /**
  11031. * Transforms a ray by a matrix
  11032. * @param ray ray to transform
  11033. * @param matrix matrix to apply
  11034. * @returns the resulting new ray
  11035. */
  11036. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11037. /**
  11038. * Transforms a ray by a matrix
  11039. * @param ray ray to transform
  11040. * @param matrix matrix to apply
  11041. * @param result ray to store result in
  11042. */
  11043. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11044. /**
  11045. * Unproject a ray from screen space to object space
  11046. * @param sourceX defines the screen space x coordinate to use
  11047. * @param sourceY defines the screen space y coordinate to use
  11048. * @param viewportWidth defines the current width of the viewport
  11049. * @param viewportHeight defines the current height of the viewport
  11050. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11051. * @param view defines the view matrix to use
  11052. * @param projection defines the projection matrix to use
  11053. */
  11054. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11055. }
  11056. /**
  11057. * Type used to define predicate used to select faces when a mesh intersection is detected
  11058. */
  11059. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11060. interface Scene {
  11061. /** @hidden */
  11062. _tempPickingRay: Nullable<Ray>;
  11063. /** @hidden */
  11064. _cachedRayForTransform: Ray;
  11065. /** @hidden */
  11066. _pickWithRayInverseMatrix: Matrix;
  11067. /** @hidden */
  11068. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11069. /** @hidden */
  11070. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11071. }
  11072. }
  11073. declare module BABYLON {
  11074. /**
  11075. * Groups all the scene component constants in one place to ease maintenance.
  11076. * @hidden
  11077. */
  11078. export class SceneComponentConstants {
  11079. static readonly NAME_EFFECTLAYER: string;
  11080. static readonly NAME_LAYER: string;
  11081. static readonly NAME_LENSFLARESYSTEM: string;
  11082. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11083. static readonly NAME_PARTICLESYSTEM: string;
  11084. static readonly NAME_GAMEPAD: string;
  11085. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11086. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11087. static readonly NAME_DEPTHRENDERER: string;
  11088. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11089. static readonly NAME_SPRITE: string;
  11090. static readonly NAME_OUTLINERENDERER: string;
  11091. static readonly NAME_PROCEDURALTEXTURE: string;
  11092. static readonly NAME_SHADOWGENERATOR: string;
  11093. static readonly NAME_OCTREE: string;
  11094. static readonly NAME_PHYSICSENGINE: string;
  11095. static readonly NAME_AUDIO: string;
  11096. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11097. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11098. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11099. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11100. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11101. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11102. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11103. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11104. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11105. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11106. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11107. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11108. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11109. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11110. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11111. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11112. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11113. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11114. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11115. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11116. static readonly STEP_AFTERRENDER_AUDIO: number;
  11117. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11118. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11119. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11120. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11121. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11122. static readonly STEP_POINTERMOVE_SPRITE: number;
  11123. static readonly STEP_POINTERDOWN_SPRITE: number;
  11124. static readonly STEP_POINTERUP_SPRITE: number;
  11125. }
  11126. /**
  11127. * This represents a scene component.
  11128. *
  11129. * This is used to decouple the dependency the scene is having on the different workloads like
  11130. * layers, post processes...
  11131. */
  11132. export interface ISceneComponent {
  11133. /**
  11134. * The name of the component. Each component must have a unique name.
  11135. */
  11136. name: string;
  11137. /**
  11138. * The scene the component belongs to.
  11139. */
  11140. scene: Scene;
  11141. /**
  11142. * Register the component to one instance of a scene.
  11143. */
  11144. register(): void;
  11145. /**
  11146. * Rebuilds the elements related to this component in case of
  11147. * context lost for instance.
  11148. */
  11149. rebuild(): void;
  11150. /**
  11151. * Disposes the component and the associated ressources.
  11152. */
  11153. dispose(): void;
  11154. }
  11155. /**
  11156. * This represents a SERIALIZABLE scene component.
  11157. *
  11158. * This extends Scene Component to add Serialization methods on top.
  11159. */
  11160. export interface ISceneSerializableComponent extends ISceneComponent {
  11161. /**
  11162. * Adds all the elements from the container to the scene
  11163. * @param container the container holding the elements
  11164. */
  11165. addFromContainer(container: AbstractScene): void;
  11166. /**
  11167. * Removes all the elements in the container from the scene
  11168. * @param container contains the elements to remove
  11169. * @param dispose if the removed element should be disposed (default: false)
  11170. */
  11171. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11172. /**
  11173. * Serializes the component data to the specified json object
  11174. * @param serializationObject The object to serialize to
  11175. */
  11176. serialize(serializationObject: any): void;
  11177. }
  11178. /**
  11179. * Strong typing of a Mesh related stage step action
  11180. */
  11181. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11182. /**
  11183. * Strong typing of a Evaluate Sub Mesh related stage step action
  11184. */
  11185. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11186. /**
  11187. * Strong typing of a Active Mesh related stage step action
  11188. */
  11189. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11190. /**
  11191. * Strong typing of a Camera related stage step action
  11192. */
  11193. export type CameraStageAction = (camera: Camera) => void;
  11194. /**
  11195. * Strong typing of a Camera Frame buffer related stage step action
  11196. */
  11197. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11198. /**
  11199. * Strong typing of a Render Target related stage step action
  11200. */
  11201. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11202. /**
  11203. * Strong typing of a RenderingGroup related stage step action
  11204. */
  11205. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11206. /**
  11207. * Strong typing of a Mesh Render related stage step action
  11208. */
  11209. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11210. /**
  11211. * Strong typing of a simple stage step action
  11212. */
  11213. export type SimpleStageAction = () => void;
  11214. /**
  11215. * Strong typing of a render target action.
  11216. */
  11217. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11218. /**
  11219. * Strong typing of a pointer move action.
  11220. */
  11221. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11222. /**
  11223. * Strong typing of a pointer up/down action.
  11224. */
  11225. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11226. /**
  11227. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11228. * @hidden
  11229. */
  11230. export class Stage<T extends Function> extends Array<{
  11231. index: number;
  11232. component: ISceneComponent;
  11233. action: T;
  11234. }> {
  11235. /**
  11236. * Hide ctor from the rest of the world.
  11237. * @param items The items to add.
  11238. */
  11239. private constructor();
  11240. /**
  11241. * Creates a new Stage.
  11242. * @returns A new instance of a Stage
  11243. */
  11244. static Create<T extends Function>(): Stage<T>;
  11245. /**
  11246. * Registers a step in an ordered way in the targeted stage.
  11247. * @param index Defines the position to register the step in
  11248. * @param component Defines the component attached to the step
  11249. * @param action Defines the action to launch during the step
  11250. */
  11251. registerStep(index: number, component: ISceneComponent, action: T): void;
  11252. /**
  11253. * Clears all the steps from the stage.
  11254. */
  11255. clear(): void;
  11256. }
  11257. }
  11258. declare module BABYLON {
  11259. interface Scene {
  11260. /** @hidden */
  11261. _pointerOverSprite: Nullable<Sprite>;
  11262. /** @hidden */
  11263. _pickedDownSprite: Nullable<Sprite>;
  11264. /** @hidden */
  11265. _tempSpritePickingRay: Nullable<Ray>;
  11266. /**
  11267. * All of the sprite managers added to this scene
  11268. * @see http://doc.babylonjs.com/babylon101/sprites
  11269. */
  11270. spriteManagers: Array<ISpriteManager>;
  11271. /**
  11272. * An event triggered when sprites rendering is about to start
  11273. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11274. */
  11275. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11276. /**
  11277. * An event triggered when sprites rendering is done
  11278. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11279. */
  11280. onAfterSpritesRenderingObservable: Observable<Scene>;
  11281. /** @hidden */
  11282. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11283. /** Launch a ray to try to pick a sprite in the scene
  11284. * @param x position on screen
  11285. * @param y position on screen
  11286. * @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
  11287. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11288. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11289. * @returns a PickingInfo
  11290. */
  11291. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11292. /** Use the given ray to pick a sprite in the scene
  11293. * @param ray The ray (in world space) to use to pick meshes
  11294. * @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
  11295. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11296. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11297. * @returns a PickingInfo
  11298. */
  11299. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11300. /** @hidden */
  11301. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11302. /** Launch a ray to try to pick sprites in the scene
  11303. * @param x position on screen
  11304. * @param y position on screen
  11305. * @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
  11306. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11307. * @returns a PickingInfo array
  11308. */
  11309. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11310. /** Use the given ray to pick sprites in the scene
  11311. * @param ray The ray (in world space) to use to pick meshes
  11312. * @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
  11313. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11314. * @returns a PickingInfo array
  11315. */
  11316. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11317. /**
  11318. * Force the sprite under the pointer
  11319. * @param sprite defines the sprite to use
  11320. */
  11321. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11322. /**
  11323. * Gets the sprite under the pointer
  11324. * @returns a Sprite or null if no sprite is under the pointer
  11325. */
  11326. getPointerOverSprite(): Nullable<Sprite>;
  11327. }
  11328. /**
  11329. * Defines the sprite scene component responsible to manage sprites
  11330. * in a given scene.
  11331. */
  11332. export class SpriteSceneComponent implements ISceneComponent {
  11333. /**
  11334. * The component name helpfull to identify the component in the list of scene components.
  11335. */
  11336. readonly name: string;
  11337. /**
  11338. * The scene the component belongs to.
  11339. */
  11340. scene: Scene;
  11341. /** @hidden */
  11342. private _spritePredicate;
  11343. /**
  11344. * Creates a new instance of the component for the given scene
  11345. * @param scene Defines the scene to register the component in
  11346. */
  11347. constructor(scene: Scene);
  11348. /**
  11349. * Registers the component in a given scene
  11350. */
  11351. register(): void;
  11352. /**
  11353. * Rebuilds the elements related to this component in case of
  11354. * context lost for instance.
  11355. */
  11356. rebuild(): void;
  11357. /**
  11358. * Disposes the component and the associated ressources.
  11359. */
  11360. dispose(): void;
  11361. private _pickSpriteButKeepRay;
  11362. private _pointerMove;
  11363. private _pointerDown;
  11364. private _pointerUp;
  11365. }
  11366. }
  11367. declare module BABYLON {
  11368. /** @hidden */
  11369. export var fogFragmentDeclaration: {
  11370. name: string;
  11371. shader: string;
  11372. };
  11373. }
  11374. declare module BABYLON {
  11375. /** @hidden */
  11376. export var fogFragment: {
  11377. name: string;
  11378. shader: string;
  11379. };
  11380. }
  11381. declare module BABYLON {
  11382. /** @hidden */
  11383. export var spritesPixelShader: {
  11384. name: string;
  11385. shader: string;
  11386. };
  11387. }
  11388. declare module BABYLON {
  11389. /** @hidden */
  11390. export var fogVertexDeclaration: {
  11391. name: string;
  11392. shader: string;
  11393. };
  11394. }
  11395. declare module BABYLON {
  11396. /** @hidden */
  11397. export var spritesVertexShader: {
  11398. name: string;
  11399. shader: string;
  11400. };
  11401. }
  11402. declare module BABYLON {
  11403. /**
  11404. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11405. */
  11406. export interface ISpriteManager extends IDisposable {
  11407. /**
  11408. * Restricts the camera to viewing objects with the same layerMask.
  11409. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11410. */
  11411. layerMask: number;
  11412. /**
  11413. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11414. */
  11415. isPickable: boolean;
  11416. /**
  11417. * Specifies the rendering group id for this mesh (0 by default)
  11418. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11419. */
  11420. renderingGroupId: number;
  11421. /**
  11422. * Defines the list of sprites managed by the manager.
  11423. */
  11424. sprites: Array<Sprite>;
  11425. /**
  11426. * Tests the intersection of a sprite with a specific ray.
  11427. * @param ray The ray we are sending to test the collision
  11428. * @param camera The camera space we are sending rays in
  11429. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11430. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11431. * @returns picking info or null.
  11432. */
  11433. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11434. /**
  11435. * Intersects the sprites with a ray
  11436. * @param ray defines the ray to intersect with
  11437. * @param camera defines the current active camera
  11438. * @param predicate defines a predicate used to select candidate sprites
  11439. * @returns null if no hit or a PickingInfo array
  11440. */
  11441. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Renders the list of sprites on screen.
  11444. */
  11445. render(): void;
  11446. }
  11447. /**
  11448. * Class used to manage multiple sprites on the same spritesheet
  11449. * @see http://doc.babylonjs.com/babylon101/sprites
  11450. */
  11451. export class SpriteManager implements ISpriteManager {
  11452. /** defines the manager's name */
  11453. name: string;
  11454. /** Gets the list of sprites */
  11455. sprites: Sprite[];
  11456. /** Gets or sets the rendering group id (0 by default) */
  11457. renderingGroupId: number;
  11458. /** Gets or sets camera layer mask */
  11459. layerMask: number;
  11460. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11461. fogEnabled: boolean;
  11462. /** Gets or sets a boolean indicating if the sprites are pickable */
  11463. isPickable: boolean;
  11464. /** Defines the default width of a cell in the spritesheet */
  11465. cellWidth: number;
  11466. /** Defines the default height of a cell in the spritesheet */
  11467. cellHeight: number;
  11468. /** Associative array from JSON sprite data file */
  11469. private _cellData;
  11470. /** Array of sprite names from JSON sprite data file */
  11471. private _spriteMap;
  11472. /** True when packed cell data from JSON file is ready*/
  11473. private _packedAndReady;
  11474. /**
  11475. * An event triggered when the manager is disposed.
  11476. */
  11477. onDisposeObservable: Observable<SpriteManager>;
  11478. private _onDisposeObserver;
  11479. /**
  11480. * Callback called when the manager is disposed
  11481. */
  11482. onDispose: () => void;
  11483. private _capacity;
  11484. private _fromPacked;
  11485. private _spriteTexture;
  11486. private _epsilon;
  11487. private _scene;
  11488. private _vertexData;
  11489. private _buffer;
  11490. private _vertexBuffers;
  11491. private _indexBuffer;
  11492. private _effectBase;
  11493. private _effectFog;
  11494. /**
  11495. * Gets or sets the spritesheet texture
  11496. */
  11497. texture: Texture;
  11498. /**
  11499. * Creates a new sprite manager
  11500. * @param name defines the manager's name
  11501. * @param imgUrl defines the sprite sheet url
  11502. * @param capacity defines the maximum allowed number of sprites
  11503. * @param cellSize defines the size of a sprite cell
  11504. * @param scene defines the hosting scene
  11505. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11506. * @param samplingMode defines the smapling mode to use with spritesheet
  11507. * @param fromPacked set to false; do not alter
  11508. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11509. */
  11510. constructor(
  11511. /** defines the manager's name */
  11512. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11513. private _makePacked;
  11514. private _appendSpriteVertex;
  11515. /**
  11516. * Intersects the sprites with a ray
  11517. * @param ray defines the ray to intersect with
  11518. * @param camera defines the current active camera
  11519. * @param predicate defines a predicate used to select candidate sprites
  11520. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11521. * @returns null if no hit or a PickingInfo
  11522. */
  11523. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11524. /**
  11525. * Intersects the sprites with a ray
  11526. * @param ray defines the ray to intersect with
  11527. * @param camera defines the current active camera
  11528. * @param predicate defines a predicate used to select candidate sprites
  11529. * @returns null if no hit or a PickingInfo array
  11530. */
  11531. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11532. /**
  11533. * Render all child sprites
  11534. */
  11535. render(): void;
  11536. /**
  11537. * Release associated resources
  11538. */
  11539. dispose(): void;
  11540. }
  11541. }
  11542. declare module BABYLON {
  11543. /**
  11544. * Class used to represent a sprite
  11545. * @see http://doc.babylonjs.com/babylon101/sprites
  11546. */
  11547. export class Sprite {
  11548. /** defines the name */
  11549. name: string;
  11550. /** Gets or sets the current world position */
  11551. position: Vector3;
  11552. /** Gets or sets the main color */
  11553. color: Color4;
  11554. /** Gets or sets the width */
  11555. width: number;
  11556. /** Gets or sets the height */
  11557. height: number;
  11558. /** Gets or sets rotation angle */
  11559. angle: number;
  11560. /** Gets or sets the cell index in the sprite sheet */
  11561. cellIndex: number;
  11562. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11563. cellRef: string;
  11564. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11565. invertU: number;
  11566. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11567. invertV: number;
  11568. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11569. disposeWhenFinishedAnimating: boolean;
  11570. /** Gets the list of attached animations */
  11571. animations: Animation[];
  11572. /** Gets or sets a boolean indicating if the sprite can be picked */
  11573. isPickable: boolean;
  11574. /**
  11575. * Gets or sets the associated action manager
  11576. */
  11577. actionManager: Nullable<ActionManager>;
  11578. private _animationStarted;
  11579. private _loopAnimation;
  11580. private _fromIndex;
  11581. private _toIndex;
  11582. private _delay;
  11583. private _direction;
  11584. private _manager;
  11585. private _time;
  11586. private _onAnimationEnd;
  11587. /**
  11588. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11589. */
  11590. isVisible: boolean;
  11591. /**
  11592. * Gets or sets the sprite size
  11593. */
  11594. size: number;
  11595. /**
  11596. * Creates a new Sprite
  11597. * @param name defines the name
  11598. * @param manager defines the manager
  11599. */
  11600. constructor(
  11601. /** defines the name */
  11602. name: string, manager: ISpriteManager);
  11603. /**
  11604. * Starts an animation
  11605. * @param from defines the initial key
  11606. * @param to defines the end key
  11607. * @param loop defines if the animation must loop
  11608. * @param delay defines the start delay (in ms)
  11609. * @param onAnimationEnd defines a callback to call when animation ends
  11610. */
  11611. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11612. /** Stops current animation (if any) */
  11613. stopAnimation(): void;
  11614. /** @hidden */
  11615. _animate(deltaTime: number): void;
  11616. /** Release associated resources */
  11617. dispose(): void;
  11618. }
  11619. }
  11620. declare module BABYLON {
  11621. /**
  11622. * Information about the result of picking within a scene
  11623. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11624. */
  11625. export class PickingInfo {
  11626. /** @hidden */
  11627. _pickingUnavailable: boolean;
  11628. /**
  11629. * If the pick collided with an object
  11630. */
  11631. hit: boolean;
  11632. /**
  11633. * Distance away where the pick collided
  11634. */
  11635. distance: number;
  11636. /**
  11637. * The location of pick collision
  11638. */
  11639. pickedPoint: Nullable<Vector3>;
  11640. /**
  11641. * The mesh corresponding the the pick collision
  11642. */
  11643. pickedMesh: Nullable<AbstractMesh>;
  11644. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11645. bu: number;
  11646. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11647. bv: number;
  11648. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11649. faceId: number;
  11650. /** Id of the the submesh that was picked */
  11651. subMeshId: number;
  11652. /** If a sprite was picked, this will be the sprite the pick collided with */
  11653. pickedSprite: Nullable<Sprite>;
  11654. /**
  11655. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11656. */
  11657. originMesh: Nullable<AbstractMesh>;
  11658. /**
  11659. * The ray that was used to perform the picking.
  11660. */
  11661. ray: Nullable<Ray>;
  11662. /**
  11663. * Gets the normal correspodning to the face the pick collided with
  11664. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11665. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11666. * @returns The normal correspodning to the face the pick collided with
  11667. */
  11668. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11669. /**
  11670. * Gets the texture coordinates of where the pick occured
  11671. * @returns the vector containing the coordnates of the texture
  11672. */
  11673. getTextureCoordinates(): Nullable<Vector2>;
  11674. }
  11675. }
  11676. declare module BABYLON {
  11677. /**
  11678. * Gather the list of pointer event types as constants.
  11679. */
  11680. export class PointerEventTypes {
  11681. /**
  11682. * 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.
  11683. */
  11684. static readonly POINTERDOWN: number;
  11685. /**
  11686. * The pointerup event is fired when a pointer is no longer active.
  11687. */
  11688. static readonly POINTERUP: number;
  11689. /**
  11690. * The pointermove event is fired when a pointer changes coordinates.
  11691. */
  11692. static readonly POINTERMOVE: number;
  11693. /**
  11694. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11695. */
  11696. static readonly POINTERWHEEL: number;
  11697. /**
  11698. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11699. */
  11700. static readonly POINTERPICK: number;
  11701. /**
  11702. * The pointertap event is fired when a the object has been touched and released without drag.
  11703. */
  11704. static readonly POINTERTAP: number;
  11705. /**
  11706. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11707. */
  11708. static readonly POINTERDOUBLETAP: number;
  11709. }
  11710. /**
  11711. * Base class of pointer info types.
  11712. */
  11713. export class PointerInfoBase {
  11714. /**
  11715. * Defines the type of event (PointerEventTypes)
  11716. */
  11717. type: number;
  11718. /**
  11719. * Defines the related dom event
  11720. */
  11721. event: PointerEvent | MouseWheelEvent;
  11722. /**
  11723. * Instantiates the base class of pointers info.
  11724. * @param type Defines the type of event (PointerEventTypes)
  11725. * @param event Defines the related dom event
  11726. */
  11727. constructor(
  11728. /**
  11729. * Defines the type of event (PointerEventTypes)
  11730. */
  11731. type: number,
  11732. /**
  11733. * Defines the related dom event
  11734. */
  11735. event: PointerEvent | MouseWheelEvent);
  11736. }
  11737. /**
  11738. * This class is used to store pointer related info for the onPrePointerObservable event.
  11739. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11740. */
  11741. export class PointerInfoPre extends PointerInfoBase {
  11742. /**
  11743. * Ray from a pointer if availible (eg. 6dof controller)
  11744. */
  11745. ray: Nullable<Ray>;
  11746. /**
  11747. * Defines the local position of the pointer on the canvas.
  11748. */
  11749. localPosition: Vector2;
  11750. /**
  11751. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11752. */
  11753. skipOnPointerObservable: boolean;
  11754. /**
  11755. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11756. * @param type Defines the type of event (PointerEventTypes)
  11757. * @param event Defines the related dom event
  11758. * @param localX Defines the local x coordinates of the pointer when the event occured
  11759. * @param localY Defines the local y coordinates of the pointer when the event occured
  11760. */
  11761. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11762. }
  11763. /**
  11764. * This type contains all the data related to a pointer event in Babylon.js.
  11765. * 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.
  11766. */
  11767. export class PointerInfo extends PointerInfoBase {
  11768. /**
  11769. * Defines the picking info associated to the info (if any)\
  11770. */
  11771. pickInfo: Nullable<PickingInfo>;
  11772. /**
  11773. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11774. * @param type Defines the type of event (PointerEventTypes)
  11775. * @param event Defines the related dom event
  11776. * @param pickInfo Defines the picking info associated to the info (if any)\
  11777. */
  11778. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11779. /**
  11780. * Defines the picking info associated to the info (if any)\
  11781. */
  11782. pickInfo: Nullable<PickingInfo>);
  11783. }
  11784. /**
  11785. * Data relating to a touch event on the screen.
  11786. */
  11787. export interface PointerTouch {
  11788. /**
  11789. * X coordinate of touch.
  11790. */
  11791. x: number;
  11792. /**
  11793. * Y coordinate of touch.
  11794. */
  11795. y: number;
  11796. /**
  11797. * Id of touch. Unique for each finger.
  11798. */
  11799. pointerId: number;
  11800. /**
  11801. * Event type passed from DOM.
  11802. */
  11803. type: any;
  11804. }
  11805. }
  11806. declare module BABYLON {
  11807. /**
  11808. * Manage the mouse inputs to control the movement of a free camera.
  11809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11810. */
  11811. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11812. /**
  11813. * Define if touch is enabled in the mouse input
  11814. */
  11815. touchEnabled: boolean;
  11816. /**
  11817. * Defines the camera the input is attached to.
  11818. */
  11819. camera: FreeCamera;
  11820. /**
  11821. * Defines the buttons associated with the input to handle camera move.
  11822. */
  11823. buttons: number[];
  11824. /**
  11825. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11826. */
  11827. angularSensibility: number;
  11828. private _pointerInput;
  11829. private _onMouseMove;
  11830. private _observer;
  11831. private previousPosition;
  11832. /**
  11833. * Observable for when a pointer move event occurs containing the move offset
  11834. */
  11835. onPointerMovedObservable: Observable<{
  11836. offsetX: number;
  11837. offsetY: number;
  11838. }>;
  11839. /**
  11840. * @hidden
  11841. * If the camera should be rotated automatically based on pointer movement
  11842. */
  11843. _allowCameraRotation: boolean;
  11844. /**
  11845. * Manage the mouse inputs to control the movement of a free camera.
  11846. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11847. * @param touchEnabled Defines if touch is enabled or not
  11848. */
  11849. constructor(
  11850. /**
  11851. * Define if touch is enabled in the mouse input
  11852. */
  11853. touchEnabled?: boolean);
  11854. /**
  11855. * Attach the input controls to a specific dom element to get the input from.
  11856. * @param element Defines the element the controls should be listened from
  11857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11858. */
  11859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11860. /**
  11861. * Called on JS contextmenu event.
  11862. * Override this method to provide functionality.
  11863. */
  11864. protected onContextMenu(evt: PointerEvent): void;
  11865. /**
  11866. * Detach the current controls from the specified dom element.
  11867. * @param element Defines the element to stop listening the inputs from
  11868. */
  11869. detachControl(element: Nullable<HTMLElement>): void;
  11870. /**
  11871. * Gets the class name of the current intput.
  11872. * @returns the class name
  11873. */
  11874. getClassName(): string;
  11875. /**
  11876. * Get the friendly name associated with the input class.
  11877. * @returns the input friendly name
  11878. */
  11879. getSimpleName(): string;
  11880. }
  11881. }
  11882. declare module BABYLON {
  11883. /**
  11884. * Manage the touch inputs to control the movement of a free camera.
  11885. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11886. */
  11887. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11888. /**
  11889. * Defines the camera the input is attached to.
  11890. */
  11891. camera: FreeCamera;
  11892. /**
  11893. * Defines the touch sensibility for rotation.
  11894. * The higher the faster.
  11895. */
  11896. touchAngularSensibility: number;
  11897. /**
  11898. * Defines the touch sensibility for move.
  11899. * The higher the faster.
  11900. */
  11901. touchMoveSensibility: number;
  11902. private _offsetX;
  11903. private _offsetY;
  11904. private _pointerPressed;
  11905. private _pointerInput;
  11906. private _observer;
  11907. private _onLostFocus;
  11908. /**
  11909. * Attach the input controls to a specific dom element to get the input from.
  11910. * @param element Defines the element the controls should be listened from
  11911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11912. */
  11913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11914. /**
  11915. * Detach the current controls from the specified dom element.
  11916. * @param element Defines the element to stop listening the inputs from
  11917. */
  11918. detachControl(element: Nullable<HTMLElement>): void;
  11919. /**
  11920. * Update the current camera state depending on the inputs that have been used this frame.
  11921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11922. */
  11923. checkInputs(): void;
  11924. /**
  11925. * Gets the class name of the current intput.
  11926. * @returns the class name
  11927. */
  11928. getClassName(): string;
  11929. /**
  11930. * Get the friendly name associated with the input class.
  11931. * @returns the input friendly name
  11932. */
  11933. getSimpleName(): string;
  11934. }
  11935. }
  11936. declare module BABYLON {
  11937. /**
  11938. * Default Inputs manager for the FreeCamera.
  11939. * It groups all the default supported inputs for ease of use.
  11940. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11941. */
  11942. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11943. /**
  11944. * @hidden
  11945. */
  11946. _mouseInput: Nullable<FreeCameraMouseInput>;
  11947. /**
  11948. * Instantiates a new FreeCameraInputsManager.
  11949. * @param camera Defines the camera the inputs belong to
  11950. */
  11951. constructor(camera: FreeCamera);
  11952. /**
  11953. * Add keyboard input support to the input manager.
  11954. * @returns the current input manager
  11955. */
  11956. addKeyboard(): FreeCameraInputsManager;
  11957. /**
  11958. * Add mouse input support to the input manager.
  11959. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11960. * @returns the current input manager
  11961. */
  11962. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11963. /**
  11964. * Removes the mouse input support from the manager
  11965. * @returns the current input manager
  11966. */
  11967. removeMouse(): FreeCameraInputsManager;
  11968. /**
  11969. * Add touch input support to the input manager.
  11970. * @returns the current input manager
  11971. */
  11972. addTouch(): FreeCameraInputsManager;
  11973. /**
  11974. * Remove all attached input methods from a camera
  11975. */
  11976. clear(): void;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11982. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11984. */
  11985. export class FreeCamera extends TargetCamera {
  11986. /**
  11987. * Define the collision ellipsoid of the camera.
  11988. * This is helpful to simulate a camera body like the player body around the camera
  11989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11990. */
  11991. ellipsoid: Vector3;
  11992. /**
  11993. * Define an offset for the position of the ellipsoid around the camera.
  11994. * This can be helpful to determine the center of the body near the gravity center of the body
  11995. * instead of its head.
  11996. */
  11997. ellipsoidOffset: Vector3;
  11998. /**
  11999. * Enable or disable collisions of the camera with the rest of the scene objects.
  12000. */
  12001. checkCollisions: boolean;
  12002. /**
  12003. * Enable or disable gravity on the camera.
  12004. */
  12005. applyGravity: boolean;
  12006. /**
  12007. * Define the input manager associated to the camera.
  12008. */
  12009. inputs: FreeCameraInputsManager;
  12010. /**
  12011. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12012. * Higher values reduce sensitivity.
  12013. */
  12014. /**
  12015. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12016. * Higher values reduce sensitivity.
  12017. */
  12018. angularSensibility: number;
  12019. /**
  12020. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12021. */
  12022. keysUp: number[];
  12023. /**
  12024. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12025. */
  12026. keysDown: number[];
  12027. /**
  12028. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12029. */
  12030. keysLeft: number[];
  12031. /**
  12032. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12033. */
  12034. keysRight: number[];
  12035. /**
  12036. * Event raised when the camera collide with a mesh in the scene.
  12037. */
  12038. onCollide: (collidedMesh: AbstractMesh) => void;
  12039. private _collider;
  12040. private _needMoveForGravity;
  12041. private _oldPosition;
  12042. private _diffPosition;
  12043. private _newPosition;
  12044. /** @hidden */
  12045. _localDirection: Vector3;
  12046. /** @hidden */
  12047. _transformedDirection: Vector3;
  12048. /**
  12049. * Instantiates a Free Camera.
  12050. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12051. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12052. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12053. * @param name Define the name of the camera in the scene
  12054. * @param position Define the start position of the camera in the scene
  12055. * @param scene Define the scene the camera belongs to
  12056. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12057. */
  12058. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12059. /**
  12060. * Attached controls to the current camera.
  12061. * @param element Defines the element the controls should be listened from
  12062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12063. */
  12064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12065. /**
  12066. * Detach the current controls from the camera.
  12067. * The camera will stop reacting to inputs.
  12068. * @param element Defines the element to stop listening the inputs from
  12069. */
  12070. detachControl(element: HTMLElement): void;
  12071. private _collisionMask;
  12072. /**
  12073. * Define a collision mask to limit the list of object the camera can collide with
  12074. */
  12075. collisionMask: number;
  12076. /** @hidden */
  12077. _collideWithWorld(displacement: Vector3): void;
  12078. private _onCollisionPositionChange;
  12079. /** @hidden */
  12080. _checkInputs(): void;
  12081. /** @hidden */
  12082. _decideIfNeedsToMove(): boolean;
  12083. /** @hidden */
  12084. _updatePosition(): void;
  12085. /**
  12086. * Destroy the camera and release the current resources hold by it.
  12087. */
  12088. dispose(): void;
  12089. /**
  12090. * Gets the current object class name.
  12091. * @return the class name
  12092. */
  12093. getClassName(): string;
  12094. }
  12095. }
  12096. declare module BABYLON {
  12097. /**
  12098. * Represents a gamepad control stick position
  12099. */
  12100. export class StickValues {
  12101. /**
  12102. * The x component of the control stick
  12103. */
  12104. x: number;
  12105. /**
  12106. * The y component of the control stick
  12107. */
  12108. y: number;
  12109. /**
  12110. * Initializes the gamepad x and y control stick values
  12111. * @param x The x component of the gamepad control stick value
  12112. * @param y The y component of the gamepad control stick value
  12113. */
  12114. constructor(
  12115. /**
  12116. * The x component of the control stick
  12117. */
  12118. x: number,
  12119. /**
  12120. * The y component of the control stick
  12121. */
  12122. y: number);
  12123. }
  12124. /**
  12125. * An interface which manages callbacks for gamepad button changes
  12126. */
  12127. export interface GamepadButtonChanges {
  12128. /**
  12129. * Called when a gamepad has been changed
  12130. */
  12131. changed: boolean;
  12132. /**
  12133. * Called when a gamepad press event has been triggered
  12134. */
  12135. pressChanged: boolean;
  12136. /**
  12137. * Called when a touch event has been triggered
  12138. */
  12139. touchChanged: boolean;
  12140. /**
  12141. * Called when a value has changed
  12142. */
  12143. valueChanged: boolean;
  12144. }
  12145. /**
  12146. * Represents a gamepad
  12147. */
  12148. export class Gamepad {
  12149. /**
  12150. * The id of the gamepad
  12151. */
  12152. id: string;
  12153. /**
  12154. * The index of the gamepad
  12155. */
  12156. index: number;
  12157. /**
  12158. * The browser gamepad
  12159. */
  12160. browserGamepad: any;
  12161. /**
  12162. * Specifies what type of gamepad this represents
  12163. */
  12164. type: number;
  12165. private _leftStick;
  12166. private _rightStick;
  12167. /** @hidden */
  12168. _isConnected: boolean;
  12169. private _leftStickAxisX;
  12170. private _leftStickAxisY;
  12171. private _rightStickAxisX;
  12172. private _rightStickAxisY;
  12173. /**
  12174. * Triggered when the left control stick has been changed
  12175. */
  12176. private _onleftstickchanged;
  12177. /**
  12178. * Triggered when the right control stick has been changed
  12179. */
  12180. private _onrightstickchanged;
  12181. /**
  12182. * Represents a gamepad controller
  12183. */
  12184. static GAMEPAD: number;
  12185. /**
  12186. * Represents a generic controller
  12187. */
  12188. static GENERIC: number;
  12189. /**
  12190. * Represents an XBox controller
  12191. */
  12192. static XBOX: number;
  12193. /**
  12194. * Represents a pose-enabled controller
  12195. */
  12196. static POSE_ENABLED: number;
  12197. /**
  12198. * Represents an Dual Shock controller
  12199. */
  12200. static DUALSHOCK: number;
  12201. /**
  12202. * Specifies whether the left control stick should be Y-inverted
  12203. */
  12204. protected _invertLeftStickY: boolean;
  12205. /**
  12206. * Specifies if the gamepad has been connected
  12207. */
  12208. readonly isConnected: boolean;
  12209. /**
  12210. * Initializes the gamepad
  12211. * @param id The id of the gamepad
  12212. * @param index The index of the gamepad
  12213. * @param browserGamepad The browser gamepad
  12214. * @param leftStickX The x component of the left joystick
  12215. * @param leftStickY The y component of the left joystick
  12216. * @param rightStickX The x component of the right joystick
  12217. * @param rightStickY The y component of the right joystick
  12218. */
  12219. constructor(
  12220. /**
  12221. * The id of the gamepad
  12222. */
  12223. id: string,
  12224. /**
  12225. * The index of the gamepad
  12226. */
  12227. index: number,
  12228. /**
  12229. * The browser gamepad
  12230. */
  12231. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12232. /**
  12233. * Callback triggered when the left joystick has changed
  12234. * @param callback
  12235. */
  12236. onleftstickchanged(callback: (values: StickValues) => void): void;
  12237. /**
  12238. * Callback triggered when the right joystick has changed
  12239. * @param callback
  12240. */
  12241. onrightstickchanged(callback: (values: StickValues) => void): void;
  12242. /**
  12243. * Gets the left joystick
  12244. */
  12245. /**
  12246. * Sets the left joystick values
  12247. */
  12248. leftStick: StickValues;
  12249. /**
  12250. * Gets the right joystick
  12251. */
  12252. /**
  12253. * Sets the right joystick value
  12254. */
  12255. rightStick: StickValues;
  12256. /**
  12257. * Updates the gamepad joystick positions
  12258. */
  12259. update(): void;
  12260. /**
  12261. * Disposes the gamepad
  12262. */
  12263. dispose(): void;
  12264. }
  12265. /**
  12266. * Represents a generic gamepad
  12267. */
  12268. export class GenericPad extends Gamepad {
  12269. private _buttons;
  12270. private _onbuttondown;
  12271. private _onbuttonup;
  12272. /**
  12273. * Observable triggered when a button has been pressed
  12274. */
  12275. onButtonDownObservable: Observable<number>;
  12276. /**
  12277. * Observable triggered when a button has been released
  12278. */
  12279. onButtonUpObservable: Observable<number>;
  12280. /**
  12281. * Callback triggered when a button has been pressed
  12282. * @param callback Called when a button has been pressed
  12283. */
  12284. onbuttondown(callback: (buttonPressed: number) => void): void;
  12285. /**
  12286. * Callback triggered when a button has been released
  12287. * @param callback Called when a button has been released
  12288. */
  12289. onbuttonup(callback: (buttonReleased: number) => void): void;
  12290. /**
  12291. * Initializes the generic gamepad
  12292. * @param id The id of the generic gamepad
  12293. * @param index The index of the generic gamepad
  12294. * @param browserGamepad The browser gamepad
  12295. */
  12296. constructor(id: string, index: number, browserGamepad: any);
  12297. private _setButtonValue;
  12298. /**
  12299. * Updates the generic gamepad
  12300. */
  12301. update(): void;
  12302. /**
  12303. * Disposes the generic gamepad
  12304. */
  12305. dispose(): void;
  12306. }
  12307. }
  12308. declare module BABYLON {
  12309. interface Engine {
  12310. /**
  12311. * Creates a raw texture
  12312. * @param data defines the data to store in the texture
  12313. * @param width defines the width of the texture
  12314. * @param height defines the height of the texture
  12315. * @param format defines the format of the data
  12316. * @param generateMipMaps defines if the engine should generate the mip levels
  12317. * @param invertY defines if data must be stored with Y axis inverted
  12318. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12319. * @param compression defines the compression used (null by default)
  12320. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12321. * @returns the raw texture inside an InternalTexture
  12322. */
  12323. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12324. /**
  12325. * Update a raw texture
  12326. * @param texture defines the texture to update
  12327. * @param data defines the data to store in the texture
  12328. * @param format defines the format of the data
  12329. * @param invertY defines if data must be stored with Y axis inverted
  12330. */
  12331. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12332. /**
  12333. * Update a raw texture
  12334. * @param texture defines the texture to update
  12335. * @param data defines the data to store in the texture
  12336. * @param format defines the format of the data
  12337. * @param invertY defines if data must be stored with Y axis inverted
  12338. * @param compression defines the compression used (null by default)
  12339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12340. */
  12341. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12342. /**
  12343. * Creates a new raw cube texture
  12344. * @param data defines the array of data to use to create each face
  12345. * @param size defines the size of the textures
  12346. * @param format defines the format of the data
  12347. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12348. * @param generateMipMaps defines if the engine should generate the mip levels
  12349. * @param invertY defines if data must be stored with Y axis inverted
  12350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12351. * @param compression defines the compression used (null by default)
  12352. * @returns the cube texture as an InternalTexture
  12353. */
  12354. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12355. /**
  12356. * Update a raw cube texture
  12357. * @param texture defines the texture to udpdate
  12358. * @param data defines the data to store
  12359. * @param format defines the data format
  12360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12361. * @param invertY defines if data must be stored with Y axis inverted
  12362. */
  12363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12364. /**
  12365. * Update a raw cube texture
  12366. * @param texture defines the texture to udpdate
  12367. * @param data defines the data to store
  12368. * @param format defines the data format
  12369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. * @param compression defines the compression used (null by default)
  12372. */
  12373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12374. /**
  12375. * Update a raw cube texture
  12376. * @param texture defines the texture to udpdate
  12377. * @param data defines the data to store
  12378. * @param format defines the data format
  12379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12380. * @param invertY defines if data must be stored with Y axis inverted
  12381. * @param compression defines the compression used (null by default)
  12382. * @param level defines which level of the texture to update
  12383. */
  12384. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12385. /**
  12386. * Creates a new raw cube texture from a specified url
  12387. * @param url defines the url where the data is located
  12388. * @param scene defines the current scene
  12389. * @param size defines the size of the textures
  12390. * @param format defines the format of the data
  12391. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12392. * @param noMipmap defines if the engine should avoid generating the mip levels
  12393. * @param callback defines a callback used to extract texture data from loaded data
  12394. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12395. * @param onLoad defines a callback called when texture is loaded
  12396. * @param onError defines a callback called if there is an error
  12397. * @returns the cube texture as an InternalTexture
  12398. */
  12399. 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;
  12400. /**
  12401. * Creates a new raw cube texture from a specified url
  12402. * @param url defines the url where the data is located
  12403. * @param scene defines the current scene
  12404. * @param size defines the size of the textures
  12405. * @param format defines the format of the data
  12406. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12407. * @param noMipmap defines if the engine should avoid generating the mip levels
  12408. * @param callback defines a callback used to extract texture data from loaded data
  12409. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12410. * @param onLoad defines a callback called when texture is loaded
  12411. * @param onError defines a callback called if there is an error
  12412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12413. * @param invertY defines if data must be stored with Y axis inverted
  12414. * @returns the cube texture as an InternalTexture
  12415. */
  12416. 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;
  12417. /**
  12418. * Creates a new raw 3D texture
  12419. * @param data defines the data used to create the texture
  12420. * @param width defines the width of the texture
  12421. * @param height defines the height of the texture
  12422. * @param depth defines the depth of the texture
  12423. * @param format defines the format of the texture
  12424. * @param generateMipMaps defines if the engine must generate mip levels
  12425. * @param invertY defines if data must be stored with Y axis inverted
  12426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12427. * @param compression defines the compressed used (can be null)
  12428. * @param textureType defines the compressed used (can be null)
  12429. * @returns a new raw 3D texture (stored in an InternalTexture)
  12430. */
  12431. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12432. /**
  12433. * Update a raw 3D texture
  12434. * @param texture defines the texture to update
  12435. * @param data defines the data to store
  12436. * @param format defines the data format
  12437. * @param invertY defines if data must be stored with Y axis inverted
  12438. */
  12439. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12440. /**
  12441. * Update a raw 3D texture
  12442. * @param texture defines the texture to update
  12443. * @param data defines the data to store
  12444. * @param format defines the data format
  12445. * @param invertY defines if data must be stored with Y axis inverted
  12446. * @param compression defines the used compression (can be null)
  12447. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12448. */
  12449. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12450. }
  12451. }
  12452. declare module BABYLON {
  12453. /**
  12454. * Raw texture can help creating a texture directly from an array of data.
  12455. * This can be super useful if you either get the data from an uncompressed source or
  12456. * if you wish to create your texture pixel by pixel.
  12457. */
  12458. export class RawTexture extends Texture {
  12459. /**
  12460. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12461. */
  12462. format: number;
  12463. private _engine;
  12464. /**
  12465. * Instantiates a new RawTexture.
  12466. * Raw texture can help creating a texture directly from an array of data.
  12467. * This can be super useful if you either get the data from an uncompressed source or
  12468. * if you wish to create your texture pixel by pixel.
  12469. * @param data define the array of data to use to create the texture
  12470. * @param width define the width of the texture
  12471. * @param height define the height of the texture
  12472. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12473. * @param scene define the scene the texture belongs to
  12474. * @param generateMipMaps define whether mip maps should be generated or not
  12475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12477. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12478. */
  12479. constructor(data: ArrayBufferView, width: number, height: number,
  12480. /**
  12481. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12482. */
  12483. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12484. /**
  12485. * Updates the texture underlying data.
  12486. * @param data Define the new data of the texture
  12487. */
  12488. update(data: ArrayBufferView): void;
  12489. /**
  12490. * Creates a luminance texture from some data.
  12491. * @param data Define the texture data
  12492. * @param width Define the width of the texture
  12493. * @param height Define the height of the texture
  12494. * @param scene Define the scene the texture belongs to
  12495. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12496. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12497. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12498. * @returns the luminance texture
  12499. */
  12500. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12501. /**
  12502. * Creates a luminance alpha texture from some data.
  12503. * @param data Define the texture data
  12504. * @param width Define the width of the texture
  12505. * @param height Define the height of the texture
  12506. * @param scene Define the scene the texture belongs to
  12507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12510. * @returns the luminance alpha texture
  12511. */
  12512. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12513. /**
  12514. * Creates an alpha texture from some data.
  12515. * @param data Define the texture data
  12516. * @param width Define the width of the texture
  12517. * @param height Define the height of the texture
  12518. * @param scene Define the scene the texture belongs to
  12519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12522. * @returns the alpha texture
  12523. */
  12524. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12525. /**
  12526. * Creates a RGB texture from some data.
  12527. * @param data Define the texture data
  12528. * @param width Define the width of the texture
  12529. * @param height Define the height of the texture
  12530. * @param scene Define the scene the texture belongs to
  12531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12534. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12535. * @returns the RGB alpha texture
  12536. */
  12537. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12538. /**
  12539. * Creates a RGBA texture from some data.
  12540. * @param data Define the texture data
  12541. * @param width Define the width of the texture
  12542. * @param height Define the height of the texture
  12543. * @param scene Define the scene the texture belongs to
  12544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12547. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12548. * @returns the RGBA texture
  12549. */
  12550. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12551. /**
  12552. * Creates a R texture from some data.
  12553. * @param data Define the texture data
  12554. * @param width Define the width of the texture
  12555. * @param height Define the height of the texture
  12556. * @param scene Define the scene the texture belongs to
  12557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12561. * @returns the R texture
  12562. */
  12563. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. /**
  12568. * Interface for the size containing width and height
  12569. */
  12570. export interface ISize {
  12571. /**
  12572. * Width
  12573. */
  12574. width: number;
  12575. /**
  12576. * Heighht
  12577. */
  12578. height: number;
  12579. }
  12580. /**
  12581. * Size containing widht and height
  12582. */
  12583. export class Size implements ISize {
  12584. /**
  12585. * Width
  12586. */
  12587. width: number;
  12588. /**
  12589. * Height
  12590. */
  12591. height: number;
  12592. /**
  12593. * Creates a Size object from the given width and height (floats).
  12594. * @param width width of the new size
  12595. * @param height height of the new size
  12596. */
  12597. constructor(width: number, height: number);
  12598. /**
  12599. * Returns a string with the Size width and height
  12600. * @returns a string with the Size width and height
  12601. */
  12602. toString(): string;
  12603. /**
  12604. * "Size"
  12605. * @returns the string "Size"
  12606. */
  12607. getClassName(): string;
  12608. /**
  12609. * Returns the Size hash code.
  12610. * @returns a hash code for a unique width and height
  12611. */
  12612. getHashCode(): number;
  12613. /**
  12614. * Updates the current size from the given one.
  12615. * @param src the given size
  12616. */
  12617. copyFrom(src: Size): void;
  12618. /**
  12619. * Updates in place the current Size from the given floats.
  12620. * @param width width of the new size
  12621. * @param height height of the new size
  12622. * @returns the updated Size.
  12623. */
  12624. copyFromFloats(width: number, height: number): Size;
  12625. /**
  12626. * Updates in place the current Size from the given floats.
  12627. * @param width width to set
  12628. * @param height height to set
  12629. * @returns the updated Size.
  12630. */
  12631. set(width: number, height: number): Size;
  12632. /**
  12633. * Multiplies the width and height by numbers
  12634. * @param w factor to multiple the width by
  12635. * @param h factor to multiple the height by
  12636. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12637. */
  12638. multiplyByFloats(w: number, h: number): Size;
  12639. /**
  12640. * Clones the size
  12641. * @returns a new Size copied from the given one.
  12642. */
  12643. clone(): Size;
  12644. /**
  12645. * True if the current Size and the given one width and height are strictly equal.
  12646. * @param other the other size to compare against
  12647. * @returns True if the current Size and the given one width and height are strictly equal.
  12648. */
  12649. equals(other: Size): boolean;
  12650. /**
  12651. * The surface of the Size : width * height (float).
  12652. */
  12653. readonly surface: number;
  12654. /**
  12655. * Create a new size of zero
  12656. * @returns a new Size set to (0.0, 0.0)
  12657. */
  12658. static Zero(): Size;
  12659. /**
  12660. * Sums the width and height of two sizes
  12661. * @param otherSize size to add to this size
  12662. * @returns a new Size set as the addition result of the current Size and the given one.
  12663. */
  12664. add(otherSize: Size): Size;
  12665. /**
  12666. * Subtracts the width and height of two
  12667. * @param otherSize size to subtract to this size
  12668. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12669. */
  12670. subtract(otherSize: Size): Size;
  12671. /**
  12672. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12673. * @param start starting size to lerp between
  12674. * @param end end size to lerp between
  12675. * @param amount amount to lerp between the start and end values
  12676. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12677. */
  12678. static Lerp(start: Size, end: Size, amount: number): Size;
  12679. }
  12680. }
  12681. declare module BABYLON {
  12682. /**
  12683. * Defines a runtime animation
  12684. */
  12685. export class RuntimeAnimation {
  12686. private _events;
  12687. /**
  12688. * The current frame of the runtime animation
  12689. */
  12690. private _currentFrame;
  12691. /**
  12692. * The animation used by the runtime animation
  12693. */
  12694. private _animation;
  12695. /**
  12696. * The target of the runtime animation
  12697. */
  12698. private _target;
  12699. /**
  12700. * The initiating animatable
  12701. */
  12702. private _host;
  12703. /**
  12704. * The original value of the runtime animation
  12705. */
  12706. private _originalValue;
  12707. /**
  12708. * The original blend value of the runtime animation
  12709. */
  12710. private _originalBlendValue;
  12711. /**
  12712. * The offsets cache of the runtime animation
  12713. */
  12714. private _offsetsCache;
  12715. /**
  12716. * The high limits cache of the runtime animation
  12717. */
  12718. private _highLimitsCache;
  12719. /**
  12720. * Specifies if the runtime animation has been stopped
  12721. */
  12722. private _stopped;
  12723. /**
  12724. * The blending factor of the runtime animation
  12725. */
  12726. private _blendingFactor;
  12727. /**
  12728. * The BabylonJS scene
  12729. */
  12730. private _scene;
  12731. /**
  12732. * The current value of the runtime animation
  12733. */
  12734. private _currentValue;
  12735. /** @hidden */
  12736. _animationState: _IAnimationState;
  12737. /**
  12738. * The active target of the runtime animation
  12739. */
  12740. private _activeTargets;
  12741. private _currentActiveTarget;
  12742. private _directTarget;
  12743. /**
  12744. * The target path of the runtime animation
  12745. */
  12746. private _targetPath;
  12747. /**
  12748. * The weight of the runtime animation
  12749. */
  12750. private _weight;
  12751. /**
  12752. * The ratio offset of the runtime animation
  12753. */
  12754. private _ratioOffset;
  12755. /**
  12756. * The previous delay of the runtime animation
  12757. */
  12758. private _previousDelay;
  12759. /**
  12760. * The previous ratio of the runtime animation
  12761. */
  12762. private _previousRatio;
  12763. private _enableBlending;
  12764. private _keys;
  12765. private _minFrame;
  12766. private _maxFrame;
  12767. private _minValue;
  12768. private _maxValue;
  12769. private _targetIsArray;
  12770. /**
  12771. * Gets the current frame of the runtime animation
  12772. */
  12773. readonly currentFrame: number;
  12774. /**
  12775. * Gets the weight of the runtime animation
  12776. */
  12777. readonly weight: number;
  12778. /**
  12779. * Gets the current value of the runtime animation
  12780. */
  12781. readonly currentValue: any;
  12782. /**
  12783. * Gets the target path of the runtime animation
  12784. */
  12785. readonly targetPath: string;
  12786. /**
  12787. * Gets the actual target of the runtime animation
  12788. */
  12789. readonly target: any;
  12790. /** @hidden */
  12791. _onLoop: () => void;
  12792. /**
  12793. * Create a new RuntimeAnimation object
  12794. * @param target defines the target of the animation
  12795. * @param animation defines the source animation object
  12796. * @param scene defines the hosting scene
  12797. * @param host defines the initiating Animatable
  12798. */
  12799. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12800. private _preparePath;
  12801. /**
  12802. * Gets the animation from the runtime animation
  12803. */
  12804. readonly animation: Animation;
  12805. /**
  12806. * Resets the runtime animation to the beginning
  12807. * @param restoreOriginal defines whether to restore the target property to the original value
  12808. */
  12809. reset(restoreOriginal?: boolean): void;
  12810. /**
  12811. * Specifies if the runtime animation is stopped
  12812. * @returns Boolean specifying if the runtime animation is stopped
  12813. */
  12814. isStopped(): boolean;
  12815. /**
  12816. * Disposes of the runtime animation
  12817. */
  12818. dispose(): void;
  12819. /**
  12820. * Apply the interpolated value to the target
  12821. * @param currentValue defines the value computed by the animation
  12822. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12823. */
  12824. setValue(currentValue: any, weight: number): void;
  12825. private _getOriginalValues;
  12826. private _setValue;
  12827. /**
  12828. * Gets the loop pmode of the runtime animation
  12829. * @returns Loop Mode
  12830. */
  12831. private _getCorrectLoopMode;
  12832. /**
  12833. * Move the current animation to a given frame
  12834. * @param frame defines the frame to move to
  12835. */
  12836. goToFrame(frame: number): void;
  12837. /**
  12838. * @hidden Internal use only
  12839. */
  12840. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12841. /**
  12842. * Execute the current animation
  12843. * @param delay defines the delay to add to the current frame
  12844. * @param from defines the lower bound of the animation range
  12845. * @param to defines the upper bound of the animation range
  12846. * @param loop defines if the current animation must loop
  12847. * @param speedRatio defines the current speed ratio
  12848. * @param weight defines the weight of the animation (default is -1 so no weight)
  12849. * @param onLoop optional callback called when animation loops
  12850. * @returns a boolean indicating if the animation is running
  12851. */
  12852. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12853. }
  12854. }
  12855. declare module BABYLON {
  12856. /**
  12857. * Class used to store an actual running animation
  12858. */
  12859. export class Animatable {
  12860. /** defines the target object */
  12861. target: any;
  12862. /** defines the starting frame number (default is 0) */
  12863. fromFrame: number;
  12864. /** defines the ending frame number (default is 100) */
  12865. toFrame: number;
  12866. /** defines if the animation must loop (default is false) */
  12867. loopAnimation: boolean;
  12868. /** defines a callback to call when animation ends if it is not looping */
  12869. onAnimationEnd?: (() => void) | null | undefined;
  12870. /** defines a callback to call when animation loops */
  12871. onAnimationLoop?: (() => void) | null | undefined;
  12872. private _localDelayOffset;
  12873. private _pausedDelay;
  12874. private _runtimeAnimations;
  12875. private _paused;
  12876. private _scene;
  12877. private _speedRatio;
  12878. private _weight;
  12879. private _syncRoot;
  12880. /**
  12881. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12882. * This will only apply for non looping animation (default is true)
  12883. */
  12884. disposeOnEnd: boolean;
  12885. /**
  12886. * Gets a boolean indicating if the animation has started
  12887. */
  12888. animationStarted: boolean;
  12889. /**
  12890. * Observer raised when the animation ends
  12891. */
  12892. onAnimationEndObservable: Observable<Animatable>;
  12893. /**
  12894. * Observer raised when the animation loops
  12895. */
  12896. onAnimationLoopObservable: Observable<Animatable>;
  12897. /**
  12898. * Gets the root Animatable used to synchronize and normalize animations
  12899. */
  12900. readonly syncRoot: Nullable<Animatable>;
  12901. /**
  12902. * Gets the current frame of the first RuntimeAnimation
  12903. * Used to synchronize Animatables
  12904. */
  12905. readonly masterFrame: number;
  12906. /**
  12907. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12908. */
  12909. weight: number;
  12910. /**
  12911. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12912. */
  12913. speedRatio: number;
  12914. /**
  12915. * Creates a new Animatable
  12916. * @param scene defines the hosting scene
  12917. * @param target defines the target object
  12918. * @param fromFrame defines the starting frame number (default is 0)
  12919. * @param toFrame defines the ending frame number (default is 100)
  12920. * @param loopAnimation defines if the animation must loop (default is false)
  12921. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12922. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12923. * @param animations defines a group of animation to add to the new Animatable
  12924. * @param onAnimationLoop defines a callback to call when animation loops
  12925. */
  12926. constructor(scene: Scene,
  12927. /** defines the target object */
  12928. target: any,
  12929. /** defines the starting frame number (default is 0) */
  12930. fromFrame?: number,
  12931. /** defines the ending frame number (default is 100) */
  12932. toFrame?: number,
  12933. /** defines if the animation must loop (default is false) */
  12934. loopAnimation?: boolean, speedRatio?: number,
  12935. /** defines a callback to call when animation ends if it is not looping */
  12936. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12937. /** defines a callback to call when animation loops */
  12938. onAnimationLoop?: (() => void) | null | undefined);
  12939. /**
  12940. * Synchronize and normalize current Animatable with a source Animatable
  12941. * This is useful when using animation weights and when animations are not of the same length
  12942. * @param root defines the root Animatable to synchronize with
  12943. * @returns the current Animatable
  12944. */
  12945. syncWith(root: Animatable): Animatable;
  12946. /**
  12947. * Gets the list of runtime animations
  12948. * @returns an array of RuntimeAnimation
  12949. */
  12950. getAnimations(): RuntimeAnimation[];
  12951. /**
  12952. * Adds more animations to the current animatable
  12953. * @param target defines the target of the animations
  12954. * @param animations defines the new animations to add
  12955. */
  12956. appendAnimations(target: any, animations: Animation[]): void;
  12957. /**
  12958. * Gets the source animation for a specific property
  12959. * @param property defines the propertyu to look for
  12960. * @returns null or the source animation for the given property
  12961. */
  12962. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12963. /**
  12964. * Gets the runtime animation for a specific property
  12965. * @param property defines the propertyu to look for
  12966. * @returns null or the runtime animation for the given property
  12967. */
  12968. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12969. /**
  12970. * Resets the animatable to its original state
  12971. */
  12972. reset(): void;
  12973. /**
  12974. * Allows the animatable to blend with current running animations
  12975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12976. * @param blendingSpeed defines the blending speed to use
  12977. */
  12978. enableBlending(blendingSpeed: number): void;
  12979. /**
  12980. * Disable animation blending
  12981. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12982. */
  12983. disableBlending(): void;
  12984. /**
  12985. * Jump directly to a given frame
  12986. * @param frame defines the frame to jump to
  12987. */
  12988. goToFrame(frame: number): void;
  12989. /**
  12990. * Pause the animation
  12991. */
  12992. pause(): void;
  12993. /**
  12994. * Restart the animation
  12995. */
  12996. restart(): void;
  12997. private _raiseOnAnimationEnd;
  12998. /**
  12999. * Stop and delete the current animation
  13000. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13001. * @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)
  13002. */
  13003. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13004. /**
  13005. * Wait asynchronously for the animation to end
  13006. * @returns a promise which will be fullfilled when the animation ends
  13007. */
  13008. waitAsync(): Promise<Animatable>;
  13009. /** @hidden */
  13010. _animate(delay: number): boolean;
  13011. }
  13012. interface Scene {
  13013. /** @hidden */
  13014. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13015. /** @hidden */
  13016. _processLateAnimationBindingsForMatrices(holder: {
  13017. totalWeight: number;
  13018. animations: RuntimeAnimation[];
  13019. originalValue: Matrix;
  13020. }): any;
  13021. /** @hidden */
  13022. _processLateAnimationBindingsForQuaternions(holder: {
  13023. totalWeight: number;
  13024. animations: RuntimeAnimation[];
  13025. originalValue: Quaternion;
  13026. }, refQuaternion: Quaternion): Quaternion;
  13027. /** @hidden */
  13028. _processLateAnimationBindings(): void;
  13029. /**
  13030. * Will start the animation sequence of a given target
  13031. * @param target defines the target
  13032. * @param from defines from which frame should animation start
  13033. * @param to defines until which frame should animation run.
  13034. * @param weight defines the weight to apply to the animation (1.0 by default)
  13035. * @param loop defines if the animation loops
  13036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13037. * @param onAnimationEnd defines the function to be executed when the animation ends
  13038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13039. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13040. * @param onAnimationLoop defines the callback to call when an animation loops
  13041. * @returns the animatable object created for this animation
  13042. */
  13043. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13044. /**
  13045. * Will start the animation sequence of a given target
  13046. * @param target defines the target
  13047. * @param from defines from which frame should animation start
  13048. * @param to defines until which frame should animation run.
  13049. * @param loop defines if the animation loops
  13050. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13051. * @param onAnimationEnd defines the function to be executed when the animation ends
  13052. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13053. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13054. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13055. * @param onAnimationLoop defines the callback to call when an animation loops
  13056. * @returns the animatable object created for this animation
  13057. */
  13058. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13059. /**
  13060. * Will start the animation sequence of a given target and its hierarchy
  13061. * @param target defines the target
  13062. * @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.
  13063. * @param from defines from which frame should animation start
  13064. * @param to defines until which frame should animation run.
  13065. * @param loop defines if the animation loops
  13066. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13067. * @param onAnimationEnd defines the function to be executed when the animation ends
  13068. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13069. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13070. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13071. * @param onAnimationLoop defines the callback to call when an animation loops
  13072. * @returns the list of created animatables
  13073. */
  13074. 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[];
  13075. /**
  13076. * Begin a new animation on a given node
  13077. * @param target defines the target where the animation will take place
  13078. * @param animations defines the list of animations to start
  13079. * @param from defines the initial value
  13080. * @param to defines the final value
  13081. * @param loop defines if you want animation to loop (off by default)
  13082. * @param speedRatio defines the speed ratio to apply to all animations
  13083. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13084. * @param onAnimationLoop defines the callback to call when an animation loops
  13085. * @returns the list of created animatables
  13086. */
  13087. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13088. /**
  13089. * Begin a new animation on a given node and its hierarchy
  13090. * @param target defines the root node where the animation will take place
  13091. * @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.
  13092. * @param animations defines the list of animations to start
  13093. * @param from defines the initial value
  13094. * @param to defines the final value
  13095. * @param loop defines if you want animation to loop (off by default)
  13096. * @param speedRatio defines the speed ratio to apply to all animations
  13097. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13098. * @param onAnimationLoop defines the callback to call when an animation loops
  13099. * @returns the list of animatables created for all nodes
  13100. */
  13101. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13102. /**
  13103. * Gets the animatable associated with a specific target
  13104. * @param target defines the target of the animatable
  13105. * @returns the required animatable if found
  13106. */
  13107. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13108. /**
  13109. * Gets all animatables associated with a given target
  13110. * @param target defines the target to look animatables for
  13111. * @returns an array of Animatables
  13112. */
  13113. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13114. /**
  13115. * Stops and removes all animations that have been applied to the scene
  13116. */
  13117. stopAllAnimations(): void;
  13118. /**
  13119. * Gets the current delta time used by animation engine
  13120. */
  13121. deltaTime: number;
  13122. }
  13123. interface Bone {
  13124. /**
  13125. * Copy an animation range from another bone
  13126. * @param source defines the source bone
  13127. * @param rangeName defines the range name to copy
  13128. * @param frameOffset defines the frame offset
  13129. * @param rescaleAsRequired defines if rescaling must be applied if required
  13130. * @param skelDimensionsRatio defines the scaling ratio
  13131. * @returns true if operation was successful
  13132. */
  13133. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13134. }
  13135. }
  13136. declare module BABYLON {
  13137. /**
  13138. * Class used to override all child animations of a given target
  13139. */
  13140. export class AnimationPropertiesOverride {
  13141. /**
  13142. * Gets or sets a value indicating if animation blending must be used
  13143. */
  13144. enableBlending: boolean;
  13145. /**
  13146. * Gets or sets the blending speed to use when enableBlending is true
  13147. */
  13148. blendingSpeed: number;
  13149. /**
  13150. * Gets or sets the default loop mode to use
  13151. */
  13152. loopMode: number;
  13153. }
  13154. }
  13155. declare module BABYLON {
  13156. /**
  13157. * Class used to handle skinning animations
  13158. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13159. */
  13160. export class Skeleton implements IAnimatable {
  13161. /** defines the skeleton name */
  13162. name: string;
  13163. /** defines the skeleton Id */
  13164. id: string;
  13165. /**
  13166. * Defines the list of child bones
  13167. */
  13168. bones: Bone[];
  13169. /**
  13170. * Defines an estimate of the dimension of the skeleton at rest
  13171. */
  13172. dimensionsAtRest: Vector3;
  13173. /**
  13174. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13175. */
  13176. needInitialSkinMatrix: boolean;
  13177. /**
  13178. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13179. */
  13180. overrideMesh: Nullable<AbstractMesh>;
  13181. /**
  13182. * Gets the list of animations attached to this skeleton
  13183. */
  13184. animations: Array<Animation>;
  13185. private _scene;
  13186. private _isDirty;
  13187. private _transformMatrices;
  13188. private _transformMatrixTexture;
  13189. private _meshesWithPoseMatrix;
  13190. private _animatables;
  13191. private _identity;
  13192. private _synchronizedWithMesh;
  13193. private _ranges;
  13194. private _lastAbsoluteTransformsUpdateId;
  13195. private _canUseTextureForBones;
  13196. private _uniqueId;
  13197. /** @hidden */
  13198. _numBonesWithLinkedTransformNode: number;
  13199. /** @hidden */
  13200. _hasWaitingData: Nullable<boolean>;
  13201. /**
  13202. * Specifies if the skeleton should be serialized
  13203. */
  13204. doNotSerialize: boolean;
  13205. private _useTextureToStoreBoneMatrices;
  13206. /**
  13207. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13208. * Please note that this option is not available if the hardware does not support it
  13209. */
  13210. useTextureToStoreBoneMatrices: boolean;
  13211. private _animationPropertiesOverride;
  13212. /**
  13213. * Gets or sets the animation properties override
  13214. */
  13215. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13216. /**
  13217. * List of inspectable custom properties (used by the Inspector)
  13218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13219. */
  13220. inspectableCustomProperties: IInspectable[];
  13221. /**
  13222. * An observable triggered before computing the skeleton's matrices
  13223. */
  13224. onBeforeComputeObservable: Observable<Skeleton>;
  13225. /**
  13226. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13227. */
  13228. readonly isUsingTextureForMatrices: boolean;
  13229. /**
  13230. * Gets the unique ID of this skeleton
  13231. */
  13232. readonly uniqueId: number;
  13233. /**
  13234. * Creates a new skeleton
  13235. * @param name defines the skeleton name
  13236. * @param id defines the skeleton Id
  13237. * @param scene defines the hosting scene
  13238. */
  13239. constructor(
  13240. /** defines the skeleton name */
  13241. name: string,
  13242. /** defines the skeleton Id */
  13243. id: string, scene: Scene);
  13244. /**
  13245. * Gets the current object class name.
  13246. * @return the class name
  13247. */
  13248. getClassName(): string;
  13249. /**
  13250. * Returns an array containing the root bones
  13251. * @returns an array containing the root bones
  13252. */
  13253. getChildren(): Array<Bone>;
  13254. /**
  13255. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13256. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13257. * @returns a Float32Array containing matrices data
  13258. */
  13259. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13260. /**
  13261. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13262. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13263. * @returns a raw texture containing the data
  13264. */
  13265. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13266. /**
  13267. * Gets the current hosting scene
  13268. * @returns a scene object
  13269. */
  13270. getScene(): Scene;
  13271. /**
  13272. * Gets a string representing the current skeleton data
  13273. * @param fullDetails defines a boolean indicating if we want a verbose version
  13274. * @returns a string representing the current skeleton data
  13275. */
  13276. toString(fullDetails?: boolean): string;
  13277. /**
  13278. * Get bone's index searching by name
  13279. * @param name defines bone's name to search for
  13280. * @return the indice of the bone. Returns -1 if not found
  13281. */
  13282. getBoneIndexByName(name: string): number;
  13283. /**
  13284. * Creater a new animation range
  13285. * @param name defines the name of the range
  13286. * @param from defines the start key
  13287. * @param to defines the end key
  13288. */
  13289. createAnimationRange(name: string, from: number, to: number): void;
  13290. /**
  13291. * Delete a specific animation range
  13292. * @param name defines the name of the range
  13293. * @param deleteFrames defines if frames must be removed as well
  13294. */
  13295. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13296. /**
  13297. * Gets a specific animation range
  13298. * @param name defines the name of the range to look for
  13299. * @returns the requested animation range or null if not found
  13300. */
  13301. getAnimationRange(name: string): Nullable<AnimationRange>;
  13302. /**
  13303. * Gets the list of all animation ranges defined on this skeleton
  13304. * @returns an array
  13305. */
  13306. getAnimationRanges(): Nullable<AnimationRange>[];
  13307. /**
  13308. * Copy animation range from a source skeleton.
  13309. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13310. * @param source defines the source skeleton
  13311. * @param name defines the name of the range to copy
  13312. * @param rescaleAsRequired defines if rescaling must be applied if required
  13313. * @returns true if operation was successful
  13314. */
  13315. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13316. /**
  13317. * Forces the skeleton to go to rest pose
  13318. */
  13319. returnToRest(): void;
  13320. private _getHighestAnimationFrame;
  13321. /**
  13322. * Begin a specific animation range
  13323. * @param name defines the name of the range to start
  13324. * @param loop defines if looping must be turned on (false by default)
  13325. * @param speedRatio defines the speed ratio to apply (1 by default)
  13326. * @param onAnimationEnd defines a callback which will be called when animation will end
  13327. * @returns a new animatable
  13328. */
  13329. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13330. /** @hidden */
  13331. _markAsDirty(): void;
  13332. /** @hidden */
  13333. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13334. /** @hidden */
  13335. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13336. private _computeTransformMatrices;
  13337. /**
  13338. * Build all resources required to render a skeleton
  13339. */
  13340. prepare(): void;
  13341. /**
  13342. * Gets the list of animatables currently running for this skeleton
  13343. * @returns an array of animatables
  13344. */
  13345. getAnimatables(): IAnimatable[];
  13346. /**
  13347. * Clone the current skeleton
  13348. * @param name defines the name of the new skeleton
  13349. * @param id defines the id of the new skeleton
  13350. * @returns the new skeleton
  13351. */
  13352. clone(name: string, id: string): Skeleton;
  13353. /**
  13354. * Enable animation blending for this skeleton
  13355. * @param blendingSpeed defines the blending speed to apply
  13356. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13357. */
  13358. enableBlending(blendingSpeed?: number): void;
  13359. /**
  13360. * Releases all resources associated with the current skeleton
  13361. */
  13362. dispose(): void;
  13363. /**
  13364. * Serialize the skeleton in a JSON object
  13365. * @returns a JSON object
  13366. */
  13367. serialize(): any;
  13368. /**
  13369. * Creates a new skeleton from serialized data
  13370. * @param parsedSkeleton defines the serialized data
  13371. * @param scene defines the hosting scene
  13372. * @returns a new skeleton
  13373. */
  13374. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13375. /**
  13376. * Compute all node absolute transforms
  13377. * @param forceUpdate defines if computation must be done even if cache is up to date
  13378. */
  13379. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13380. /**
  13381. * Gets the root pose matrix
  13382. * @returns a matrix
  13383. */
  13384. getPoseMatrix(): Nullable<Matrix>;
  13385. /**
  13386. * Sorts bones per internal index
  13387. */
  13388. sortBones(): void;
  13389. private _sortBones;
  13390. }
  13391. }
  13392. declare module BABYLON {
  13393. /**
  13394. * Class used to store bone information
  13395. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13396. */
  13397. export class Bone extends Node {
  13398. /**
  13399. * defines the bone name
  13400. */
  13401. name: string;
  13402. private static _tmpVecs;
  13403. private static _tmpQuat;
  13404. private static _tmpMats;
  13405. /**
  13406. * Gets the list of child bones
  13407. */
  13408. children: Bone[];
  13409. /** Gets the animations associated with this bone */
  13410. animations: Animation[];
  13411. /**
  13412. * Gets or sets bone length
  13413. */
  13414. length: number;
  13415. /**
  13416. * @hidden Internal only
  13417. * Set this value to map this bone to a different index in the transform matrices
  13418. * Set this value to -1 to exclude the bone from the transform matrices
  13419. */
  13420. _index: Nullable<number>;
  13421. private _skeleton;
  13422. private _localMatrix;
  13423. private _restPose;
  13424. private _baseMatrix;
  13425. private _absoluteTransform;
  13426. private _invertedAbsoluteTransform;
  13427. private _parent;
  13428. private _scalingDeterminant;
  13429. private _worldTransform;
  13430. private _localScaling;
  13431. private _localRotation;
  13432. private _localPosition;
  13433. private _needToDecompose;
  13434. private _needToCompose;
  13435. /** @hidden */
  13436. _linkedTransformNode: Nullable<TransformNode>;
  13437. /** @hidden */
  13438. _waitingTransformNodeId: Nullable<string>;
  13439. /** @hidden */
  13440. /** @hidden */
  13441. _matrix: Matrix;
  13442. /**
  13443. * Create a new bone
  13444. * @param name defines the bone name
  13445. * @param skeleton defines the parent skeleton
  13446. * @param parentBone defines the parent (can be null if the bone is the root)
  13447. * @param localMatrix defines the local matrix
  13448. * @param restPose defines the rest pose matrix
  13449. * @param baseMatrix defines the base matrix
  13450. * @param index defines index of the bone in the hiearchy
  13451. */
  13452. constructor(
  13453. /**
  13454. * defines the bone name
  13455. */
  13456. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13457. /**
  13458. * Gets the current object class name.
  13459. * @return the class name
  13460. */
  13461. getClassName(): string;
  13462. /**
  13463. * Gets the parent skeleton
  13464. * @returns a skeleton
  13465. */
  13466. getSkeleton(): Skeleton;
  13467. /**
  13468. * Gets parent bone
  13469. * @returns a bone or null if the bone is the root of the bone hierarchy
  13470. */
  13471. getParent(): Nullable<Bone>;
  13472. /**
  13473. * Returns an array containing the root bones
  13474. * @returns an array containing the root bones
  13475. */
  13476. getChildren(): Array<Bone>;
  13477. /**
  13478. * Sets the parent bone
  13479. * @param parent defines the parent (can be null if the bone is the root)
  13480. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13481. */
  13482. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13483. /**
  13484. * Gets the local matrix
  13485. * @returns a matrix
  13486. */
  13487. getLocalMatrix(): Matrix;
  13488. /**
  13489. * Gets the base matrix (initial matrix which remains unchanged)
  13490. * @returns a matrix
  13491. */
  13492. getBaseMatrix(): Matrix;
  13493. /**
  13494. * Gets the rest pose matrix
  13495. * @returns a matrix
  13496. */
  13497. getRestPose(): Matrix;
  13498. /**
  13499. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13500. */
  13501. getWorldMatrix(): Matrix;
  13502. /**
  13503. * Sets the local matrix to rest pose matrix
  13504. */
  13505. returnToRest(): void;
  13506. /**
  13507. * Gets the inverse of the absolute transform matrix.
  13508. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13509. * @returns a matrix
  13510. */
  13511. getInvertedAbsoluteTransform(): Matrix;
  13512. /**
  13513. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13514. * @returns a matrix
  13515. */
  13516. getAbsoluteTransform(): Matrix;
  13517. /**
  13518. * Links with the given transform node.
  13519. * The local matrix of this bone is copied from the transform node every frame.
  13520. * @param transformNode defines the transform node to link to
  13521. */
  13522. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13523. /**
  13524. * Gets the node used to drive the bone's transformation
  13525. * @returns a transform node or null
  13526. */
  13527. getTransformNode(): Nullable<TransformNode>;
  13528. /** Gets or sets current position (in local space) */
  13529. position: Vector3;
  13530. /** Gets or sets current rotation (in local space) */
  13531. rotation: Vector3;
  13532. /** Gets or sets current rotation quaternion (in local space) */
  13533. rotationQuaternion: Quaternion;
  13534. /** Gets or sets current scaling (in local space) */
  13535. scaling: Vector3;
  13536. /**
  13537. * Gets the animation properties override
  13538. */
  13539. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13540. private _decompose;
  13541. private _compose;
  13542. /**
  13543. * Update the base and local matrices
  13544. * @param matrix defines the new base or local matrix
  13545. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13546. * @param updateLocalMatrix defines if the local matrix should be updated
  13547. */
  13548. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13549. /** @hidden */
  13550. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13551. /**
  13552. * Flag the bone as dirty (Forcing it to update everything)
  13553. */
  13554. markAsDirty(): void;
  13555. /** @hidden */
  13556. _markAsDirtyAndCompose(): void;
  13557. private _markAsDirtyAndDecompose;
  13558. /**
  13559. * Translate the bone in local or world space
  13560. * @param vec The amount to translate the bone
  13561. * @param space The space that the translation is in
  13562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13563. */
  13564. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13565. /**
  13566. * Set the postion of the bone in local or world space
  13567. * @param position The position to set the bone
  13568. * @param space The space that the position is in
  13569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13570. */
  13571. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13572. /**
  13573. * Set the absolute position of the bone (world space)
  13574. * @param position The position to set the bone
  13575. * @param mesh The mesh that this bone is attached to
  13576. */
  13577. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13578. /**
  13579. * Scale the bone on the x, y and z axes (in local space)
  13580. * @param x The amount to scale the bone on the x axis
  13581. * @param y The amount to scale the bone on the y axis
  13582. * @param z The amount to scale the bone on the z axis
  13583. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13584. */
  13585. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13586. /**
  13587. * Set the bone scaling in local space
  13588. * @param scale defines the scaling vector
  13589. */
  13590. setScale(scale: Vector3): void;
  13591. /**
  13592. * Gets the current scaling in local space
  13593. * @returns the current scaling vector
  13594. */
  13595. getScale(): Vector3;
  13596. /**
  13597. * Gets the current scaling in local space and stores it in a target vector
  13598. * @param result defines the target vector
  13599. */
  13600. getScaleToRef(result: Vector3): void;
  13601. /**
  13602. * Set the yaw, pitch, and roll of the bone in local or world space
  13603. * @param yaw The rotation of the bone on the y axis
  13604. * @param pitch The rotation of the bone on the x axis
  13605. * @param roll The rotation of the bone on the z axis
  13606. * @param space The space that the axes of rotation are in
  13607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13608. */
  13609. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13610. /**
  13611. * Add a rotation to the bone on an axis in local or world space
  13612. * @param axis The axis to rotate the bone on
  13613. * @param amount The amount to rotate the bone
  13614. * @param space The space that the axis is in
  13615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13616. */
  13617. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13618. /**
  13619. * Set the rotation of the bone to a particular axis angle in local or world space
  13620. * @param axis The axis to rotate the bone on
  13621. * @param angle The angle that the bone should be rotated to
  13622. * @param space The space that the axis is in
  13623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13624. */
  13625. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13626. /**
  13627. * Set the euler rotation of the bone in local of world space
  13628. * @param rotation The euler rotation that the bone should be set to
  13629. * @param space The space that the rotation is in
  13630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13631. */
  13632. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13633. /**
  13634. * Set the quaternion rotation of the bone in local of world space
  13635. * @param quat The quaternion rotation that the bone should be set to
  13636. * @param space The space that the rotation is in
  13637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13638. */
  13639. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13640. /**
  13641. * Set the rotation matrix of the bone in local of world space
  13642. * @param rotMat The rotation matrix that the bone should be set to
  13643. * @param space The space that the rotation is in
  13644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13645. */
  13646. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13647. private _rotateWithMatrix;
  13648. private _getNegativeRotationToRef;
  13649. /**
  13650. * Get the position of the bone in local or world space
  13651. * @param space The space that the returned position is in
  13652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13653. * @returns The position of the bone
  13654. */
  13655. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13656. /**
  13657. * Copy the position of the bone to a vector3 in local or world space
  13658. * @param space The space that the returned position is in
  13659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13660. * @param result The vector3 to copy the position to
  13661. */
  13662. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13663. /**
  13664. * Get the absolute position of the bone (world space)
  13665. * @param mesh The mesh that this bone is attached to
  13666. * @returns The absolute position of the bone
  13667. */
  13668. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13669. /**
  13670. * Copy the absolute position of the bone (world space) to the result param
  13671. * @param mesh The mesh that this bone is attached to
  13672. * @param result The vector3 to copy the absolute position to
  13673. */
  13674. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13675. /**
  13676. * Compute the absolute transforms of this bone and its children
  13677. */
  13678. computeAbsoluteTransforms(): void;
  13679. /**
  13680. * Get the world direction from an axis that is in the local space of the bone
  13681. * @param localAxis The local direction that is used to compute the world direction
  13682. * @param mesh The mesh that this bone is attached to
  13683. * @returns The world direction
  13684. */
  13685. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13686. /**
  13687. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13688. * @param localAxis The local direction that is used to compute the world direction
  13689. * @param mesh The mesh that this bone is attached to
  13690. * @param result The vector3 that the world direction will be copied to
  13691. */
  13692. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13693. /**
  13694. * Get the euler rotation of the bone in local or world space
  13695. * @param space The space that the rotation should be in
  13696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13697. * @returns The euler rotation
  13698. */
  13699. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13700. /**
  13701. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13702. * @param space The space that the rotation should be in
  13703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13704. * @param result The vector3 that the rotation should be copied to
  13705. */
  13706. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13707. /**
  13708. * Get the quaternion rotation of the bone in either local or world space
  13709. * @param space The space that the rotation should be in
  13710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13711. * @returns The quaternion rotation
  13712. */
  13713. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13714. /**
  13715. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13716. * @param space The space that the rotation should be in
  13717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13718. * @param result The quaternion that the rotation should be copied to
  13719. */
  13720. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13721. /**
  13722. * Get the rotation matrix of the bone in local or world space
  13723. * @param space The space that the rotation should be in
  13724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13725. * @returns The rotation matrix
  13726. */
  13727. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13728. /**
  13729. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13730. * @param space The space that the rotation should be in
  13731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13732. * @param result The quaternion that the rotation should be copied to
  13733. */
  13734. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13735. /**
  13736. * Get the world position of a point that is in the local space of the bone
  13737. * @param position The local position
  13738. * @param mesh The mesh that this bone is attached to
  13739. * @returns The world position
  13740. */
  13741. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13742. /**
  13743. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13744. * @param position The local position
  13745. * @param mesh The mesh that this bone is attached to
  13746. * @param result The vector3 that the world position should be copied to
  13747. */
  13748. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13749. /**
  13750. * Get the local position of a point that is in world space
  13751. * @param position The world position
  13752. * @param mesh The mesh that this bone is attached to
  13753. * @returns The local position
  13754. */
  13755. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13756. /**
  13757. * Get the local position of a point that is in world space and copy it to the result param
  13758. * @param position The world position
  13759. * @param mesh The mesh that this bone is attached to
  13760. * @param result The vector3 that the local position should be copied to
  13761. */
  13762. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13763. }
  13764. }
  13765. declare module BABYLON {
  13766. /**
  13767. * 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.
  13768. * @see https://doc.babylonjs.com/how_to/transformnode
  13769. */
  13770. export class TransformNode extends Node {
  13771. /**
  13772. * Object will not rotate to face the camera
  13773. */
  13774. static BILLBOARDMODE_NONE: number;
  13775. /**
  13776. * Object will rotate to face the camera but only on the x axis
  13777. */
  13778. static BILLBOARDMODE_X: number;
  13779. /**
  13780. * Object will rotate to face the camera but only on the y axis
  13781. */
  13782. static BILLBOARDMODE_Y: number;
  13783. /**
  13784. * Object will rotate to face the camera but only on the z axis
  13785. */
  13786. static BILLBOARDMODE_Z: number;
  13787. /**
  13788. * Object will rotate to face the camera
  13789. */
  13790. static BILLBOARDMODE_ALL: number;
  13791. /**
  13792. * Object will rotate to face the camera's position instead of orientation
  13793. */
  13794. static BILLBOARDMODE_USE_POSITION: number;
  13795. private _forward;
  13796. private _forwardInverted;
  13797. private _up;
  13798. private _right;
  13799. private _rightInverted;
  13800. private _position;
  13801. private _rotation;
  13802. private _rotationQuaternion;
  13803. protected _scaling: Vector3;
  13804. protected _isDirty: boolean;
  13805. private _transformToBoneReferal;
  13806. private _isAbsoluteSynced;
  13807. private _billboardMode;
  13808. /**
  13809. * Gets or sets the billboard mode. Default is 0.
  13810. *
  13811. * | Value | Type | Description |
  13812. * | --- | --- | --- |
  13813. * | 0 | BILLBOARDMODE_NONE | |
  13814. * | 1 | BILLBOARDMODE_X | |
  13815. * | 2 | BILLBOARDMODE_Y | |
  13816. * | 4 | BILLBOARDMODE_Z | |
  13817. * | 7 | BILLBOARDMODE_ALL | |
  13818. *
  13819. */
  13820. billboardMode: number;
  13821. private _preserveParentRotationForBillboard;
  13822. /**
  13823. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13824. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13825. */
  13826. preserveParentRotationForBillboard: boolean;
  13827. /**
  13828. * 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
  13829. */
  13830. scalingDeterminant: number;
  13831. private _infiniteDistance;
  13832. /**
  13833. * Gets or sets the distance of the object to max, often used by skybox
  13834. */
  13835. infiniteDistance: boolean;
  13836. /**
  13837. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13838. * By default the system will update normals to compensate
  13839. */
  13840. ignoreNonUniformScaling: boolean;
  13841. /**
  13842. * 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
  13843. */
  13844. reIntegrateRotationIntoRotationQuaternion: boolean;
  13845. /** @hidden */
  13846. _poseMatrix: Nullable<Matrix>;
  13847. /** @hidden */
  13848. _localMatrix: Matrix;
  13849. private _usePivotMatrix;
  13850. private _absolutePosition;
  13851. private _absoluteScaling;
  13852. private _absoluteRotationQuaternion;
  13853. private _pivotMatrix;
  13854. private _pivotMatrixInverse;
  13855. protected _postMultiplyPivotMatrix: boolean;
  13856. protected _isWorldMatrixFrozen: boolean;
  13857. /** @hidden */
  13858. _indexInSceneTransformNodesArray: number;
  13859. /**
  13860. * An event triggered after the world matrix is updated
  13861. */
  13862. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13863. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13864. /**
  13865. * Gets a string identifying the name of the class
  13866. * @returns "TransformNode" string
  13867. */
  13868. getClassName(): string;
  13869. /**
  13870. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13871. */
  13872. position: Vector3;
  13873. /**
  13874. * 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)).
  13875. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13876. */
  13877. rotation: Vector3;
  13878. /**
  13879. * 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)).
  13880. */
  13881. scaling: Vector3;
  13882. /**
  13883. * 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).
  13884. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13885. */
  13886. rotationQuaternion: Nullable<Quaternion>;
  13887. /**
  13888. * The forward direction of that transform in world space.
  13889. */
  13890. readonly forward: Vector3;
  13891. /**
  13892. * The up direction of that transform in world space.
  13893. */
  13894. readonly up: Vector3;
  13895. /**
  13896. * The right direction of that transform in world space.
  13897. */
  13898. readonly right: Vector3;
  13899. /**
  13900. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13901. * @param matrix the matrix to copy the pose from
  13902. * @returns this TransformNode.
  13903. */
  13904. updatePoseMatrix(matrix: Matrix): TransformNode;
  13905. /**
  13906. * Returns the mesh Pose matrix.
  13907. * @returns the pose matrix
  13908. */
  13909. getPoseMatrix(): Matrix;
  13910. /** @hidden */
  13911. _isSynchronized(): boolean;
  13912. /** @hidden */
  13913. _initCache(): void;
  13914. /**
  13915. * Flag the transform node as dirty (Forcing it to update everything)
  13916. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13917. * @returns this transform node
  13918. */
  13919. markAsDirty(property: string): TransformNode;
  13920. /**
  13921. * Returns the current mesh absolute position.
  13922. * Returns a Vector3.
  13923. */
  13924. readonly absolutePosition: Vector3;
  13925. /**
  13926. * Returns the current mesh absolute scaling.
  13927. * Returns a Vector3.
  13928. */
  13929. readonly absoluteScaling: Vector3;
  13930. /**
  13931. * Returns the current mesh absolute rotation.
  13932. * Returns a Quaternion.
  13933. */
  13934. readonly absoluteRotationQuaternion: Quaternion;
  13935. /**
  13936. * Sets a new matrix to apply before all other transformation
  13937. * @param matrix defines the transform matrix
  13938. * @returns the current TransformNode
  13939. */
  13940. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13941. /**
  13942. * Sets a new pivot matrix to the current node
  13943. * @param matrix defines the new pivot matrix to use
  13944. * @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
  13945. * @returns the current TransformNode
  13946. */
  13947. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13948. /**
  13949. * Returns the mesh pivot matrix.
  13950. * Default : Identity.
  13951. * @returns the matrix
  13952. */
  13953. getPivotMatrix(): Matrix;
  13954. /**
  13955. * Instantiate (when possible) or clone that node with its hierarchy
  13956. * @param newParent defines the new parent to use for the instance (or clone)
  13957. * @returns an instance (or a clone) of the current node with its hiearchy
  13958. */
  13959. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13960. /**
  13961. * Prevents the World matrix to be computed any longer
  13962. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13963. * @returns the TransformNode.
  13964. */
  13965. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13966. /**
  13967. * Allows back the World matrix computation.
  13968. * @returns the TransformNode.
  13969. */
  13970. unfreezeWorldMatrix(): this;
  13971. /**
  13972. * True if the World matrix has been frozen.
  13973. */
  13974. readonly isWorldMatrixFrozen: boolean;
  13975. /**
  13976. * Retuns the mesh absolute position in the World.
  13977. * @returns a Vector3.
  13978. */
  13979. getAbsolutePosition(): Vector3;
  13980. /**
  13981. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13982. * @param absolutePosition the absolute position to set
  13983. * @returns the TransformNode.
  13984. */
  13985. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13986. /**
  13987. * Sets the mesh position in its local space.
  13988. * @param vector3 the position to set in localspace
  13989. * @returns the TransformNode.
  13990. */
  13991. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13992. /**
  13993. * Returns the mesh position in the local space from the current World matrix values.
  13994. * @returns a new Vector3.
  13995. */
  13996. getPositionExpressedInLocalSpace(): Vector3;
  13997. /**
  13998. * Translates the mesh along the passed Vector3 in its local space.
  13999. * @param vector3 the distance to translate in localspace
  14000. * @returns the TransformNode.
  14001. */
  14002. locallyTranslate(vector3: Vector3): TransformNode;
  14003. private static _lookAtVectorCache;
  14004. /**
  14005. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14006. * @param targetPoint the position (must be in same space as current mesh) to look at
  14007. * @param yawCor optional yaw (y-axis) correction in radians
  14008. * @param pitchCor optional pitch (x-axis) correction in radians
  14009. * @param rollCor optional roll (z-axis) correction in radians
  14010. * @param space the choosen space of the target
  14011. * @returns the TransformNode.
  14012. */
  14013. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14014. /**
  14015. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14016. * This Vector3 is expressed in the World space.
  14017. * @param localAxis axis to rotate
  14018. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14019. */
  14020. getDirection(localAxis: Vector3): Vector3;
  14021. /**
  14022. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14023. * localAxis is expressed in the mesh local space.
  14024. * result is computed in the Wordl space from the mesh World matrix.
  14025. * @param localAxis axis to rotate
  14026. * @param result the resulting transformnode
  14027. * @returns this TransformNode.
  14028. */
  14029. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14030. /**
  14031. * Sets this transform node rotation to the given local axis.
  14032. * @param localAxis the axis in local space
  14033. * @param yawCor optional yaw (y-axis) correction in radians
  14034. * @param pitchCor optional pitch (x-axis) correction in radians
  14035. * @param rollCor optional roll (z-axis) correction in radians
  14036. * @returns this TransformNode
  14037. */
  14038. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14039. /**
  14040. * Sets a new pivot point to the current node
  14041. * @param point defines the new pivot point to use
  14042. * @param space defines if the point is in world or local space (local by default)
  14043. * @returns the current TransformNode
  14044. */
  14045. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14046. /**
  14047. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14048. * @returns the pivot point
  14049. */
  14050. getPivotPoint(): Vector3;
  14051. /**
  14052. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14053. * @param result the vector3 to store the result
  14054. * @returns this TransformNode.
  14055. */
  14056. getPivotPointToRef(result: Vector3): TransformNode;
  14057. /**
  14058. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14059. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14060. */
  14061. getAbsolutePivotPoint(): Vector3;
  14062. /**
  14063. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14064. * @param result vector3 to store the result
  14065. * @returns this TransformNode.
  14066. */
  14067. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14068. /**
  14069. * Defines the passed node as the parent of the current node.
  14070. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14071. * @see https://doc.babylonjs.com/how_to/parenting
  14072. * @param node the node ot set as the parent
  14073. * @returns this TransformNode.
  14074. */
  14075. setParent(node: Nullable<Node>): TransformNode;
  14076. private _nonUniformScaling;
  14077. /**
  14078. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14079. */
  14080. readonly nonUniformScaling: boolean;
  14081. /** @hidden */
  14082. _updateNonUniformScalingState(value: boolean): boolean;
  14083. /**
  14084. * Attach the current TransformNode to another TransformNode associated with a bone
  14085. * @param bone Bone affecting the TransformNode
  14086. * @param affectedTransformNode TransformNode associated with the bone
  14087. * @returns this object
  14088. */
  14089. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14090. /**
  14091. * Detach the transform node if its associated with a bone
  14092. * @returns this object
  14093. */
  14094. detachFromBone(): TransformNode;
  14095. private static _rotationAxisCache;
  14096. /**
  14097. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14098. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14099. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14100. * The passed axis is also normalized.
  14101. * @param axis the axis to rotate around
  14102. * @param amount the amount to rotate in radians
  14103. * @param space Space to rotate in (Default: local)
  14104. * @returns the TransformNode.
  14105. */
  14106. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14107. /**
  14108. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14109. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14110. * The passed axis is also normalized. .
  14111. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14112. * @param point the point to rotate around
  14113. * @param axis the axis to rotate around
  14114. * @param amount the amount to rotate in radians
  14115. * @returns the TransformNode
  14116. */
  14117. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14118. /**
  14119. * Translates the mesh along the axis vector for the passed distance in the given space.
  14120. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14121. * @param axis the axis to translate in
  14122. * @param distance the distance to translate
  14123. * @param space Space to rotate in (Default: local)
  14124. * @returns the TransformNode.
  14125. */
  14126. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14127. /**
  14128. * Adds a rotation step to the mesh current rotation.
  14129. * x, y, z are Euler angles expressed in radians.
  14130. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14131. * This means this rotation is made in the mesh local space only.
  14132. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14133. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14134. * ```javascript
  14135. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14136. * ```
  14137. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14138. * 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.
  14139. * @param x Rotation to add
  14140. * @param y Rotation to add
  14141. * @param z Rotation to add
  14142. * @returns the TransformNode.
  14143. */
  14144. addRotation(x: number, y: number, z: number): TransformNode;
  14145. /**
  14146. * @hidden
  14147. */
  14148. protected _getEffectiveParent(): Nullable<Node>;
  14149. /**
  14150. * Computes the world matrix of the node
  14151. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14152. * @returns the world matrix
  14153. */
  14154. computeWorldMatrix(force?: boolean): Matrix;
  14155. protected _afterComputeWorldMatrix(): void;
  14156. /**
  14157. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14158. * @param func callback function to add
  14159. *
  14160. * @returns the TransformNode.
  14161. */
  14162. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14163. /**
  14164. * Removes a registered callback function.
  14165. * @param func callback function to remove
  14166. * @returns the TransformNode.
  14167. */
  14168. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14169. /**
  14170. * Gets the position of the current mesh in camera space
  14171. * @param camera defines the camera to use
  14172. * @returns a position
  14173. */
  14174. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14175. /**
  14176. * Returns the distance from the mesh to the active camera
  14177. * @param camera defines the camera to use
  14178. * @returns the distance
  14179. */
  14180. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14181. /**
  14182. * Clone the current transform node
  14183. * @param name Name of the new clone
  14184. * @param newParent New parent for the clone
  14185. * @param doNotCloneChildren Do not clone children hierarchy
  14186. * @returns the new transform node
  14187. */
  14188. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14189. /**
  14190. * Serializes the objects information.
  14191. * @param currentSerializationObject defines the object to serialize in
  14192. * @returns the serialized object
  14193. */
  14194. serialize(currentSerializationObject?: any): any;
  14195. /**
  14196. * Returns a new TransformNode object parsed from the source provided.
  14197. * @param parsedTransformNode is the source.
  14198. * @param scene the scne the object belongs to
  14199. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14200. * @returns a new TransformNode object parsed from the source provided.
  14201. */
  14202. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14203. /**
  14204. * Get all child-transformNodes of this node
  14205. * @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
  14206. * @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
  14207. * @returns an array of TransformNode
  14208. */
  14209. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14210. /**
  14211. * Releases resources associated with this transform node.
  14212. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14213. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14214. */
  14215. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14216. /**
  14217. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14218. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14219. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14220. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14221. * @returns the current mesh
  14222. */
  14223. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14224. private _syncAbsoluteScalingAndRotation;
  14225. }
  14226. }
  14227. declare module BABYLON {
  14228. /**
  14229. * Defines the types of pose enabled controllers that are supported
  14230. */
  14231. export enum PoseEnabledControllerType {
  14232. /**
  14233. * HTC Vive
  14234. */
  14235. VIVE = 0,
  14236. /**
  14237. * Oculus Rift
  14238. */
  14239. OCULUS = 1,
  14240. /**
  14241. * Windows mixed reality
  14242. */
  14243. WINDOWS = 2,
  14244. /**
  14245. * Samsung gear VR
  14246. */
  14247. GEAR_VR = 3,
  14248. /**
  14249. * Google Daydream
  14250. */
  14251. DAYDREAM = 4,
  14252. /**
  14253. * Generic
  14254. */
  14255. GENERIC = 5
  14256. }
  14257. /**
  14258. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14259. */
  14260. export interface MutableGamepadButton {
  14261. /**
  14262. * Value of the button/trigger
  14263. */
  14264. value: number;
  14265. /**
  14266. * If the button/trigger is currently touched
  14267. */
  14268. touched: boolean;
  14269. /**
  14270. * If the button/trigger is currently pressed
  14271. */
  14272. pressed: boolean;
  14273. }
  14274. /**
  14275. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14276. * @hidden
  14277. */
  14278. export interface ExtendedGamepadButton extends GamepadButton {
  14279. /**
  14280. * If the button/trigger is currently pressed
  14281. */
  14282. readonly pressed: boolean;
  14283. /**
  14284. * If the button/trigger is currently touched
  14285. */
  14286. readonly touched: boolean;
  14287. /**
  14288. * Value of the button/trigger
  14289. */
  14290. readonly value: number;
  14291. }
  14292. /** @hidden */
  14293. export interface _GamePadFactory {
  14294. /**
  14295. * Returns wether or not the current gamepad can be created for this type of controller.
  14296. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14297. * @returns true if it can be created, otherwise false
  14298. */
  14299. canCreate(gamepadInfo: any): boolean;
  14300. /**
  14301. * Creates a new instance of the Gamepad.
  14302. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14303. * @returns the new gamepad instance
  14304. */
  14305. create(gamepadInfo: any): Gamepad;
  14306. }
  14307. /**
  14308. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14309. */
  14310. export class PoseEnabledControllerHelper {
  14311. /** @hidden */
  14312. static _ControllerFactories: _GamePadFactory[];
  14313. /** @hidden */
  14314. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14315. /**
  14316. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14317. * @param vrGamepad the gamepad to initialized
  14318. * @returns a vr controller of the type the gamepad identified as
  14319. */
  14320. static InitiateController(vrGamepad: any): Gamepad;
  14321. }
  14322. /**
  14323. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14324. */
  14325. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14326. /**
  14327. * If the controller is used in a webXR session
  14328. */
  14329. isXR: boolean;
  14330. private _deviceRoomPosition;
  14331. private _deviceRoomRotationQuaternion;
  14332. /**
  14333. * The device position in babylon space
  14334. */
  14335. devicePosition: Vector3;
  14336. /**
  14337. * The device rotation in babylon space
  14338. */
  14339. deviceRotationQuaternion: Quaternion;
  14340. /**
  14341. * The scale factor of the device in babylon space
  14342. */
  14343. deviceScaleFactor: number;
  14344. /**
  14345. * (Likely devicePosition should be used instead) The device position in its room space
  14346. */
  14347. position: Vector3;
  14348. /**
  14349. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14350. */
  14351. rotationQuaternion: Quaternion;
  14352. /**
  14353. * The type of controller (Eg. Windows mixed reality)
  14354. */
  14355. controllerType: PoseEnabledControllerType;
  14356. protected _calculatedPosition: Vector3;
  14357. private _calculatedRotation;
  14358. /**
  14359. * The raw pose from the device
  14360. */
  14361. rawPose: DevicePose;
  14362. private _trackPosition;
  14363. private _maxRotationDistFromHeadset;
  14364. private _draggedRoomRotation;
  14365. /**
  14366. * @hidden
  14367. */
  14368. _disableTrackPosition(fixedPosition: Vector3): void;
  14369. /**
  14370. * Internal, the mesh attached to the controller
  14371. * @hidden
  14372. */
  14373. _mesh: Nullable<AbstractMesh>;
  14374. private _poseControlledCamera;
  14375. private _leftHandSystemQuaternion;
  14376. /**
  14377. * Internal, matrix used to convert room space to babylon space
  14378. * @hidden
  14379. */
  14380. _deviceToWorld: Matrix;
  14381. /**
  14382. * Node to be used when casting a ray from the controller
  14383. * @hidden
  14384. */
  14385. _pointingPoseNode: Nullable<TransformNode>;
  14386. /**
  14387. * Name of the child mesh that can be used to cast a ray from the controller
  14388. */
  14389. static readonly POINTING_POSE: string;
  14390. /**
  14391. * Creates a new PoseEnabledController from a gamepad
  14392. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14393. */
  14394. constructor(browserGamepad: any);
  14395. private _workingMatrix;
  14396. /**
  14397. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14398. */
  14399. update(): void;
  14400. /**
  14401. * Updates only the pose device and mesh without doing any button event checking
  14402. */
  14403. protected _updatePoseAndMesh(): void;
  14404. /**
  14405. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14406. * @param poseData raw pose fromthe device
  14407. */
  14408. updateFromDevice(poseData: DevicePose): void;
  14409. /**
  14410. * @hidden
  14411. */
  14412. _meshAttachedObservable: Observable<AbstractMesh>;
  14413. /**
  14414. * Attaches a mesh to the controller
  14415. * @param mesh the mesh to be attached
  14416. */
  14417. attachToMesh(mesh: AbstractMesh): void;
  14418. /**
  14419. * Attaches the controllers mesh to a camera
  14420. * @param camera the camera the mesh should be attached to
  14421. */
  14422. attachToPoseControlledCamera(camera: TargetCamera): void;
  14423. /**
  14424. * Disposes of the controller
  14425. */
  14426. dispose(): void;
  14427. /**
  14428. * The mesh that is attached to the controller
  14429. */
  14430. readonly mesh: Nullable<AbstractMesh>;
  14431. /**
  14432. * Gets the ray of the controller in the direction the controller is pointing
  14433. * @param length the length the resulting ray should be
  14434. * @returns a ray in the direction the controller is pointing
  14435. */
  14436. getForwardRay(length?: number): Ray;
  14437. }
  14438. }
  14439. declare module BABYLON {
  14440. /**
  14441. * Defines the WebVRController object that represents controllers tracked in 3D space
  14442. */
  14443. export abstract class WebVRController extends PoseEnabledController {
  14444. /**
  14445. * Internal, the default controller model for the controller
  14446. */
  14447. protected _defaultModel: Nullable<AbstractMesh>;
  14448. /**
  14449. * Fired when the trigger state has changed
  14450. */
  14451. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14452. /**
  14453. * Fired when the main button state has changed
  14454. */
  14455. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14456. /**
  14457. * Fired when the secondary button state has changed
  14458. */
  14459. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14460. /**
  14461. * Fired when the pad state has changed
  14462. */
  14463. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14464. /**
  14465. * Fired when controllers stick values have changed
  14466. */
  14467. onPadValuesChangedObservable: Observable<StickValues>;
  14468. /**
  14469. * Array of button availible on the controller
  14470. */
  14471. protected _buttons: Array<MutableGamepadButton>;
  14472. private _onButtonStateChange;
  14473. /**
  14474. * Fired when a controller button's state has changed
  14475. * @param callback the callback containing the button that was modified
  14476. */
  14477. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14478. /**
  14479. * X and Y axis corresponding to the controllers joystick
  14480. */
  14481. pad: StickValues;
  14482. /**
  14483. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14484. */
  14485. hand: string;
  14486. /**
  14487. * The default controller model for the controller
  14488. */
  14489. readonly defaultModel: Nullable<AbstractMesh>;
  14490. /**
  14491. * Creates a new WebVRController from a gamepad
  14492. * @param vrGamepad the gamepad that the WebVRController should be created from
  14493. */
  14494. constructor(vrGamepad: any);
  14495. /**
  14496. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14497. */
  14498. update(): void;
  14499. /**
  14500. * Function to be called when a button is modified
  14501. */
  14502. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14503. /**
  14504. * Loads a mesh and attaches it to the controller
  14505. * @param scene the scene the mesh should be added to
  14506. * @param meshLoaded callback for when the mesh has been loaded
  14507. */
  14508. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14509. private _setButtonValue;
  14510. private _changes;
  14511. private _checkChanges;
  14512. /**
  14513. * Disposes of th webVRCOntroller
  14514. */
  14515. dispose(): void;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /**
  14520. * The HemisphericLight simulates the ambient environment light,
  14521. * so the passed direction is the light reflection direction, not the incoming direction.
  14522. */
  14523. export class HemisphericLight extends Light {
  14524. /**
  14525. * The groundColor is the light in the opposite direction to the one specified during creation.
  14526. * 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.
  14527. */
  14528. groundColor: Color3;
  14529. /**
  14530. * The light reflection direction, not the incoming direction.
  14531. */
  14532. direction: Vector3;
  14533. /**
  14534. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14535. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14536. * The HemisphericLight can't cast shadows.
  14537. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14538. * @param name The friendly name of the light
  14539. * @param direction The direction of the light reflection
  14540. * @param scene The scene the light belongs to
  14541. */
  14542. constructor(name: string, direction: Vector3, scene: Scene);
  14543. protected _buildUniformLayout(): void;
  14544. /**
  14545. * Returns the string "HemisphericLight".
  14546. * @return The class name
  14547. */
  14548. getClassName(): string;
  14549. /**
  14550. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14551. * Returns the updated direction.
  14552. * @param target The target the direction should point to
  14553. * @return The computed direction
  14554. */
  14555. setDirectionToTarget(target: Vector3): Vector3;
  14556. /**
  14557. * Returns the shadow generator associated to the light.
  14558. * @returns Always null for hemispheric lights because it does not support shadows.
  14559. */
  14560. getShadowGenerator(): Nullable<IShadowGenerator>;
  14561. /**
  14562. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14563. * @param effect The effect to update
  14564. * @param lightIndex The index of the light in the effect to update
  14565. * @returns The hemispheric light
  14566. */
  14567. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14568. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14569. /**
  14570. * Computes the world matrix of the node
  14571. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14572. * @param useWasUpdatedFlag defines a reserved property
  14573. * @returns the world matrix
  14574. */
  14575. computeWorldMatrix(): Matrix;
  14576. /**
  14577. * Returns the integer 3.
  14578. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14579. */
  14580. getTypeID(): number;
  14581. /**
  14582. * Prepares the list of defines specific to the light type.
  14583. * @param defines the list of defines
  14584. * @param lightIndex defines the index of the light for the effect
  14585. */
  14586. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14587. }
  14588. }
  14589. declare module BABYLON {
  14590. /** @hidden */
  14591. export var vrMultiviewToSingleviewPixelShader: {
  14592. name: string;
  14593. shader: string;
  14594. };
  14595. }
  14596. declare module BABYLON {
  14597. /**
  14598. * Renders to multiple views with a single draw call
  14599. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14600. */
  14601. export class MultiviewRenderTarget extends RenderTargetTexture {
  14602. /**
  14603. * Creates a multiview render target
  14604. * @param scene scene used with the render target
  14605. * @param size the size of the render target (used for each view)
  14606. */
  14607. constructor(scene: Scene, size?: number | {
  14608. width: number;
  14609. height: number;
  14610. } | {
  14611. ratio: number;
  14612. });
  14613. /**
  14614. * @hidden
  14615. * @param faceIndex the face index, if its a cube texture
  14616. */
  14617. _bindFrameBuffer(faceIndex?: number): void;
  14618. /**
  14619. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14620. * @returns the view count
  14621. */
  14622. getViewCount(): number;
  14623. }
  14624. }
  14625. declare module BABYLON {
  14626. /**
  14627. * Represents a camera frustum
  14628. */
  14629. export class Frustum {
  14630. /**
  14631. * Gets the planes representing the frustum
  14632. * @param transform matrix to be applied to the returned planes
  14633. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14634. */
  14635. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14636. /**
  14637. * Gets the near frustum plane transformed by the transform matrix
  14638. * @param transform transformation matrix to be applied to the resulting frustum plane
  14639. * @param frustumPlane the resuling frustum plane
  14640. */
  14641. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14642. /**
  14643. * Gets the far frustum plane transformed by the transform matrix
  14644. * @param transform transformation matrix to be applied to the resulting frustum plane
  14645. * @param frustumPlane the resuling frustum plane
  14646. */
  14647. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14648. /**
  14649. * Gets the left frustum plane transformed by the transform matrix
  14650. * @param transform transformation matrix to be applied to the resulting frustum plane
  14651. * @param frustumPlane the resuling frustum plane
  14652. */
  14653. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14654. /**
  14655. * Gets the right frustum plane transformed by the transform matrix
  14656. * @param transform transformation matrix to be applied to the resulting frustum plane
  14657. * @param frustumPlane the resuling frustum plane
  14658. */
  14659. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14660. /**
  14661. * Gets the top frustum plane transformed by the transform matrix
  14662. * @param transform transformation matrix to be applied to the resulting frustum plane
  14663. * @param frustumPlane the resuling frustum plane
  14664. */
  14665. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14666. /**
  14667. * Gets the bottom frustum plane transformed by the transform matrix
  14668. * @param transform transformation matrix to be applied to the resulting frustum plane
  14669. * @param frustumPlane the resuling frustum plane
  14670. */
  14671. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14672. /**
  14673. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14674. * @param transform transformation matrix to be applied to the resulting frustum planes
  14675. * @param frustumPlanes the resuling frustum planes
  14676. */
  14677. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14678. }
  14679. }
  14680. declare module BABYLON {
  14681. interface Engine {
  14682. /**
  14683. * Creates a new multiview render target
  14684. * @param width defines the width of the texture
  14685. * @param height defines the height of the texture
  14686. * @returns the created multiview texture
  14687. */
  14688. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14689. /**
  14690. * Binds a multiview framebuffer to be drawn to
  14691. * @param multiviewTexture texture to bind
  14692. */
  14693. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14694. }
  14695. interface Camera {
  14696. /**
  14697. * @hidden
  14698. * 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)
  14699. */
  14700. _useMultiviewToSingleView: boolean;
  14701. /**
  14702. * @hidden
  14703. * 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)
  14704. */
  14705. _multiviewTexture: Nullable<RenderTargetTexture>;
  14706. /**
  14707. * @hidden
  14708. * ensures the multiview texture of the camera exists and has the specified width/height
  14709. * @param width height to set on the multiview texture
  14710. * @param height width to set on the multiview texture
  14711. */
  14712. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14713. }
  14714. interface Scene {
  14715. /** @hidden */
  14716. _transformMatrixR: Matrix;
  14717. /** @hidden */
  14718. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14719. /** @hidden */
  14720. _createMultiviewUbo(): void;
  14721. /** @hidden */
  14722. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14723. /** @hidden */
  14724. _renderMultiviewToSingleView(camera: Camera): void;
  14725. }
  14726. }
  14727. declare module BABYLON {
  14728. /**
  14729. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14730. * This will not be used for webXR as it supports displaying texture arrays directly
  14731. */
  14732. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14733. /**
  14734. * Initializes a VRMultiviewToSingleview
  14735. * @param name name of the post process
  14736. * @param camera camera to be applied to
  14737. * @param scaleFactor scaling factor to the size of the output texture
  14738. */
  14739. constructor(name: string, camera: Camera, scaleFactor: number);
  14740. }
  14741. }
  14742. declare module BABYLON {
  14743. interface Engine {
  14744. /** @hidden */
  14745. _vrDisplay: any;
  14746. /** @hidden */
  14747. _vrSupported: boolean;
  14748. /** @hidden */
  14749. _oldSize: Size;
  14750. /** @hidden */
  14751. _oldHardwareScaleFactor: number;
  14752. /** @hidden */
  14753. _vrExclusivePointerMode: boolean;
  14754. /** @hidden */
  14755. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14756. /** @hidden */
  14757. _onVRDisplayPointerRestricted: () => void;
  14758. /** @hidden */
  14759. _onVRDisplayPointerUnrestricted: () => void;
  14760. /** @hidden */
  14761. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14762. /** @hidden */
  14763. _onVrDisplayDisconnect: Nullable<() => void>;
  14764. /** @hidden */
  14765. _onVrDisplayPresentChange: Nullable<() => void>;
  14766. /**
  14767. * Observable signaled when VR display mode changes
  14768. */
  14769. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14770. /**
  14771. * Observable signaled when VR request present is complete
  14772. */
  14773. onVRRequestPresentComplete: Observable<boolean>;
  14774. /**
  14775. * Observable signaled when VR request present starts
  14776. */
  14777. onVRRequestPresentStart: Observable<Engine>;
  14778. /**
  14779. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14780. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14781. */
  14782. isInVRExclusivePointerMode: boolean;
  14783. /**
  14784. * Gets a boolean indicating if a webVR device was detected
  14785. * @returns true if a webVR device was detected
  14786. */
  14787. isVRDevicePresent(): boolean;
  14788. /**
  14789. * Gets the current webVR device
  14790. * @returns the current webVR device (or null)
  14791. */
  14792. getVRDevice(): any;
  14793. /**
  14794. * Initializes a webVR display and starts listening to display change events
  14795. * The onVRDisplayChangedObservable will be notified upon these changes
  14796. * @returns A promise containing a VRDisplay and if vr is supported
  14797. */
  14798. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14799. /** @hidden */
  14800. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14801. /**
  14802. * Call this function to switch to webVR mode
  14803. * Will do nothing if webVR is not supported or if there is no webVR device
  14804. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14805. */
  14806. enableVR(): void;
  14807. /** @hidden */
  14808. _onVRFullScreenTriggered(): void;
  14809. }
  14810. }
  14811. declare module BABYLON {
  14812. /**
  14813. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14814. * IMPORTANT!! The data is right-hand data.
  14815. * @export
  14816. * @interface DevicePose
  14817. */
  14818. export interface DevicePose {
  14819. /**
  14820. * The position of the device, values in array are [x,y,z].
  14821. */
  14822. readonly position: Nullable<Float32Array>;
  14823. /**
  14824. * The linearVelocity of the device, values in array are [x,y,z].
  14825. */
  14826. readonly linearVelocity: Nullable<Float32Array>;
  14827. /**
  14828. * The linearAcceleration of the device, values in array are [x,y,z].
  14829. */
  14830. readonly linearAcceleration: Nullable<Float32Array>;
  14831. /**
  14832. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14833. */
  14834. readonly orientation: Nullable<Float32Array>;
  14835. /**
  14836. * The angularVelocity of the device, values in array are [x,y,z].
  14837. */
  14838. readonly angularVelocity: Nullable<Float32Array>;
  14839. /**
  14840. * The angularAcceleration of the device, values in array are [x,y,z].
  14841. */
  14842. readonly angularAcceleration: Nullable<Float32Array>;
  14843. }
  14844. /**
  14845. * Interface representing a pose controlled object in Babylon.
  14846. * A pose controlled object has both regular pose values as well as pose values
  14847. * from an external device such as a VR head mounted display
  14848. */
  14849. export interface PoseControlled {
  14850. /**
  14851. * The position of the object in babylon space.
  14852. */
  14853. position: Vector3;
  14854. /**
  14855. * The rotation quaternion of the object in babylon space.
  14856. */
  14857. rotationQuaternion: Quaternion;
  14858. /**
  14859. * The position of the device in babylon space.
  14860. */
  14861. devicePosition?: Vector3;
  14862. /**
  14863. * The rotation quaternion of the device in babylon space.
  14864. */
  14865. deviceRotationQuaternion: Quaternion;
  14866. /**
  14867. * The raw pose coming from the device.
  14868. */
  14869. rawPose: Nullable<DevicePose>;
  14870. /**
  14871. * The scale of the device to be used when translating from device space to babylon space.
  14872. */
  14873. deviceScaleFactor: number;
  14874. /**
  14875. * Updates the poseControlled values based on the input device pose.
  14876. * @param poseData the pose data to update the object with
  14877. */
  14878. updateFromDevice(poseData: DevicePose): void;
  14879. }
  14880. /**
  14881. * Set of options to customize the webVRCamera
  14882. */
  14883. export interface WebVROptions {
  14884. /**
  14885. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14886. */
  14887. trackPosition?: boolean;
  14888. /**
  14889. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14890. */
  14891. positionScale?: number;
  14892. /**
  14893. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14894. */
  14895. displayName?: string;
  14896. /**
  14897. * Should the native controller meshes be initialized. (default: true)
  14898. */
  14899. controllerMeshes?: boolean;
  14900. /**
  14901. * Creating a default HemiLight only on controllers. (default: true)
  14902. */
  14903. defaultLightingOnControllers?: boolean;
  14904. /**
  14905. * If you don't want to use the default VR button of the helper. (default: false)
  14906. */
  14907. useCustomVRButton?: boolean;
  14908. /**
  14909. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14910. */
  14911. customVRButton?: HTMLButtonElement;
  14912. /**
  14913. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14914. */
  14915. rayLength?: number;
  14916. /**
  14917. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14918. */
  14919. defaultHeight?: number;
  14920. /**
  14921. * If multiview should be used if availible (default: false)
  14922. */
  14923. useMultiview?: boolean;
  14924. }
  14925. /**
  14926. * This represents a WebVR camera.
  14927. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14928. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14929. */
  14930. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14931. private webVROptions;
  14932. /**
  14933. * @hidden
  14934. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14935. */
  14936. _vrDevice: any;
  14937. /**
  14938. * The rawPose of the vrDevice.
  14939. */
  14940. rawPose: Nullable<DevicePose>;
  14941. private _onVREnabled;
  14942. private _specsVersion;
  14943. private _attached;
  14944. private _frameData;
  14945. protected _descendants: Array<Node>;
  14946. private _deviceRoomPosition;
  14947. /** @hidden */
  14948. _deviceRoomRotationQuaternion: Quaternion;
  14949. private _standingMatrix;
  14950. /**
  14951. * Represents device position in babylon space.
  14952. */
  14953. devicePosition: Vector3;
  14954. /**
  14955. * Represents device rotation in babylon space.
  14956. */
  14957. deviceRotationQuaternion: Quaternion;
  14958. /**
  14959. * The scale of the device to be used when translating from device space to babylon space.
  14960. */
  14961. deviceScaleFactor: number;
  14962. private _deviceToWorld;
  14963. private _worldToDevice;
  14964. /**
  14965. * References to the webVR controllers for the vrDevice.
  14966. */
  14967. controllers: Array<WebVRController>;
  14968. /**
  14969. * Emits an event when a controller is attached.
  14970. */
  14971. onControllersAttachedObservable: Observable<WebVRController[]>;
  14972. /**
  14973. * Emits an event when a controller's mesh has been loaded;
  14974. */
  14975. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14976. /**
  14977. * Emits an event when the HMD's pose has been updated.
  14978. */
  14979. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14980. private _poseSet;
  14981. /**
  14982. * If the rig cameras be used as parent instead of this camera.
  14983. */
  14984. rigParenting: boolean;
  14985. private _lightOnControllers;
  14986. private _defaultHeight?;
  14987. /**
  14988. * Instantiates a WebVRFreeCamera.
  14989. * @param name The name of the WebVRFreeCamera
  14990. * @param position The starting anchor position for the camera
  14991. * @param scene The scene the camera belongs to
  14992. * @param webVROptions a set of customizable options for the webVRCamera
  14993. */
  14994. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14995. /**
  14996. * Gets the device distance from the ground in meters.
  14997. * @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.
  14998. */
  14999. deviceDistanceToRoomGround(): number;
  15000. /**
  15001. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15002. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15003. */
  15004. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15005. /**
  15006. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15007. * @returns A promise with a boolean set to if the standing matrix is supported.
  15008. */
  15009. useStandingMatrixAsync(): Promise<boolean>;
  15010. /**
  15011. * Disposes the camera
  15012. */
  15013. dispose(): void;
  15014. /**
  15015. * Gets a vrController by name.
  15016. * @param name The name of the controller to retreive
  15017. * @returns the controller matching the name specified or null if not found
  15018. */
  15019. getControllerByName(name: string): Nullable<WebVRController>;
  15020. private _leftController;
  15021. /**
  15022. * The controller corresponding to the users left hand.
  15023. */
  15024. readonly leftController: Nullable<WebVRController>;
  15025. private _rightController;
  15026. /**
  15027. * The controller corresponding to the users right hand.
  15028. */
  15029. readonly rightController: Nullable<WebVRController>;
  15030. /**
  15031. * Casts a ray forward from the vrCamera's gaze.
  15032. * @param length Length of the ray (default: 100)
  15033. * @returns the ray corresponding to the gaze
  15034. */
  15035. getForwardRay(length?: number): Ray;
  15036. /**
  15037. * @hidden
  15038. * Updates the camera based on device's frame data
  15039. */
  15040. _checkInputs(): void;
  15041. /**
  15042. * Updates the poseControlled values based on the input device pose.
  15043. * @param poseData Pose coming from the device
  15044. */
  15045. updateFromDevice(poseData: DevicePose): void;
  15046. private _htmlElementAttached;
  15047. private _detachIfAttached;
  15048. /**
  15049. * WebVR's attach control will start broadcasting frames to the device.
  15050. * Note that in certain browsers (chrome for example) this function must be called
  15051. * within a user-interaction callback. Example:
  15052. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15053. *
  15054. * @param element html element to attach the vrDevice to
  15055. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15056. */
  15057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15058. /**
  15059. * Detaches the camera from the html element and disables VR
  15060. *
  15061. * @param element html element to detach from
  15062. */
  15063. detachControl(element: HTMLElement): void;
  15064. /**
  15065. * @returns the name of this class
  15066. */
  15067. getClassName(): string;
  15068. /**
  15069. * Calls resetPose on the vrDisplay
  15070. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15071. */
  15072. resetToCurrentRotation(): void;
  15073. /**
  15074. * @hidden
  15075. * Updates the rig cameras (left and right eye)
  15076. */
  15077. _updateRigCameras(): void;
  15078. private _workingVector;
  15079. private _oneVector;
  15080. private _workingMatrix;
  15081. private updateCacheCalled;
  15082. private _correctPositionIfNotTrackPosition;
  15083. /**
  15084. * @hidden
  15085. * Updates the cached values of the camera
  15086. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15087. */
  15088. _updateCache(ignoreParentClass?: boolean): void;
  15089. /**
  15090. * @hidden
  15091. * Get current device position in babylon world
  15092. */
  15093. _computeDevicePosition(): void;
  15094. /**
  15095. * Updates the current device position and rotation in the babylon world
  15096. */
  15097. update(): void;
  15098. /**
  15099. * @hidden
  15100. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15101. * @returns an identity matrix
  15102. */
  15103. _getViewMatrix(): Matrix;
  15104. private _tmpMatrix;
  15105. /**
  15106. * This function is called by the two RIG cameras.
  15107. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15108. * @hidden
  15109. */
  15110. _getWebVRViewMatrix(): Matrix;
  15111. /** @hidden */
  15112. _getWebVRProjectionMatrix(): Matrix;
  15113. private _onGamepadConnectedObserver;
  15114. private _onGamepadDisconnectedObserver;
  15115. private _updateCacheWhenTrackingDisabledObserver;
  15116. /**
  15117. * Initializes the controllers and their meshes
  15118. */
  15119. initControllers(): void;
  15120. }
  15121. }
  15122. declare module BABYLON {
  15123. /**
  15124. * Size options for a post process
  15125. */
  15126. export type PostProcessOptions = {
  15127. width: number;
  15128. height: number;
  15129. };
  15130. /**
  15131. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15132. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15133. */
  15134. export class PostProcess {
  15135. /** Name of the PostProcess. */
  15136. name: string;
  15137. /**
  15138. * Gets or sets the unique id of the post process
  15139. */
  15140. uniqueId: number;
  15141. /**
  15142. * Width of the texture to apply the post process on
  15143. */
  15144. width: number;
  15145. /**
  15146. * Height of the texture to apply the post process on
  15147. */
  15148. height: number;
  15149. /**
  15150. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15151. * @hidden
  15152. */
  15153. _outputTexture: Nullable<InternalTexture>;
  15154. /**
  15155. * Sampling mode used by the shader
  15156. * See https://doc.babylonjs.com/classes/3.1/texture
  15157. */
  15158. renderTargetSamplingMode: number;
  15159. /**
  15160. * Clear color to use when screen clearing
  15161. */
  15162. clearColor: Color4;
  15163. /**
  15164. * If the buffer needs to be cleared before applying the post process. (default: true)
  15165. * Should be set to false if shader will overwrite all previous pixels.
  15166. */
  15167. autoClear: boolean;
  15168. /**
  15169. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15170. */
  15171. alphaMode: number;
  15172. /**
  15173. * Sets the setAlphaBlendConstants of the babylon engine
  15174. */
  15175. alphaConstants: Color4;
  15176. /**
  15177. * Animations to be used for the post processing
  15178. */
  15179. animations: Animation[];
  15180. /**
  15181. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15182. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15183. */
  15184. enablePixelPerfectMode: boolean;
  15185. /**
  15186. * Force the postprocess to be applied without taking in account viewport
  15187. */
  15188. forceFullscreenViewport: boolean;
  15189. /**
  15190. * List of inspectable custom properties (used by the Inspector)
  15191. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15192. */
  15193. inspectableCustomProperties: IInspectable[];
  15194. /**
  15195. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15196. *
  15197. * | Value | Type | Description |
  15198. * | ----- | ----------------------------------- | ----------- |
  15199. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15200. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15201. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15202. *
  15203. */
  15204. scaleMode: number;
  15205. /**
  15206. * Force textures to be a power of two (default: false)
  15207. */
  15208. alwaysForcePOT: boolean;
  15209. private _samples;
  15210. /**
  15211. * Number of sample textures (default: 1)
  15212. */
  15213. samples: number;
  15214. /**
  15215. * Modify the scale of the post process to be the same as the viewport (default: false)
  15216. */
  15217. adaptScaleToCurrentViewport: boolean;
  15218. private _camera;
  15219. private _scene;
  15220. private _engine;
  15221. private _options;
  15222. private _reusable;
  15223. private _textureType;
  15224. /**
  15225. * Smart array of input and output textures for the post process.
  15226. * @hidden
  15227. */
  15228. _textures: SmartArray<InternalTexture>;
  15229. /**
  15230. * The index in _textures that corresponds to the output texture.
  15231. * @hidden
  15232. */
  15233. _currentRenderTextureInd: number;
  15234. private _effect;
  15235. private _samplers;
  15236. private _fragmentUrl;
  15237. private _vertexUrl;
  15238. private _parameters;
  15239. private _scaleRatio;
  15240. protected _indexParameters: any;
  15241. private _shareOutputWithPostProcess;
  15242. private _texelSize;
  15243. private _forcedOutputTexture;
  15244. /**
  15245. * Returns the fragment url or shader name used in the post process.
  15246. * @returns the fragment url or name in the shader store.
  15247. */
  15248. getEffectName(): string;
  15249. /**
  15250. * An event triggered when the postprocess is activated.
  15251. */
  15252. onActivateObservable: Observable<Camera>;
  15253. private _onActivateObserver;
  15254. /**
  15255. * A function that is added to the onActivateObservable
  15256. */
  15257. onActivate: Nullable<(camera: Camera) => void>;
  15258. /**
  15259. * An event triggered when the postprocess changes its size.
  15260. */
  15261. onSizeChangedObservable: Observable<PostProcess>;
  15262. private _onSizeChangedObserver;
  15263. /**
  15264. * A function that is added to the onSizeChangedObservable
  15265. */
  15266. onSizeChanged: (postProcess: PostProcess) => void;
  15267. /**
  15268. * An event triggered when the postprocess applies its effect.
  15269. */
  15270. onApplyObservable: Observable<Effect>;
  15271. private _onApplyObserver;
  15272. /**
  15273. * A function that is added to the onApplyObservable
  15274. */
  15275. onApply: (effect: Effect) => void;
  15276. /**
  15277. * An event triggered before rendering the postprocess
  15278. */
  15279. onBeforeRenderObservable: Observable<Effect>;
  15280. private _onBeforeRenderObserver;
  15281. /**
  15282. * A function that is added to the onBeforeRenderObservable
  15283. */
  15284. onBeforeRender: (effect: Effect) => void;
  15285. /**
  15286. * An event triggered after rendering the postprocess
  15287. */
  15288. onAfterRenderObservable: Observable<Effect>;
  15289. private _onAfterRenderObserver;
  15290. /**
  15291. * A function that is added to the onAfterRenderObservable
  15292. */
  15293. onAfterRender: (efect: Effect) => void;
  15294. /**
  15295. * 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
  15296. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15297. */
  15298. inputTexture: InternalTexture;
  15299. /**
  15300. * Gets the camera which post process is applied to.
  15301. * @returns The camera the post process is applied to.
  15302. */
  15303. getCamera(): Camera;
  15304. /**
  15305. * Gets the texel size of the postprocess.
  15306. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15307. */
  15308. readonly texelSize: Vector2;
  15309. /**
  15310. * Creates a new instance PostProcess
  15311. * @param name The name of the PostProcess.
  15312. * @param fragmentUrl The url of the fragment shader to be used.
  15313. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15314. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15315. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15316. * @param camera The camera to apply the render pass to.
  15317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15318. * @param engine The engine which the post process will be applied. (default: current engine)
  15319. * @param reusable If the post process can be reused on the same frame. (default: false)
  15320. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15321. * @param textureType Type of textures used when performing the post process. (default: 0)
  15322. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15323. * @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
  15324. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15325. */
  15326. constructor(
  15327. /** Name of the PostProcess. */
  15328. 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);
  15329. /**
  15330. * Gets a string idenfifying the name of the class
  15331. * @returns "PostProcess" string
  15332. */
  15333. getClassName(): string;
  15334. /**
  15335. * Gets the engine which this post process belongs to.
  15336. * @returns The engine the post process was enabled with.
  15337. */
  15338. getEngine(): Engine;
  15339. /**
  15340. * The effect that is created when initializing the post process.
  15341. * @returns The created effect corresponding the the postprocess.
  15342. */
  15343. getEffect(): Effect;
  15344. /**
  15345. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15346. * @param postProcess The post process to share the output with.
  15347. * @returns This post process.
  15348. */
  15349. shareOutputWith(postProcess: PostProcess): PostProcess;
  15350. /**
  15351. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15352. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15353. */
  15354. useOwnOutput(): void;
  15355. /**
  15356. * Updates the effect with the current post process compile time values and recompiles the shader.
  15357. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15358. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15359. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15360. * @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
  15361. * @param onCompiled Called when the shader has been compiled.
  15362. * @param onError Called if there is an error when compiling a shader.
  15363. */
  15364. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15365. /**
  15366. * The post process is reusable if it can be used multiple times within one frame.
  15367. * @returns If the post process is reusable
  15368. */
  15369. isReusable(): boolean;
  15370. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15371. markTextureDirty(): void;
  15372. /**
  15373. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15374. * 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.
  15375. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15376. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15377. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15378. * @returns The target texture that was bound to be written to.
  15379. */
  15380. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15381. /**
  15382. * If the post process is supported.
  15383. */
  15384. readonly isSupported: boolean;
  15385. /**
  15386. * The aspect ratio of the output texture.
  15387. */
  15388. readonly aspectRatio: number;
  15389. /**
  15390. * Get a value indicating if the post-process is ready to be used
  15391. * @returns true if the post-process is ready (shader is compiled)
  15392. */
  15393. isReady(): boolean;
  15394. /**
  15395. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15396. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15397. */
  15398. apply(): Nullable<Effect>;
  15399. private _disposeTextures;
  15400. /**
  15401. * Disposes the post process.
  15402. * @param camera The camera to dispose the post process on.
  15403. */
  15404. dispose(camera?: Camera): void;
  15405. }
  15406. }
  15407. declare module BABYLON {
  15408. /** @hidden */
  15409. export var kernelBlurVaryingDeclaration: {
  15410. name: string;
  15411. shader: string;
  15412. };
  15413. }
  15414. declare module BABYLON {
  15415. /** @hidden */
  15416. export var kernelBlurFragment: {
  15417. name: string;
  15418. shader: string;
  15419. };
  15420. }
  15421. declare module BABYLON {
  15422. /** @hidden */
  15423. export var kernelBlurFragment2: {
  15424. name: string;
  15425. shader: string;
  15426. };
  15427. }
  15428. declare module BABYLON {
  15429. /** @hidden */
  15430. export var kernelBlurPixelShader: {
  15431. name: string;
  15432. shader: string;
  15433. };
  15434. }
  15435. declare module BABYLON {
  15436. /** @hidden */
  15437. export var kernelBlurVertex: {
  15438. name: string;
  15439. shader: string;
  15440. };
  15441. }
  15442. declare module BABYLON {
  15443. /** @hidden */
  15444. export var kernelBlurVertexShader: {
  15445. name: string;
  15446. shader: string;
  15447. };
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * The Blur Post Process which blurs an image based on a kernel and direction.
  15452. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15453. */
  15454. export class BlurPostProcess extends PostProcess {
  15455. /** The direction in which to blur the image. */
  15456. direction: Vector2;
  15457. private blockCompilation;
  15458. protected _kernel: number;
  15459. protected _idealKernel: number;
  15460. protected _packedFloat: boolean;
  15461. private _staticDefines;
  15462. /**
  15463. * Sets the length in pixels of the blur sample region
  15464. */
  15465. /**
  15466. * Gets the length in pixels of the blur sample region
  15467. */
  15468. kernel: number;
  15469. /**
  15470. * Sets wether or not the blur needs to unpack/repack floats
  15471. */
  15472. /**
  15473. * Gets wether or not the blur is unpacking/repacking floats
  15474. */
  15475. packedFloat: boolean;
  15476. /**
  15477. * Creates a new instance BlurPostProcess
  15478. * @param name The name of the effect.
  15479. * @param direction The direction in which to blur the image.
  15480. * @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.
  15481. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15482. * @param camera The camera to apply the render pass to.
  15483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15484. * @param engine The engine which the post process will be applied. (default: current engine)
  15485. * @param reusable If the post process can be reused on the same frame. (default: false)
  15486. * @param textureType Type of textures used when performing the post process. (default: 0)
  15487. * @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)
  15488. */
  15489. constructor(name: string,
  15490. /** The direction in which to blur the image. */
  15491. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15492. /**
  15493. * Updates the effect with the current post process compile time values and recompiles the shader.
  15494. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15495. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15496. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15497. * @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
  15498. * @param onCompiled Called when the shader has been compiled.
  15499. * @param onError Called if there is an error when compiling a shader.
  15500. */
  15501. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15502. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15503. /**
  15504. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15505. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15506. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15507. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15508. * The gaps between physical kernels are compensated for in the weighting of the samples
  15509. * @param idealKernel Ideal blur kernel.
  15510. * @return Nearest best kernel.
  15511. */
  15512. protected _nearestBestKernel(idealKernel: number): number;
  15513. /**
  15514. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15515. * @param x The point on the Gaussian distribution to sample.
  15516. * @return the value of the Gaussian function at x.
  15517. */
  15518. protected _gaussianWeight(x: number): number;
  15519. /**
  15520. * Generates a string that can be used as a floating point number in GLSL.
  15521. * @param x Value to print.
  15522. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15523. * @return GLSL float string.
  15524. */
  15525. protected _glslFloat(x: number, decimalFigures?: number): string;
  15526. }
  15527. }
  15528. declare module BABYLON {
  15529. /**
  15530. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15531. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15532. * You can then easily use it as a reflectionTexture on a flat surface.
  15533. * In case the surface is not a plane, please consider relying on reflection probes.
  15534. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15535. */
  15536. export class MirrorTexture extends RenderTargetTexture {
  15537. private scene;
  15538. /**
  15539. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15540. * 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.
  15541. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15542. */
  15543. mirrorPlane: Plane;
  15544. /**
  15545. * Define the blur ratio used to blur the reflection if needed.
  15546. */
  15547. blurRatio: number;
  15548. /**
  15549. * Define the adaptive blur kernel used to blur the reflection if needed.
  15550. * This will autocompute the closest best match for the `blurKernel`
  15551. */
  15552. adaptiveBlurKernel: number;
  15553. /**
  15554. * Define the blur kernel used to blur the reflection if needed.
  15555. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15556. */
  15557. blurKernel: number;
  15558. /**
  15559. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15560. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15561. */
  15562. blurKernelX: number;
  15563. /**
  15564. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15565. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15566. */
  15567. blurKernelY: number;
  15568. private _autoComputeBlurKernel;
  15569. protected _onRatioRescale(): void;
  15570. private _updateGammaSpace;
  15571. private _imageProcessingConfigChangeObserver;
  15572. private _transformMatrix;
  15573. private _mirrorMatrix;
  15574. private _savedViewMatrix;
  15575. private _blurX;
  15576. private _blurY;
  15577. private _adaptiveBlurKernel;
  15578. private _blurKernelX;
  15579. private _blurKernelY;
  15580. private _blurRatio;
  15581. /**
  15582. * Instantiates a Mirror Texture.
  15583. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15584. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15585. * You can then easily use it as a reflectionTexture on a flat surface.
  15586. * In case the surface is not a plane, please consider relying on reflection probes.
  15587. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15588. * @param name
  15589. * @param size
  15590. * @param scene
  15591. * @param generateMipMaps
  15592. * @param type
  15593. * @param samplingMode
  15594. * @param generateDepthBuffer
  15595. */
  15596. constructor(name: string, size: number | {
  15597. width: number;
  15598. height: number;
  15599. } | {
  15600. ratio: number;
  15601. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15602. private _preparePostProcesses;
  15603. /**
  15604. * Clone the mirror texture.
  15605. * @returns the cloned texture
  15606. */
  15607. clone(): MirrorTexture;
  15608. /**
  15609. * Serialize the texture to a JSON representation you could use in Parse later on
  15610. * @returns the serialized JSON representation
  15611. */
  15612. serialize(): any;
  15613. /**
  15614. * Dispose the texture and release its associated resources.
  15615. */
  15616. dispose(): void;
  15617. }
  15618. }
  15619. declare module BABYLON {
  15620. /**
  15621. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15622. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15623. */
  15624. export class Texture extends BaseTexture {
  15625. /**
  15626. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15627. */
  15628. static SerializeBuffers: boolean;
  15629. /** @hidden */
  15630. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15631. /** @hidden */
  15632. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15633. /** @hidden */
  15634. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15635. /** nearest is mag = nearest and min = nearest and mip = linear */
  15636. static readonly NEAREST_SAMPLINGMODE: number;
  15637. /** nearest is mag = nearest and min = nearest and mip = linear */
  15638. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15639. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15640. static readonly BILINEAR_SAMPLINGMODE: number;
  15641. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15642. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15643. /** Trilinear is mag = linear and min = linear and mip = linear */
  15644. static readonly TRILINEAR_SAMPLINGMODE: number;
  15645. /** Trilinear is mag = linear and min = linear and mip = linear */
  15646. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15647. /** mag = nearest and min = nearest and mip = nearest */
  15648. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15649. /** mag = nearest and min = linear and mip = nearest */
  15650. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15651. /** mag = nearest and min = linear and mip = linear */
  15652. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15653. /** mag = nearest and min = linear and mip = none */
  15654. static readonly NEAREST_LINEAR: number;
  15655. /** mag = nearest and min = nearest and mip = none */
  15656. static readonly NEAREST_NEAREST: number;
  15657. /** mag = linear and min = nearest and mip = nearest */
  15658. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15659. /** mag = linear and min = nearest and mip = linear */
  15660. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15661. /** mag = linear and min = linear and mip = none */
  15662. static readonly LINEAR_LINEAR: number;
  15663. /** mag = linear and min = nearest and mip = none */
  15664. static readonly LINEAR_NEAREST: number;
  15665. /** Explicit coordinates mode */
  15666. static readonly EXPLICIT_MODE: number;
  15667. /** Spherical coordinates mode */
  15668. static readonly SPHERICAL_MODE: number;
  15669. /** Planar coordinates mode */
  15670. static readonly PLANAR_MODE: number;
  15671. /** Cubic coordinates mode */
  15672. static readonly CUBIC_MODE: number;
  15673. /** Projection coordinates mode */
  15674. static readonly PROJECTION_MODE: number;
  15675. /** Inverse Cubic coordinates mode */
  15676. static readonly SKYBOX_MODE: number;
  15677. /** Inverse Cubic coordinates mode */
  15678. static readonly INVCUBIC_MODE: number;
  15679. /** Equirectangular coordinates mode */
  15680. static readonly EQUIRECTANGULAR_MODE: number;
  15681. /** Equirectangular Fixed coordinates mode */
  15682. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15683. /** Equirectangular Fixed Mirrored coordinates mode */
  15684. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15685. /** Texture is not repeating outside of 0..1 UVs */
  15686. static readonly CLAMP_ADDRESSMODE: number;
  15687. /** Texture is repeating outside of 0..1 UVs */
  15688. static readonly WRAP_ADDRESSMODE: number;
  15689. /** Texture is repeating and mirrored */
  15690. static readonly MIRROR_ADDRESSMODE: number;
  15691. /**
  15692. * 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
  15693. */
  15694. static UseSerializedUrlIfAny: boolean;
  15695. /**
  15696. * Define the url of the texture.
  15697. */
  15698. url: Nullable<string>;
  15699. /**
  15700. * Define an offset on the texture to offset the u coordinates of the UVs
  15701. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15702. */
  15703. uOffset: number;
  15704. /**
  15705. * Define an offset on the texture to offset the v coordinates of the UVs
  15706. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15707. */
  15708. vOffset: number;
  15709. /**
  15710. * Define an offset on the texture to scale the u coordinates of the UVs
  15711. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15712. */
  15713. uScale: number;
  15714. /**
  15715. * Define an offset on the texture to scale the v coordinates of the UVs
  15716. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15717. */
  15718. vScale: number;
  15719. /**
  15720. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15721. * @see http://doc.babylonjs.com/how_to/more_materials
  15722. */
  15723. uAng: number;
  15724. /**
  15725. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15726. * @see http://doc.babylonjs.com/how_to/more_materials
  15727. */
  15728. vAng: number;
  15729. /**
  15730. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15731. * @see http://doc.babylonjs.com/how_to/more_materials
  15732. */
  15733. wAng: number;
  15734. /**
  15735. * Defines the center of rotation (U)
  15736. */
  15737. uRotationCenter: number;
  15738. /**
  15739. * Defines the center of rotation (V)
  15740. */
  15741. vRotationCenter: number;
  15742. /**
  15743. * Defines the center of rotation (W)
  15744. */
  15745. wRotationCenter: number;
  15746. /**
  15747. * Are mip maps generated for this texture or not.
  15748. */
  15749. readonly noMipmap: boolean;
  15750. /**
  15751. * List of inspectable custom properties (used by the Inspector)
  15752. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15753. */
  15754. inspectableCustomProperties: Nullable<IInspectable[]>;
  15755. private _noMipmap;
  15756. /** @hidden */
  15757. _invertY: boolean;
  15758. private _rowGenerationMatrix;
  15759. private _cachedTextureMatrix;
  15760. private _projectionModeMatrix;
  15761. private _t0;
  15762. private _t1;
  15763. private _t2;
  15764. private _cachedUOffset;
  15765. private _cachedVOffset;
  15766. private _cachedUScale;
  15767. private _cachedVScale;
  15768. private _cachedUAng;
  15769. private _cachedVAng;
  15770. private _cachedWAng;
  15771. private _cachedProjectionMatrixId;
  15772. private _cachedCoordinatesMode;
  15773. /** @hidden */
  15774. protected _initialSamplingMode: number;
  15775. /** @hidden */
  15776. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  15777. private _deleteBuffer;
  15778. protected _format: Nullable<number>;
  15779. private _delayedOnLoad;
  15780. private _delayedOnError;
  15781. private _mimeType?;
  15782. /**
  15783. * Observable triggered once the texture has been loaded.
  15784. */
  15785. onLoadObservable: Observable<Texture>;
  15786. protected _isBlocking: boolean;
  15787. /**
  15788. * Is the texture preventing material to render while loading.
  15789. * If false, a default texture will be used instead of the loading one during the preparation step.
  15790. */
  15791. isBlocking: boolean;
  15792. /**
  15793. * Get the current sampling mode associated with the texture.
  15794. */
  15795. readonly samplingMode: number;
  15796. /**
  15797. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15798. */
  15799. readonly invertY: boolean;
  15800. /**
  15801. * Instantiates a new texture.
  15802. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15803. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15804. * @param url defines the url of the picture to load as a texture
  15805. * @param scene defines the scene or engine the texture will belong to
  15806. * @param noMipmap defines if the texture will require mip maps or not
  15807. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  15808. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15809. * @param onLoad defines a callback triggered when the texture has been loaded
  15810. * @param onError defines a callback triggered when an error occurred during the loading session
  15811. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  15812. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  15813. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15814. * @param mimeType defines an optional mime type information
  15815. */
  15816. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  15817. /**
  15818. * Update the url (and optional buffer) of this texture if url was null during construction.
  15819. * @param url the url of the texture
  15820. * @param buffer the buffer of the texture (defaults to null)
  15821. * @param onLoad callback called when the texture is loaded (defaults to null)
  15822. */
  15823. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15824. /**
  15825. * Finish the loading sequence of a texture flagged as delayed load.
  15826. * @hidden
  15827. */
  15828. delayLoad(): void;
  15829. private _prepareRowForTextureGeneration;
  15830. /**
  15831. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15832. * @returns the transform matrix of the texture.
  15833. */
  15834. getTextureMatrix(): Matrix;
  15835. /**
  15836. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15837. * @returns The reflection texture transform
  15838. */
  15839. getReflectionTextureMatrix(): Matrix;
  15840. /**
  15841. * Clones the texture.
  15842. * @returns the cloned texture
  15843. */
  15844. clone(): Texture;
  15845. /**
  15846. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15847. * @returns The JSON representation of the texture
  15848. */
  15849. serialize(): any;
  15850. /**
  15851. * Get the current class name of the texture useful for serialization or dynamic coding.
  15852. * @returns "Texture"
  15853. */
  15854. getClassName(): string;
  15855. /**
  15856. * Dispose the texture and release its associated resources.
  15857. */
  15858. dispose(): void;
  15859. /**
  15860. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15861. * @param parsedTexture Define the JSON representation of the texture
  15862. * @param scene Define the scene the parsed texture should be instantiated in
  15863. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15864. * @returns The parsed texture if successful
  15865. */
  15866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15867. /**
  15868. * Creates a texture from its base 64 representation.
  15869. * @param data Define the base64 payload without the data: prefix
  15870. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15871. * @param scene Define the scene the texture should belong to
  15872. * @param noMipmap Forces the texture to not create mip map information if true
  15873. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15874. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15875. * @param onLoad define a callback triggered when the texture has been loaded
  15876. * @param onError define a callback triggered when an error occurred during the loading session
  15877. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15878. * @returns the created texture
  15879. */
  15880. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15881. /**
  15882. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15883. * @param data Define the base64 payload without the data: prefix
  15884. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15885. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15886. * @param scene Define the scene the texture should belong to
  15887. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15888. * @param noMipmap Forces the texture to not create mip map information if true
  15889. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15890. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15891. * @param onLoad define a callback triggered when the texture has been loaded
  15892. * @param onError define a callback triggered when an error occurred during the loading session
  15893. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15894. * @returns the created texture
  15895. */
  15896. 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;
  15897. }
  15898. }
  15899. declare module BABYLON {
  15900. /**
  15901. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15902. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15903. */
  15904. export class PostProcessManager {
  15905. private _scene;
  15906. private _indexBuffer;
  15907. private _vertexBuffers;
  15908. /**
  15909. * Creates a new instance PostProcess
  15910. * @param scene The scene that the post process is associated with.
  15911. */
  15912. constructor(scene: Scene);
  15913. private _prepareBuffers;
  15914. private _buildIndexBuffer;
  15915. /**
  15916. * Rebuilds the vertex buffers of the manager.
  15917. * @hidden
  15918. */
  15919. _rebuild(): void;
  15920. /**
  15921. * Prepares a frame to be run through a post process.
  15922. * @param sourceTexture The input texture to the post procesess. (default: null)
  15923. * @param postProcesses An array of post processes to be run. (default: null)
  15924. * @returns True if the post processes were able to be run.
  15925. * @hidden
  15926. */
  15927. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15928. /**
  15929. * Manually render a set of post processes to a texture.
  15930. * @param postProcesses An array of post processes to be run.
  15931. * @param targetTexture The target texture to render to.
  15932. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15933. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15934. * @param lodLevel defines which lod of the texture to render to
  15935. */
  15936. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15937. /**
  15938. * Finalize the result of the output of the postprocesses.
  15939. * @param doNotPresent If true the result will not be displayed to the screen.
  15940. * @param targetTexture The target texture to render to.
  15941. * @param faceIndex The index of the face to bind the target texture to.
  15942. * @param postProcesses The array of post processes to render.
  15943. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15944. * @hidden
  15945. */
  15946. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15947. /**
  15948. * Disposes of the post process manager.
  15949. */
  15950. dispose(): void;
  15951. }
  15952. }
  15953. declare module BABYLON {
  15954. /** Interface used by value gradients (color, factor, ...) */
  15955. export interface IValueGradient {
  15956. /**
  15957. * Gets or sets the gradient value (between 0 and 1)
  15958. */
  15959. gradient: number;
  15960. }
  15961. /** Class used to store color4 gradient */
  15962. export class ColorGradient implements IValueGradient {
  15963. /**
  15964. * Gets or sets the gradient value (between 0 and 1)
  15965. */
  15966. gradient: number;
  15967. /**
  15968. * Gets or sets first associated color
  15969. */
  15970. color1: Color4;
  15971. /**
  15972. * Gets or sets second associated color
  15973. */
  15974. color2?: Color4;
  15975. /**
  15976. * Will get a color picked randomly between color1 and color2.
  15977. * If color2 is undefined then color1 will be used
  15978. * @param result defines the target Color4 to store the result in
  15979. */
  15980. getColorToRef(result: Color4): void;
  15981. }
  15982. /** Class used to store color 3 gradient */
  15983. export class Color3Gradient implements IValueGradient {
  15984. /**
  15985. * Gets or sets the gradient value (between 0 and 1)
  15986. */
  15987. gradient: number;
  15988. /**
  15989. * Gets or sets the associated color
  15990. */
  15991. color: Color3;
  15992. }
  15993. /** Class used to store factor gradient */
  15994. export class FactorGradient implements IValueGradient {
  15995. /**
  15996. * Gets or sets the gradient value (between 0 and 1)
  15997. */
  15998. gradient: number;
  15999. /**
  16000. * Gets or sets first associated factor
  16001. */
  16002. factor1: number;
  16003. /**
  16004. * Gets or sets second associated factor
  16005. */
  16006. factor2?: number;
  16007. /**
  16008. * Will get a number picked randomly between factor1 and factor2.
  16009. * If factor2 is undefined then factor1 will be used
  16010. * @returns the picked number
  16011. */
  16012. getFactor(): number;
  16013. }
  16014. /**
  16015. * Helper used to simplify some generic gradient tasks
  16016. */
  16017. export class GradientHelper {
  16018. /**
  16019. * Gets the current gradient from an array of IValueGradient
  16020. * @param ratio defines the current ratio to get
  16021. * @param gradients defines the array of IValueGradient
  16022. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16023. */
  16024. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16025. }
  16026. }
  16027. declare module BABYLON {
  16028. interface ThinEngine {
  16029. /**
  16030. * Creates a dynamic texture
  16031. * @param width defines the width of the texture
  16032. * @param height defines the height of the texture
  16033. * @param generateMipMaps defines if the engine should generate the mip levels
  16034. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16035. * @returns the dynamic texture inside an InternalTexture
  16036. */
  16037. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16038. /**
  16039. * Update the content of a dynamic texture
  16040. * @param texture defines the texture to update
  16041. * @param canvas defines the canvas containing the source
  16042. * @param invertY defines if data must be stored with Y axis inverted
  16043. * @param premulAlpha defines if alpha is stored as premultiplied
  16044. * @param format defines the format of the data
  16045. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16046. */
  16047. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16048. }
  16049. }
  16050. declare module BABYLON {
  16051. /**
  16052. * Helper class used to generate a canvas to manipulate images
  16053. */
  16054. export class CanvasGenerator {
  16055. /**
  16056. * Create a new canvas (or offscreen canvas depending on the context)
  16057. * @param width defines the expected width
  16058. * @param height defines the expected height
  16059. * @return a new canvas or offscreen canvas
  16060. */
  16061. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16062. }
  16063. }
  16064. declare module BABYLON {
  16065. /**
  16066. * A class extending Texture allowing drawing on a texture
  16067. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16068. */
  16069. export class DynamicTexture extends Texture {
  16070. private _generateMipMaps;
  16071. private _canvas;
  16072. private _context;
  16073. private _engine;
  16074. /**
  16075. * Creates a DynamicTexture
  16076. * @param name defines the name of the texture
  16077. * @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
  16078. * @param scene defines the scene where you want the texture
  16079. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16080. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16081. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16082. */
  16083. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16084. /**
  16085. * Get the current class name of the texture useful for serialization or dynamic coding.
  16086. * @returns "DynamicTexture"
  16087. */
  16088. getClassName(): string;
  16089. /**
  16090. * Gets the current state of canRescale
  16091. */
  16092. readonly canRescale: boolean;
  16093. private _recreate;
  16094. /**
  16095. * Scales the texture
  16096. * @param ratio the scale factor to apply to both width and height
  16097. */
  16098. scale(ratio: number): void;
  16099. /**
  16100. * Resizes the texture
  16101. * @param width the new width
  16102. * @param height the new height
  16103. */
  16104. scaleTo(width: number, height: number): void;
  16105. /**
  16106. * Gets the context of the canvas used by the texture
  16107. * @returns the canvas context of the dynamic texture
  16108. */
  16109. getContext(): CanvasRenderingContext2D;
  16110. /**
  16111. * Clears the texture
  16112. */
  16113. clear(): void;
  16114. /**
  16115. * Updates the texture
  16116. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16117. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16118. */
  16119. update(invertY?: boolean, premulAlpha?: boolean): void;
  16120. /**
  16121. * Draws text onto the texture
  16122. * @param text defines the text to be drawn
  16123. * @param x defines the placement of the text from the left
  16124. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16125. * @param font defines the font to be used with font-style, font-size, font-name
  16126. * @param color defines the color used for the text
  16127. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16128. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16129. * @param update defines whether texture is immediately update (default is true)
  16130. */
  16131. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16132. /**
  16133. * Clones the texture
  16134. * @returns the clone of the texture.
  16135. */
  16136. clone(): DynamicTexture;
  16137. /**
  16138. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16139. * @returns a serialized dynamic texture object
  16140. */
  16141. serialize(): any;
  16142. /** @hidden */
  16143. _rebuild(): void;
  16144. }
  16145. }
  16146. declare module BABYLON {
  16147. interface AbstractScene {
  16148. /**
  16149. * The list of procedural textures added to the scene
  16150. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16151. */
  16152. proceduralTextures: Array<ProceduralTexture>;
  16153. }
  16154. /**
  16155. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16156. * in a given scene.
  16157. */
  16158. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16159. /**
  16160. * The component name helpfull to identify the component in the list of scene components.
  16161. */
  16162. readonly name: string;
  16163. /**
  16164. * The scene the component belongs to.
  16165. */
  16166. scene: Scene;
  16167. /**
  16168. * Creates a new instance of the component for the given scene
  16169. * @param scene Defines the scene to register the component in
  16170. */
  16171. constructor(scene: Scene);
  16172. /**
  16173. * Registers the component in a given scene
  16174. */
  16175. register(): void;
  16176. /**
  16177. * Rebuilds the elements related to this component in case of
  16178. * context lost for instance.
  16179. */
  16180. rebuild(): void;
  16181. /**
  16182. * Disposes the component and the associated ressources.
  16183. */
  16184. dispose(): void;
  16185. private _beforeClear;
  16186. }
  16187. }
  16188. declare module BABYLON {
  16189. interface ThinEngine {
  16190. /**
  16191. * Creates a new render target cube texture
  16192. * @param size defines the size of the texture
  16193. * @param options defines the options used to create the texture
  16194. * @returns a new render target cube texture stored in an InternalTexture
  16195. */
  16196. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16197. }
  16198. }
  16199. declare module BABYLON {
  16200. /** @hidden */
  16201. export var proceduralVertexShader: {
  16202. name: string;
  16203. shader: string;
  16204. };
  16205. }
  16206. declare module BABYLON {
  16207. /**
  16208. * 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.
  16209. * This is the base class of any Procedural texture and contains most of the shareable code.
  16210. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16211. */
  16212. export class ProceduralTexture extends Texture {
  16213. isCube: boolean;
  16214. /**
  16215. * Define if the texture is enabled or not (disabled texture will not render)
  16216. */
  16217. isEnabled: boolean;
  16218. /**
  16219. * Define if the texture must be cleared before rendering (default is true)
  16220. */
  16221. autoClear: boolean;
  16222. /**
  16223. * Callback called when the texture is generated
  16224. */
  16225. onGenerated: () => void;
  16226. /**
  16227. * Event raised when the texture is generated
  16228. */
  16229. onGeneratedObservable: Observable<ProceduralTexture>;
  16230. /** @hidden */
  16231. _generateMipMaps: boolean;
  16232. /** @hidden **/
  16233. _effect: Effect;
  16234. /** @hidden */
  16235. _textures: {
  16236. [key: string]: Texture;
  16237. };
  16238. private _size;
  16239. private _currentRefreshId;
  16240. private _refreshRate;
  16241. private _vertexBuffers;
  16242. private _indexBuffer;
  16243. private _uniforms;
  16244. private _samplers;
  16245. private _fragment;
  16246. private _floats;
  16247. private _ints;
  16248. private _floatsArrays;
  16249. private _colors3;
  16250. private _colors4;
  16251. private _vectors2;
  16252. private _vectors3;
  16253. private _matrices;
  16254. private _fallbackTexture;
  16255. private _fallbackTextureUsed;
  16256. private _engine;
  16257. private _cachedDefines;
  16258. private _contentUpdateId;
  16259. private _contentData;
  16260. /**
  16261. * Instantiates a new procedural texture.
  16262. * 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.
  16263. * This is the base class of any Procedural texture and contains most of the shareable code.
  16264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16265. * @param name Define the name of the texture
  16266. * @param size Define the size of the texture to create
  16267. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16268. * @param scene Define the scene the texture belongs to
  16269. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16270. * @param generateMipMaps Define if the texture should creates mip maps or not
  16271. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16272. */
  16273. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16274. /**
  16275. * The effect that is created when initializing the post process.
  16276. * @returns The created effect corresponding the the postprocess.
  16277. */
  16278. getEffect(): Effect;
  16279. /**
  16280. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16281. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16282. */
  16283. getContent(): Nullable<ArrayBufferView>;
  16284. private _createIndexBuffer;
  16285. /** @hidden */
  16286. _rebuild(): void;
  16287. /**
  16288. * Resets the texture in order to recreate its associated resources.
  16289. * This can be called in case of context loss
  16290. */
  16291. reset(): void;
  16292. protected _getDefines(): string;
  16293. /**
  16294. * Is the texture ready to be used ? (rendered at least once)
  16295. * @returns true if ready, otherwise, false.
  16296. */
  16297. isReady(): boolean;
  16298. /**
  16299. * Resets the refresh counter of the texture and start bak from scratch.
  16300. * Could be useful to regenerate the texture if it is setup to render only once.
  16301. */
  16302. resetRefreshCounter(): void;
  16303. /**
  16304. * Set the fragment shader to use in order to render the texture.
  16305. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16306. */
  16307. setFragment(fragment: any): void;
  16308. /**
  16309. * Define the refresh rate of the texture or the rendering frequency.
  16310. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16311. */
  16312. refreshRate: number;
  16313. /** @hidden */
  16314. _shouldRender(): boolean;
  16315. /**
  16316. * Get the size the texture is rendering at.
  16317. * @returns the size (texture is always squared)
  16318. */
  16319. getRenderSize(): number;
  16320. /**
  16321. * Resize the texture to new value.
  16322. * @param size Define the new size the texture should have
  16323. * @param generateMipMaps Define whether the new texture should create mip maps
  16324. */
  16325. resize(size: number, generateMipMaps: boolean): void;
  16326. private _checkUniform;
  16327. /**
  16328. * Set a texture in the shader program used to render.
  16329. * @param name Define the name of the uniform samplers as defined in the shader
  16330. * @param texture Define the texture to bind to this sampler
  16331. * @return the texture itself allowing "fluent" like uniform updates
  16332. */
  16333. setTexture(name: string, texture: Texture): ProceduralTexture;
  16334. /**
  16335. * Set a float in the shader.
  16336. * @param name Define the name of the uniform as defined in the shader
  16337. * @param value Define the value to give to the uniform
  16338. * @return the texture itself allowing "fluent" like uniform updates
  16339. */
  16340. setFloat(name: string, value: number): ProceduralTexture;
  16341. /**
  16342. * Set a int in the shader.
  16343. * @param name Define the name of the uniform as defined in the shader
  16344. * @param value Define the value to give to the uniform
  16345. * @return the texture itself allowing "fluent" like uniform updates
  16346. */
  16347. setInt(name: string, value: number): ProceduralTexture;
  16348. /**
  16349. * Set an array of floats in the shader.
  16350. * @param name Define the name of the uniform as defined in the shader
  16351. * @param value Define the value to give to the uniform
  16352. * @return the texture itself allowing "fluent" like uniform updates
  16353. */
  16354. setFloats(name: string, value: number[]): ProceduralTexture;
  16355. /**
  16356. * Set a vec3 in the shader from a Color3.
  16357. * @param name Define the name of the uniform as defined in the shader
  16358. * @param value Define the value to give to the uniform
  16359. * @return the texture itself allowing "fluent" like uniform updates
  16360. */
  16361. setColor3(name: string, value: Color3): ProceduralTexture;
  16362. /**
  16363. * Set a vec4 in the shader from a Color4.
  16364. * @param name Define the name of the uniform as defined in the shader
  16365. * @param value Define the value to give to the uniform
  16366. * @return the texture itself allowing "fluent" like uniform updates
  16367. */
  16368. setColor4(name: string, value: Color4): ProceduralTexture;
  16369. /**
  16370. * Set a vec2 in the shader from a Vector2.
  16371. * @param name Define the name of the uniform as defined in the shader
  16372. * @param value Define the value to give to the uniform
  16373. * @return the texture itself allowing "fluent" like uniform updates
  16374. */
  16375. setVector2(name: string, value: Vector2): ProceduralTexture;
  16376. /**
  16377. * Set a vec3 in the shader from a Vector3.
  16378. * @param name Define the name of the uniform as defined in the shader
  16379. * @param value Define the value to give to the uniform
  16380. * @return the texture itself allowing "fluent" like uniform updates
  16381. */
  16382. setVector3(name: string, value: Vector3): ProceduralTexture;
  16383. /**
  16384. * Set a mat4 in the shader from a MAtrix.
  16385. * @param name Define the name of the uniform as defined in the shader
  16386. * @param value Define the value to give to the uniform
  16387. * @return the texture itself allowing "fluent" like uniform updates
  16388. */
  16389. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16390. /**
  16391. * Render the texture to its associated render target.
  16392. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16393. */
  16394. render(useCameraPostProcess?: boolean): void;
  16395. /**
  16396. * Clone the texture.
  16397. * @returns the cloned texture
  16398. */
  16399. clone(): ProceduralTexture;
  16400. /**
  16401. * Dispose the texture and release its asoociated resources.
  16402. */
  16403. dispose(): void;
  16404. }
  16405. }
  16406. declare module BABYLON {
  16407. /**
  16408. * This represents the base class for particle system in Babylon.
  16409. * 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.
  16410. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16411. * @example https://doc.babylonjs.com/babylon101/particles
  16412. */
  16413. export class BaseParticleSystem {
  16414. /**
  16415. * Source color is added to the destination color without alpha affecting the result
  16416. */
  16417. static BLENDMODE_ONEONE: number;
  16418. /**
  16419. * Blend current color and particle color using particle’s alpha
  16420. */
  16421. static BLENDMODE_STANDARD: number;
  16422. /**
  16423. * Add current color and particle color multiplied by particle’s alpha
  16424. */
  16425. static BLENDMODE_ADD: number;
  16426. /**
  16427. * Multiply current color with particle color
  16428. */
  16429. static BLENDMODE_MULTIPLY: number;
  16430. /**
  16431. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16432. */
  16433. static BLENDMODE_MULTIPLYADD: number;
  16434. /**
  16435. * List of animations used by the particle system.
  16436. */
  16437. animations: Animation[];
  16438. /**
  16439. * The id of the Particle system.
  16440. */
  16441. id: string;
  16442. /**
  16443. * The friendly name of the Particle system.
  16444. */
  16445. name: string;
  16446. /**
  16447. * The rendering group used by the Particle system to chose when to render.
  16448. */
  16449. renderingGroupId: number;
  16450. /**
  16451. * The emitter represents the Mesh or position we are attaching the particle system to.
  16452. */
  16453. emitter: Nullable<AbstractMesh | Vector3>;
  16454. /**
  16455. * The maximum number of particles to emit per frame
  16456. */
  16457. emitRate: number;
  16458. /**
  16459. * If you want to launch only a few particles at once, that can be done, as well.
  16460. */
  16461. manualEmitCount: number;
  16462. /**
  16463. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16464. */
  16465. updateSpeed: number;
  16466. /**
  16467. * The amount of time the particle system is running (depends of the overall update speed).
  16468. */
  16469. targetStopDuration: number;
  16470. /**
  16471. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16472. */
  16473. disposeOnStop: boolean;
  16474. /**
  16475. * Minimum power of emitting particles.
  16476. */
  16477. minEmitPower: number;
  16478. /**
  16479. * Maximum power of emitting particles.
  16480. */
  16481. maxEmitPower: number;
  16482. /**
  16483. * Minimum life time of emitting particles.
  16484. */
  16485. minLifeTime: number;
  16486. /**
  16487. * Maximum life time of emitting particles.
  16488. */
  16489. maxLifeTime: number;
  16490. /**
  16491. * Minimum Size of emitting particles.
  16492. */
  16493. minSize: number;
  16494. /**
  16495. * Maximum Size of emitting particles.
  16496. */
  16497. maxSize: number;
  16498. /**
  16499. * Minimum scale of emitting particles on X axis.
  16500. */
  16501. minScaleX: number;
  16502. /**
  16503. * Maximum scale of emitting particles on X axis.
  16504. */
  16505. maxScaleX: number;
  16506. /**
  16507. * Minimum scale of emitting particles on Y axis.
  16508. */
  16509. minScaleY: number;
  16510. /**
  16511. * Maximum scale of emitting particles on Y axis.
  16512. */
  16513. maxScaleY: number;
  16514. /**
  16515. * Gets or sets the minimal initial rotation in radians.
  16516. */
  16517. minInitialRotation: number;
  16518. /**
  16519. * Gets or sets the maximal initial rotation in radians.
  16520. */
  16521. maxInitialRotation: number;
  16522. /**
  16523. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16524. */
  16525. minAngularSpeed: number;
  16526. /**
  16527. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16528. */
  16529. maxAngularSpeed: number;
  16530. /**
  16531. * The texture used to render each particle. (this can be a spritesheet)
  16532. */
  16533. particleTexture: Nullable<Texture>;
  16534. /**
  16535. * The layer mask we are rendering the particles through.
  16536. */
  16537. layerMask: number;
  16538. /**
  16539. * This can help using your own shader to render the particle system.
  16540. * The according effect will be created
  16541. */
  16542. customShader: any;
  16543. /**
  16544. * By default particle system starts as soon as they are created. This prevents the
  16545. * automatic start to happen and let you decide when to start emitting particles.
  16546. */
  16547. preventAutoStart: boolean;
  16548. private _noiseTexture;
  16549. /**
  16550. * Gets or sets a texture used to add random noise to particle positions
  16551. */
  16552. noiseTexture: Nullable<ProceduralTexture>;
  16553. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16554. noiseStrength: Vector3;
  16555. /**
  16556. * Callback triggered when the particle animation is ending.
  16557. */
  16558. onAnimationEnd: Nullable<() => void>;
  16559. /**
  16560. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16561. */
  16562. blendMode: number;
  16563. /**
  16564. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16565. * to override the particles.
  16566. */
  16567. forceDepthWrite: boolean;
  16568. /** 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 */
  16569. preWarmCycles: number;
  16570. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16571. preWarmStepOffset: number;
  16572. /**
  16573. * 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)
  16574. */
  16575. spriteCellChangeSpeed: number;
  16576. /**
  16577. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16578. */
  16579. startSpriteCellID: number;
  16580. /**
  16581. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16582. */
  16583. endSpriteCellID: number;
  16584. /**
  16585. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16586. */
  16587. spriteCellWidth: number;
  16588. /**
  16589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16590. */
  16591. spriteCellHeight: number;
  16592. /**
  16593. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16594. */
  16595. spriteRandomStartCell: boolean;
  16596. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16597. translationPivot: Vector2;
  16598. /** @hidden */
  16599. protected _isAnimationSheetEnabled: boolean;
  16600. /**
  16601. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16602. */
  16603. beginAnimationOnStart: boolean;
  16604. /**
  16605. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16606. */
  16607. beginAnimationFrom: number;
  16608. /**
  16609. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16610. */
  16611. beginAnimationTo: number;
  16612. /**
  16613. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16614. */
  16615. beginAnimationLoop: boolean;
  16616. /**
  16617. * Gets or sets a world offset applied to all particles
  16618. */
  16619. worldOffset: Vector3;
  16620. /**
  16621. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16622. */
  16623. isAnimationSheetEnabled: boolean;
  16624. /**
  16625. * Get hosting scene
  16626. * @returns the scene
  16627. */
  16628. getScene(): Scene;
  16629. /**
  16630. * You can use gravity if you want to give an orientation to your particles.
  16631. */
  16632. gravity: Vector3;
  16633. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16634. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16635. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16636. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16637. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16638. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16639. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16640. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16641. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16642. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16643. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16644. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16645. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16646. /**
  16647. * Defines the delay in milliseconds before starting the system (0 by default)
  16648. */
  16649. startDelay: number;
  16650. /**
  16651. * Gets the current list of drag gradients.
  16652. * You must use addDragGradient and removeDragGradient to udpate this list
  16653. * @returns the list of drag gradients
  16654. */
  16655. getDragGradients(): Nullable<Array<FactorGradient>>;
  16656. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16657. limitVelocityDamping: number;
  16658. /**
  16659. * Gets the current list of limit velocity gradients.
  16660. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16661. * @returns the list of limit velocity gradients
  16662. */
  16663. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16664. /**
  16665. * Gets the current list of color gradients.
  16666. * You must use addColorGradient and removeColorGradient to udpate this list
  16667. * @returns the list of color gradients
  16668. */
  16669. getColorGradients(): Nullable<Array<ColorGradient>>;
  16670. /**
  16671. * Gets the current list of size gradients.
  16672. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16673. * @returns the list of size gradients
  16674. */
  16675. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16676. /**
  16677. * Gets the current list of color remap gradients.
  16678. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16679. * @returns the list of color remap gradients
  16680. */
  16681. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16682. /**
  16683. * Gets the current list of alpha remap gradients.
  16684. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16685. * @returns the list of alpha remap gradients
  16686. */
  16687. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16688. /**
  16689. * Gets the current list of life time gradients.
  16690. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16691. * @returns the list of life time gradients
  16692. */
  16693. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16694. /**
  16695. * Gets the current list of angular speed gradients.
  16696. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16697. * @returns the list of angular speed gradients
  16698. */
  16699. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16700. /**
  16701. * Gets the current list of velocity gradients.
  16702. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16703. * @returns the list of velocity gradients
  16704. */
  16705. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16706. /**
  16707. * Gets the current list of start size gradients.
  16708. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16709. * @returns the list of start size gradients
  16710. */
  16711. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16712. /**
  16713. * Gets the current list of emit rate gradients.
  16714. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16715. * @returns the list of emit rate gradients
  16716. */
  16717. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16718. /**
  16719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16720. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16721. */
  16722. direction1: Vector3;
  16723. /**
  16724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16725. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16726. */
  16727. direction2: Vector3;
  16728. /**
  16729. * 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.
  16730. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16731. */
  16732. minEmitBox: Vector3;
  16733. /**
  16734. * 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.
  16735. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16736. */
  16737. maxEmitBox: Vector3;
  16738. /**
  16739. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16740. */
  16741. color1: Color4;
  16742. /**
  16743. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16744. */
  16745. color2: Color4;
  16746. /**
  16747. * Color the particle will have at the end of its lifetime
  16748. */
  16749. colorDead: Color4;
  16750. /**
  16751. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16752. */
  16753. textureMask: Color4;
  16754. /**
  16755. * The particle emitter type defines the emitter used by the particle system.
  16756. * It can be for example box, sphere, or cone...
  16757. */
  16758. particleEmitterType: IParticleEmitterType;
  16759. /** @hidden */
  16760. _isSubEmitter: boolean;
  16761. /**
  16762. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16763. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16764. */
  16765. billboardMode: number;
  16766. protected _isBillboardBased: boolean;
  16767. /**
  16768. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16769. */
  16770. isBillboardBased: boolean;
  16771. /**
  16772. * The scene the particle system belongs to.
  16773. */
  16774. protected _scene: Scene;
  16775. /**
  16776. * Local cache of defines for image processing.
  16777. */
  16778. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16779. /**
  16780. * Default configuration related to image processing available in the standard Material.
  16781. */
  16782. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16783. /**
  16784. * Gets the image processing configuration used either in this material.
  16785. */
  16786. /**
  16787. * Sets the Default image processing configuration used either in the this material.
  16788. *
  16789. * If sets to null, the scene one is in use.
  16790. */
  16791. imageProcessingConfiguration: ImageProcessingConfiguration;
  16792. /**
  16793. * Attaches a new image processing configuration to the Standard Material.
  16794. * @param configuration
  16795. */
  16796. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16797. /** @hidden */
  16798. protected _reset(): void;
  16799. /** @hidden */
  16800. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16801. /**
  16802. * Instantiates a particle system.
  16803. * 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.
  16804. * @param name The name of the particle system
  16805. */
  16806. constructor(name: string);
  16807. /**
  16808. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16809. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16810. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16811. * @returns the emitter
  16812. */
  16813. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16814. /**
  16815. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16816. * @param radius The radius of the hemisphere to emit from
  16817. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16818. * @returns the emitter
  16819. */
  16820. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16821. /**
  16822. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16823. * @param radius The radius of the sphere to emit from
  16824. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16825. * @returns the emitter
  16826. */
  16827. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16828. /**
  16829. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16830. * @param radius The radius of the sphere to emit from
  16831. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16832. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16833. * @returns the emitter
  16834. */
  16835. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16836. /**
  16837. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16838. * @param radius The radius of the emission cylinder
  16839. * @param height The height of the emission cylinder
  16840. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16841. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16842. * @returns the emitter
  16843. */
  16844. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16845. /**
  16846. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16847. * @param radius The radius of the cylinder to emit from
  16848. * @param height The height of the emission cylinder
  16849. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16850. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16851. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16852. * @returns the emitter
  16853. */
  16854. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16855. /**
  16856. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16857. * @param radius The radius of the cone to emit from
  16858. * @param angle The base angle of the cone
  16859. * @returns the emitter
  16860. */
  16861. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16862. /**
  16863. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16864. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16865. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16866. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16867. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16868. * @returns the emitter
  16869. */
  16870. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16871. }
  16872. }
  16873. declare module BABYLON {
  16874. /**
  16875. * Type of sub emitter
  16876. */
  16877. export enum SubEmitterType {
  16878. /**
  16879. * Attached to the particle over it's lifetime
  16880. */
  16881. ATTACHED = 0,
  16882. /**
  16883. * Created when the particle dies
  16884. */
  16885. END = 1
  16886. }
  16887. /**
  16888. * Sub emitter class used to emit particles from an existing particle
  16889. */
  16890. export class SubEmitter {
  16891. /**
  16892. * the particle system to be used by the sub emitter
  16893. */
  16894. particleSystem: ParticleSystem;
  16895. /**
  16896. * Type of the submitter (Default: END)
  16897. */
  16898. type: SubEmitterType;
  16899. /**
  16900. * 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)
  16901. * Note: This only is supported when using an emitter of type Mesh
  16902. */
  16903. inheritDirection: boolean;
  16904. /**
  16905. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16906. */
  16907. inheritedVelocityAmount: number;
  16908. /**
  16909. * Creates a sub emitter
  16910. * @param particleSystem the particle system to be used by the sub emitter
  16911. */
  16912. constructor(
  16913. /**
  16914. * the particle system to be used by the sub emitter
  16915. */
  16916. particleSystem: ParticleSystem);
  16917. /**
  16918. * Clones the sub emitter
  16919. * @returns the cloned sub emitter
  16920. */
  16921. clone(): SubEmitter;
  16922. /**
  16923. * Serialize current object to a JSON object
  16924. * @returns the serialized object
  16925. */
  16926. serialize(): any;
  16927. /** @hidden */
  16928. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16929. /**
  16930. * Creates a new SubEmitter from a serialized JSON version
  16931. * @param serializationObject defines the JSON object to read from
  16932. * @param scene defines the hosting scene
  16933. * @param rootUrl defines the rootUrl for data loading
  16934. * @returns a new SubEmitter
  16935. */
  16936. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16937. /** Release associated resources */
  16938. dispose(): void;
  16939. }
  16940. }
  16941. declare module BABYLON {
  16942. /** @hidden */
  16943. export var clipPlaneFragmentDeclaration: {
  16944. name: string;
  16945. shader: string;
  16946. };
  16947. }
  16948. declare module BABYLON {
  16949. /** @hidden */
  16950. export var imageProcessingDeclaration: {
  16951. name: string;
  16952. shader: string;
  16953. };
  16954. }
  16955. declare module BABYLON {
  16956. /** @hidden */
  16957. export var imageProcessingFunctions: {
  16958. name: string;
  16959. shader: string;
  16960. };
  16961. }
  16962. declare module BABYLON {
  16963. /** @hidden */
  16964. export var clipPlaneFragment: {
  16965. name: string;
  16966. shader: string;
  16967. };
  16968. }
  16969. declare module BABYLON {
  16970. /** @hidden */
  16971. export var particlesPixelShader: {
  16972. name: string;
  16973. shader: string;
  16974. };
  16975. }
  16976. declare module BABYLON {
  16977. /** @hidden */
  16978. export var clipPlaneVertexDeclaration: {
  16979. name: string;
  16980. shader: string;
  16981. };
  16982. }
  16983. declare module BABYLON {
  16984. /** @hidden */
  16985. export var clipPlaneVertex: {
  16986. name: string;
  16987. shader: string;
  16988. };
  16989. }
  16990. declare module BABYLON {
  16991. /** @hidden */
  16992. export var particlesVertexShader: {
  16993. name: string;
  16994. shader: string;
  16995. };
  16996. }
  16997. declare module BABYLON {
  16998. /**
  16999. * This represents a particle system in Babylon.
  17000. * 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.
  17001. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17002. * @example https://doc.babylonjs.com/babylon101/particles
  17003. */
  17004. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17005. /**
  17006. * Billboard mode will only apply to Y axis
  17007. */
  17008. static readonly BILLBOARDMODE_Y: number;
  17009. /**
  17010. * Billboard mode will apply to all axes
  17011. */
  17012. static readonly BILLBOARDMODE_ALL: number;
  17013. /**
  17014. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17015. */
  17016. static readonly BILLBOARDMODE_STRETCHED: number;
  17017. /**
  17018. * This function can be defined to provide custom update for active particles.
  17019. * This function will be called instead of regular update (age, position, color, etc.).
  17020. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17021. */
  17022. updateFunction: (particles: Particle[]) => void;
  17023. private _emitterWorldMatrix;
  17024. /**
  17025. * This function can be defined to specify initial direction for every new particle.
  17026. * It by default use the emitterType defined function
  17027. */
  17028. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17029. /**
  17030. * This function can be defined to specify initial position for every new particle.
  17031. * It by default use the emitterType defined function
  17032. */
  17033. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17034. /**
  17035. * @hidden
  17036. */
  17037. _inheritedVelocityOffset: Vector3;
  17038. /**
  17039. * An event triggered when the system is disposed
  17040. */
  17041. onDisposeObservable: Observable<ParticleSystem>;
  17042. private _onDisposeObserver;
  17043. /**
  17044. * Sets a callback that will be triggered when the system is disposed
  17045. */
  17046. onDispose: () => void;
  17047. private _particles;
  17048. private _epsilon;
  17049. private _capacity;
  17050. private _stockParticles;
  17051. private _newPartsExcess;
  17052. private _vertexData;
  17053. private _vertexBuffer;
  17054. private _vertexBuffers;
  17055. private _spriteBuffer;
  17056. private _indexBuffer;
  17057. private _effect;
  17058. private _customEffect;
  17059. private _cachedDefines;
  17060. private _scaledColorStep;
  17061. private _colorDiff;
  17062. private _scaledDirection;
  17063. private _scaledGravity;
  17064. private _currentRenderId;
  17065. private _alive;
  17066. private _useInstancing;
  17067. private _started;
  17068. private _stopped;
  17069. private _actualFrame;
  17070. private _scaledUpdateSpeed;
  17071. private _vertexBufferSize;
  17072. /** @hidden */
  17073. _currentEmitRateGradient: Nullable<FactorGradient>;
  17074. /** @hidden */
  17075. _currentEmitRate1: number;
  17076. /** @hidden */
  17077. _currentEmitRate2: number;
  17078. /** @hidden */
  17079. _currentStartSizeGradient: Nullable<FactorGradient>;
  17080. /** @hidden */
  17081. _currentStartSize1: number;
  17082. /** @hidden */
  17083. _currentStartSize2: number;
  17084. private readonly _rawTextureWidth;
  17085. private _rampGradientsTexture;
  17086. private _useRampGradients;
  17087. /** Gets or sets a boolean indicating that ramp gradients must be used
  17088. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17089. */
  17090. useRampGradients: boolean;
  17091. /**
  17092. * 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.
  17093. * 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: [])
  17094. */
  17095. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17096. private _subEmitters;
  17097. /**
  17098. * @hidden
  17099. * If the particle systems emitter should be disposed when the particle system is disposed
  17100. */
  17101. _disposeEmitterOnDispose: boolean;
  17102. /**
  17103. * The current active Sub-systems, this property is used by the root particle system only.
  17104. */
  17105. activeSubSystems: Array<ParticleSystem>;
  17106. private _rootParticleSystem;
  17107. /**
  17108. * Gets the current list of active particles
  17109. */
  17110. readonly particles: Particle[];
  17111. /**
  17112. * Returns the string "ParticleSystem"
  17113. * @returns a string containing the class name
  17114. */
  17115. getClassName(): string;
  17116. /**
  17117. * Instantiates a particle system.
  17118. * 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.
  17119. * @param name The name of the particle system
  17120. * @param capacity The max number of particles alive at the same time
  17121. * @param scene The scene the particle system belongs to
  17122. * @param customEffect a custom effect used to change the way particles are rendered by default
  17123. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17124. * @param epsilon Offset used to render the particles
  17125. */
  17126. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17127. private _addFactorGradient;
  17128. private _removeFactorGradient;
  17129. /**
  17130. * Adds a new life time gradient
  17131. * @param gradient defines the gradient to use (between 0 and 1)
  17132. * @param factor defines the life time factor to affect to the specified gradient
  17133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17134. * @returns the current particle system
  17135. */
  17136. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17137. /**
  17138. * Remove a specific life time gradient
  17139. * @param gradient defines the gradient to remove
  17140. * @returns the current particle system
  17141. */
  17142. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17143. /**
  17144. * Adds a new size gradient
  17145. * @param gradient defines the gradient to use (between 0 and 1)
  17146. * @param factor defines the size factor to affect to the specified gradient
  17147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17148. * @returns the current particle system
  17149. */
  17150. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17151. /**
  17152. * Remove a specific size gradient
  17153. * @param gradient defines the gradient to remove
  17154. * @returns the current particle system
  17155. */
  17156. removeSizeGradient(gradient: number): IParticleSystem;
  17157. /**
  17158. * Adds a new color remap gradient
  17159. * @param gradient defines the gradient to use (between 0 and 1)
  17160. * @param min defines the color remap minimal range
  17161. * @param max defines the color remap maximal range
  17162. * @returns the current particle system
  17163. */
  17164. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17165. /**
  17166. * Remove a specific color remap gradient
  17167. * @param gradient defines the gradient to remove
  17168. * @returns the current particle system
  17169. */
  17170. removeColorRemapGradient(gradient: number): IParticleSystem;
  17171. /**
  17172. * Adds a new alpha remap gradient
  17173. * @param gradient defines the gradient to use (between 0 and 1)
  17174. * @param min defines the alpha remap minimal range
  17175. * @param max defines the alpha remap maximal range
  17176. * @returns the current particle system
  17177. */
  17178. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17179. /**
  17180. * Remove a specific alpha remap gradient
  17181. * @param gradient defines the gradient to remove
  17182. * @returns the current particle system
  17183. */
  17184. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17185. /**
  17186. * Adds a new angular speed gradient
  17187. * @param gradient defines the gradient to use (between 0 and 1)
  17188. * @param factor defines the angular speed to affect to the specified gradient
  17189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17190. * @returns the current particle system
  17191. */
  17192. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17193. /**
  17194. * Remove a specific angular speed gradient
  17195. * @param gradient defines the gradient to remove
  17196. * @returns the current particle system
  17197. */
  17198. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17199. /**
  17200. * Adds a new velocity gradient
  17201. * @param gradient defines the gradient to use (between 0 and 1)
  17202. * @param factor defines the velocity to affect to the specified gradient
  17203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17204. * @returns the current particle system
  17205. */
  17206. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17207. /**
  17208. * Remove a specific velocity gradient
  17209. * @param gradient defines the gradient to remove
  17210. * @returns the current particle system
  17211. */
  17212. removeVelocityGradient(gradient: number): IParticleSystem;
  17213. /**
  17214. * Adds a new limit velocity gradient
  17215. * @param gradient defines the gradient to use (between 0 and 1)
  17216. * @param factor defines the limit velocity value to affect to the specified gradient
  17217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17218. * @returns the current particle system
  17219. */
  17220. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17221. /**
  17222. * Remove a specific limit velocity gradient
  17223. * @param gradient defines the gradient to remove
  17224. * @returns the current particle system
  17225. */
  17226. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17227. /**
  17228. * Adds a new drag gradient
  17229. * @param gradient defines the gradient to use (between 0 and 1)
  17230. * @param factor defines the drag value to affect to the specified gradient
  17231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17232. * @returns the current particle system
  17233. */
  17234. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17235. /**
  17236. * Remove a specific drag gradient
  17237. * @param gradient defines the gradient to remove
  17238. * @returns the current particle system
  17239. */
  17240. removeDragGradient(gradient: number): IParticleSystem;
  17241. /**
  17242. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17243. * @param gradient defines the gradient to use (between 0 and 1)
  17244. * @param factor defines the emit rate value to affect to the specified gradient
  17245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17246. * @returns the current particle system
  17247. */
  17248. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17249. /**
  17250. * Remove a specific emit rate gradient
  17251. * @param gradient defines the gradient to remove
  17252. * @returns the current particle system
  17253. */
  17254. removeEmitRateGradient(gradient: number): IParticleSystem;
  17255. /**
  17256. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17257. * @param gradient defines the gradient to use (between 0 and 1)
  17258. * @param factor defines the start size value to affect to the specified gradient
  17259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17260. * @returns the current particle system
  17261. */
  17262. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17263. /**
  17264. * Remove a specific start size gradient
  17265. * @param gradient defines the gradient to remove
  17266. * @returns the current particle system
  17267. */
  17268. removeStartSizeGradient(gradient: number): IParticleSystem;
  17269. private _createRampGradientTexture;
  17270. /**
  17271. * Gets the current list of ramp gradients.
  17272. * You must use addRampGradient and removeRampGradient to udpate this list
  17273. * @returns the list of ramp gradients
  17274. */
  17275. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17276. /**
  17277. * Adds a new ramp gradient used to remap particle colors
  17278. * @param gradient defines the gradient to use (between 0 and 1)
  17279. * @param color defines the color to affect to the specified gradient
  17280. * @returns the current particle system
  17281. */
  17282. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17283. /**
  17284. * Remove a specific ramp gradient
  17285. * @param gradient defines the gradient to remove
  17286. * @returns the current particle system
  17287. */
  17288. removeRampGradient(gradient: number): ParticleSystem;
  17289. /**
  17290. * Adds a new color gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param color1 defines the color to affect to the specified gradient
  17293. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17294. * @returns this particle system
  17295. */
  17296. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17297. /**
  17298. * Remove a specific color gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns this particle system
  17301. */
  17302. removeColorGradient(gradient: number): IParticleSystem;
  17303. private _fetchR;
  17304. protected _reset(): void;
  17305. private _resetEffect;
  17306. private _createVertexBuffers;
  17307. private _createIndexBuffer;
  17308. /**
  17309. * Gets the maximum number of particles active at the same time.
  17310. * @returns The max number of active particles.
  17311. */
  17312. getCapacity(): number;
  17313. /**
  17314. * Gets whether there are still active particles in the system.
  17315. * @returns True if it is alive, otherwise false.
  17316. */
  17317. isAlive(): boolean;
  17318. /**
  17319. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17320. * @returns True if it has been started, otherwise false.
  17321. */
  17322. isStarted(): boolean;
  17323. private _prepareSubEmitterInternalArray;
  17324. /**
  17325. * Starts the particle system and begins to emit
  17326. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17327. */
  17328. start(delay?: number): void;
  17329. /**
  17330. * Stops the particle system.
  17331. * @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.
  17332. */
  17333. stop(stopSubEmitters?: boolean): void;
  17334. /**
  17335. * Remove all active particles
  17336. */
  17337. reset(): void;
  17338. /**
  17339. * @hidden (for internal use only)
  17340. */
  17341. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17342. /**
  17343. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17344. * Its lifetime will start back at 0.
  17345. */
  17346. recycleParticle: (particle: Particle) => void;
  17347. private _stopSubEmitters;
  17348. private _createParticle;
  17349. private _removeFromRoot;
  17350. private _emitFromParticle;
  17351. private _update;
  17352. /** @hidden */
  17353. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17354. /** @hidden */
  17355. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17356. /** @hidden */
  17357. private _getEffect;
  17358. /**
  17359. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17360. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17361. */
  17362. animate(preWarmOnly?: boolean): void;
  17363. private _appendParticleVertices;
  17364. /**
  17365. * Rebuilds the particle system.
  17366. */
  17367. rebuild(): void;
  17368. /**
  17369. * Is this system ready to be used/rendered
  17370. * @return true if the system is ready
  17371. */
  17372. isReady(): boolean;
  17373. private _render;
  17374. /**
  17375. * Renders the particle system in its current state.
  17376. * @returns the current number of particles
  17377. */
  17378. render(): number;
  17379. /**
  17380. * Disposes the particle system and free the associated resources
  17381. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17382. */
  17383. dispose(disposeTexture?: boolean): void;
  17384. /**
  17385. * Clones the particle system.
  17386. * @param name The name of the cloned object
  17387. * @param newEmitter The new emitter to use
  17388. * @returns the cloned particle system
  17389. */
  17390. clone(name: string, newEmitter: any): ParticleSystem;
  17391. /**
  17392. * Serializes the particle system to a JSON object.
  17393. * @returns the JSON object
  17394. */
  17395. serialize(): any;
  17396. /** @hidden */
  17397. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17398. /** @hidden */
  17399. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17400. /**
  17401. * Parses a JSON object to create a particle system.
  17402. * @param parsedParticleSystem The JSON object to parse
  17403. * @param scene The scene to create the particle system in
  17404. * @param rootUrl The root url to use to load external dependencies like texture
  17405. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17406. * @returns the Parsed particle system
  17407. */
  17408. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17409. }
  17410. }
  17411. declare module BABYLON {
  17412. /**
  17413. * A particle represents one of the element emitted by a particle system.
  17414. * This is mainly define by its coordinates, direction, velocity and age.
  17415. */
  17416. export class Particle {
  17417. /**
  17418. * The particle system the particle belongs to.
  17419. */
  17420. particleSystem: ParticleSystem;
  17421. private static _Count;
  17422. /**
  17423. * Unique ID of the particle
  17424. */
  17425. id: number;
  17426. /**
  17427. * The world position of the particle in the scene.
  17428. */
  17429. position: Vector3;
  17430. /**
  17431. * The world direction of the particle in the scene.
  17432. */
  17433. direction: Vector3;
  17434. /**
  17435. * The color of the particle.
  17436. */
  17437. color: Color4;
  17438. /**
  17439. * The color change of the particle per step.
  17440. */
  17441. colorStep: Color4;
  17442. /**
  17443. * Defines how long will the life of the particle be.
  17444. */
  17445. lifeTime: number;
  17446. /**
  17447. * The current age of the particle.
  17448. */
  17449. age: number;
  17450. /**
  17451. * The current size of the particle.
  17452. */
  17453. size: number;
  17454. /**
  17455. * The current scale of the particle.
  17456. */
  17457. scale: Vector2;
  17458. /**
  17459. * The current angle of the particle.
  17460. */
  17461. angle: number;
  17462. /**
  17463. * Defines how fast is the angle changing.
  17464. */
  17465. angularSpeed: number;
  17466. /**
  17467. * Defines the cell index used by the particle to be rendered from a sprite.
  17468. */
  17469. cellIndex: number;
  17470. /**
  17471. * The information required to support color remapping
  17472. */
  17473. remapData: Vector4;
  17474. /** @hidden */
  17475. _randomCellOffset?: number;
  17476. /** @hidden */
  17477. _initialDirection: Nullable<Vector3>;
  17478. /** @hidden */
  17479. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17480. /** @hidden */
  17481. _initialStartSpriteCellID: number;
  17482. /** @hidden */
  17483. _initialEndSpriteCellID: number;
  17484. /** @hidden */
  17485. _currentColorGradient: Nullable<ColorGradient>;
  17486. /** @hidden */
  17487. _currentColor1: Color4;
  17488. /** @hidden */
  17489. _currentColor2: Color4;
  17490. /** @hidden */
  17491. _currentSizeGradient: Nullable<FactorGradient>;
  17492. /** @hidden */
  17493. _currentSize1: number;
  17494. /** @hidden */
  17495. _currentSize2: number;
  17496. /** @hidden */
  17497. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17498. /** @hidden */
  17499. _currentAngularSpeed1: number;
  17500. /** @hidden */
  17501. _currentAngularSpeed2: number;
  17502. /** @hidden */
  17503. _currentVelocityGradient: Nullable<FactorGradient>;
  17504. /** @hidden */
  17505. _currentVelocity1: number;
  17506. /** @hidden */
  17507. _currentVelocity2: number;
  17508. /** @hidden */
  17509. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17510. /** @hidden */
  17511. _currentLimitVelocity1: number;
  17512. /** @hidden */
  17513. _currentLimitVelocity2: number;
  17514. /** @hidden */
  17515. _currentDragGradient: Nullable<FactorGradient>;
  17516. /** @hidden */
  17517. _currentDrag1: number;
  17518. /** @hidden */
  17519. _currentDrag2: number;
  17520. /** @hidden */
  17521. _randomNoiseCoordinates1: Vector3;
  17522. /** @hidden */
  17523. _randomNoiseCoordinates2: Vector3;
  17524. /**
  17525. * Creates a new instance Particle
  17526. * @param particleSystem the particle system the particle belongs to
  17527. */
  17528. constructor(
  17529. /**
  17530. * The particle system the particle belongs to.
  17531. */
  17532. particleSystem: ParticleSystem);
  17533. private updateCellInfoFromSystem;
  17534. /**
  17535. * Defines how the sprite cell index is updated for the particle
  17536. */
  17537. updateCellIndex(): void;
  17538. /** @hidden */
  17539. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17540. /** @hidden */
  17541. _inheritParticleInfoToSubEmitters(): void;
  17542. /** @hidden */
  17543. _reset(): void;
  17544. /**
  17545. * Copy the properties of particle to another one.
  17546. * @param other the particle to copy the information to.
  17547. */
  17548. copyTo(other: Particle): void;
  17549. }
  17550. }
  17551. declare module BABYLON {
  17552. /**
  17553. * Particle emitter represents a volume emitting particles.
  17554. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17555. */
  17556. export interface IParticleEmitterType {
  17557. /**
  17558. * Called by the particle System when the direction is computed for the created particle.
  17559. * @param worldMatrix is the world matrix of the particle system
  17560. * @param directionToUpdate is the direction vector to update with the result
  17561. * @param particle is the particle we are computed the direction for
  17562. */
  17563. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17564. /**
  17565. * Called by the particle System when the position is computed for the created particle.
  17566. * @param worldMatrix is the world matrix of the particle system
  17567. * @param positionToUpdate is the position vector to update with the result
  17568. * @param particle is the particle we are computed the position for
  17569. */
  17570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17571. /**
  17572. * Clones the current emitter and returns a copy of it
  17573. * @returns the new emitter
  17574. */
  17575. clone(): IParticleEmitterType;
  17576. /**
  17577. * Called by the GPUParticleSystem to setup the update shader
  17578. * @param effect defines the update shader
  17579. */
  17580. applyToShader(effect: Effect): void;
  17581. /**
  17582. * Returns a string to use to update the GPU particles update shader
  17583. * @returns the effect defines string
  17584. */
  17585. getEffectDefines(): string;
  17586. /**
  17587. * Returns a string representing the class name
  17588. * @returns a string containing the class name
  17589. */
  17590. getClassName(): string;
  17591. /**
  17592. * Serializes the particle system to a JSON object.
  17593. * @returns the JSON object
  17594. */
  17595. serialize(): any;
  17596. /**
  17597. * Parse properties from a JSON object
  17598. * @param serializationObject defines the JSON object
  17599. */
  17600. parse(serializationObject: any): void;
  17601. }
  17602. }
  17603. declare module BABYLON {
  17604. /**
  17605. * Particle emitter emitting particles from the inside of a box.
  17606. * It emits the particles randomly between 2 given directions.
  17607. */
  17608. export class BoxParticleEmitter implements IParticleEmitterType {
  17609. /**
  17610. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17611. */
  17612. direction1: Vector3;
  17613. /**
  17614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17615. */
  17616. direction2: Vector3;
  17617. /**
  17618. * 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.
  17619. */
  17620. minEmitBox: Vector3;
  17621. /**
  17622. * 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.
  17623. */
  17624. maxEmitBox: Vector3;
  17625. /**
  17626. * Creates a new instance BoxParticleEmitter
  17627. */
  17628. constructor();
  17629. /**
  17630. * Called by the particle System when the direction is computed for the created particle.
  17631. * @param worldMatrix is the world matrix of the particle system
  17632. * @param directionToUpdate is the direction vector to update with the result
  17633. * @param particle is the particle we are computed the direction for
  17634. */
  17635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17636. /**
  17637. * Called by the particle System when the position is computed for the created particle.
  17638. * @param worldMatrix is the world matrix of the particle system
  17639. * @param positionToUpdate is the position vector to update with the result
  17640. * @param particle is the particle we are computed the position for
  17641. */
  17642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17643. /**
  17644. * Clones the current emitter and returns a copy of it
  17645. * @returns the new emitter
  17646. */
  17647. clone(): BoxParticleEmitter;
  17648. /**
  17649. * Called by the GPUParticleSystem to setup the update shader
  17650. * @param effect defines the update shader
  17651. */
  17652. applyToShader(effect: Effect): void;
  17653. /**
  17654. * Returns a string to use to update the GPU particles update shader
  17655. * @returns a string containng the defines string
  17656. */
  17657. getEffectDefines(): string;
  17658. /**
  17659. * Returns the string "BoxParticleEmitter"
  17660. * @returns a string containing the class name
  17661. */
  17662. getClassName(): string;
  17663. /**
  17664. * Serializes the particle system to a JSON object.
  17665. * @returns the JSON object
  17666. */
  17667. serialize(): any;
  17668. /**
  17669. * Parse properties from a JSON object
  17670. * @param serializationObject defines the JSON object
  17671. */
  17672. parse(serializationObject: any): void;
  17673. }
  17674. }
  17675. declare module BABYLON {
  17676. /**
  17677. * Particle emitter emitting particles from the inside of a cone.
  17678. * It emits the particles alongside the cone volume from the base to the particle.
  17679. * The emission direction might be randomized.
  17680. */
  17681. export class ConeParticleEmitter implements IParticleEmitterType {
  17682. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17683. directionRandomizer: number;
  17684. private _radius;
  17685. private _angle;
  17686. private _height;
  17687. /**
  17688. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17689. */
  17690. radiusRange: number;
  17691. /**
  17692. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17693. */
  17694. heightRange: number;
  17695. /**
  17696. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17697. */
  17698. emitFromSpawnPointOnly: boolean;
  17699. /**
  17700. * Gets or sets the radius of the emission cone
  17701. */
  17702. radius: number;
  17703. /**
  17704. * Gets or sets the angle of the emission cone
  17705. */
  17706. angle: number;
  17707. private _buildHeight;
  17708. /**
  17709. * Creates a new instance ConeParticleEmitter
  17710. * @param radius the radius of the emission cone (1 by default)
  17711. * @param angle the cone base angle (PI by default)
  17712. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17713. */
  17714. constructor(radius?: number, angle?: number,
  17715. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17716. directionRandomizer?: number);
  17717. /**
  17718. * Called by the particle System when the direction is computed for the created particle.
  17719. * @param worldMatrix is the world matrix of the particle system
  17720. * @param directionToUpdate is the direction vector to update with the result
  17721. * @param particle is the particle we are computed the direction for
  17722. */
  17723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17724. /**
  17725. * Called by the particle System when the position is computed for the created particle.
  17726. * @param worldMatrix is the world matrix of the particle system
  17727. * @param positionToUpdate is the position vector to update with the result
  17728. * @param particle is the particle we are computed the position for
  17729. */
  17730. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17731. /**
  17732. * Clones the current emitter and returns a copy of it
  17733. * @returns the new emitter
  17734. */
  17735. clone(): ConeParticleEmitter;
  17736. /**
  17737. * Called by the GPUParticleSystem to setup the update shader
  17738. * @param effect defines the update shader
  17739. */
  17740. applyToShader(effect: Effect): void;
  17741. /**
  17742. * Returns a string to use to update the GPU particles update shader
  17743. * @returns a string containng the defines string
  17744. */
  17745. getEffectDefines(): string;
  17746. /**
  17747. * Returns the string "ConeParticleEmitter"
  17748. * @returns a string containing the class name
  17749. */
  17750. getClassName(): string;
  17751. /**
  17752. * Serializes the particle system to a JSON object.
  17753. * @returns the JSON object
  17754. */
  17755. serialize(): any;
  17756. /**
  17757. * Parse properties from a JSON object
  17758. * @param serializationObject defines the JSON object
  17759. */
  17760. parse(serializationObject: any): void;
  17761. }
  17762. }
  17763. declare module BABYLON {
  17764. /**
  17765. * Particle emitter emitting particles from the inside of a cylinder.
  17766. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17767. */
  17768. export class CylinderParticleEmitter implements IParticleEmitterType {
  17769. /**
  17770. * The radius of the emission cylinder.
  17771. */
  17772. radius: number;
  17773. /**
  17774. * The height of the emission cylinder.
  17775. */
  17776. height: number;
  17777. /**
  17778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17779. */
  17780. radiusRange: number;
  17781. /**
  17782. * How much to randomize the particle direction [0-1].
  17783. */
  17784. directionRandomizer: number;
  17785. /**
  17786. * Creates a new instance CylinderParticleEmitter
  17787. * @param radius the radius of the emission cylinder (1 by default)
  17788. * @param height the height of the emission cylinder (1 by default)
  17789. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17790. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17791. */
  17792. constructor(
  17793. /**
  17794. * The radius of the emission cylinder.
  17795. */
  17796. radius?: number,
  17797. /**
  17798. * The height of the emission cylinder.
  17799. */
  17800. height?: number,
  17801. /**
  17802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17803. */
  17804. radiusRange?: number,
  17805. /**
  17806. * How much to randomize the particle direction [0-1].
  17807. */
  17808. directionRandomizer?: number);
  17809. /**
  17810. * Called by the particle System when the direction is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param directionToUpdate is the direction vector to update with the result
  17813. * @param particle is the particle we are computed the direction for
  17814. */
  17815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Called by the particle System when the position is computed for the created particle.
  17818. * @param worldMatrix is the world matrix of the particle system
  17819. * @param positionToUpdate is the position vector to update with the result
  17820. * @param particle is the particle we are computed the position for
  17821. */
  17822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17823. /**
  17824. * Clones the current emitter and returns a copy of it
  17825. * @returns the new emitter
  17826. */
  17827. clone(): CylinderParticleEmitter;
  17828. /**
  17829. * Called by the GPUParticleSystem to setup the update shader
  17830. * @param effect defines the update shader
  17831. */
  17832. applyToShader(effect: Effect): void;
  17833. /**
  17834. * Returns a string to use to update the GPU particles update shader
  17835. * @returns a string containng the defines string
  17836. */
  17837. getEffectDefines(): string;
  17838. /**
  17839. * Returns the string "CylinderParticleEmitter"
  17840. * @returns a string containing the class name
  17841. */
  17842. getClassName(): string;
  17843. /**
  17844. * Serializes the particle system to a JSON object.
  17845. * @returns the JSON object
  17846. */
  17847. serialize(): any;
  17848. /**
  17849. * Parse properties from a JSON object
  17850. * @param serializationObject defines the JSON object
  17851. */
  17852. parse(serializationObject: any): void;
  17853. }
  17854. /**
  17855. * Particle emitter emitting particles from the inside of a cylinder.
  17856. * It emits the particles randomly between two vectors.
  17857. */
  17858. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17859. /**
  17860. * The min limit of the emission direction.
  17861. */
  17862. direction1: Vector3;
  17863. /**
  17864. * The max limit of the emission direction.
  17865. */
  17866. direction2: Vector3;
  17867. /**
  17868. * Creates a new instance CylinderDirectedParticleEmitter
  17869. * @param radius the radius of the emission cylinder (1 by default)
  17870. * @param height the height of the emission cylinder (1 by default)
  17871. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17872. * @param direction1 the min limit of the emission direction (up vector by default)
  17873. * @param direction2 the max limit of the emission direction (up vector by default)
  17874. */
  17875. constructor(radius?: number, height?: number, radiusRange?: number,
  17876. /**
  17877. * The min limit of the emission direction.
  17878. */
  17879. direction1?: Vector3,
  17880. /**
  17881. * The max limit of the emission direction.
  17882. */
  17883. direction2?: Vector3);
  17884. /**
  17885. * Called by the particle System when the direction is computed for the created particle.
  17886. * @param worldMatrix is the world matrix of the particle system
  17887. * @param directionToUpdate is the direction vector to update with the result
  17888. * @param particle is the particle we are computed the direction for
  17889. */
  17890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17891. /**
  17892. * Clones the current emitter and returns a copy of it
  17893. * @returns the new emitter
  17894. */
  17895. clone(): CylinderDirectedParticleEmitter;
  17896. /**
  17897. * Called by the GPUParticleSystem to setup the update shader
  17898. * @param effect defines the update shader
  17899. */
  17900. applyToShader(effect: Effect): void;
  17901. /**
  17902. * Returns a string to use to update the GPU particles update shader
  17903. * @returns a string containng the defines string
  17904. */
  17905. getEffectDefines(): string;
  17906. /**
  17907. * Returns the string "CylinderDirectedParticleEmitter"
  17908. * @returns a string containing the class name
  17909. */
  17910. getClassName(): string;
  17911. /**
  17912. * Serializes the particle system to a JSON object.
  17913. * @returns the JSON object
  17914. */
  17915. serialize(): any;
  17916. /**
  17917. * Parse properties from a JSON object
  17918. * @param serializationObject defines the JSON object
  17919. */
  17920. parse(serializationObject: any): void;
  17921. }
  17922. }
  17923. declare module BABYLON {
  17924. /**
  17925. * Particle emitter emitting particles from the inside of a hemisphere.
  17926. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17927. */
  17928. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17929. /**
  17930. * The radius of the emission hemisphere.
  17931. */
  17932. radius: number;
  17933. /**
  17934. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17935. */
  17936. radiusRange: number;
  17937. /**
  17938. * How much to randomize the particle direction [0-1].
  17939. */
  17940. directionRandomizer: number;
  17941. /**
  17942. * Creates a new instance HemisphericParticleEmitter
  17943. * @param radius the radius of the emission hemisphere (1 by default)
  17944. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17945. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17946. */
  17947. constructor(
  17948. /**
  17949. * The radius of the emission hemisphere.
  17950. */
  17951. radius?: number,
  17952. /**
  17953. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17954. */
  17955. radiusRange?: number,
  17956. /**
  17957. * How much to randomize the particle direction [0-1].
  17958. */
  17959. directionRandomizer?: number);
  17960. /**
  17961. * Called by the particle System when the direction is computed for the created particle.
  17962. * @param worldMatrix is the world matrix of the particle system
  17963. * @param directionToUpdate is the direction vector to update with the result
  17964. * @param particle is the particle we are computed the direction for
  17965. */
  17966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17967. /**
  17968. * Called by the particle System when the position is computed for the created particle.
  17969. * @param worldMatrix is the world matrix of the particle system
  17970. * @param positionToUpdate is the position vector to update with the result
  17971. * @param particle is the particle we are computed the position for
  17972. */
  17973. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17974. /**
  17975. * Clones the current emitter and returns a copy of it
  17976. * @returns the new emitter
  17977. */
  17978. clone(): HemisphericParticleEmitter;
  17979. /**
  17980. * Called by the GPUParticleSystem to setup the update shader
  17981. * @param effect defines the update shader
  17982. */
  17983. applyToShader(effect: Effect): void;
  17984. /**
  17985. * Returns a string to use to update the GPU particles update shader
  17986. * @returns a string containng the defines string
  17987. */
  17988. getEffectDefines(): string;
  17989. /**
  17990. * Returns the string "HemisphericParticleEmitter"
  17991. * @returns a string containing the class name
  17992. */
  17993. getClassName(): string;
  17994. /**
  17995. * Serializes the particle system to a JSON object.
  17996. * @returns the JSON object
  17997. */
  17998. serialize(): any;
  17999. /**
  18000. * Parse properties from a JSON object
  18001. * @param serializationObject defines the JSON object
  18002. */
  18003. parse(serializationObject: any): void;
  18004. }
  18005. }
  18006. declare module BABYLON {
  18007. /**
  18008. * Particle emitter emitting particles from a point.
  18009. * It emits the particles randomly between 2 given directions.
  18010. */
  18011. export class PointParticleEmitter implements IParticleEmitterType {
  18012. /**
  18013. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18014. */
  18015. direction1: Vector3;
  18016. /**
  18017. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18018. */
  18019. direction2: Vector3;
  18020. /**
  18021. * Creates a new instance PointParticleEmitter
  18022. */
  18023. constructor();
  18024. /**
  18025. * Called by the particle System when the direction is computed for the created particle.
  18026. * @param worldMatrix is the world matrix of the particle system
  18027. * @param directionToUpdate is the direction vector to update with the result
  18028. * @param particle is the particle we are computed the direction for
  18029. */
  18030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18031. /**
  18032. * Called by the particle System when the position is computed for the created particle.
  18033. * @param worldMatrix is the world matrix of the particle system
  18034. * @param positionToUpdate is the position vector to update with the result
  18035. * @param particle is the particle we are computed the position for
  18036. */
  18037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18038. /**
  18039. * Clones the current emitter and returns a copy of it
  18040. * @returns the new emitter
  18041. */
  18042. clone(): PointParticleEmitter;
  18043. /**
  18044. * Called by the GPUParticleSystem to setup the update shader
  18045. * @param effect defines the update shader
  18046. */
  18047. applyToShader(effect: Effect): void;
  18048. /**
  18049. * Returns a string to use to update the GPU particles update shader
  18050. * @returns a string containng the defines string
  18051. */
  18052. getEffectDefines(): string;
  18053. /**
  18054. * Returns the string "PointParticleEmitter"
  18055. * @returns a string containing the class name
  18056. */
  18057. getClassName(): string;
  18058. /**
  18059. * Serializes the particle system to a JSON object.
  18060. * @returns the JSON object
  18061. */
  18062. serialize(): any;
  18063. /**
  18064. * Parse properties from a JSON object
  18065. * @param serializationObject defines the JSON object
  18066. */
  18067. parse(serializationObject: any): void;
  18068. }
  18069. }
  18070. declare module BABYLON {
  18071. /**
  18072. * Particle emitter emitting particles from the inside of a sphere.
  18073. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18074. */
  18075. export class SphereParticleEmitter implements IParticleEmitterType {
  18076. /**
  18077. * The radius of the emission sphere.
  18078. */
  18079. radius: number;
  18080. /**
  18081. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18082. */
  18083. radiusRange: number;
  18084. /**
  18085. * How much to randomize the particle direction [0-1].
  18086. */
  18087. directionRandomizer: number;
  18088. /**
  18089. * Creates a new instance SphereParticleEmitter
  18090. * @param radius the radius of the emission sphere (1 by default)
  18091. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18092. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18093. */
  18094. constructor(
  18095. /**
  18096. * The radius of the emission sphere.
  18097. */
  18098. radius?: number,
  18099. /**
  18100. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18101. */
  18102. radiusRange?: number,
  18103. /**
  18104. * How much to randomize the particle direction [0-1].
  18105. */
  18106. directionRandomizer?: number);
  18107. /**
  18108. * Called by the particle System when the direction is computed for the created particle.
  18109. * @param worldMatrix is the world matrix of the particle system
  18110. * @param directionToUpdate is the direction vector to update with the result
  18111. * @param particle is the particle we are computed the direction for
  18112. */
  18113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18114. /**
  18115. * Called by the particle System when the position is computed for the created particle.
  18116. * @param worldMatrix is the world matrix of the particle system
  18117. * @param positionToUpdate is the position vector to update with the result
  18118. * @param particle is the particle we are computed the position for
  18119. */
  18120. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18121. /**
  18122. * Clones the current emitter and returns a copy of it
  18123. * @returns the new emitter
  18124. */
  18125. clone(): SphereParticleEmitter;
  18126. /**
  18127. * Called by the GPUParticleSystem to setup the update shader
  18128. * @param effect defines the update shader
  18129. */
  18130. applyToShader(effect: Effect): void;
  18131. /**
  18132. * Returns a string to use to update the GPU particles update shader
  18133. * @returns a string containng the defines string
  18134. */
  18135. getEffectDefines(): string;
  18136. /**
  18137. * Returns the string "SphereParticleEmitter"
  18138. * @returns a string containing the class name
  18139. */
  18140. getClassName(): string;
  18141. /**
  18142. * Serializes the particle system to a JSON object.
  18143. * @returns the JSON object
  18144. */
  18145. serialize(): any;
  18146. /**
  18147. * Parse properties from a JSON object
  18148. * @param serializationObject defines the JSON object
  18149. */
  18150. parse(serializationObject: any): void;
  18151. }
  18152. /**
  18153. * Particle emitter emitting particles from the inside of a sphere.
  18154. * It emits the particles randomly between two vectors.
  18155. */
  18156. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18157. /**
  18158. * The min limit of the emission direction.
  18159. */
  18160. direction1: Vector3;
  18161. /**
  18162. * The max limit of the emission direction.
  18163. */
  18164. direction2: Vector3;
  18165. /**
  18166. * Creates a new instance SphereDirectedParticleEmitter
  18167. * @param radius the radius of the emission sphere (1 by default)
  18168. * @param direction1 the min limit of the emission direction (up vector by default)
  18169. * @param direction2 the max limit of the emission direction (up vector by default)
  18170. */
  18171. constructor(radius?: number,
  18172. /**
  18173. * The min limit of the emission direction.
  18174. */
  18175. direction1?: Vector3,
  18176. /**
  18177. * The max limit of the emission direction.
  18178. */
  18179. direction2?: Vector3);
  18180. /**
  18181. * Called by the particle System when the direction is computed for the created particle.
  18182. * @param worldMatrix is the world matrix of the particle system
  18183. * @param directionToUpdate is the direction vector to update with the result
  18184. * @param particle is the particle we are computed the direction for
  18185. */
  18186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18187. /**
  18188. * Clones the current emitter and returns a copy of it
  18189. * @returns the new emitter
  18190. */
  18191. clone(): SphereDirectedParticleEmitter;
  18192. /**
  18193. * Called by the GPUParticleSystem to setup the update shader
  18194. * @param effect defines the update shader
  18195. */
  18196. applyToShader(effect: Effect): void;
  18197. /**
  18198. * Returns a string to use to update the GPU particles update shader
  18199. * @returns a string containng the defines string
  18200. */
  18201. getEffectDefines(): string;
  18202. /**
  18203. * Returns the string "SphereDirectedParticleEmitter"
  18204. * @returns a string containing the class name
  18205. */
  18206. getClassName(): string;
  18207. /**
  18208. * Serializes the particle system to a JSON object.
  18209. * @returns the JSON object
  18210. */
  18211. serialize(): any;
  18212. /**
  18213. * Parse properties from a JSON object
  18214. * @param serializationObject defines the JSON object
  18215. */
  18216. parse(serializationObject: any): void;
  18217. }
  18218. }
  18219. declare module BABYLON {
  18220. /**
  18221. * Interface representing a particle system in Babylon.js.
  18222. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18223. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18224. */
  18225. export interface IParticleSystem {
  18226. /**
  18227. * List of animations used by the particle system.
  18228. */
  18229. animations: Animation[];
  18230. /**
  18231. * The id of the Particle system.
  18232. */
  18233. id: string;
  18234. /**
  18235. * The name of the Particle system.
  18236. */
  18237. name: string;
  18238. /**
  18239. * The emitter represents the Mesh or position we are attaching the particle system to.
  18240. */
  18241. emitter: Nullable<AbstractMesh | Vector3>;
  18242. /**
  18243. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18244. */
  18245. isBillboardBased: boolean;
  18246. /**
  18247. * The rendering group used by the Particle system to chose when to render.
  18248. */
  18249. renderingGroupId: number;
  18250. /**
  18251. * The layer mask we are rendering the particles through.
  18252. */
  18253. layerMask: number;
  18254. /**
  18255. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18256. */
  18257. updateSpeed: number;
  18258. /**
  18259. * The amount of time the particle system is running (depends of the overall update speed).
  18260. */
  18261. targetStopDuration: number;
  18262. /**
  18263. * The texture used to render each particle. (this can be a spritesheet)
  18264. */
  18265. particleTexture: Nullable<Texture>;
  18266. /**
  18267. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18268. */
  18269. blendMode: number;
  18270. /**
  18271. * Minimum life time of emitting particles.
  18272. */
  18273. minLifeTime: number;
  18274. /**
  18275. * Maximum life time of emitting particles.
  18276. */
  18277. maxLifeTime: number;
  18278. /**
  18279. * Minimum Size of emitting particles.
  18280. */
  18281. minSize: number;
  18282. /**
  18283. * Maximum Size of emitting particles.
  18284. */
  18285. maxSize: number;
  18286. /**
  18287. * Minimum scale of emitting particles on X axis.
  18288. */
  18289. minScaleX: number;
  18290. /**
  18291. * Maximum scale of emitting particles on X axis.
  18292. */
  18293. maxScaleX: number;
  18294. /**
  18295. * Minimum scale of emitting particles on Y axis.
  18296. */
  18297. minScaleY: number;
  18298. /**
  18299. * Maximum scale of emitting particles on Y axis.
  18300. */
  18301. maxScaleY: number;
  18302. /**
  18303. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18304. */
  18305. color1: Color4;
  18306. /**
  18307. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18308. */
  18309. color2: Color4;
  18310. /**
  18311. * Color the particle will have at the end of its lifetime.
  18312. */
  18313. colorDead: Color4;
  18314. /**
  18315. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18316. */
  18317. emitRate: number;
  18318. /**
  18319. * You can use gravity if you want to give an orientation to your particles.
  18320. */
  18321. gravity: Vector3;
  18322. /**
  18323. * Minimum power of emitting particles.
  18324. */
  18325. minEmitPower: number;
  18326. /**
  18327. * Maximum power of emitting particles.
  18328. */
  18329. maxEmitPower: number;
  18330. /**
  18331. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18332. */
  18333. minAngularSpeed: number;
  18334. /**
  18335. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18336. */
  18337. maxAngularSpeed: number;
  18338. /**
  18339. * Gets or sets the minimal initial rotation in radians.
  18340. */
  18341. minInitialRotation: number;
  18342. /**
  18343. * Gets or sets the maximal initial rotation in radians.
  18344. */
  18345. maxInitialRotation: number;
  18346. /**
  18347. * The particle emitter type defines the emitter used by the particle system.
  18348. * It can be for example box, sphere, or cone...
  18349. */
  18350. particleEmitterType: Nullable<IParticleEmitterType>;
  18351. /**
  18352. * Defines the delay in milliseconds before starting the system (0 by default)
  18353. */
  18354. startDelay: number;
  18355. /**
  18356. * 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
  18357. */
  18358. preWarmCycles: number;
  18359. /**
  18360. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18361. */
  18362. preWarmStepOffset: number;
  18363. /**
  18364. * 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)
  18365. */
  18366. spriteCellChangeSpeed: number;
  18367. /**
  18368. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18369. */
  18370. startSpriteCellID: number;
  18371. /**
  18372. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18373. */
  18374. endSpriteCellID: number;
  18375. /**
  18376. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18377. */
  18378. spriteCellWidth: number;
  18379. /**
  18380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18381. */
  18382. spriteCellHeight: number;
  18383. /**
  18384. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18385. */
  18386. spriteRandomStartCell: boolean;
  18387. /**
  18388. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18389. */
  18390. isAnimationSheetEnabled: boolean;
  18391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18392. translationPivot: Vector2;
  18393. /**
  18394. * Gets or sets a texture used to add random noise to particle positions
  18395. */
  18396. noiseTexture: Nullable<BaseTexture>;
  18397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18398. noiseStrength: Vector3;
  18399. /**
  18400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18402. */
  18403. billboardMode: number;
  18404. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18405. limitVelocityDamping: number;
  18406. /**
  18407. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18408. */
  18409. beginAnimationOnStart: boolean;
  18410. /**
  18411. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18412. */
  18413. beginAnimationFrom: number;
  18414. /**
  18415. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18416. */
  18417. beginAnimationTo: number;
  18418. /**
  18419. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18420. */
  18421. beginAnimationLoop: boolean;
  18422. /**
  18423. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18424. */
  18425. disposeOnStop: boolean;
  18426. /**
  18427. * Gets the maximum number of particles active at the same time.
  18428. * @returns The max number of active particles.
  18429. */
  18430. getCapacity(): number;
  18431. /**
  18432. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18433. * @returns True if it has been started, otherwise false.
  18434. */
  18435. isStarted(): boolean;
  18436. /**
  18437. * Animates the particle system for this frame.
  18438. */
  18439. animate(): void;
  18440. /**
  18441. * Renders the particle system in its current state.
  18442. * @returns the current number of particles
  18443. */
  18444. render(): number;
  18445. /**
  18446. * Dispose the particle system and frees its associated resources.
  18447. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18448. */
  18449. dispose(disposeTexture?: boolean): void;
  18450. /**
  18451. * Clones the particle system.
  18452. * @param name The name of the cloned object
  18453. * @param newEmitter The new emitter to use
  18454. * @returns the cloned particle system
  18455. */
  18456. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18457. /**
  18458. * Serializes the particle system to a JSON object.
  18459. * @returns the JSON object
  18460. */
  18461. serialize(): any;
  18462. /**
  18463. * Rebuild the particle system
  18464. */
  18465. rebuild(): void;
  18466. /**
  18467. * Starts the particle system and begins to emit
  18468. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18469. */
  18470. start(delay?: number): void;
  18471. /**
  18472. * Stops the particle system.
  18473. */
  18474. stop(): void;
  18475. /**
  18476. * Remove all active particles
  18477. */
  18478. reset(): void;
  18479. /**
  18480. * Is this system ready to be used/rendered
  18481. * @return true if the system is ready
  18482. */
  18483. isReady(): boolean;
  18484. /**
  18485. * Adds a new color gradient
  18486. * @param gradient defines the gradient to use (between 0 and 1)
  18487. * @param color1 defines the color to affect to the specified gradient
  18488. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18489. * @returns the current particle system
  18490. */
  18491. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18492. /**
  18493. * Remove a specific color gradient
  18494. * @param gradient defines the gradient to remove
  18495. * @returns the current particle system
  18496. */
  18497. removeColorGradient(gradient: number): IParticleSystem;
  18498. /**
  18499. * Adds a new size gradient
  18500. * @param gradient defines the gradient to use (between 0 and 1)
  18501. * @param factor defines the size factor to affect to the specified gradient
  18502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18503. * @returns the current particle system
  18504. */
  18505. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18506. /**
  18507. * Remove a specific size gradient
  18508. * @param gradient defines the gradient to remove
  18509. * @returns the current particle system
  18510. */
  18511. removeSizeGradient(gradient: number): IParticleSystem;
  18512. /**
  18513. * Gets the current list of color gradients.
  18514. * You must use addColorGradient and removeColorGradient to udpate this list
  18515. * @returns the list of color gradients
  18516. */
  18517. getColorGradients(): Nullable<Array<ColorGradient>>;
  18518. /**
  18519. * Gets the current list of size gradients.
  18520. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18521. * @returns the list of size gradients
  18522. */
  18523. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18524. /**
  18525. * Gets the current list of angular speed gradients.
  18526. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18527. * @returns the list of angular speed gradients
  18528. */
  18529. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18530. /**
  18531. * Adds a new angular speed gradient
  18532. * @param gradient defines the gradient to use (between 0 and 1)
  18533. * @param factor defines the angular speed to affect to the specified gradient
  18534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18535. * @returns the current particle system
  18536. */
  18537. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18538. /**
  18539. * Remove a specific angular speed gradient
  18540. * @param gradient defines the gradient to remove
  18541. * @returns the current particle system
  18542. */
  18543. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18544. /**
  18545. * Gets the current list of velocity gradients.
  18546. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18547. * @returns the list of velocity gradients
  18548. */
  18549. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18550. /**
  18551. * Adds a new velocity gradient
  18552. * @param gradient defines the gradient to use (between 0 and 1)
  18553. * @param factor defines the velocity to affect to the specified gradient
  18554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18555. * @returns the current particle system
  18556. */
  18557. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18558. /**
  18559. * Remove a specific velocity gradient
  18560. * @param gradient defines the gradient to remove
  18561. * @returns the current particle system
  18562. */
  18563. removeVelocityGradient(gradient: number): IParticleSystem;
  18564. /**
  18565. * Gets the current list of limit velocity gradients.
  18566. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18567. * @returns the list of limit velocity gradients
  18568. */
  18569. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18570. /**
  18571. * Adds a new limit velocity gradient
  18572. * @param gradient defines the gradient to use (between 0 and 1)
  18573. * @param factor defines the limit velocity to affect to the specified gradient
  18574. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18575. * @returns the current particle system
  18576. */
  18577. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18578. /**
  18579. * Remove a specific limit velocity gradient
  18580. * @param gradient defines the gradient to remove
  18581. * @returns the current particle system
  18582. */
  18583. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18584. /**
  18585. * Adds a new drag gradient
  18586. * @param gradient defines the gradient to use (between 0 and 1)
  18587. * @param factor defines the drag to affect to the specified gradient
  18588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18589. * @returns the current particle system
  18590. */
  18591. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18592. /**
  18593. * Remove a specific drag gradient
  18594. * @param gradient defines the gradient to remove
  18595. * @returns the current particle system
  18596. */
  18597. removeDragGradient(gradient: number): IParticleSystem;
  18598. /**
  18599. * Gets the current list of drag gradients.
  18600. * You must use addDragGradient and removeDragGradient to udpate this list
  18601. * @returns the list of drag gradients
  18602. */
  18603. getDragGradients(): Nullable<Array<FactorGradient>>;
  18604. /**
  18605. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18606. * @param gradient defines the gradient to use (between 0 and 1)
  18607. * @param factor defines the emit rate to affect to the specified gradient
  18608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18609. * @returns the current particle system
  18610. */
  18611. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18612. /**
  18613. * Remove a specific emit rate gradient
  18614. * @param gradient defines the gradient to remove
  18615. * @returns the current particle system
  18616. */
  18617. removeEmitRateGradient(gradient: number): IParticleSystem;
  18618. /**
  18619. * Gets the current list of emit rate gradients.
  18620. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18621. * @returns the list of emit rate gradients
  18622. */
  18623. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18624. /**
  18625. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18626. * @param gradient defines the gradient to use (between 0 and 1)
  18627. * @param factor defines the start size to affect to the specified gradient
  18628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18629. * @returns the current particle system
  18630. */
  18631. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18632. /**
  18633. * Remove a specific start size gradient
  18634. * @param gradient defines the gradient to remove
  18635. * @returns the current particle system
  18636. */
  18637. removeStartSizeGradient(gradient: number): IParticleSystem;
  18638. /**
  18639. * Gets the current list of start size gradients.
  18640. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18641. * @returns the list of start size gradients
  18642. */
  18643. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18644. /**
  18645. * Adds a new life time gradient
  18646. * @param gradient defines the gradient to use (between 0 and 1)
  18647. * @param factor defines the life time factor to affect to the specified gradient
  18648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18649. * @returns the current particle system
  18650. */
  18651. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18652. /**
  18653. * Remove a specific life time gradient
  18654. * @param gradient defines the gradient to remove
  18655. * @returns the current particle system
  18656. */
  18657. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18658. /**
  18659. * Gets the current list of life time gradients.
  18660. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18661. * @returns the list of life time gradients
  18662. */
  18663. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18664. /**
  18665. * Gets the current list of color gradients.
  18666. * You must use addColorGradient and removeColorGradient to udpate this list
  18667. * @returns the list of color gradients
  18668. */
  18669. getColorGradients(): Nullable<Array<ColorGradient>>;
  18670. /**
  18671. * Adds a new ramp gradient used to remap particle colors
  18672. * @param gradient defines the gradient to use (between 0 and 1)
  18673. * @param color defines the color to affect to the specified gradient
  18674. * @returns the current particle system
  18675. */
  18676. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18677. /**
  18678. * Gets the current list of ramp gradients.
  18679. * You must use addRampGradient and removeRampGradient to udpate this list
  18680. * @returns the list of ramp gradients
  18681. */
  18682. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18683. /** Gets or sets a boolean indicating that ramp gradients must be used
  18684. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18685. */
  18686. useRampGradients: boolean;
  18687. /**
  18688. * Adds a new color remap gradient
  18689. * @param gradient defines the gradient to use (between 0 and 1)
  18690. * @param min defines the color remap minimal range
  18691. * @param max defines the color remap maximal range
  18692. * @returns the current particle system
  18693. */
  18694. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18695. /**
  18696. * Gets the current list of color remap gradients.
  18697. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18698. * @returns the list of color remap gradients
  18699. */
  18700. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18701. /**
  18702. * Adds a new alpha remap gradient
  18703. * @param gradient defines the gradient to use (between 0 and 1)
  18704. * @param min defines the alpha remap minimal range
  18705. * @param max defines the alpha remap maximal range
  18706. * @returns the current particle system
  18707. */
  18708. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18709. /**
  18710. * Gets the current list of alpha remap gradients.
  18711. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18712. * @returns the list of alpha remap gradients
  18713. */
  18714. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18715. /**
  18716. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18717. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18718. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18719. * @returns the emitter
  18720. */
  18721. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18722. /**
  18723. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18724. * @param radius The radius of the hemisphere to emit from
  18725. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18726. * @returns the emitter
  18727. */
  18728. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18729. /**
  18730. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18731. * @param radius The radius of the sphere to emit from
  18732. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18733. * @returns the emitter
  18734. */
  18735. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18736. /**
  18737. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18738. * @param radius The radius of the sphere to emit from
  18739. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18740. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18741. * @returns the emitter
  18742. */
  18743. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18744. /**
  18745. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18746. * @param radius The radius of the emission cylinder
  18747. * @param height The height of the emission cylinder
  18748. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18749. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18750. * @returns the emitter
  18751. */
  18752. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18753. /**
  18754. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18755. * @param radius The radius of the cylinder to emit from
  18756. * @param height The height of the emission cylinder
  18757. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18760. * @returns the emitter
  18761. */
  18762. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18763. /**
  18764. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18765. * @param radius The radius of the cone to emit from
  18766. * @param angle The base angle of the cone
  18767. * @returns the emitter
  18768. */
  18769. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18770. /**
  18771. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18772. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18773. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18774. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18775. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18776. * @returns the emitter
  18777. */
  18778. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18779. /**
  18780. * Get hosting scene
  18781. * @returns the scene
  18782. */
  18783. getScene(): Scene;
  18784. }
  18785. }
  18786. declare module BABYLON {
  18787. /**
  18788. * Creates an instance based on a source mesh.
  18789. */
  18790. export class InstancedMesh extends AbstractMesh {
  18791. private _sourceMesh;
  18792. private _currentLOD;
  18793. /** @hidden */
  18794. _indexInSourceMeshInstanceArray: number;
  18795. constructor(name: string, source: Mesh);
  18796. /**
  18797. * Returns the string "InstancedMesh".
  18798. */
  18799. getClassName(): string;
  18800. /** Gets the list of lights affecting that mesh */
  18801. readonly lightSources: Light[];
  18802. _resyncLightSources(): void;
  18803. _resyncLighSource(light: Light): void;
  18804. _removeLightSource(light: Light, dispose: boolean): void;
  18805. /**
  18806. * If the source mesh receives shadows
  18807. */
  18808. readonly receiveShadows: boolean;
  18809. /**
  18810. * The material of the source mesh
  18811. */
  18812. readonly material: Nullable<Material>;
  18813. /**
  18814. * Visibility of the source mesh
  18815. */
  18816. readonly visibility: number;
  18817. /**
  18818. * Skeleton of the source mesh
  18819. */
  18820. readonly skeleton: Nullable<Skeleton>;
  18821. /**
  18822. * Rendering ground id of the source mesh
  18823. */
  18824. renderingGroupId: number;
  18825. /**
  18826. * Returns the total number of vertices (integer).
  18827. */
  18828. getTotalVertices(): number;
  18829. /**
  18830. * Returns a positive integer : the total number of indices in this mesh geometry.
  18831. * @returns the numner of indices or zero if the mesh has no geometry.
  18832. */
  18833. getTotalIndices(): number;
  18834. /**
  18835. * The source mesh of the instance
  18836. */
  18837. readonly sourceMesh: Mesh;
  18838. /**
  18839. * Is this node ready to be used/rendered
  18840. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18841. * @return {boolean} is it ready
  18842. */
  18843. isReady(completeCheck?: boolean): boolean;
  18844. /**
  18845. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18846. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18847. * @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.
  18848. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18849. */
  18850. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18851. /**
  18852. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18853. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18854. * The `data` are either a numeric array either a Float32Array.
  18855. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18856. * 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).
  18857. * Note that a new underlying VertexBuffer object is created each call.
  18858. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18859. *
  18860. * Possible `kind` values :
  18861. * - VertexBuffer.PositionKind
  18862. * - VertexBuffer.UVKind
  18863. * - VertexBuffer.UV2Kind
  18864. * - VertexBuffer.UV3Kind
  18865. * - VertexBuffer.UV4Kind
  18866. * - VertexBuffer.UV5Kind
  18867. * - VertexBuffer.UV6Kind
  18868. * - VertexBuffer.ColorKind
  18869. * - VertexBuffer.MatricesIndicesKind
  18870. * - VertexBuffer.MatricesIndicesExtraKind
  18871. * - VertexBuffer.MatricesWeightsKind
  18872. * - VertexBuffer.MatricesWeightsExtraKind
  18873. *
  18874. * Returns the Mesh.
  18875. */
  18876. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18877. /**
  18878. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18879. * If the mesh has no geometry, it is simply returned as it is.
  18880. * The `data` are either a numeric array either a Float32Array.
  18881. * No new underlying VertexBuffer object is created.
  18882. * 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.
  18883. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18884. *
  18885. * Possible `kind` values :
  18886. * - VertexBuffer.PositionKind
  18887. * - VertexBuffer.UVKind
  18888. * - VertexBuffer.UV2Kind
  18889. * - VertexBuffer.UV3Kind
  18890. * - VertexBuffer.UV4Kind
  18891. * - VertexBuffer.UV5Kind
  18892. * - VertexBuffer.UV6Kind
  18893. * - VertexBuffer.ColorKind
  18894. * - VertexBuffer.MatricesIndicesKind
  18895. * - VertexBuffer.MatricesIndicesExtraKind
  18896. * - VertexBuffer.MatricesWeightsKind
  18897. * - VertexBuffer.MatricesWeightsExtraKind
  18898. *
  18899. * Returns the Mesh.
  18900. */
  18901. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18902. /**
  18903. * Sets the mesh indices.
  18904. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18905. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18906. * This method creates a new index buffer each call.
  18907. * Returns the Mesh.
  18908. */
  18909. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18910. /**
  18911. * Boolean : True if the mesh owns the requested kind of data.
  18912. */
  18913. isVerticesDataPresent(kind: string): boolean;
  18914. /**
  18915. * Returns an array of indices (IndicesArray).
  18916. */
  18917. getIndices(): Nullable<IndicesArray>;
  18918. readonly _positions: Nullable<Vector3[]>;
  18919. /**
  18920. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18921. * This means the mesh underlying bounding box and sphere are recomputed.
  18922. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18923. * @returns the current mesh
  18924. */
  18925. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18926. /** @hidden */
  18927. _preActivate(): InstancedMesh;
  18928. /** @hidden */
  18929. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18930. /** @hidden */
  18931. _postActivate(): void;
  18932. getWorldMatrix(): Matrix;
  18933. readonly isAnInstance: boolean;
  18934. /**
  18935. * Returns the current associated LOD AbstractMesh.
  18936. */
  18937. getLOD(camera: Camera): AbstractMesh;
  18938. /** @hidden */
  18939. _syncSubMeshes(): InstancedMesh;
  18940. /** @hidden */
  18941. _generatePointsArray(): boolean;
  18942. /**
  18943. * Creates a new InstancedMesh from the current mesh.
  18944. * - name (string) : the cloned mesh name
  18945. * - newParent (optional Node) : the optional Node to parent the clone to.
  18946. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18947. *
  18948. * Returns the clone.
  18949. */
  18950. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18951. /**
  18952. * Disposes the InstancedMesh.
  18953. * Returns nothing.
  18954. */
  18955. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18956. }
  18957. interface Mesh {
  18958. /**
  18959. * Register a custom buffer that will be instanced
  18960. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18961. * @param kind defines the buffer kind
  18962. * @param stride defines the stride in floats
  18963. */
  18964. registerInstancedBuffer(kind: string, stride: number): void;
  18965. /** @hidden */
  18966. _userInstancedBuffersStorage: {
  18967. data: {
  18968. [key: string]: Float32Array;
  18969. };
  18970. sizes: {
  18971. [key: string]: number;
  18972. };
  18973. vertexBuffers: {
  18974. [key: string]: Nullable<VertexBuffer>;
  18975. };
  18976. strides: {
  18977. [key: string]: number;
  18978. };
  18979. };
  18980. }
  18981. interface AbstractMesh {
  18982. /**
  18983. * Object used to store instanced buffers defined by user
  18984. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  18985. */
  18986. instancedBuffers: {
  18987. [key: string]: any;
  18988. };
  18989. }
  18990. }
  18991. declare module BABYLON {
  18992. /**
  18993. * Defines the options associated with the creation of a shader material.
  18994. */
  18995. export interface IShaderMaterialOptions {
  18996. /**
  18997. * Does the material work in alpha blend mode
  18998. */
  18999. needAlphaBlending: boolean;
  19000. /**
  19001. * Does the material work in alpha test mode
  19002. */
  19003. needAlphaTesting: boolean;
  19004. /**
  19005. * The list of attribute names used in the shader
  19006. */
  19007. attributes: string[];
  19008. /**
  19009. * The list of unifrom names used in the shader
  19010. */
  19011. uniforms: string[];
  19012. /**
  19013. * The list of UBO names used in the shader
  19014. */
  19015. uniformBuffers: string[];
  19016. /**
  19017. * The list of sampler names used in the shader
  19018. */
  19019. samplers: string[];
  19020. /**
  19021. * The list of defines used in the shader
  19022. */
  19023. defines: string[];
  19024. }
  19025. /**
  19026. * 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.
  19027. *
  19028. * This returned material effects how the mesh will look based on the code in the shaders.
  19029. *
  19030. * @see http://doc.babylonjs.com/how_to/shader_material
  19031. */
  19032. export class ShaderMaterial extends Material {
  19033. private _shaderPath;
  19034. private _options;
  19035. private _textures;
  19036. private _textureArrays;
  19037. private _floats;
  19038. private _ints;
  19039. private _floatsArrays;
  19040. private _colors3;
  19041. private _colors3Arrays;
  19042. private _colors4;
  19043. private _colors4Arrays;
  19044. private _vectors2;
  19045. private _vectors3;
  19046. private _vectors4;
  19047. private _matrices;
  19048. private _matrices3x3;
  19049. private _matrices2x2;
  19050. private _vectors2Arrays;
  19051. private _vectors3Arrays;
  19052. private _vectors4Arrays;
  19053. private _cachedWorldViewMatrix;
  19054. private _cachedWorldViewProjectionMatrix;
  19055. private _renderId;
  19056. /**
  19057. * Instantiate a new shader material.
  19058. * 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.
  19059. * This returned material effects how the mesh will look based on the code in the shaders.
  19060. * @see http://doc.babylonjs.com/how_to/shader_material
  19061. * @param name Define the name of the material in the scene
  19062. * @param scene Define the scene the material belongs to
  19063. * @param shaderPath Defines the route to the shader code in one of three ways:
  19064. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19065. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19066. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19067. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19068. * @param options Define the options used to create the shader
  19069. */
  19070. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19071. /**
  19072. * Gets the options used to compile the shader.
  19073. * They can be modified to trigger a new compilation
  19074. */
  19075. readonly options: IShaderMaterialOptions;
  19076. /**
  19077. * Gets the current class name of the material e.g. "ShaderMaterial"
  19078. * Mainly use in serialization.
  19079. * @returns the class name
  19080. */
  19081. getClassName(): string;
  19082. /**
  19083. * Specifies if the material will require alpha blending
  19084. * @returns a boolean specifying if alpha blending is needed
  19085. */
  19086. needAlphaBlending(): boolean;
  19087. /**
  19088. * Specifies if this material should be rendered in alpha test mode
  19089. * @returns a boolean specifying if an alpha test is needed.
  19090. */
  19091. needAlphaTesting(): boolean;
  19092. private _checkUniform;
  19093. /**
  19094. * Set a texture in the shader.
  19095. * @param name Define the name of the uniform samplers as defined in the shader
  19096. * @param texture Define the texture to bind to this sampler
  19097. * @return the material itself allowing "fluent" like uniform updates
  19098. */
  19099. setTexture(name: string, texture: Texture): ShaderMaterial;
  19100. /**
  19101. * Set a texture array in the shader.
  19102. * @param name Define the name of the uniform sampler array as defined in the shader
  19103. * @param textures Define the list of textures to bind to this sampler
  19104. * @return the material itself allowing "fluent" like uniform updates
  19105. */
  19106. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19107. /**
  19108. * Set a float in the shader.
  19109. * @param name Define the name of the uniform as defined in the shader
  19110. * @param value Define the value to give to the uniform
  19111. * @return the material itself allowing "fluent" like uniform updates
  19112. */
  19113. setFloat(name: string, value: number): ShaderMaterial;
  19114. /**
  19115. * Set a int in the shader.
  19116. * @param name Define the name of the uniform as defined in the shader
  19117. * @param value Define the value to give to the uniform
  19118. * @return the material itself allowing "fluent" like uniform updates
  19119. */
  19120. setInt(name: string, value: number): ShaderMaterial;
  19121. /**
  19122. * Set an array of floats in the shader.
  19123. * @param name Define the name of the uniform as defined in the shader
  19124. * @param value Define the value to give to the uniform
  19125. * @return the material itself allowing "fluent" like uniform updates
  19126. */
  19127. setFloats(name: string, value: number[]): ShaderMaterial;
  19128. /**
  19129. * Set a vec3 in the shader from a Color3.
  19130. * @param name Define the name of the uniform as defined in the shader
  19131. * @param value Define the value to give to the uniform
  19132. * @return the material itself allowing "fluent" like uniform updates
  19133. */
  19134. setColor3(name: string, value: Color3): ShaderMaterial;
  19135. /**
  19136. * Set a vec3 array in the shader from a Color3 array.
  19137. * @param name Define the name of the uniform as defined in the shader
  19138. * @param value Define the value to give to the uniform
  19139. * @return the material itself allowing "fluent" like uniform updates
  19140. */
  19141. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19142. /**
  19143. * Set a vec4 in the shader from a Color4.
  19144. * @param name Define the name of the uniform as defined in the shader
  19145. * @param value Define the value to give to the uniform
  19146. * @return the material itself allowing "fluent" like uniform updates
  19147. */
  19148. setColor4(name: string, value: Color4): ShaderMaterial;
  19149. /**
  19150. * Set a vec4 array in the shader from a Color4 array.
  19151. * @param name Define the name of the uniform as defined in the shader
  19152. * @param value Define the value to give to the uniform
  19153. * @return the material itself allowing "fluent" like uniform updates
  19154. */
  19155. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19156. /**
  19157. * Set a vec2 in the shader from a Vector2.
  19158. * @param name Define the name of the uniform as defined in the shader
  19159. * @param value Define the value to give to the uniform
  19160. * @return the material itself allowing "fluent" like uniform updates
  19161. */
  19162. setVector2(name: string, value: Vector2): ShaderMaterial;
  19163. /**
  19164. * Set a vec3 in the shader from a Vector3.
  19165. * @param name Define the name of the uniform as defined in the shader
  19166. * @param value Define the value to give to the uniform
  19167. * @return the material itself allowing "fluent" like uniform updates
  19168. */
  19169. setVector3(name: string, value: Vector3): ShaderMaterial;
  19170. /**
  19171. * Set a vec4 in the shader from a Vector4.
  19172. * @param name Define the name of the uniform as defined in the shader
  19173. * @param value Define the value to give to the uniform
  19174. * @return the material itself allowing "fluent" like uniform updates
  19175. */
  19176. setVector4(name: string, value: Vector4): ShaderMaterial;
  19177. /**
  19178. * Set a mat4 in the shader from a Matrix.
  19179. * @param name Define the name of the uniform as defined in the shader
  19180. * @param value Define the value to give to the uniform
  19181. * @return the material itself allowing "fluent" like uniform updates
  19182. */
  19183. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19184. /**
  19185. * Set a mat3 in the shader from a Float32Array.
  19186. * @param name Define the name of the uniform as defined in the shader
  19187. * @param value Define the value to give to the uniform
  19188. * @return the material itself allowing "fluent" like uniform updates
  19189. */
  19190. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19191. /**
  19192. * Set a mat2 in the shader from a Float32Array.
  19193. * @param name Define the name of the uniform as defined in the shader
  19194. * @param value Define the value to give to the uniform
  19195. * @return the material itself allowing "fluent" like uniform updates
  19196. */
  19197. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19198. /**
  19199. * Set a vec2 array in the shader from a number array.
  19200. * @param name Define the name of the uniform as defined in the shader
  19201. * @param value Define the value to give to the uniform
  19202. * @return the material itself allowing "fluent" like uniform updates
  19203. */
  19204. setArray2(name: string, value: number[]): ShaderMaterial;
  19205. /**
  19206. * Set a vec3 array in the shader from a number array.
  19207. * @param name Define the name of the uniform as defined in the shader
  19208. * @param value Define the value to give to the uniform
  19209. * @return the material itself allowing "fluent" like uniform updates
  19210. */
  19211. setArray3(name: string, value: number[]): ShaderMaterial;
  19212. /**
  19213. * Set a vec4 array in the shader from a number array.
  19214. * @param name Define the name of the uniform as defined in the shader
  19215. * @param value Define the value to give to the uniform
  19216. * @return the material itself allowing "fluent" like uniform updates
  19217. */
  19218. setArray4(name: string, value: number[]): ShaderMaterial;
  19219. private _checkCache;
  19220. /**
  19221. * Specifies that the submesh is ready to be used
  19222. * @param mesh defines the mesh to check
  19223. * @param subMesh defines which submesh to check
  19224. * @param useInstances specifies that instances should be used
  19225. * @returns a boolean indicating that the submesh is ready or not
  19226. */
  19227. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19228. /**
  19229. * Checks if the material is ready to render the requested mesh
  19230. * @param mesh Define the mesh to render
  19231. * @param useInstances Define whether or not the material is used with instances
  19232. * @returns true if ready, otherwise false
  19233. */
  19234. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19235. /**
  19236. * Binds the world matrix to the material
  19237. * @param world defines the world transformation matrix
  19238. */
  19239. bindOnlyWorldMatrix(world: Matrix): void;
  19240. /**
  19241. * Binds the material to the mesh
  19242. * @param world defines the world transformation matrix
  19243. * @param mesh defines the mesh to bind the material to
  19244. */
  19245. bind(world: Matrix, mesh?: Mesh): void;
  19246. /**
  19247. * Gets the active textures from the material
  19248. * @returns an array of textures
  19249. */
  19250. getActiveTextures(): BaseTexture[];
  19251. /**
  19252. * Specifies if the material uses a texture
  19253. * @param texture defines the texture to check against the material
  19254. * @returns a boolean specifying if the material uses the texture
  19255. */
  19256. hasTexture(texture: BaseTexture): boolean;
  19257. /**
  19258. * Makes a duplicate of the material, and gives it a new name
  19259. * @param name defines the new name for the duplicated material
  19260. * @returns the cloned material
  19261. */
  19262. clone(name: string): ShaderMaterial;
  19263. /**
  19264. * Disposes the material
  19265. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19266. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19267. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19268. */
  19269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19270. /**
  19271. * Serializes this material in a JSON representation
  19272. * @returns the serialized material object
  19273. */
  19274. serialize(): any;
  19275. /**
  19276. * Creates a shader material from parsed shader material data
  19277. * @param source defines the JSON represnetation of the material
  19278. * @param scene defines the hosting scene
  19279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19280. * @returns a new material
  19281. */
  19282. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19283. }
  19284. }
  19285. declare module BABYLON {
  19286. /** @hidden */
  19287. export var colorPixelShader: {
  19288. name: string;
  19289. shader: string;
  19290. };
  19291. }
  19292. declare module BABYLON {
  19293. /** @hidden */
  19294. export var colorVertexShader: {
  19295. name: string;
  19296. shader: string;
  19297. };
  19298. }
  19299. declare module BABYLON {
  19300. /**
  19301. * Line mesh
  19302. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19303. */
  19304. export class LinesMesh extends Mesh {
  19305. /**
  19306. * If vertex color should be applied to the mesh
  19307. */
  19308. readonly useVertexColor?: boolean | undefined;
  19309. /**
  19310. * If vertex alpha should be applied to the mesh
  19311. */
  19312. readonly useVertexAlpha?: boolean | undefined;
  19313. /**
  19314. * Color of the line (Default: White)
  19315. */
  19316. color: Color3;
  19317. /**
  19318. * Alpha of the line (Default: 1)
  19319. */
  19320. alpha: number;
  19321. /**
  19322. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19323. * This margin is expressed in world space coordinates, so its value may vary.
  19324. * Default value is 0.1
  19325. */
  19326. intersectionThreshold: number;
  19327. private _colorShader;
  19328. private color4;
  19329. /**
  19330. * Creates a new LinesMesh
  19331. * @param name defines the name
  19332. * @param scene defines the hosting scene
  19333. * @param parent defines the parent mesh if any
  19334. * @param source defines the optional source LinesMesh used to clone data from
  19335. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19336. * When false, achieved by calling a clone(), also passing False.
  19337. * This will make creation of children, recursive.
  19338. * @param useVertexColor defines if this LinesMesh supports vertex color
  19339. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19340. */
  19341. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19342. /**
  19343. * If vertex color should be applied to the mesh
  19344. */
  19345. useVertexColor?: boolean | undefined,
  19346. /**
  19347. * If vertex alpha should be applied to the mesh
  19348. */
  19349. useVertexAlpha?: boolean | undefined);
  19350. private _addClipPlaneDefine;
  19351. private _removeClipPlaneDefine;
  19352. isReady(): boolean;
  19353. /**
  19354. * Returns the string "LineMesh"
  19355. */
  19356. getClassName(): string;
  19357. /**
  19358. * @hidden
  19359. */
  19360. /**
  19361. * @hidden
  19362. */
  19363. material: Material;
  19364. /**
  19365. * @hidden
  19366. */
  19367. readonly checkCollisions: boolean;
  19368. /** @hidden */
  19369. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19370. /** @hidden */
  19371. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19372. /**
  19373. * Disposes of the line mesh
  19374. * @param doNotRecurse If children should be disposed
  19375. */
  19376. dispose(doNotRecurse?: boolean): void;
  19377. /**
  19378. * Returns a new LineMesh object cloned from the current one.
  19379. */
  19380. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19381. /**
  19382. * Creates a new InstancedLinesMesh object from the mesh model.
  19383. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19384. * @param name defines the name of the new instance
  19385. * @returns a new InstancedLinesMesh
  19386. */
  19387. createInstance(name: string): InstancedLinesMesh;
  19388. }
  19389. /**
  19390. * Creates an instance based on a source LinesMesh
  19391. */
  19392. export class InstancedLinesMesh extends InstancedMesh {
  19393. /**
  19394. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19395. * This margin is expressed in world space coordinates, so its value may vary.
  19396. * Initilized with the intersectionThreshold value of the source LinesMesh
  19397. */
  19398. intersectionThreshold: number;
  19399. constructor(name: string, source: LinesMesh);
  19400. /**
  19401. * Returns the string "InstancedLinesMesh".
  19402. */
  19403. getClassName(): string;
  19404. }
  19405. }
  19406. declare module BABYLON {
  19407. /** @hidden */
  19408. export var linePixelShader: {
  19409. name: string;
  19410. shader: string;
  19411. };
  19412. }
  19413. declare module BABYLON {
  19414. /** @hidden */
  19415. export var lineVertexShader: {
  19416. name: string;
  19417. shader: string;
  19418. };
  19419. }
  19420. declare module BABYLON {
  19421. interface AbstractMesh {
  19422. /**
  19423. * Gets the edgesRenderer associated with the mesh
  19424. */
  19425. edgesRenderer: Nullable<EdgesRenderer>;
  19426. }
  19427. interface LinesMesh {
  19428. /**
  19429. * Enables the edge rendering mode on the mesh.
  19430. * This mode makes the mesh edges visible
  19431. * @param epsilon defines the maximal distance between two angles to detect a face
  19432. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19433. * @returns the currentAbstractMesh
  19434. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19435. */
  19436. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19437. }
  19438. interface InstancedLinesMesh {
  19439. /**
  19440. * Enables the edge rendering mode on the mesh.
  19441. * This mode makes the mesh edges visible
  19442. * @param epsilon defines the maximal distance between two angles to detect a face
  19443. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19444. * @returns the current InstancedLinesMesh
  19445. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19446. */
  19447. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19448. }
  19449. /**
  19450. * Defines the minimum contract an Edges renderer should follow.
  19451. */
  19452. export interface IEdgesRenderer extends IDisposable {
  19453. /**
  19454. * Gets or sets a boolean indicating if the edgesRenderer is active
  19455. */
  19456. isEnabled: boolean;
  19457. /**
  19458. * Renders the edges of the attached mesh,
  19459. */
  19460. render(): void;
  19461. /**
  19462. * Checks wether or not the edges renderer is ready to render.
  19463. * @return true if ready, otherwise false.
  19464. */
  19465. isReady(): boolean;
  19466. }
  19467. /**
  19468. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19469. */
  19470. export class EdgesRenderer implements IEdgesRenderer {
  19471. /**
  19472. * Define the size of the edges with an orthographic camera
  19473. */
  19474. edgesWidthScalerForOrthographic: number;
  19475. /**
  19476. * Define the size of the edges with a perspective camera
  19477. */
  19478. edgesWidthScalerForPerspective: number;
  19479. protected _source: AbstractMesh;
  19480. protected _linesPositions: number[];
  19481. protected _linesNormals: number[];
  19482. protected _linesIndices: number[];
  19483. protected _epsilon: number;
  19484. protected _indicesCount: number;
  19485. protected _lineShader: ShaderMaterial;
  19486. protected _ib: DataBuffer;
  19487. protected _buffers: {
  19488. [key: string]: Nullable<VertexBuffer>;
  19489. };
  19490. protected _checkVerticesInsteadOfIndices: boolean;
  19491. private _meshRebuildObserver;
  19492. private _meshDisposeObserver;
  19493. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19494. isEnabled: boolean;
  19495. /**
  19496. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19497. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19498. * @param source Mesh used to create edges
  19499. * @param epsilon sum of angles in adjacency to check for edge
  19500. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19501. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19502. */
  19503. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19504. protected _prepareRessources(): void;
  19505. /** @hidden */
  19506. _rebuild(): void;
  19507. /**
  19508. * Releases the required resources for the edges renderer
  19509. */
  19510. dispose(): void;
  19511. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19512. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19513. /**
  19514. * Checks if the pair of p0 and p1 is en edge
  19515. * @param faceIndex
  19516. * @param edge
  19517. * @param faceNormals
  19518. * @param p0
  19519. * @param p1
  19520. * @private
  19521. */
  19522. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19523. /**
  19524. * push line into the position, normal and index buffer
  19525. * @protected
  19526. */
  19527. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19528. /**
  19529. * Generates lines edges from adjacencjes
  19530. * @private
  19531. */
  19532. _generateEdgesLines(): void;
  19533. /**
  19534. * Checks wether or not the edges renderer is ready to render.
  19535. * @return true if ready, otherwise false.
  19536. */
  19537. isReady(): boolean;
  19538. /**
  19539. * Renders the edges of the attached mesh,
  19540. */
  19541. render(): void;
  19542. }
  19543. /**
  19544. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19545. */
  19546. export class LineEdgesRenderer extends EdgesRenderer {
  19547. /**
  19548. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19549. * @param source LineMesh used to generate edges
  19550. * @param epsilon not important (specified angle for edge detection)
  19551. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19552. */
  19553. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19554. /**
  19555. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19556. */
  19557. _generateEdgesLines(): void;
  19558. }
  19559. }
  19560. declare module BABYLON {
  19561. /**
  19562. * This represents the object necessary to create a rendering group.
  19563. * This is exclusively used and created by the rendering manager.
  19564. * To modify the behavior, you use the available helpers in your scene or meshes.
  19565. * @hidden
  19566. */
  19567. export class RenderingGroup {
  19568. index: number;
  19569. private static _zeroVector;
  19570. private _scene;
  19571. private _opaqueSubMeshes;
  19572. private _transparentSubMeshes;
  19573. private _alphaTestSubMeshes;
  19574. private _depthOnlySubMeshes;
  19575. private _particleSystems;
  19576. private _spriteManagers;
  19577. private _opaqueSortCompareFn;
  19578. private _alphaTestSortCompareFn;
  19579. private _transparentSortCompareFn;
  19580. private _renderOpaque;
  19581. private _renderAlphaTest;
  19582. private _renderTransparent;
  19583. /** @hidden */
  19584. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19585. onBeforeTransparentRendering: () => void;
  19586. /**
  19587. * Set the opaque sort comparison function.
  19588. * If null the sub meshes will be render in the order they were created
  19589. */
  19590. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19591. /**
  19592. * Set the alpha test sort comparison function.
  19593. * If null the sub meshes will be render in the order they were created
  19594. */
  19595. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19596. /**
  19597. * Set the transparent sort comparison function.
  19598. * If null the sub meshes will be render in the order they were created
  19599. */
  19600. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19601. /**
  19602. * Creates a new rendering group.
  19603. * @param index The rendering group index
  19604. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19605. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19606. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19607. */
  19608. 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>);
  19609. /**
  19610. * Render all the sub meshes contained in the group.
  19611. * @param customRenderFunction Used to override the default render behaviour of the group.
  19612. * @returns true if rendered some submeshes.
  19613. */
  19614. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19615. /**
  19616. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19617. * @param subMeshes The submeshes to render
  19618. */
  19619. private renderOpaqueSorted;
  19620. /**
  19621. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19622. * @param subMeshes The submeshes to render
  19623. */
  19624. private renderAlphaTestSorted;
  19625. /**
  19626. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19627. * @param subMeshes The submeshes to render
  19628. */
  19629. private renderTransparentSorted;
  19630. /**
  19631. * Renders the submeshes in a specified order.
  19632. * @param subMeshes The submeshes to sort before render
  19633. * @param sortCompareFn The comparison function use to sort
  19634. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19635. * @param transparent Specifies to activate blending if true
  19636. */
  19637. private static renderSorted;
  19638. /**
  19639. * Renders the submeshes in the order they were dispatched (no sort applied).
  19640. * @param subMeshes The submeshes to render
  19641. */
  19642. private static renderUnsorted;
  19643. /**
  19644. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19645. * are rendered back to front if in the same alpha index.
  19646. *
  19647. * @param a The first submesh
  19648. * @param b The second submesh
  19649. * @returns The result of the comparison
  19650. */
  19651. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19652. /**
  19653. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19654. * are rendered back to front.
  19655. *
  19656. * @param a The first submesh
  19657. * @param b The second submesh
  19658. * @returns The result of the comparison
  19659. */
  19660. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19661. /**
  19662. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19663. * are rendered front to back (prevent overdraw).
  19664. *
  19665. * @param a The first submesh
  19666. * @param b The second submesh
  19667. * @returns The result of the comparison
  19668. */
  19669. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19670. /**
  19671. * Resets the different lists of submeshes to prepare a new frame.
  19672. */
  19673. prepare(): void;
  19674. dispose(): void;
  19675. /**
  19676. * Inserts the submesh in its correct queue depending on its material.
  19677. * @param subMesh The submesh to dispatch
  19678. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19679. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19680. */
  19681. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19682. dispatchSprites(spriteManager: ISpriteManager): void;
  19683. dispatchParticles(particleSystem: IParticleSystem): void;
  19684. private _renderParticles;
  19685. private _renderSprites;
  19686. }
  19687. }
  19688. declare module BABYLON {
  19689. /**
  19690. * Interface describing the different options available in the rendering manager
  19691. * regarding Auto Clear between groups.
  19692. */
  19693. export interface IRenderingManagerAutoClearSetup {
  19694. /**
  19695. * Defines whether or not autoclear is enable.
  19696. */
  19697. autoClear: boolean;
  19698. /**
  19699. * Defines whether or not to autoclear the depth buffer.
  19700. */
  19701. depth: boolean;
  19702. /**
  19703. * Defines whether or not to autoclear the stencil buffer.
  19704. */
  19705. stencil: boolean;
  19706. }
  19707. /**
  19708. * This class is used by the onRenderingGroupObservable
  19709. */
  19710. export class RenderingGroupInfo {
  19711. /**
  19712. * The Scene that being rendered
  19713. */
  19714. scene: Scene;
  19715. /**
  19716. * The camera currently used for the rendering pass
  19717. */
  19718. camera: Nullable<Camera>;
  19719. /**
  19720. * The ID of the renderingGroup being processed
  19721. */
  19722. renderingGroupId: number;
  19723. }
  19724. /**
  19725. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19726. * It is enable to manage the different groups as well as the different necessary sort functions.
  19727. * This should not be used directly aside of the few static configurations
  19728. */
  19729. export class RenderingManager {
  19730. /**
  19731. * The max id used for rendering groups (not included)
  19732. */
  19733. static MAX_RENDERINGGROUPS: number;
  19734. /**
  19735. * The min id used for rendering groups (included)
  19736. */
  19737. static MIN_RENDERINGGROUPS: number;
  19738. /**
  19739. * Used to globally prevent autoclearing scenes.
  19740. */
  19741. static AUTOCLEAR: boolean;
  19742. /**
  19743. * @hidden
  19744. */
  19745. _useSceneAutoClearSetup: boolean;
  19746. private _scene;
  19747. private _renderingGroups;
  19748. private _depthStencilBufferAlreadyCleaned;
  19749. private _autoClearDepthStencil;
  19750. private _customOpaqueSortCompareFn;
  19751. private _customAlphaTestSortCompareFn;
  19752. private _customTransparentSortCompareFn;
  19753. private _renderingGroupInfo;
  19754. /**
  19755. * Instantiates a new rendering group for a particular scene
  19756. * @param scene Defines the scene the groups belongs to
  19757. */
  19758. constructor(scene: Scene);
  19759. private _clearDepthStencilBuffer;
  19760. /**
  19761. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19762. * @hidden
  19763. */
  19764. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19765. /**
  19766. * Resets the different information of the group to prepare a new frame
  19767. * @hidden
  19768. */
  19769. reset(): void;
  19770. /**
  19771. * Dispose and release the group and its associated resources.
  19772. * @hidden
  19773. */
  19774. dispose(): void;
  19775. /**
  19776. * Clear the info related to rendering groups preventing retention points during dispose.
  19777. */
  19778. freeRenderingGroups(): void;
  19779. private _prepareRenderingGroup;
  19780. /**
  19781. * Add a sprite manager to the rendering manager in order to render it this frame.
  19782. * @param spriteManager Define the sprite manager to render
  19783. */
  19784. dispatchSprites(spriteManager: ISpriteManager): void;
  19785. /**
  19786. * Add a particle system to the rendering manager in order to render it this frame.
  19787. * @param particleSystem Define the particle system to render
  19788. */
  19789. dispatchParticles(particleSystem: IParticleSystem): void;
  19790. /**
  19791. * Add a submesh to the manager in order to render it this frame
  19792. * @param subMesh The submesh to dispatch
  19793. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19794. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19795. */
  19796. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19797. /**
  19798. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19799. * This allowed control for front to back rendering or reversly depending of the special needs.
  19800. *
  19801. * @param renderingGroupId The rendering group id corresponding to its index
  19802. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19803. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19804. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19805. */
  19806. 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;
  19807. /**
  19808. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19809. *
  19810. * @param renderingGroupId The rendering group id corresponding to its index
  19811. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19812. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19813. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19814. */
  19815. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19816. /**
  19817. * Gets the current auto clear configuration for one rendering group of the rendering
  19818. * manager.
  19819. * @param index the rendering group index to get the information for
  19820. * @returns The auto clear setup for the requested rendering group
  19821. */
  19822. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19823. }
  19824. }
  19825. declare module BABYLON {
  19826. /**
  19827. * This Helps creating a texture that will be created from a camera in your scene.
  19828. * It is basically a dynamic texture that could be used to create special effects for instance.
  19829. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19830. */
  19831. export class RenderTargetTexture extends Texture {
  19832. isCube: boolean;
  19833. /**
  19834. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19835. */
  19836. static readonly REFRESHRATE_RENDER_ONCE: number;
  19837. /**
  19838. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19839. */
  19840. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19841. /**
  19842. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19843. * the central point of your effect and can save a lot of performances.
  19844. */
  19845. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19846. /**
  19847. * Use this predicate to dynamically define the list of mesh you want to render.
  19848. * If set, the renderList property will be overwritten.
  19849. */
  19850. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19851. private _renderList;
  19852. /**
  19853. * Use this list to define the list of mesh you want to render.
  19854. */
  19855. renderList: Nullable<Array<AbstractMesh>>;
  19856. private _hookArray;
  19857. /**
  19858. * Define if particles should be rendered in your texture.
  19859. */
  19860. renderParticles: boolean;
  19861. /**
  19862. * Define if sprites should be rendered in your texture.
  19863. */
  19864. renderSprites: boolean;
  19865. /**
  19866. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19867. */
  19868. coordinatesMode: number;
  19869. /**
  19870. * Define the camera used to render the texture.
  19871. */
  19872. activeCamera: Nullable<Camera>;
  19873. /**
  19874. * Override the render function of the texture with your own one.
  19875. */
  19876. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19877. /**
  19878. * Define if camera post processes should be use while rendering the texture.
  19879. */
  19880. useCameraPostProcesses: boolean;
  19881. /**
  19882. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19883. */
  19884. ignoreCameraViewport: boolean;
  19885. private _postProcessManager;
  19886. private _postProcesses;
  19887. private _resizeObserver;
  19888. /**
  19889. * An event triggered when the texture is unbind.
  19890. */
  19891. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19892. /**
  19893. * An event triggered when the texture is unbind.
  19894. */
  19895. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19896. private _onAfterUnbindObserver;
  19897. /**
  19898. * Set a after unbind callback in the texture.
  19899. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19900. */
  19901. onAfterUnbind: () => void;
  19902. /**
  19903. * An event triggered before rendering the texture
  19904. */
  19905. onBeforeRenderObservable: Observable<number>;
  19906. private _onBeforeRenderObserver;
  19907. /**
  19908. * Set a before render callback in the texture.
  19909. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19910. */
  19911. onBeforeRender: (faceIndex: number) => void;
  19912. /**
  19913. * An event triggered after rendering the texture
  19914. */
  19915. onAfterRenderObservable: Observable<number>;
  19916. private _onAfterRenderObserver;
  19917. /**
  19918. * Set a after render callback in the texture.
  19919. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19920. */
  19921. onAfterRender: (faceIndex: number) => void;
  19922. /**
  19923. * An event triggered after the texture clear
  19924. */
  19925. onClearObservable: Observable<Engine>;
  19926. private _onClearObserver;
  19927. /**
  19928. * Set a clear callback in the texture.
  19929. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19930. */
  19931. onClear: (Engine: Engine) => void;
  19932. /**
  19933. * An event triggered when the texture is resized.
  19934. */
  19935. onResizeObservable: Observable<RenderTargetTexture>;
  19936. /**
  19937. * Define the clear color of the Render Target if it should be different from the scene.
  19938. */
  19939. clearColor: Color4;
  19940. protected _size: number | {
  19941. width: number;
  19942. height: number;
  19943. };
  19944. protected _initialSizeParameter: number | {
  19945. width: number;
  19946. height: number;
  19947. } | {
  19948. ratio: number;
  19949. };
  19950. protected _sizeRatio: Nullable<number>;
  19951. /** @hidden */
  19952. _generateMipMaps: boolean;
  19953. protected _renderingManager: RenderingManager;
  19954. /** @hidden */
  19955. _waitingRenderList: string[];
  19956. protected _doNotChangeAspectRatio: boolean;
  19957. protected _currentRefreshId: number;
  19958. protected _refreshRate: number;
  19959. protected _textureMatrix: Matrix;
  19960. protected _samples: number;
  19961. protected _renderTargetOptions: RenderTargetCreationOptions;
  19962. /**
  19963. * Gets render target creation options that were used.
  19964. */
  19965. readonly renderTargetOptions: RenderTargetCreationOptions;
  19966. protected _engine: Engine;
  19967. protected _onRatioRescale(): void;
  19968. /**
  19969. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19970. * It must define where the camera used to render the texture is set
  19971. */
  19972. boundingBoxPosition: Vector3;
  19973. private _boundingBoxSize;
  19974. /**
  19975. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19976. * When defined, the cubemap will switch to local mode
  19977. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19978. * @example https://www.babylonjs-playground.com/#RNASML
  19979. */
  19980. boundingBoxSize: Vector3;
  19981. /**
  19982. * In case the RTT has been created with a depth texture, get the associated
  19983. * depth texture.
  19984. * Otherwise, return null.
  19985. */
  19986. depthStencilTexture: Nullable<InternalTexture>;
  19987. /**
  19988. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19989. * or used a shadow, depth texture...
  19990. * @param name The friendly name of the texture
  19991. * @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)
  19992. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19993. * @param generateMipMaps True if mip maps need to be generated after render.
  19994. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19995. * @param type The type of the buffer in the RTT (int, half float, float...)
  19996. * @param isCube True if a cube texture needs to be created
  19997. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19998. * @param generateDepthBuffer True to generate a depth buffer
  19999. * @param generateStencilBuffer True to generate a stencil buffer
  20000. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20001. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20002. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20003. */
  20004. constructor(name: string, size: number | {
  20005. width: number;
  20006. height: number;
  20007. } | {
  20008. ratio: number;
  20009. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20010. /**
  20011. * Creates a depth stencil texture.
  20012. * This is only available in WebGL 2 or with the depth texture extension available.
  20013. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20014. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20015. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20016. */
  20017. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20018. private _processSizeParameter;
  20019. /**
  20020. * Define the number of samples to use in case of MSAA.
  20021. * It defaults to one meaning no MSAA has been enabled.
  20022. */
  20023. samples: number;
  20024. /**
  20025. * Resets the refresh counter of the texture and start bak from scratch.
  20026. * Could be useful to regenerate the texture if it is setup to render only once.
  20027. */
  20028. resetRefreshCounter(): void;
  20029. /**
  20030. * Define the refresh rate of the texture or the rendering frequency.
  20031. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20032. */
  20033. refreshRate: number;
  20034. /**
  20035. * Adds a post process to the render target rendering passes.
  20036. * @param postProcess define the post process to add
  20037. */
  20038. addPostProcess(postProcess: PostProcess): void;
  20039. /**
  20040. * Clear all the post processes attached to the render target
  20041. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20042. */
  20043. clearPostProcesses(dispose?: boolean): void;
  20044. /**
  20045. * Remove one of the post process from the list of attached post processes to the texture
  20046. * @param postProcess define the post process to remove from the list
  20047. */
  20048. removePostProcess(postProcess: PostProcess): void;
  20049. /** @hidden */
  20050. _shouldRender(): boolean;
  20051. /**
  20052. * Gets the actual render size of the texture.
  20053. * @returns the width of the render size
  20054. */
  20055. getRenderSize(): number;
  20056. /**
  20057. * Gets the actual render width of the texture.
  20058. * @returns the width of the render size
  20059. */
  20060. getRenderWidth(): number;
  20061. /**
  20062. * Gets the actual render height of the texture.
  20063. * @returns the height of the render size
  20064. */
  20065. getRenderHeight(): number;
  20066. /**
  20067. * Get if the texture can be rescaled or not.
  20068. */
  20069. readonly canRescale: boolean;
  20070. /**
  20071. * Resize the texture using a ratio.
  20072. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20073. */
  20074. scale(ratio: number): void;
  20075. /**
  20076. * Get the texture reflection matrix used to rotate/transform the reflection.
  20077. * @returns the reflection matrix
  20078. */
  20079. getReflectionTextureMatrix(): Matrix;
  20080. /**
  20081. * Resize the texture to a new desired size.
  20082. * Be carrefull as it will recreate all the data in the new texture.
  20083. * @param size Define the new size. It can be:
  20084. * - a number for squared texture,
  20085. * - an object containing { width: number, height: number }
  20086. * - or an object containing a ratio { ratio: number }
  20087. */
  20088. resize(size: number | {
  20089. width: number;
  20090. height: number;
  20091. } | {
  20092. ratio: number;
  20093. }): void;
  20094. /**
  20095. * Renders all the objects from the render list into the texture.
  20096. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20097. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20098. */
  20099. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20100. private _bestReflectionRenderTargetDimension;
  20101. /**
  20102. * @hidden
  20103. * @param faceIndex face index to bind to if this is a cubetexture
  20104. */
  20105. _bindFrameBuffer(faceIndex?: number): void;
  20106. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20107. private renderToTarget;
  20108. /**
  20109. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20110. * This allowed control for front to back rendering or reversly depending of the special needs.
  20111. *
  20112. * @param renderingGroupId The rendering group id corresponding to its index
  20113. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20114. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20115. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20116. */
  20117. 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;
  20118. /**
  20119. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20120. *
  20121. * @param renderingGroupId The rendering group id corresponding to its index
  20122. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20123. */
  20124. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20125. /**
  20126. * Clones the texture.
  20127. * @returns the cloned texture
  20128. */
  20129. clone(): RenderTargetTexture;
  20130. /**
  20131. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20132. * @returns The JSON representation of the texture
  20133. */
  20134. serialize(): any;
  20135. /**
  20136. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20137. */
  20138. disposeFramebufferObjects(): void;
  20139. /**
  20140. * Dispose the texture and release its associated resources.
  20141. */
  20142. dispose(): void;
  20143. /** @hidden */
  20144. _rebuild(): void;
  20145. /**
  20146. * Clear the info related to rendering groups preventing retention point in material dispose.
  20147. */
  20148. freeRenderingGroups(): void;
  20149. /**
  20150. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20151. * @returns the view count
  20152. */
  20153. getViewCount(): number;
  20154. }
  20155. }
  20156. declare module BABYLON {
  20157. /**
  20158. * Base class for the main features of a material in Babylon.js
  20159. */
  20160. export class Material implements IAnimatable {
  20161. /**
  20162. * Returns the triangle fill mode
  20163. */
  20164. static readonly TriangleFillMode: number;
  20165. /**
  20166. * Returns the wireframe mode
  20167. */
  20168. static readonly WireFrameFillMode: number;
  20169. /**
  20170. * Returns the point fill mode
  20171. */
  20172. static readonly PointFillMode: number;
  20173. /**
  20174. * Returns the point list draw mode
  20175. */
  20176. static readonly PointListDrawMode: number;
  20177. /**
  20178. * Returns the line list draw mode
  20179. */
  20180. static readonly LineListDrawMode: number;
  20181. /**
  20182. * Returns the line loop draw mode
  20183. */
  20184. static readonly LineLoopDrawMode: number;
  20185. /**
  20186. * Returns the line strip draw mode
  20187. */
  20188. static readonly LineStripDrawMode: number;
  20189. /**
  20190. * Returns the triangle strip draw mode
  20191. */
  20192. static readonly TriangleStripDrawMode: number;
  20193. /**
  20194. * Returns the triangle fan draw mode
  20195. */
  20196. static readonly TriangleFanDrawMode: number;
  20197. /**
  20198. * Stores the clock-wise side orientation
  20199. */
  20200. static readonly ClockWiseSideOrientation: number;
  20201. /**
  20202. * Stores the counter clock-wise side orientation
  20203. */
  20204. static readonly CounterClockWiseSideOrientation: number;
  20205. /**
  20206. * The dirty texture flag value
  20207. */
  20208. static readonly TextureDirtyFlag: number;
  20209. /**
  20210. * The dirty light flag value
  20211. */
  20212. static readonly LightDirtyFlag: number;
  20213. /**
  20214. * The dirty fresnel flag value
  20215. */
  20216. static readonly FresnelDirtyFlag: number;
  20217. /**
  20218. * The dirty attribute flag value
  20219. */
  20220. static readonly AttributesDirtyFlag: number;
  20221. /**
  20222. * The dirty misc flag value
  20223. */
  20224. static readonly MiscDirtyFlag: number;
  20225. /**
  20226. * The all dirty flag value
  20227. */
  20228. static readonly AllDirtyFlag: number;
  20229. /**
  20230. * The ID of the material
  20231. */
  20232. id: string;
  20233. /**
  20234. * Gets or sets the unique id of the material
  20235. */
  20236. uniqueId: number;
  20237. /**
  20238. * The name of the material
  20239. */
  20240. name: string;
  20241. /**
  20242. * Gets or sets user defined metadata
  20243. */
  20244. metadata: any;
  20245. /**
  20246. * For internal use only. Please do not use.
  20247. */
  20248. reservedDataStore: any;
  20249. /**
  20250. * Specifies if the ready state should be checked on each call
  20251. */
  20252. checkReadyOnEveryCall: boolean;
  20253. /**
  20254. * Specifies if the ready state should be checked once
  20255. */
  20256. checkReadyOnlyOnce: boolean;
  20257. /**
  20258. * The state of the material
  20259. */
  20260. state: string;
  20261. /**
  20262. * The alpha value of the material
  20263. */
  20264. protected _alpha: number;
  20265. /**
  20266. * List of inspectable custom properties (used by the Inspector)
  20267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20268. */
  20269. inspectableCustomProperties: IInspectable[];
  20270. /**
  20271. * Sets the alpha value of the material
  20272. */
  20273. /**
  20274. * Gets the alpha value of the material
  20275. */
  20276. alpha: number;
  20277. /**
  20278. * Specifies if back face culling is enabled
  20279. */
  20280. protected _backFaceCulling: boolean;
  20281. /**
  20282. * Sets the back-face culling state
  20283. */
  20284. /**
  20285. * Gets the back-face culling state
  20286. */
  20287. backFaceCulling: boolean;
  20288. /**
  20289. * Stores the value for side orientation
  20290. */
  20291. sideOrientation: number;
  20292. /**
  20293. * Callback triggered when the material is compiled
  20294. */
  20295. onCompiled: Nullable<(effect: Effect) => void>;
  20296. /**
  20297. * Callback triggered when an error occurs
  20298. */
  20299. onError: Nullable<(effect: Effect, errors: string) => void>;
  20300. /**
  20301. * Callback triggered to get the render target textures
  20302. */
  20303. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20304. /**
  20305. * Gets a boolean indicating that current material needs to register RTT
  20306. */
  20307. readonly hasRenderTargetTextures: boolean;
  20308. /**
  20309. * Specifies if the material should be serialized
  20310. */
  20311. doNotSerialize: boolean;
  20312. /**
  20313. * @hidden
  20314. */
  20315. _storeEffectOnSubMeshes: boolean;
  20316. /**
  20317. * Stores the animations for the material
  20318. */
  20319. animations: Nullable<Array<Animation>>;
  20320. /**
  20321. * An event triggered when the material is disposed
  20322. */
  20323. onDisposeObservable: Observable<Material>;
  20324. /**
  20325. * An observer which watches for dispose events
  20326. */
  20327. private _onDisposeObserver;
  20328. private _onUnBindObservable;
  20329. /**
  20330. * Called during a dispose event
  20331. */
  20332. onDispose: () => void;
  20333. private _onBindObservable;
  20334. /**
  20335. * An event triggered when the material is bound
  20336. */
  20337. readonly onBindObservable: Observable<AbstractMesh>;
  20338. /**
  20339. * An observer which watches for bind events
  20340. */
  20341. private _onBindObserver;
  20342. /**
  20343. * Called during a bind event
  20344. */
  20345. onBind: (Mesh: AbstractMesh) => void;
  20346. /**
  20347. * An event triggered when the material is unbound
  20348. */
  20349. readonly onUnBindObservable: Observable<Material>;
  20350. /**
  20351. * Stores the value of the alpha mode
  20352. */
  20353. private _alphaMode;
  20354. /**
  20355. * Sets the value of the alpha mode.
  20356. *
  20357. * | Value | Type | Description |
  20358. * | --- | --- | --- |
  20359. * | 0 | ALPHA_DISABLE | |
  20360. * | 1 | ALPHA_ADD | |
  20361. * | 2 | ALPHA_COMBINE | |
  20362. * | 3 | ALPHA_SUBTRACT | |
  20363. * | 4 | ALPHA_MULTIPLY | |
  20364. * | 5 | ALPHA_MAXIMIZED | |
  20365. * | 6 | ALPHA_ONEONE | |
  20366. * | 7 | ALPHA_PREMULTIPLIED | |
  20367. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20368. * | 9 | ALPHA_INTERPOLATE | |
  20369. * | 10 | ALPHA_SCREENMODE | |
  20370. *
  20371. */
  20372. /**
  20373. * Gets the value of the alpha mode
  20374. */
  20375. alphaMode: number;
  20376. /**
  20377. * Stores the state of the need depth pre-pass value
  20378. */
  20379. private _needDepthPrePass;
  20380. /**
  20381. * Sets the need depth pre-pass value
  20382. */
  20383. /**
  20384. * Gets the depth pre-pass value
  20385. */
  20386. needDepthPrePass: boolean;
  20387. /**
  20388. * Specifies if depth writing should be disabled
  20389. */
  20390. disableDepthWrite: boolean;
  20391. /**
  20392. * Specifies if depth writing should be forced
  20393. */
  20394. forceDepthWrite: boolean;
  20395. /**
  20396. * Specifies if there should be a separate pass for culling
  20397. */
  20398. separateCullingPass: boolean;
  20399. /**
  20400. * Stores the state specifing if fog should be enabled
  20401. */
  20402. private _fogEnabled;
  20403. /**
  20404. * Sets the state for enabling fog
  20405. */
  20406. /**
  20407. * Gets the value of the fog enabled state
  20408. */
  20409. fogEnabled: boolean;
  20410. /**
  20411. * Stores the size of points
  20412. */
  20413. pointSize: number;
  20414. /**
  20415. * Stores the z offset value
  20416. */
  20417. zOffset: number;
  20418. /**
  20419. * Gets a value specifying if wireframe mode is enabled
  20420. */
  20421. /**
  20422. * Sets the state of wireframe mode
  20423. */
  20424. wireframe: boolean;
  20425. /**
  20426. * Gets the value specifying if point clouds are enabled
  20427. */
  20428. /**
  20429. * Sets the state of point cloud mode
  20430. */
  20431. pointsCloud: boolean;
  20432. /**
  20433. * Gets the material fill mode
  20434. */
  20435. /**
  20436. * Sets the material fill mode
  20437. */
  20438. fillMode: number;
  20439. /**
  20440. * @hidden
  20441. * Stores the effects for the material
  20442. */
  20443. _effect: Nullable<Effect>;
  20444. /**
  20445. * @hidden
  20446. * Specifies if the material was previously ready
  20447. */
  20448. _wasPreviouslyReady: boolean;
  20449. /**
  20450. * Specifies if uniform buffers should be used
  20451. */
  20452. private _useUBO;
  20453. /**
  20454. * Stores a reference to the scene
  20455. */
  20456. private _scene;
  20457. /**
  20458. * Stores the fill mode state
  20459. */
  20460. private _fillMode;
  20461. /**
  20462. * Specifies if the depth write state should be cached
  20463. */
  20464. private _cachedDepthWriteState;
  20465. /**
  20466. * Stores the uniform buffer
  20467. */
  20468. protected _uniformBuffer: UniformBuffer;
  20469. /** @hidden */
  20470. _indexInSceneMaterialArray: number;
  20471. /** @hidden */
  20472. meshMap: Nullable<{
  20473. [id: string]: AbstractMesh | undefined;
  20474. }>;
  20475. /**
  20476. * Creates a material instance
  20477. * @param name defines the name of the material
  20478. * @param scene defines the scene to reference
  20479. * @param doNotAdd specifies if the material should be added to the scene
  20480. */
  20481. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20482. /**
  20483. * Returns a string representation of the current material
  20484. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20485. * @returns a string with material information
  20486. */
  20487. toString(fullDetails?: boolean): string;
  20488. /**
  20489. * Gets the class name of the material
  20490. * @returns a string with the class name of the material
  20491. */
  20492. getClassName(): string;
  20493. /**
  20494. * Specifies if updates for the material been locked
  20495. */
  20496. readonly isFrozen: boolean;
  20497. /**
  20498. * Locks updates for the material
  20499. */
  20500. freeze(): void;
  20501. /**
  20502. * Unlocks updates for the material
  20503. */
  20504. unfreeze(): void;
  20505. /**
  20506. * Specifies if the material is ready to be used
  20507. * @param mesh defines the mesh to check
  20508. * @param useInstances specifies if instances should be used
  20509. * @returns a boolean indicating if the material is ready to be used
  20510. */
  20511. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20512. /**
  20513. * Specifies that the submesh is ready to be used
  20514. * @param mesh defines the mesh to check
  20515. * @param subMesh defines which submesh to check
  20516. * @param useInstances specifies that instances should be used
  20517. * @returns a boolean indicating that the submesh is ready or not
  20518. */
  20519. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20520. /**
  20521. * Returns the material effect
  20522. * @returns the effect associated with the material
  20523. */
  20524. getEffect(): Nullable<Effect>;
  20525. /**
  20526. * Returns the current scene
  20527. * @returns a Scene
  20528. */
  20529. getScene(): Scene;
  20530. /**
  20531. * Specifies if the material will require alpha blending
  20532. * @returns a boolean specifying if alpha blending is needed
  20533. */
  20534. needAlphaBlending(): boolean;
  20535. /**
  20536. * Specifies if the mesh will require alpha blending
  20537. * @param mesh defines the mesh to check
  20538. * @returns a boolean specifying if alpha blending is needed for the mesh
  20539. */
  20540. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20541. /**
  20542. * Specifies if this material should be rendered in alpha test mode
  20543. * @returns a boolean specifying if an alpha test is needed.
  20544. */
  20545. needAlphaTesting(): boolean;
  20546. /**
  20547. * Gets the texture used for the alpha test
  20548. * @returns the texture to use for alpha testing
  20549. */
  20550. getAlphaTestTexture(): Nullable<BaseTexture>;
  20551. /**
  20552. * Marks the material to indicate that it needs to be re-calculated
  20553. */
  20554. markDirty(): void;
  20555. /** @hidden */
  20556. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20557. /**
  20558. * Binds the material to the mesh
  20559. * @param world defines the world transformation matrix
  20560. * @param mesh defines the mesh to bind the material to
  20561. */
  20562. bind(world: Matrix, mesh?: Mesh): void;
  20563. /**
  20564. * Binds the submesh to the material
  20565. * @param world defines the world transformation matrix
  20566. * @param mesh defines the mesh containing the submesh
  20567. * @param subMesh defines the submesh to bind the material to
  20568. */
  20569. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20570. /**
  20571. * Binds the world matrix to the material
  20572. * @param world defines the world transformation matrix
  20573. */
  20574. bindOnlyWorldMatrix(world: Matrix): void;
  20575. /**
  20576. * Binds the scene's uniform buffer to the effect.
  20577. * @param effect defines the effect to bind to the scene uniform buffer
  20578. * @param sceneUbo defines the uniform buffer storing scene data
  20579. */
  20580. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20581. /**
  20582. * Binds the view matrix to the effect
  20583. * @param effect defines the effect to bind the view matrix to
  20584. */
  20585. bindView(effect: Effect): void;
  20586. /**
  20587. * Binds the view projection matrix to the effect
  20588. * @param effect defines the effect to bind the view projection matrix to
  20589. */
  20590. bindViewProjection(effect: Effect): void;
  20591. /**
  20592. * Specifies if material alpha testing should be turned on for the mesh
  20593. * @param mesh defines the mesh to check
  20594. */
  20595. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20596. /**
  20597. * Processes to execute after binding the material to a mesh
  20598. * @param mesh defines the rendered mesh
  20599. */
  20600. protected _afterBind(mesh?: Mesh): void;
  20601. /**
  20602. * Unbinds the material from the mesh
  20603. */
  20604. unbind(): void;
  20605. /**
  20606. * Gets the active textures from the material
  20607. * @returns an array of textures
  20608. */
  20609. getActiveTextures(): BaseTexture[];
  20610. /**
  20611. * Specifies if the material uses a texture
  20612. * @param texture defines the texture to check against the material
  20613. * @returns a boolean specifying if the material uses the texture
  20614. */
  20615. hasTexture(texture: BaseTexture): boolean;
  20616. /**
  20617. * Makes a duplicate of the material, and gives it a new name
  20618. * @param name defines the new name for the duplicated material
  20619. * @returns the cloned material
  20620. */
  20621. clone(name: string): Nullable<Material>;
  20622. /**
  20623. * Gets the meshes bound to the material
  20624. * @returns an array of meshes bound to the material
  20625. */
  20626. getBindedMeshes(): AbstractMesh[];
  20627. /**
  20628. * Force shader compilation
  20629. * @param mesh defines the mesh associated with this material
  20630. * @param onCompiled defines a function to execute once the material is compiled
  20631. * @param options defines the options to configure the compilation
  20632. * @param onError defines a function to execute if the material fails compiling
  20633. */
  20634. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20635. clipPlane: boolean;
  20636. }>, onError?: (reason: string) => void): void;
  20637. /**
  20638. * Force shader compilation
  20639. * @param mesh defines the mesh that will use this material
  20640. * @param options defines additional options for compiling the shaders
  20641. * @returns a promise that resolves when the compilation completes
  20642. */
  20643. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20644. clipPlane: boolean;
  20645. }>): Promise<void>;
  20646. private static readonly _AllDirtyCallBack;
  20647. private static readonly _ImageProcessingDirtyCallBack;
  20648. private static readonly _TextureDirtyCallBack;
  20649. private static readonly _FresnelDirtyCallBack;
  20650. private static readonly _MiscDirtyCallBack;
  20651. private static readonly _LightsDirtyCallBack;
  20652. private static readonly _AttributeDirtyCallBack;
  20653. private static _FresnelAndMiscDirtyCallBack;
  20654. private static _TextureAndMiscDirtyCallBack;
  20655. private static readonly _DirtyCallbackArray;
  20656. private static readonly _RunDirtyCallBacks;
  20657. /**
  20658. * Marks a define in the material to indicate that it needs to be re-computed
  20659. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20660. */
  20661. markAsDirty(flag: number): void;
  20662. /**
  20663. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20664. * @param func defines a function which checks material defines against the submeshes
  20665. */
  20666. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20667. /**
  20668. * Indicates that we need to re-calculated for all submeshes
  20669. */
  20670. protected _markAllSubMeshesAsAllDirty(): void;
  20671. /**
  20672. * Indicates that image processing needs to be re-calculated for all submeshes
  20673. */
  20674. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20675. /**
  20676. * Indicates that textures need to be re-calculated for all submeshes
  20677. */
  20678. protected _markAllSubMeshesAsTexturesDirty(): void;
  20679. /**
  20680. * Indicates that fresnel needs to be re-calculated for all submeshes
  20681. */
  20682. protected _markAllSubMeshesAsFresnelDirty(): void;
  20683. /**
  20684. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20685. */
  20686. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20687. /**
  20688. * Indicates that lights need to be re-calculated for all submeshes
  20689. */
  20690. protected _markAllSubMeshesAsLightsDirty(): void;
  20691. /**
  20692. * Indicates that attributes need to be re-calculated for all submeshes
  20693. */
  20694. protected _markAllSubMeshesAsAttributesDirty(): void;
  20695. /**
  20696. * Indicates that misc needs to be re-calculated for all submeshes
  20697. */
  20698. protected _markAllSubMeshesAsMiscDirty(): void;
  20699. /**
  20700. * Indicates that textures and misc need to be re-calculated for all submeshes
  20701. */
  20702. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20703. /**
  20704. * Disposes the material
  20705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20706. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20707. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20708. */
  20709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20710. /** @hidden */
  20711. private releaseVertexArrayObject;
  20712. /**
  20713. * Serializes this material
  20714. * @returns the serialized material object
  20715. */
  20716. serialize(): any;
  20717. /**
  20718. * Creates a material from parsed material data
  20719. * @param parsedMaterial defines parsed material data
  20720. * @param scene defines the hosting scene
  20721. * @param rootUrl defines the root URL to use to load textures
  20722. * @returns a new material
  20723. */
  20724. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20725. }
  20726. }
  20727. declare module BABYLON {
  20728. /**
  20729. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20730. * separate meshes. This can be use to improve performances.
  20731. * @see http://doc.babylonjs.com/how_to/multi_materials
  20732. */
  20733. export class MultiMaterial extends Material {
  20734. private _subMaterials;
  20735. /**
  20736. * Gets or Sets the list of Materials used within the multi material.
  20737. * They need to be ordered according to the submeshes order in the associated mesh
  20738. */
  20739. subMaterials: Nullable<Material>[];
  20740. /**
  20741. * Function used to align with Node.getChildren()
  20742. * @returns the list of Materials used within the multi material
  20743. */
  20744. getChildren(): Nullable<Material>[];
  20745. /**
  20746. * Instantiates a new Multi Material
  20747. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20748. * separate meshes. This can be use to improve performances.
  20749. * @see http://doc.babylonjs.com/how_to/multi_materials
  20750. * @param name Define the name in the scene
  20751. * @param scene Define the scene the material belongs to
  20752. */
  20753. constructor(name: string, scene: Scene);
  20754. private _hookArray;
  20755. /**
  20756. * Get one of the submaterial by its index in the submaterials array
  20757. * @param index The index to look the sub material at
  20758. * @returns The Material if the index has been defined
  20759. */
  20760. getSubMaterial(index: number): Nullable<Material>;
  20761. /**
  20762. * Get the list of active textures for the whole sub materials list.
  20763. * @returns All the textures that will be used during the rendering
  20764. */
  20765. getActiveTextures(): BaseTexture[];
  20766. /**
  20767. * Gets the current class name of the material e.g. "MultiMaterial"
  20768. * Mainly use in serialization.
  20769. * @returns the class name
  20770. */
  20771. getClassName(): string;
  20772. /**
  20773. * Checks if the material is ready to render the requested sub mesh
  20774. * @param mesh Define the mesh the submesh belongs to
  20775. * @param subMesh Define the sub mesh to look readyness for
  20776. * @param useInstances Define whether or not the material is used with instances
  20777. * @returns true if ready, otherwise false
  20778. */
  20779. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20780. /**
  20781. * Clones the current material and its related sub materials
  20782. * @param name Define the name of the newly cloned material
  20783. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20784. * @returns the cloned material
  20785. */
  20786. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20787. /**
  20788. * Serializes the materials into a JSON representation.
  20789. * @returns the JSON representation
  20790. */
  20791. serialize(): any;
  20792. /**
  20793. * Dispose the material and release its associated resources
  20794. * @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)
  20795. * @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)
  20796. * @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)
  20797. */
  20798. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20799. /**
  20800. * Creates a MultiMaterial from parsed MultiMaterial data.
  20801. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20802. * @param scene defines the hosting scene
  20803. * @returns a new MultiMaterial
  20804. */
  20805. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20806. }
  20807. }
  20808. declare module BABYLON {
  20809. /**
  20810. * Base class for submeshes
  20811. */
  20812. export class BaseSubMesh {
  20813. /** @hidden */
  20814. _materialDefines: Nullable<MaterialDefines>;
  20815. /** @hidden */
  20816. _materialEffect: Nullable<Effect>;
  20817. /**
  20818. * Gets associated effect
  20819. */
  20820. readonly effect: Nullable<Effect>;
  20821. /**
  20822. * Sets associated effect (effect used to render this submesh)
  20823. * @param effect defines the effect to associate with
  20824. * @param defines defines the set of defines used to compile this effect
  20825. */
  20826. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20827. }
  20828. /**
  20829. * Defines a subdivision inside a mesh
  20830. */
  20831. export class SubMesh extends BaseSubMesh implements ICullable {
  20832. /** the material index to use */
  20833. materialIndex: number;
  20834. /** vertex index start */
  20835. verticesStart: number;
  20836. /** vertices count */
  20837. verticesCount: number;
  20838. /** index start */
  20839. indexStart: number;
  20840. /** indices count */
  20841. indexCount: number;
  20842. /** @hidden */
  20843. _linesIndexCount: number;
  20844. private _mesh;
  20845. private _renderingMesh;
  20846. private _boundingInfo;
  20847. private _linesIndexBuffer;
  20848. /** @hidden */
  20849. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20850. /** @hidden */
  20851. _trianglePlanes: Plane[];
  20852. /** @hidden */
  20853. _lastColliderTransformMatrix: Nullable<Matrix>;
  20854. /** @hidden */
  20855. _renderId: number;
  20856. /** @hidden */
  20857. _alphaIndex: number;
  20858. /** @hidden */
  20859. _distanceToCamera: number;
  20860. /** @hidden */
  20861. _id: number;
  20862. private _currentMaterial;
  20863. /**
  20864. * Add a new submesh to a mesh
  20865. * @param materialIndex defines the material index to use
  20866. * @param verticesStart defines vertex index start
  20867. * @param verticesCount defines vertices count
  20868. * @param indexStart defines index start
  20869. * @param indexCount defines indices count
  20870. * @param mesh defines the parent mesh
  20871. * @param renderingMesh defines an optional rendering mesh
  20872. * @param createBoundingBox defines if bounding box should be created for this submesh
  20873. * @returns the new submesh
  20874. */
  20875. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20876. /**
  20877. * Creates a new submesh
  20878. * @param materialIndex defines the material index to use
  20879. * @param verticesStart defines vertex index start
  20880. * @param verticesCount defines vertices count
  20881. * @param indexStart defines index start
  20882. * @param indexCount defines indices count
  20883. * @param mesh defines the parent mesh
  20884. * @param renderingMesh defines an optional rendering mesh
  20885. * @param createBoundingBox defines if bounding box should be created for this submesh
  20886. */
  20887. constructor(
  20888. /** the material index to use */
  20889. materialIndex: number,
  20890. /** vertex index start */
  20891. verticesStart: number,
  20892. /** vertices count */
  20893. verticesCount: number,
  20894. /** index start */
  20895. indexStart: number,
  20896. /** indices count */
  20897. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20898. /**
  20899. * Returns true if this submesh covers the entire parent mesh
  20900. * @ignorenaming
  20901. */
  20902. readonly IsGlobal: boolean;
  20903. /**
  20904. * Returns the submesh BoudingInfo object
  20905. * @returns current bounding info (or mesh's one if the submesh is global)
  20906. */
  20907. getBoundingInfo(): BoundingInfo;
  20908. /**
  20909. * Sets the submesh BoundingInfo
  20910. * @param boundingInfo defines the new bounding info to use
  20911. * @returns the SubMesh
  20912. */
  20913. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20914. /**
  20915. * Returns the mesh of the current submesh
  20916. * @return the parent mesh
  20917. */
  20918. getMesh(): AbstractMesh;
  20919. /**
  20920. * Returns the rendering mesh of the submesh
  20921. * @returns the rendering mesh (could be different from parent mesh)
  20922. */
  20923. getRenderingMesh(): Mesh;
  20924. /**
  20925. * Returns the submesh material
  20926. * @returns null or the current material
  20927. */
  20928. getMaterial(): Nullable<Material>;
  20929. /**
  20930. * Sets a new updated BoundingInfo object to the submesh
  20931. * @param data defines an optional position array to use to determine the bounding info
  20932. * @returns the SubMesh
  20933. */
  20934. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20935. /** @hidden */
  20936. _checkCollision(collider: Collider): boolean;
  20937. /**
  20938. * Updates the submesh BoundingInfo
  20939. * @param world defines the world matrix to use to update the bounding info
  20940. * @returns the submesh
  20941. */
  20942. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20943. /**
  20944. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20945. * @param frustumPlanes defines the frustum planes
  20946. * @returns true if the submesh is intersecting with the frustum
  20947. */
  20948. isInFrustum(frustumPlanes: Plane[]): boolean;
  20949. /**
  20950. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20951. * @param frustumPlanes defines the frustum planes
  20952. * @returns true if the submesh is inside the frustum
  20953. */
  20954. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20955. /**
  20956. * Renders the submesh
  20957. * @param enableAlphaMode defines if alpha needs to be used
  20958. * @returns the submesh
  20959. */
  20960. render(enableAlphaMode: boolean): SubMesh;
  20961. /**
  20962. * @hidden
  20963. */
  20964. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20965. /**
  20966. * Checks if the submesh intersects with a ray
  20967. * @param ray defines the ray to test
  20968. * @returns true is the passed ray intersects the submesh bounding box
  20969. */
  20970. canIntersects(ray: Ray): boolean;
  20971. /**
  20972. * Intersects current submesh with a ray
  20973. * @param ray defines the ray to test
  20974. * @param positions defines mesh's positions array
  20975. * @param indices defines mesh's indices array
  20976. * @param fastCheck defines if only bounding info should be used
  20977. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20978. * @returns intersection info or null if no intersection
  20979. */
  20980. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20981. /** @hidden */
  20982. private _intersectLines;
  20983. /** @hidden */
  20984. private _intersectUnIndexedLines;
  20985. /** @hidden */
  20986. private _intersectTriangles;
  20987. /** @hidden */
  20988. private _intersectUnIndexedTriangles;
  20989. /** @hidden */
  20990. _rebuild(): void;
  20991. /**
  20992. * Creates a new submesh from the passed mesh
  20993. * @param newMesh defines the new hosting mesh
  20994. * @param newRenderingMesh defines an optional rendering mesh
  20995. * @returns the new submesh
  20996. */
  20997. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20998. /**
  20999. * Release associated resources
  21000. */
  21001. dispose(): void;
  21002. /**
  21003. * Gets the class name
  21004. * @returns the string "SubMesh".
  21005. */
  21006. getClassName(): string;
  21007. /**
  21008. * Creates a new submesh from indices data
  21009. * @param materialIndex the index of the main mesh material
  21010. * @param startIndex the index where to start the copy in the mesh indices array
  21011. * @param indexCount the number of indices to copy then from the startIndex
  21012. * @param mesh the main mesh to create the submesh from
  21013. * @param renderingMesh the optional rendering mesh
  21014. * @returns a new submesh
  21015. */
  21016. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21017. }
  21018. }
  21019. declare module BABYLON {
  21020. /**
  21021. * Class used to represent data loading progression
  21022. */
  21023. export class SceneLoaderFlags {
  21024. private static _ForceFullSceneLoadingForIncremental;
  21025. private static _ShowLoadingScreen;
  21026. private static _CleanBoneMatrixWeights;
  21027. private static _loggingLevel;
  21028. /**
  21029. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21030. */
  21031. static ForceFullSceneLoadingForIncremental: boolean;
  21032. /**
  21033. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21034. */
  21035. static ShowLoadingScreen: boolean;
  21036. /**
  21037. * Defines the current logging level (while loading the scene)
  21038. * @ignorenaming
  21039. */
  21040. static loggingLevel: number;
  21041. /**
  21042. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21043. */
  21044. static CleanBoneMatrixWeights: boolean;
  21045. }
  21046. }
  21047. declare module BABYLON {
  21048. /**
  21049. * Class used to store geometry data (vertex buffers + index buffer)
  21050. */
  21051. export class Geometry implements IGetSetVerticesData {
  21052. /**
  21053. * Gets or sets the ID of the geometry
  21054. */
  21055. id: string;
  21056. /**
  21057. * Gets or sets the unique ID of the geometry
  21058. */
  21059. uniqueId: number;
  21060. /**
  21061. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21062. */
  21063. delayLoadState: number;
  21064. /**
  21065. * Gets the file containing the data to load when running in delay load state
  21066. */
  21067. delayLoadingFile: Nullable<string>;
  21068. /**
  21069. * Callback called when the geometry is updated
  21070. */
  21071. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21072. private _scene;
  21073. private _engine;
  21074. private _meshes;
  21075. private _totalVertices;
  21076. /** @hidden */
  21077. _indices: IndicesArray;
  21078. /** @hidden */
  21079. _vertexBuffers: {
  21080. [key: string]: VertexBuffer;
  21081. };
  21082. private _isDisposed;
  21083. private _extend;
  21084. private _boundingBias;
  21085. /** @hidden */
  21086. _delayInfo: Array<string>;
  21087. private _indexBuffer;
  21088. private _indexBufferIsUpdatable;
  21089. /** @hidden */
  21090. _boundingInfo: Nullable<BoundingInfo>;
  21091. /** @hidden */
  21092. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21093. /** @hidden */
  21094. _softwareSkinningFrameId: number;
  21095. private _vertexArrayObjects;
  21096. private _updatable;
  21097. /** @hidden */
  21098. _positions: Nullable<Vector3[]>;
  21099. /**
  21100. * 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
  21101. */
  21102. /**
  21103. * 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
  21104. */
  21105. boundingBias: Vector2;
  21106. /**
  21107. * Static function used to attach a new empty geometry to a mesh
  21108. * @param mesh defines the mesh to attach the geometry to
  21109. * @returns the new Geometry
  21110. */
  21111. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21112. /**
  21113. * Creates a new geometry
  21114. * @param id defines the unique ID
  21115. * @param scene defines the hosting scene
  21116. * @param vertexData defines the VertexData used to get geometry data
  21117. * @param updatable defines if geometry must be updatable (false by default)
  21118. * @param mesh defines the mesh that will be associated with the geometry
  21119. */
  21120. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21121. /**
  21122. * Gets the current extend of the geometry
  21123. */
  21124. readonly extend: {
  21125. minimum: Vector3;
  21126. maximum: Vector3;
  21127. };
  21128. /**
  21129. * Gets the hosting scene
  21130. * @returns the hosting Scene
  21131. */
  21132. getScene(): Scene;
  21133. /**
  21134. * Gets the hosting engine
  21135. * @returns the hosting Engine
  21136. */
  21137. getEngine(): Engine;
  21138. /**
  21139. * Defines if the geometry is ready to use
  21140. * @returns true if the geometry is ready to be used
  21141. */
  21142. isReady(): boolean;
  21143. /**
  21144. * Gets a value indicating that the geometry should not be serialized
  21145. */
  21146. readonly doNotSerialize: boolean;
  21147. /** @hidden */
  21148. _rebuild(): void;
  21149. /**
  21150. * Affects all geometry data in one call
  21151. * @param vertexData defines the geometry data
  21152. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21153. */
  21154. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21155. /**
  21156. * Set specific vertex data
  21157. * @param kind defines the data kind (Position, normal, etc...)
  21158. * @param data defines the vertex data to use
  21159. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21160. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21161. */
  21162. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21163. /**
  21164. * Removes a specific vertex data
  21165. * @param kind defines the data kind (Position, normal, etc...)
  21166. */
  21167. removeVerticesData(kind: string): void;
  21168. /**
  21169. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21170. * @param buffer defines the vertex buffer to use
  21171. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21172. */
  21173. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21174. /**
  21175. * Update a specific vertex buffer
  21176. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21177. * It will do nothing if the buffer is not updatable
  21178. * @param kind defines the data kind (Position, normal, etc...)
  21179. * @param data defines the data to use
  21180. * @param offset defines the offset in the target buffer where to store the data
  21181. * @param useBytes set to true if the offset is in bytes
  21182. */
  21183. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21184. /**
  21185. * Update a specific vertex buffer
  21186. * This function will create a new buffer if the current one is not updatable
  21187. * @param kind defines the data kind (Position, normal, etc...)
  21188. * @param data defines the data to use
  21189. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21190. */
  21191. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21192. private _updateBoundingInfo;
  21193. /** @hidden */
  21194. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21195. /**
  21196. * Gets total number of vertices
  21197. * @returns the total number of vertices
  21198. */
  21199. getTotalVertices(): number;
  21200. /**
  21201. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21202. * @param kind defines the data kind (Position, normal, etc...)
  21203. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21204. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21205. * @returns a float array containing vertex data
  21206. */
  21207. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21208. /**
  21209. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21210. * @param kind defines the data kind (Position, normal, etc...)
  21211. * @returns true if the vertex buffer with the specified kind is updatable
  21212. */
  21213. isVertexBufferUpdatable(kind: string): boolean;
  21214. /**
  21215. * Gets a specific vertex buffer
  21216. * @param kind defines the data kind (Position, normal, etc...)
  21217. * @returns a VertexBuffer
  21218. */
  21219. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21220. /**
  21221. * Returns all vertex buffers
  21222. * @return an object holding all vertex buffers indexed by kind
  21223. */
  21224. getVertexBuffers(): Nullable<{
  21225. [key: string]: VertexBuffer;
  21226. }>;
  21227. /**
  21228. * Gets a boolean indicating if specific vertex buffer is present
  21229. * @param kind defines the data kind (Position, normal, etc...)
  21230. * @returns true if data is present
  21231. */
  21232. isVerticesDataPresent(kind: string): boolean;
  21233. /**
  21234. * Gets a list of all attached data kinds (Position, normal, etc...)
  21235. * @returns a list of string containing all kinds
  21236. */
  21237. getVerticesDataKinds(): string[];
  21238. /**
  21239. * Update index buffer
  21240. * @param indices defines the indices to store in the index buffer
  21241. * @param offset defines the offset in the target buffer where to store the data
  21242. * @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)
  21243. */
  21244. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21245. /**
  21246. * Creates a new index buffer
  21247. * @param indices defines the indices to store in the index buffer
  21248. * @param totalVertices defines the total number of vertices (could be null)
  21249. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21250. */
  21251. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21252. /**
  21253. * Return the total number of indices
  21254. * @returns the total number of indices
  21255. */
  21256. getTotalIndices(): number;
  21257. /**
  21258. * Gets the index buffer array
  21259. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21260. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21261. * @returns the index buffer array
  21262. */
  21263. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21264. /**
  21265. * Gets the index buffer
  21266. * @return the index buffer
  21267. */
  21268. getIndexBuffer(): Nullable<DataBuffer>;
  21269. /** @hidden */
  21270. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21271. /**
  21272. * Release the associated resources for a specific mesh
  21273. * @param mesh defines the source mesh
  21274. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21275. */
  21276. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21277. /**
  21278. * Apply current geometry to a given mesh
  21279. * @param mesh defines the mesh to apply geometry to
  21280. */
  21281. applyToMesh(mesh: Mesh): void;
  21282. private _updateExtend;
  21283. private _applyToMesh;
  21284. private notifyUpdate;
  21285. /**
  21286. * Load the geometry if it was flagged as delay loaded
  21287. * @param scene defines the hosting scene
  21288. * @param onLoaded defines a callback called when the geometry is loaded
  21289. */
  21290. load(scene: Scene, onLoaded?: () => void): void;
  21291. private _queueLoad;
  21292. /**
  21293. * Invert the geometry to move from a right handed system to a left handed one.
  21294. */
  21295. toLeftHanded(): void;
  21296. /** @hidden */
  21297. _resetPointsArrayCache(): void;
  21298. /** @hidden */
  21299. _generatePointsArray(): boolean;
  21300. /**
  21301. * Gets a value indicating if the geometry is disposed
  21302. * @returns true if the geometry was disposed
  21303. */
  21304. isDisposed(): boolean;
  21305. private _disposeVertexArrayObjects;
  21306. /**
  21307. * Free all associated resources
  21308. */
  21309. dispose(): void;
  21310. /**
  21311. * Clone the current geometry into a new geometry
  21312. * @param id defines the unique ID of the new geometry
  21313. * @returns a new geometry object
  21314. */
  21315. copy(id: string): Geometry;
  21316. /**
  21317. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21318. * @return a JSON representation of the current geometry data (without the vertices data)
  21319. */
  21320. serialize(): any;
  21321. private toNumberArray;
  21322. /**
  21323. * Serialize all vertices data into a JSON oject
  21324. * @returns a JSON representation of the current geometry data
  21325. */
  21326. serializeVerticeData(): any;
  21327. /**
  21328. * Extracts a clone of a mesh geometry
  21329. * @param mesh defines the source mesh
  21330. * @param id defines the unique ID of the new geometry object
  21331. * @returns the new geometry object
  21332. */
  21333. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21334. /**
  21335. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21336. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21337. * Be aware Math.random() could cause collisions, but:
  21338. * "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"
  21339. * @returns a string containing a new GUID
  21340. */
  21341. static RandomId(): string;
  21342. /** @hidden */
  21343. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21344. private static _CleanMatricesWeights;
  21345. /**
  21346. * Create a new geometry from persisted data (Using .babylon file format)
  21347. * @param parsedVertexData defines the persisted data
  21348. * @param scene defines the hosting scene
  21349. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21350. * @returns the new geometry object
  21351. */
  21352. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21353. }
  21354. }
  21355. declare module BABYLON {
  21356. /**
  21357. * Define an interface for all classes that will get and set the data on vertices
  21358. */
  21359. export interface IGetSetVerticesData {
  21360. /**
  21361. * Gets a boolean indicating if specific vertex data is present
  21362. * @param kind defines the vertex data kind to use
  21363. * @returns true is data kind is present
  21364. */
  21365. isVerticesDataPresent(kind: string): boolean;
  21366. /**
  21367. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21368. * @param kind defines the data kind (Position, normal, etc...)
  21369. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21371. * @returns a float array containing vertex data
  21372. */
  21373. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21374. /**
  21375. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21376. * @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.
  21377. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21378. * @returns the indices array or an empty array if the mesh has no geometry
  21379. */
  21380. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21381. /**
  21382. * Set specific vertex data
  21383. * @param kind defines the data kind (Position, normal, etc...)
  21384. * @param data defines the vertex data to use
  21385. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21386. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21387. */
  21388. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21389. /**
  21390. * Update a specific associated vertex buffer
  21391. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21392. * - VertexBuffer.PositionKind
  21393. * - VertexBuffer.UVKind
  21394. * - VertexBuffer.UV2Kind
  21395. * - VertexBuffer.UV3Kind
  21396. * - VertexBuffer.UV4Kind
  21397. * - VertexBuffer.UV5Kind
  21398. * - VertexBuffer.UV6Kind
  21399. * - VertexBuffer.ColorKind
  21400. * - VertexBuffer.MatricesIndicesKind
  21401. * - VertexBuffer.MatricesIndicesExtraKind
  21402. * - VertexBuffer.MatricesWeightsKind
  21403. * - VertexBuffer.MatricesWeightsExtraKind
  21404. * @param data defines the data source
  21405. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21406. * @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)
  21407. */
  21408. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21409. /**
  21410. * Creates a new index buffer
  21411. * @param indices defines the indices to store in the index buffer
  21412. * @param totalVertices defines the total number of vertices (could be null)
  21413. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21414. */
  21415. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21416. }
  21417. /**
  21418. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21419. */
  21420. export class VertexData {
  21421. /**
  21422. * Mesh side orientation : usually the external or front surface
  21423. */
  21424. static readonly FRONTSIDE: number;
  21425. /**
  21426. * Mesh side orientation : usually the internal or back surface
  21427. */
  21428. static readonly BACKSIDE: number;
  21429. /**
  21430. * Mesh side orientation : both internal and external or front and back surfaces
  21431. */
  21432. static readonly DOUBLESIDE: number;
  21433. /**
  21434. * Mesh side orientation : by default, `FRONTSIDE`
  21435. */
  21436. static readonly DEFAULTSIDE: number;
  21437. /**
  21438. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21439. */
  21440. positions: Nullable<FloatArray>;
  21441. /**
  21442. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21443. */
  21444. normals: Nullable<FloatArray>;
  21445. /**
  21446. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21447. */
  21448. tangents: Nullable<FloatArray>;
  21449. /**
  21450. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21451. */
  21452. uvs: Nullable<FloatArray>;
  21453. /**
  21454. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21455. */
  21456. uvs2: Nullable<FloatArray>;
  21457. /**
  21458. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21459. */
  21460. uvs3: Nullable<FloatArray>;
  21461. /**
  21462. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21463. */
  21464. uvs4: Nullable<FloatArray>;
  21465. /**
  21466. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21467. */
  21468. uvs5: Nullable<FloatArray>;
  21469. /**
  21470. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21471. */
  21472. uvs6: Nullable<FloatArray>;
  21473. /**
  21474. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21475. */
  21476. colors: Nullable<FloatArray>;
  21477. /**
  21478. * 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).
  21479. */
  21480. matricesIndices: Nullable<FloatArray>;
  21481. /**
  21482. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21483. */
  21484. matricesWeights: Nullable<FloatArray>;
  21485. /**
  21486. * An array extending the number of possible indices
  21487. */
  21488. matricesIndicesExtra: Nullable<FloatArray>;
  21489. /**
  21490. * An array extending the number of possible weights when the number of indices is extended
  21491. */
  21492. matricesWeightsExtra: Nullable<FloatArray>;
  21493. /**
  21494. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21495. */
  21496. indices: Nullable<IndicesArray>;
  21497. /**
  21498. * Uses the passed data array to set the set the values for the specified kind of data
  21499. * @param data a linear array of floating numbers
  21500. * @param kind the type of data that is being set, eg positions, colors etc
  21501. */
  21502. set(data: FloatArray, kind: string): void;
  21503. /**
  21504. * Associates the vertexData to the passed Mesh.
  21505. * Sets it as updatable or not (default `false`)
  21506. * @param mesh the mesh the vertexData is applied to
  21507. * @param updatable when used and having the value true allows new data to update the vertexData
  21508. * @returns the VertexData
  21509. */
  21510. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21511. /**
  21512. * Associates the vertexData to the passed Geometry.
  21513. * Sets it as updatable or not (default `false`)
  21514. * @param geometry the geometry the vertexData is applied to
  21515. * @param updatable when used and having the value true allows new data to update the vertexData
  21516. * @returns VertexData
  21517. */
  21518. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21519. /**
  21520. * Updates the associated mesh
  21521. * @param mesh the mesh to be updated
  21522. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21523. * @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
  21524. * @returns VertexData
  21525. */
  21526. updateMesh(mesh: Mesh): VertexData;
  21527. /**
  21528. * Updates the associated geometry
  21529. * @param geometry the geometry to be updated
  21530. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21531. * @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
  21532. * @returns VertexData.
  21533. */
  21534. updateGeometry(geometry: Geometry): VertexData;
  21535. private _applyTo;
  21536. private _update;
  21537. /**
  21538. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21539. * @param matrix the transforming matrix
  21540. * @returns the VertexData
  21541. */
  21542. transform(matrix: Matrix): VertexData;
  21543. /**
  21544. * Merges the passed VertexData into the current one
  21545. * @param other the VertexData to be merged into the current one
  21546. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21547. * @returns the modified VertexData
  21548. */
  21549. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21550. private _mergeElement;
  21551. private _validate;
  21552. /**
  21553. * Serializes the VertexData
  21554. * @returns a serialized object
  21555. */
  21556. serialize(): any;
  21557. /**
  21558. * Extracts the vertexData from a mesh
  21559. * @param mesh the mesh from which to extract the VertexData
  21560. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21561. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21562. * @returns the object VertexData associated to the passed mesh
  21563. */
  21564. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21565. /**
  21566. * Extracts the vertexData from the geometry
  21567. * @param geometry the geometry from which to extract the VertexData
  21568. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21569. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21570. * @returns the object VertexData associated to the passed mesh
  21571. */
  21572. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21573. private static _ExtractFrom;
  21574. /**
  21575. * Creates the VertexData for a Ribbon
  21576. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21577. * * pathArray array of paths, each of which an array of successive Vector3
  21578. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21579. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21580. * * 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
  21581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21582. * * 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)
  21583. * * 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)
  21584. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21585. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21586. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21587. * @returns the VertexData of the ribbon
  21588. */
  21589. static CreateRibbon(options: {
  21590. pathArray: Vector3[][];
  21591. closeArray?: boolean;
  21592. closePath?: boolean;
  21593. offset?: number;
  21594. sideOrientation?: number;
  21595. frontUVs?: Vector4;
  21596. backUVs?: Vector4;
  21597. invertUV?: boolean;
  21598. uvs?: Vector2[];
  21599. colors?: Color4[];
  21600. }): VertexData;
  21601. /**
  21602. * Creates the VertexData for a box
  21603. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21604. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21605. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21606. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21607. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21608. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21609. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21611. * * 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)
  21612. * * 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)
  21613. * @returns the VertexData of the box
  21614. */
  21615. static CreateBox(options: {
  21616. size?: number;
  21617. width?: number;
  21618. height?: number;
  21619. depth?: number;
  21620. faceUV?: Vector4[];
  21621. faceColors?: Color4[];
  21622. sideOrientation?: number;
  21623. frontUVs?: Vector4;
  21624. backUVs?: Vector4;
  21625. }): VertexData;
  21626. /**
  21627. * Creates the VertexData for a tiled box
  21628. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21629. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21630. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21631. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21633. * @returns the VertexData of the box
  21634. */
  21635. static CreateTiledBox(options: {
  21636. pattern?: number;
  21637. width?: number;
  21638. height?: number;
  21639. depth?: number;
  21640. tileSize?: number;
  21641. tileWidth?: number;
  21642. tileHeight?: number;
  21643. alignHorizontal?: number;
  21644. alignVertical?: number;
  21645. faceUV?: Vector4[];
  21646. faceColors?: Color4[];
  21647. sideOrientation?: number;
  21648. }): VertexData;
  21649. /**
  21650. * Creates the VertexData for a tiled plane
  21651. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21652. * * pattern a limited pattern arrangement depending on the number
  21653. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21654. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21655. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21657. * * 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)
  21658. * * 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)
  21659. * @returns the VertexData of the tiled plane
  21660. */
  21661. static CreateTiledPlane(options: {
  21662. pattern?: number;
  21663. tileSize?: number;
  21664. tileWidth?: number;
  21665. tileHeight?: number;
  21666. size?: number;
  21667. width?: number;
  21668. height?: number;
  21669. alignHorizontal?: number;
  21670. alignVertical?: number;
  21671. sideOrientation?: number;
  21672. frontUVs?: Vector4;
  21673. backUVs?: Vector4;
  21674. }): VertexData;
  21675. /**
  21676. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21677. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21678. * * segments sets the number of horizontal strips optional, default 32
  21679. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21680. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21681. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21682. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21683. * * 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
  21684. * * 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
  21685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21686. * * 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)
  21687. * * 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)
  21688. * @returns the VertexData of the ellipsoid
  21689. */
  21690. static CreateSphere(options: {
  21691. segments?: number;
  21692. diameter?: number;
  21693. diameterX?: number;
  21694. diameterY?: number;
  21695. diameterZ?: number;
  21696. arc?: number;
  21697. slice?: number;
  21698. sideOrientation?: number;
  21699. frontUVs?: Vector4;
  21700. backUVs?: Vector4;
  21701. }): VertexData;
  21702. /**
  21703. * Creates the VertexData for a cylinder, cone or prism
  21704. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21705. * * height sets the height (y direction) of the cylinder, optional, default 2
  21706. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21707. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21708. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21709. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21710. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21711. * * 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
  21712. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21713. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21714. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21715. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21717. * * 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)
  21718. * * 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)
  21719. * @returns the VertexData of the cylinder, cone or prism
  21720. */
  21721. static CreateCylinder(options: {
  21722. height?: number;
  21723. diameterTop?: number;
  21724. diameterBottom?: number;
  21725. diameter?: number;
  21726. tessellation?: number;
  21727. subdivisions?: number;
  21728. arc?: number;
  21729. faceColors?: Color4[];
  21730. faceUV?: Vector4[];
  21731. hasRings?: boolean;
  21732. enclose?: boolean;
  21733. sideOrientation?: number;
  21734. frontUVs?: Vector4;
  21735. backUVs?: Vector4;
  21736. }): VertexData;
  21737. /**
  21738. * Creates the VertexData for a torus
  21739. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21740. * * diameter the diameter of the torus, optional default 1
  21741. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21742. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21744. * * 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)
  21745. * * 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)
  21746. * @returns the VertexData of the torus
  21747. */
  21748. static CreateTorus(options: {
  21749. diameter?: number;
  21750. thickness?: number;
  21751. tessellation?: number;
  21752. sideOrientation?: number;
  21753. frontUVs?: Vector4;
  21754. backUVs?: Vector4;
  21755. }): VertexData;
  21756. /**
  21757. * Creates the VertexData of the LineSystem
  21758. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21759. * - lines an array of lines, each line being an array of successive Vector3
  21760. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21761. * @returns the VertexData of the LineSystem
  21762. */
  21763. static CreateLineSystem(options: {
  21764. lines: Vector3[][];
  21765. colors?: Nullable<Color4[][]>;
  21766. }): VertexData;
  21767. /**
  21768. * Create the VertexData for a DashedLines
  21769. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21770. * - points an array successive Vector3
  21771. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21772. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21773. * - dashNb the intended total number of dashes, optional, default 200
  21774. * @returns the VertexData for the DashedLines
  21775. */
  21776. static CreateDashedLines(options: {
  21777. points: Vector3[];
  21778. dashSize?: number;
  21779. gapSize?: number;
  21780. dashNb?: number;
  21781. }): VertexData;
  21782. /**
  21783. * Creates the VertexData for a Ground
  21784. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21785. * - width the width (x direction) of the ground, optional, default 1
  21786. * - height the height (z direction) of the ground, optional, default 1
  21787. * - subdivisions the number of subdivisions per side, optional, default 1
  21788. * @returns the VertexData of the Ground
  21789. */
  21790. static CreateGround(options: {
  21791. width?: number;
  21792. height?: number;
  21793. subdivisions?: number;
  21794. subdivisionsX?: number;
  21795. subdivisionsY?: number;
  21796. }): VertexData;
  21797. /**
  21798. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21799. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21800. * * xmin the ground minimum X coordinate, optional, default -1
  21801. * * zmin the ground minimum Z coordinate, optional, default -1
  21802. * * xmax the ground maximum X coordinate, optional, default 1
  21803. * * zmax the ground maximum Z coordinate, optional, default 1
  21804. * * 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}
  21805. * * 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}
  21806. * @returns the VertexData of the TiledGround
  21807. */
  21808. static CreateTiledGround(options: {
  21809. xmin: number;
  21810. zmin: number;
  21811. xmax: number;
  21812. zmax: number;
  21813. subdivisions?: {
  21814. w: number;
  21815. h: number;
  21816. };
  21817. precision?: {
  21818. w: number;
  21819. h: number;
  21820. };
  21821. }): VertexData;
  21822. /**
  21823. * Creates the VertexData of the Ground designed from a heightmap
  21824. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21825. * * width the width (x direction) of the ground
  21826. * * height the height (z direction) of the ground
  21827. * * subdivisions the number of subdivisions per side
  21828. * * minHeight the minimum altitude on the ground, optional, default 0
  21829. * * maxHeight the maximum altitude on the ground, optional default 1
  21830. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21831. * * buffer the array holding the image color data
  21832. * * bufferWidth the width of image
  21833. * * bufferHeight the height of image
  21834. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21835. * @returns the VertexData of the Ground designed from a heightmap
  21836. */
  21837. static CreateGroundFromHeightMap(options: {
  21838. width: number;
  21839. height: number;
  21840. subdivisions: number;
  21841. minHeight: number;
  21842. maxHeight: number;
  21843. colorFilter: Color3;
  21844. buffer: Uint8Array;
  21845. bufferWidth: number;
  21846. bufferHeight: number;
  21847. alphaFilter: number;
  21848. }): VertexData;
  21849. /**
  21850. * Creates the VertexData for a Plane
  21851. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21852. * * size sets the width and height of the plane to the value of size, optional default 1
  21853. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21854. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21855. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21856. * * 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)
  21857. * * 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)
  21858. * @returns the VertexData of the box
  21859. */
  21860. static CreatePlane(options: {
  21861. size?: number;
  21862. width?: number;
  21863. height?: number;
  21864. sideOrientation?: number;
  21865. frontUVs?: Vector4;
  21866. backUVs?: Vector4;
  21867. }): VertexData;
  21868. /**
  21869. * Creates the VertexData of the Disc or regular Polygon
  21870. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21871. * * radius the radius of the disc, optional default 0.5
  21872. * * tessellation the number of polygon sides, optional, default 64
  21873. * * 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
  21874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21875. * * 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)
  21876. * * 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)
  21877. * @returns the VertexData of the box
  21878. */
  21879. static CreateDisc(options: {
  21880. radius?: number;
  21881. tessellation?: number;
  21882. arc?: number;
  21883. sideOrientation?: number;
  21884. frontUVs?: Vector4;
  21885. backUVs?: Vector4;
  21886. }): VertexData;
  21887. /**
  21888. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21889. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21890. * @param polygon a mesh built from polygonTriangulation.build()
  21891. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21892. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21893. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21894. * @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)
  21895. * @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)
  21896. * @returns the VertexData of the Polygon
  21897. */
  21898. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21899. /**
  21900. * Creates the VertexData of the IcoSphere
  21901. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21902. * * radius the radius of the IcoSphere, optional default 1
  21903. * * radiusX allows stretching in the x direction, optional, default radius
  21904. * * radiusY allows stretching in the y direction, optional, default radius
  21905. * * radiusZ allows stretching in the z direction, optional, default radius
  21906. * * flat when true creates a flat shaded mesh, optional, default true
  21907. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21909. * * 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)
  21910. * * 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)
  21911. * @returns the VertexData of the IcoSphere
  21912. */
  21913. static CreateIcoSphere(options: {
  21914. radius?: number;
  21915. radiusX?: number;
  21916. radiusY?: number;
  21917. radiusZ?: number;
  21918. flat?: boolean;
  21919. subdivisions?: number;
  21920. sideOrientation?: number;
  21921. frontUVs?: Vector4;
  21922. backUVs?: Vector4;
  21923. }): VertexData;
  21924. /**
  21925. * Creates the VertexData for a Polyhedron
  21926. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21927. * * type provided types are:
  21928. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21929. * * 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)
  21930. * * size the size of the IcoSphere, optional default 1
  21931. * * sizeX allows stretching in the x direction, optional, default size
  21932. * * sizeY allows stretching in the y direction, optional, default size
  21933. * * sizeZ allows stretching in the z direction, optional, default size
  21934. * * 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
  21935. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21936. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21937. * * flat when true creates a flat shaded mesh, optional, default true
  21938. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21940. * * 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)
  21941. * * 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)
  21942. * @returns the VertexData of the Polyhedron
  21943. */
  21944. static CreatePolyhedron(options: {
  21945. type?: number;
  21946. size?: number;
  21947. sizeX?: number;
  21948. sizeY?: number;
  21949. sizeZ?: number;
  21950. custom?: any;
  21951. faceUV?: Vector4[];
  21952. faceColors?: Color4[];
  21953. flat?: boolean;
  21954. sideOrientation?: number;
  21955. frontUVs?: Vector4;
  21956. backUVs?: Vector4;
  21957. }): VertexData;
  21958. /**
  21959. * Creates the VertexData for a TorusKnot
  21960. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21961. * * radius the radius of the torus knot, optional, default 2
  21962. * * tube the thickness of the tube, optional, default 0.5
  21963. * * radialSegments the number of sides on each tube segments, optional, default 32
  21964. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21965. * * p the number of windings around the z axis, optional, default 2
  21966. * * q the number of windings around the x axis, optional, default 3
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * * 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)
  21969. * * 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)
  21970. * @returns the VertexData of the Torus Knot
  21971. */
  21972. static CreateTorusKnot(options: {
  21973. radius?: number;
  21974. tube?: number;
  21975. radialSegments?: number;
  21976. tubularSegments?: number;
  21977. p?: number;
  21978. q?: number;
  21979. sideOrientation?: number;
  21980. frontUVs?: Vector4;
  21981. backUVs?: Vector4;
  21982. }): VertexData;
  21983. /**
  21984. * Compute normals for given positions and indices
  21985. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21986. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21987. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21988. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21989. * * facetNormals : optional array of facet normals (vector3)
  21990. * * facetPositions : optional array of facet positions (vector3)
  21991. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21992. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21993. * * bInfo : optional bounding info, required for facetPartitioning computation
  21994. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21995. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21996. * * useRightHandedSystem: optional boolean to for right handed system computation
  21997. * * depthSort : optional boolean to enable the facet depth sort computation
  21998. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21999. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22000. */
  22001. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22002. facetNormals?: any;
  22003. facetPositions?: any;
  22004. facetPartitioning?: any;
  22005. ratio?: number;
  22006. bInfo?: any;
  22007. bbSize?: Vector3;
  22008. subDiv?: any;
  22009. useRightHandedSystem?: boolean;
  22010. depthSort?: boolean;
  22011. distanceTo?: Vector3;
  22012. depthSortedFacets?: any;
  22013. }): void;
  22014. /** @hidden */
  22015. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22016. /**
  22017. * Applies VertexData created from the imported parameters to the geometry
  22018. * @param parsedVertexData the parsed data from an imported file
  22019. * @param geometry the geometry to apply the VertexData to
  22020. */
  22021. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22022. }
  22023. }
  22024. declare module BABYLON {
  22025. /**
  22026. * Defines a target to use with MorphTargetManager
  22027. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22028. */
  22029. export class MorphTarget implements IAnimatable {
  22030. /** defines the name of the target */
  22031. name: string;
  22032. /**
  22033. * Gets or sets the list of animations
  22034. */
  22035. animations: Animation[];
  22036. private _scene;
  22037. private _positions;
  22038. private _normals;
  22039. private _tangents;
  22040. private _uvs;
  22041. private _influence;
  22042. /**
  22043. * Observable raised when the influence changes
  22044. */
  22045. onInfluenceChanged: Observable<boolean>;
  22046. /** @hidden */
  22047. _onDataLayoutChanged: Observable<void>;
  22048. /**
  22049. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22050. */
  22051. influence: number;
  22052. /**
  22053. * Gets or sets the id of the morph Target
  22054. */
  22055. id: string;
  22056. private _animationPropertiesOverride;
  22057. /**
  22058. * Gets or sets the animation properties override
  22059. */
  22060. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22061. /**
  22062. * Creates a new MorphTarget
  22063. * @param name defines the name of the target
  22064. * @param influence defines the influence to use
  22065. * @param scene defines the scene the morphtarget belongs to
  22066. */
  22067. constructor(
  22068. /** defines the name of the target */
  22069. name: string, influence?: number, scene?: Nullable<Scene>);
  22070. /**
  22071. * Gets a boolean defining if the target contains position data
  22072. */
  22073. readonly hasPositions: boolean;
  22074. /**
  22075. * Gets a boolean defining if the target contains normal data
  22076. */
  22077. readonly hasNormals: boolean;
  22078. /**
  22079. * Gets a boolean defining if the target contains tangent data
  22080. */
  22081. readonly hasTangents: boolean;
  22082. /**
  22083. * Gets a boolean defining if the target contains texture coordinates data
  22084. */
  22085. readonly hasUVs: boolean;
  22086. /**
  22087. * Affects position data to this target
  22088. * @param data defines the position data to use
  22089. */
  22090. setPositions(data: Nullable<FloatArray>): void;
  22091. /**
  22092. * Gets the position data stored in this target
  22093. * @returns a FloatArray containing the position data (or null if not present)
  22094. */
  22095. getPositions(): Nullable<FloatArray>;
  22096. /**
  22097. * Affects normal data to this target
  22098. * @param data defines the normal data to use
  22099. */
  22100. setNormals(data: Nullable<FloatArray>): void;
  22101. /**
  22102. * Gets the normal data stored in this target
  22103. * @returns a FloatArray containing the normal data (or null if not present)
  22104. */
  22105. getNormals(): Nullable<FloatArray>;
  22106. /**
  22107. * Affects tangent data to this target
  22108. * @param data defines the tangent data to use
  22109. */
  22110. setTangents(data: Nullable<FloatArray>): void;
  22111. /**
  22112. * Gets the tangent data stored in this target
  22113. * @returns a FloatArray containing the tangent data (or null if not present)
  22114. */
  22115. getTangents(): Nullable<FloatArray>;
  22116. /**
  22117. * Affects texture coordinates data to this target
  22118. * @param data defines the texture coordinates data to use
  22119. */
  22120. setUVs(data: Nullable<FloatArray>): void;
  22121. /**
  22122. * Gets the texture coordinates data stored in this target
  22123. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22124. */
  22125. getUVs(): Nullable<FloatArray>;
  22126. /**
  22127. * Serializes the current target into a Serialization object
  22128. * @returns the serialized object
  22129. */
  22130. serialize(): any;
  22131. /**
  22132. * Returns the string "MorphTarget"
  22133. * @returns "MorphTarget"
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Creates a new target from serialized data
  22138. * @param serializationObject defines the serialized data to use
  22139. * @returns a new MorphTarget
  22140. */
  22141. static Parse(serializationObject: any): MorphTarget;
  22142. /**
  22143. * Creates a MorphTarget from mesh data
  22144. * @param mesh defines the source mesh
  22145. * @param name defines the name to use for the new target
  22146. * @param influence defines the influence to attach to the target
  22147. * @returns a new MorphTarget
  22148. */
  22149. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22150. }
  22151. }
  22152. declare module BABYLON {
  22153. /**
  22154. * This class is used to deform meshes using morphing between different targets
  22155. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22156. */
  22157. export class MorphTargetManager {
  22158. private _targets;
  22159. private _targetInfluenceChangedObservers;
  22160. private _targetDataLayoutChangedObservers;
  22161. private _activeTargets;
  22162. private _scene;
  22163. private _influences;
  22164. private _supportsNormals;
  22165. private _supportsTangents;
  22166. private _supportsUVs;
  22167. private _vertexCount;
  22168. private _uniqueId;
  22169. private _tempInfluences;
  22170. /**
  22171. * Gets or sets a boolean indicating if normals must be morphed
  22172. */
  22173. enableNormalMorphing: boolean;
  22174. /**
  22175. * Gets or sets a boolean indicating if tangents must be morphed
  22176. */
  22177. enableTangentMorphing: boolean;
  22178. /**
  22179. * Gets or sets a boolean indicating if UV must be morphed
  22180. */
  22181. enableUVMorphing: boolean;
  22182. /**
  22183. * Creates a new MorphTargetManager
  22184. * @param scene defines the current scene
  22185. */
  22186. constructor(scene?: Nullable<Scene>);
  22187. /**
  22188. * Gets the unique ID of this manager
  22189. */
  22190. readonly uniqueId: number;
  22191. /**
  22192. * Gets the number of vertices handled by this manager
  22193. */
  22194. readonly vertexCount: number;
  22195. /**
  22196. * Gets a boolean indicating if this manager supports morphing of normals
  22197. */
  22198. readonly supportsNormals: boolean;
  22199. /**
  22200. * Gets a boolean indicating if this manager supports morphing of tangents
  22201. */
  22202. readonly supportsTangents: boolean;
  22203. /**
  22204. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22205. */
  22206. readonly supportsUVs: boolean;
  22207. /**
  22208. * Gets the number of targets stored in this manager
  22209. */
  22210. readonly numTargets: number;
  22211. /**
  22212. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22213. */
  22214. readonly numInfluencers: number;
  22215. /**
  22216. * Gets the list of influences (one per target)
  22217. */
  22218. readonly influences: Float32Array;
  22219. /**
  22220. * Gets the active target at specified index. An active target is a target with an influence > 0
  22221. * @param index defines the index to check
  22222. * @returns the requested target
  22223. */
  22224. getActiveTarget(index: number): MorphTarget;
  22225. /**
  22226. * Gets the target at specified index
  22227. * @param index defines the index to check
  22228. * @returns the requested target
  22229. */
  22230. getTarget(index: number): MorphTarget;
  22231. /**
  22232. * Add a new target to this manager
  22233. * @param target defines the target to add
  22234. */
  22235. addTarget(target: MorphTarget): void;
  22236. /**
  22237. * Removes a target from the manager
  22238. * @param target defines the target to remove
  22239. */
  22240. removeTarget(target: MorphTarget): void;
  22241. /**
  22242. * Serializes the current manager into a Serialization object
  22243. * @returns the serialized object
  22244. */
  22245. serialize(): any;
  22246. private _syncActiveTargets;
  22247. /**
  22248. * Syncrhonize the targets with all the meshes using this morph target manager
  22249. */
  22250. synchronize(): void;
  22251. /**
  22252. * Creates a new MorphTargetManager from serialized data
  22253. * @param serializationObject defines the serialized data
  22254. * @param scene defines the hosting scene
  22255. * @returns the new MorphTargetManager
  22256. */
  22257. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22258. }
  22259. }
  22260. declare module BABYLON {
  22261. /**
  22262. * Class used to represent a specific level of detail of a mesh
  22263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22264. */
  22265. export class MeshLODLevel {
  22266. /** Defines the distance where this level should start being displayed */
  22267. distance: number;
  22268. /** Defines the mesh to use to render this level */
  22269. mesh: Nullable<Mesh>;
  22270. /**
  22271. * Creates a new LOD level
  22272. * @param distance defines the distance where this level should star being displayed
  22273. * @param mesh defines the mesh to use to render this level
  22274. */
  22275. constructor(
  22276. /** Defines the distance where this level should start being displayed */
  22277. distance: number,
  22278. /** Defines the mesh to use to render this level */
  22279. mesh: Nullable<Mesh>);
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Mesh representing the gorund
  22285. */
  22286. export class GroundMesh extends Mesh {
  22287. /** If octree should be generated */
  22288. generateOctree: boolean;
  22289. private _heightQuads;
  22290. /** @hidden */
  22291. _subdivisionsX: number;
  22292. /** @hidden */
  22293. _subdivisionsY: number;
  22294. /** @hidden */
  22295. _width: number;
  22296. /** @hidden */
  22297. _height: number;
  22298. /** @hidden */
  22299. _minX: number;
  22300. /** @hidden */
  22301. _maxX: number;
  22302. /** @hidden */
  22303. _minZ: number;
  22304. /** @hidden */
  22305. _maxZ: number;
  22306. constructor(name: string, scene: Scene);
  22307. /**
  22308. * "GroundMesh"
  22309. * @returns "GroundMesh"
  22310. */
  22311. getClassName(): string;
  22312. /**
  22313. * The minimum of x and y subdivisions
  22314. */
  22315. readonly subdivisions: number;
  22316. /**
  22317. * X subdivisions
  22318. */
  22319. readonly subdivisionsX: number;
  22320. /**
  22321. * Y subdivisions
  22322. */
  22323. readonly subdivisionsY: number;
  22324. /**
  22325. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22326. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22327. * @param chunksCount the number of subdivisions for x and y
  22328. * @param octreeBlocksSize (Default: 32)
  22329. */
  22330. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22331. /**
  22332. * Returns a height (y) value in the Worl system :
  22333. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22334. * @param x x coordinate
  22335. * @param z z coordinate
  22336. * @returns the ground y position if (x, z) are outside the ground surface.
  22337. */
  22338. getHeightAtCoordinates(x: number, z: number): number;
  22339. /**
  22340. * Returns a normalized vector (Vector3) orthogonal to the ground
  22341. * at the ground coordinates (x, z) expressed in the World system.
  22342. * @param x x coordinate
  22343. * @param z z coordinate
  22344. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22345. */
  22346. getNormalAtCoordinates(x: number, z: number): Vector3;
  22347. /**
  22348. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22349. * at the ground coordinates (x, z) expressed in the World system.
  22350. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22351. * @param x x coordinate
  22352. * @param z z coordinate
  22353. * @param ref vector to store the result
  22354. * @returns the GroundMesh.
  22355. */
  22356. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22357. /**
  22358. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22359. * if the ground has been updated.
  22360. * This can be used in the render loop.
  22361. * @returns the GroundMesh.
  22362. */
  22363. updateCoordinateHeights(): GroundMesh;
  22364. private _getFacetAt;
  22365. private _initHeightQuads;
  22366. private _computeHeightQuads;
  22367. /**
  22368. * Serializes this ground mesh
  22369. * @param serializationObject object to write serialization to
  22370. */
  22371. serialize(serializationObject: any): void;
  22372. /**
  22373. * Parses a serialized ground mesh
  22374. * @param parsedMesh the serialized mesh
  22375. * @param scene the scene to create the ground mesh in
  22376. * @returns the created ground mesh
  22377. */
  22378. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22379. }
  22380. }
  22381. declare module BABYLON {
  22382. /**
  22383. * Interface for Physics-Joint data
  22384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22385. */
  22386. export interface PhysicsJointData {
  22387. /**
  22388. * The main pivot of the joint
  22389. */
  22390. mainPivot?: Vector3;
  22391. /**
  22392. * The connected pivot of the joint
  22393. */
  22394. connectedPivot?: Vector3;
  22395. /**
  22396. * The main axis of the joint
  22397. */
  22398. mainAxis?: Vector3;
  22399. /**
  22400. * The connected axis of the joint
  22401. */
  22402. connectedAxis?: Vector3;
  22403. /**
  22404. * The collision of the joint
  22405. */
  22406. collision?: boolean;
  22407. /**
  22408. * Native Oimo/Cannon/Energy data
  22409. */
  22410. nativeParams?: any;
  22411. }
  22412. /**
  22413. * This is a holder class for the physics joint created by the physics plugin
  22414. * It holds a set of functions to control the underlying joint
  22415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22416. */
  22417. export class PhysicsJoint {
  22418. /**
  22419. * The type of the physics joint
  22420. */
  22421. type: number;
  22422. /**
  22423. * The data for the physics joint
  22424. */
  22425. jointData: PhysicsJointData;
  22426. private _physicsJoint;
  22427. protected _physicsPlugin: IPhysicsEnginePlugin;
  22428. /**
  22429. * Initializes the physics joint
  22430. * @param type The type of the physics joint
  22431. * @param jointData The data for the physics joint
  22432. */
  22433. constructor(
  22434. /**
  22435. * The type of the physics joint
  22436. */
  22437. type: number,
  22438. /**
  22439. * The data for the physics joint
  22440. */
  22441. jointData: PhysicsJointData);
  22442. /**
  22443. * Gets the physics joint
  22444. */
  22445. /**
  22446. * Sets the physics joint
  22447. */
  22448. physicsJoint: any;
  22449. /**
  22450. * Sets the physics plugin
  22451. */
  22452. physicsPlugin: IPhysicsEnginePlugin;
  22453. /**
  22454. * Execute a function that is physics-plugin specific.
  22455. * @param {Function} func the function that will be executed.
  22456. * It accepts two parameters: the physics world and the physics joint
  22457. */
  22458. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22459. /**
  22460. * Distance-Joint type
  22461. */
  22462. static DistanceJoint: number;
  22463. /**
  22464. * Hinge-Joint type
  22465. */
  22466. static HingeJoint: number;
  22467. /**
  22468. * Ball-and-Socket joint type
  22469. */
  22470. static BallAndSocketJoint: number;
  22471. /**
  22472. * Wheel-Joint type
  22473. */
  22474. static WheelJoint: number;
  22475. /**
  22476. * Slider-Joint type
  22477. */
  22478. static SliderJoint: number;
  22479. /**
  22480. * Prismatic-Joint type
  22481. */
  22482. static PrismaticJoint: number;
  22483. /**
  22484. * Universal-Joint type
  22485. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22486. */
  22487. static UniversalJoint: number;
  22488. /**
  22489. * Hinge-Joint 2 type
  22490. */
  22491. static Hinge2Joint: number;
  22492. /**
  22493. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22494. */
  22495. static PointToPointJoint: number;
  22496. /**
  22497. * Spring-Joint type
  22498. */
  22499. static SpringJoint: number;
  22500. /**
  22501. * Lock-Joint type
  22502. */
  22503. static LockJoint: number;
  22504. }
  22505. /**
  22506. * A class representing a physics distance joint
  22507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22508. */
  22509. export class DistanceJoint extends PhysicsJoint {
  22510. /**
  22511. *
  22512. * @param jointData The data for the Distance-Joint
  22513. */
  22514. constructor(jointData: DistanceJointData);
  22515. /**
  22516. * Update the predefined distance.
  22517. * @param maxDistance The maximum preferred distance
  22518. * @param minDistance The minimum preferred distance
  22519. */
  22520. updateDistance(maxDistance: number, minDistance?: number): void;
  22521. }
  22522. /**
  22523. * Represents a Motor-Enabled Joint
  22524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22525. */
  22526. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22527. /**
  22528. * Initializes the Motor-Enabled Joint
  22529. * @param type The type of the joint
  22530. * @param jointData The physica joint data for the joint
  22531. */
  22532. constructor(type: number, jointData: PhysicsJointData);
  22533. /**
  22534. * Set the motor values.
  22535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22536. * @param force the force to apply
  22537. * @param maxForce max force for this motor.
  22538. */
  22539. setMotor(force?: number, maxForce?: number): void;
  22540. /**
  22541. * Set the motor's limits.
  22542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22543. * @param upperLimit The upper limit of the motor
  22544. * @param lowerLimit The lower limit of the motor
  22545. */
  22546. setLimit(upperLimit: number, lowerLimit?: number): void;
  22547. }
  22548. /**
  22549. * This class represents a single physics Hinge-Joint
  22550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22551. */
  22552. export class HingeJoint extends MotorEnabledJoint {
  22553. /**
  22554. * Initializes the Hinge-Joint
  22555. * @param jointData The joint data for the Hinge-Joint
  22556. */
  22557. constructor(jointData: PhysicsJointData);
  22558. /**
  22559. * Set the motor values.
  22560. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22561. * @param {number} force the force to apply
  22562. * @param {number} maxForce max force for this motor.
  22563. */
  22564. setMotor(force?: number, maxForce?: number): void;
  22565. /**
  22566. * Set the motor's limits.
  22567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22568. * @param upperLimit The upper limit of the motor
  22569. * @param lowerLimit The lower limit of the motor
  22570. */
  22571. setLimit(upperLimit: number, lowerLimit?: number): void;
  22572. }
  22573. /**
  22574. * This class represents a dual hinge physics joint (same as wheel joint)
  22575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22576. */
  22577. export class Hinge2Joint extends MotorEnabledJoint {
  22578. /**
  22579. * Initializes the Hinge2-Joint
  22580. * @param jointData The joint data for the Hinge2-Joint
  22581. */
  22582. constructor(jointData: PhysicsJointData);
  22583. /**
  22584. * Set the motor values.
  22585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22586. * @param {number} targetSpeed the speed the motor is to reach
  22587. * @param {number} maxForce max force for this motor.
  22588. * @param {motorIndex} the motor's index, 0 or 1.
  22589. */
  22590. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22591. /**
  22592. * Set the motor limits.
  22593. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22594. * @param {number} upperLimit the upper limit
  22595. * @param {number} lowerLimit lower limit
  22596. * @param {motorIndex} the motor's index, 0 or 1.
  22597. */
  22598. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22599. }
  22600. /**
  22601. * Interface for a motor enabled joint
  22602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22603. */
  22604. export interface IMotorEnabledJoint {
  22605. /**
  22606. * Physics joint
  22607. */
  22608. physicsJoint: any;
  22609. /**
  22610. * Sets the motor of the motor-enabled joint
  22611. * @param force The force of the motor
  22612. * @param maxForce The maximum force of the motor
  22613. * @param motorIndex The index of the motor
  22614. */
  22615. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22616. /**
  22617. * Sets the limit of the motor
  22618. * @param upperLimit The upper limit of the motor
  22619. * @param lowerLimit The lower limit of the motor
  22620. * @param motorIndex The index of the motor
  22621. */
  22622. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22623. }
  22624. /**
  22625. * Joint data for a Distance-Joint
  22626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22627. */
  22628. export interface DistanceJointData extends PhysicsJointData {
  22629. /**
  22630. * Max distance the 2 joint objects can be apart
  22631. */
  22632. maxDistance: number;
  22633. }
  22634. /**
  22635. * Joint data from a spring joint
  22636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22637. */
  22638. export interface SpringJointData extends PhysicsJointData {
  22639. /**
  22640. * Length of the spring
  22641. */
  22642. length: number;
  22643. /**
  22644. * Stiffness of the spring
  22645. */
  22646. stiffness: number;
  22647. /**
  22648. * Damping of the spring
  22649. */
  22650. damping: number;
  22651. /** this callback will be called when applying the force to the impostors. */
  22652. forceApplicationCallback: () => void;
  22653. }
  22654. }
  22655. declare module BABYLON {
  22656. /**
  22657. * Holds the data for the raycast result
  22658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22659. */
  22660. export class PhysicsRaycastResult {
  22661. private _hasHit;
  22662. private _hitDistance;
  22663. private _hitNormalWorld;
  22664. private _hitPointWorld;
  22665. private _rayFromWorld;
  22666. private _rayToWorld;
  22667. /**
  22668. * Gets if there was a hit
  22669. */
  22670. readonly hasHit: boolean;
  22671. /**
  22672. * Gets the distance from the hit
  22673. */
  22674. readonly hitDistance: number;
  22675. /**
  22676. * Gets the hit normal/direction in the world
  22677. */
  22678. readonly hitNormalWorld: Vector3;
  22679. /**
  22680. * Gets the hit point in the world
  22681. */
  22682. readonly hitPointWorld: Vector3;
  22683. /**
  22684. * Gets the ray "start point" of the ray in the world
  22685. */
  22686. readonly rayFromWorld: Vector3;
  22687. /**
  22688. * Gets the ray "end point" of the ray in the world
  22689. */
  22690. readonly rayToWorld: Vector3;
  22691. /**
  22692. * Sets the hit data (normal & point in world space)
  22693. * @param hitNormalWorld defines the normal in world space
  22694. * @param hitPointWorld defines the point in world space
  22695. */
  22696. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22697. /**
  22698. * Sets the distance from the start point to the hit point
  22699. * @param distance
  22700. */
  22701. setHitDistance(distance: number): void;
  22702. /**
  22703. * Calculates the distance manually
  22704. */
  22705. calculateHitDistance(): void;
  22706. /**
  22707. * Resets all the values to default
  22708. * @param from The from point on world space
  22709. * @param to The to point on world space
  22710. */
  22711. reset(from?: Vector3, to?: Vector3): void;
  22712. }
  22713. /**
  22714. * Interface for the size containing width and height
  22715. */
  22716. interface IXYZ {
  22717. /**
  22718. * X
  22719. */
  22720. x: number;
  22721. /**
  22722. * Y
  22723. */
  22724. y: number;
  22725. /**
  22726. * Z
  22727. */
  22728. z: number;
  22729. }
  22730. }
  22731. declare module BABYLON {
  22732. /**
  22733. * Interface used to describe a physics joint
  22734. */
  22735. export interface PhysicsImpostorJoint {
  22736. /** Defines the main impostor to which the joint is linked */
  22737. mainImpostor: PhysicsImpostor;
  22738. /** Defines the impostor that is connected to the main impostor using this joint */
  22739. connectedImpostor: PhysicsImpostor;
  22740. /** Defines the joint itself */
  22741. joint: PhysicsJoint;
  22742. }
  22743. /** @hidden */
  22744. export interface IPhysicsEnginePlugin {
  22745. world: any;
  22746. name: string;
  22747. setGravity(gravity: Vector3): void;
  22748. setTimeStep(timeStep: number): void;
  22749. getTimeStep(): number;
  22750. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22751. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22752. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22753. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22754. removePhysicsBody(impostor: PhysicsImpostor): void;
  22755. generateJoint(joint: PhysicsImpostorJoint): void;
  22756. removeJoint(joint: PhysicsImpostorJoint): void;
  22757. isSupported(): boolean;
  22758. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22759. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22760. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22761. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22763. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22764. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22765. getBodyMass(impostor: PhysicsImpostor): number;
  22766. getBodyFriction(impostor: PhysicsImpostor): number;
  22767. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22768. getBodyRestitution(impostor: PhysicsImpostor): number;
  22769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22770. getBodyPressure?(impostor: PhysicsImpostor): number;
  22771. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22772. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22773. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22774. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22775. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22776. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22777. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22778. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22779. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22780. sleepBody(impostor: PhysicsImpostor): void;
  22781. wakeUpBody(impostor: PhysicsImpostor): void;
  22782. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22784. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22785. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22786. getRadius(impostor: PhysicsImpostor): number;
  22787. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22789. dispose(): void;
  22790. }
  22791. /**
  22792. * Interface used to define a physics engine
  22793. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22794. */
  22795. export interface IPhysicsEngine {
  22796. /**
  22797. * Gets the gravity vector used by the simulation
  22798. */
  22799. gravity: Vector3;
  22800. /**
  22801. * Sets the gravity vector used by the simulation
  22802. * @param gravity defines the gravity vector to use
  22803. */
  22804. setGravity(gravity: Vector3): void;
  22805. /**
  22806. * Set the time step of the physics engine.
  22807. * Default is 1/60.
  22808. * To slow it down, enter 1/600 for example.
  22809. * To speed it up, 1/30
  22810. * @param newTimeStep the new timestep to apply to this world.
  22811. */
  22812. setTimeStep(newTimeStep: number): void;
  22813. /**
  22814. * Get the time step of the physics engine.
  22815. * @returns the current time step
  22816. */
  22817. getTimeStep(): number;
  22818. /**
  22819. * Release all resources
  22820. */
  22821. dispose(): void;
  22822. /**
  22823. * Gets the name of the current physics plugin
  22824. * @returns the name of the plugin
  22825. */
  22826. getPhysicsPluginName(): string;
  22827. /**
  22828. * Adding a new impostor for the impostor tracking.
  22829. * This will be done by the impostor itself.
  22830. * @param impostor the impostor to add
  22831. */
  22832. addImpostor(impostor: PhysicsImpostor): void;
  22833. /**
  22834. * Remove an impostor from the engine.
  22835. * This impostor and its mesh will not longer be updated by the physics engine.
  22836. * @param impostor the impostor to remove
  22837. */
  22838. removeImpostor(impostor: PhysicsImpostor): void;
  22839. /**
  22840. * Add a joint to the physics engine
  22841. * @param mainImpostor defines the main impostor to which the joint is added.
  22842. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22843. * @param joint defines the joint that will connect both impostors.
  22844. */
  22845. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22846. /**
  22847. * Removes a joint from the simulation
  22848. * @param mainImpostor defines the impostor used with the joint
  22849. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22850. * @param joint defines the joint to remove
  22851. */
  22852. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22853. /**
  22854. * Gets the current plugin used to run the simulation
  22855. * @returns current plugin
  22856. */
  22857. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22858. /**
  22859. * Gets the list of physic impostors
  22860. * @returns an array of PhysicsImpostor
  22861. */
  22862. getImpostors(): Array<PhysicsImpostor>;
  22863. /**
  22864. * Gets the impostor for a physics enabled object
  22865. * @param object defines the object impersonated by the impostor
  22866. * @returns the PhysicsImpostor or null if not found
  22867. */
  22868. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22869. /**
  22870. * Gets the impostor for a physics body object
  22871. * @param body defines physics body used by the impostor
  22872. * @returns the PhysicsImpostor or null if not found
  22873. */
  22874. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22875. /**
  22876. * Does a raycast in the physics world
  22877. * @param from when should the ray start?
  22878. * @param to when should the ray end?
  22879. * @returns PhysicsRaycastResult
  22880. */
  22881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22882. /**
  22883. * Called by the scene. No need to call it.
  22884. * @param delta defines the timespam between frames
  22885. */
  22886. _step(delta: number): void;
  22887. }
  22888. }
  22889. declare module BABYLON {
  22890. /**
  22891. * The interface for the physics imposter parameters
  22892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22893. */
  22894. export interface PhysicsImpostorParameters {
  22895. /**
  22896. * The mass of the physics imposter
  22897. */
  22898. mass: number;
  22899. /**
  22900. * The friction of the physics imposter
  22901. */
  22902. friction?: number;
  22903. /**
  22904. * The coefficient of restitution of the physics imposter
  22905. */
  22906. restitution?: number;
  22907. /**
  22908. * The native options of the physics imposter
  22909. */
  22910. nativeOptions?: any;
  22911. /**
  22912. * Specifies if the parent should be ignored
  22913. */
  22914. ignoreParent?: boolean;
  22915. /**
  22916. * Specifies if bi-directional transformations should be disabled
  22917. */
  22918. disableBidirectionalTransformation?: boolean;
  22919. /**
  22920. * The pressure inside the physics imposter, soft object only
  22921. */
  22922. pressure?: number;
  22923. /**
  22924. * The stiffness the physics imposter, soft object only
  22925. */
  22926. stiffness?: number;
  22927. /**
  22928. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22929. */
  22930. velocityIterations?: number;
  22931. /**
  22932. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22933. */
  22934. positionIterations?: number;
  22935. /**
  22936. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22937. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22938. * Add to fix multiple points
  22939. */
  22940. fixedPoints?: number;
  22941. /**
  22942. * The collision margin around a soft object
  22943. */
  22944. margin?: number;
  22945. /**
  22946. * The collision margin around a soft object
  22947. */
  22948. damping?: number;
  22949. /**
  22950. * The path for a rope based on an extrusion
  22951. */
  22952. path?: any;
  22953. /**
  22954. * The shape of an extrusion used for a rope based on an extrusion
  22955. */
  22956. shape?: any;
  22957. }
  22958. /**
  22959. * Interface for a physics-enabled object
  22960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22961. */
  22962. export interface IPhysicsEnabledObject {
  22963. /**
  22964. * The position of the physics-enabled object
  22965. */
  22966. position: Vector3;
  22967. /**
  22968. * The rotation of the physics-enabled object
  22969. */
  22970. rotationQuaternion: Nullable<Quaternion>;
  22971. /**
  22972. * The scale of the physics-enabled object
  22973. */
  22974. scaling: Vector3;
  22975. /**
  22976. * The rotation of the physics-enabled object
  22977. */
  22978. rotation?: Vector3;
  22979. /**
  22980. * The parent of the physics-enabled object
  22981. */
  22982. parent?: any;
  22983. /**
  22984. * The bounding info of the physics-enabled object
  22985. * @returns The bounding info of the physics-enabled object
  22986. */
  22987. getBoundingInfo(): BoundingInfo;
  22988. /**
  22989. * Computes the world matrix
  22990. * @param force Specifies if the world matrix should be computed by force
  22991. * @returns A world matrix
  22992. */
  22993. computeWorldMatrix(force: boolean): Matrix;
  22994. /**
  22995. * Gets the world matrix
  22996. * @returns A world matrix
  22997. */
  22998. getWorldMatrix?(): Matrix;
  22999. /**
  23000. * Gets the child meshes
  23001. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23002. * @returns An array of abstract meshes
  23003. */
  23004. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23005. /**
  23006. * Gets the vertex data
  23007. * @param kind The type of vertex data
  23008. * @returns A nullable array of numbers, or a float32 array
  23009. */
  23010. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23011. /**
  23012. * Gets the indices from the mesh
  23013. * @returns A nullable array of index arrays
  23014. */
  23015. getIndices?(): Nullable<IndicesArray>;
  23016. /**
  23017. * Gets the scene from the mesh
  23018. * @returns the indices array or null
  23019. */
  23020. getScene?(): Scene;
  23021. /**
  23022. * Gets the absolute position from the mesh
  23023. * @returns the absolute position
  23024. */
  23025. getAbsolutePosition(): Vector3;
  23026. /**
  23027. * Gets the absolute pivot point from the mesh
  23028. * @returns the absolute pivot point
  23029. */
  23030. getAbsolutePivotPoint(): Vector3;
  23031. /**
  23032. * Rotates the mesh
  23033. * @param axis The axis of rotation
  23034. * @param amount The amount of rotation
  23035. * @param space The space of the rotation
  23036. * @returns The rotation transform node
  23037. */
  23038. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23039. /**
  23040. * Translates the mesh
  23041. * @param axis The axis of translation
  23042. * @param distance The distance of translation
  23043. * @param space The space of the translation
  23044. * @returns The transform node
  23045. */
  23046. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23047. /**
  23048. * Sets the absolute position of the mesh
  23049. * @param absolutePosition The absolute position of the mesh
  23050. * @returns The transform node
  23051. */
  23052. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23053. /**
  23054. * Gets the class name of the mesh
  23055. * @returns The class name
  23056. */
  23057. getClassName(): string;
  23058. }
  23059. /**
  23060. * Represents a physics imposter
  23061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23062. */
  23063. export class PhysicsImpostor {
  23064. /**
  23065. * The physics-enabled object used as the physics imposter
  23066. */
  23067. object: IPhysicsEnabledObject;
  23068. /**
  23069. * The type of the physics imposter
  23070. */
  23071. type: number;
  23072. private _options;
  23073. private _scene?;
  23074. /**
  23075. * The default object size of the imposter
  23076. */
  23077. static DEFAULT_OBJECT_SIZE: Vector3;
  23078. /**
  23079. * The identity quaternion of the imposter
  23080. */
  23081. static IDENTITY_QUATERNION: Quaternion;
  23082. /** @hidden */
  23083. _pluginData: any;
  23084. private _physicsEngine;
  23085. private _physicsBody;
  23086. private _bodyUpdateRequired;
  23087. private _onBeforePhysicsStepCallbacks;
  23088. private _onAfterPhysicsStepCallbacks;
  23089. /** @hidden */
  23090. _onPhysicsCollideCallbacks: Array<{
  23091. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23092. otherImpostors: Array<PhysicsImpostor>;
  23093. }>;
  23094. private _deltaPosition;
  23095. private _deltaRotation;
  23096. private _deltaRotationConjugated;
  23097. /** @hidden */
  23098. _isFromLine: boolean;
  23099. private _parent;
  23100. private _isDisposed;
  23101. private static _tmpVecs;
  23102. private static _tmpQuat;
  23103. /**
  23104. * Specifies if the physics imposter is disposed
  23105. */
  23106. readonly isDisposed: boolean;
  23107. /**
  23108. * Gets the mass of the physics imposter
  23109. */
  23110. mass: number;
  23111. /**
  23112. * Gets the coefficient of friction
  23113. */
  23114. /**
  23115. * Sets the coefficient of friction
  23116. */
  23117. friction: number;
  23118. /**
  23119. * Gets the coefficient of restitution
  23120. */
  23121. /**
  23122. * Sets the coefficient of restitution
  23123. */
  23124. restitution: number;
  23125. /**
  23126. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23127. */
  23128. /**
  23129. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23130. */
  23131. pressure: number;
  23132. /**
  23133. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23134. */
  23135. /**
  23136. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23137. */
  23138. stiffness: number;
  23139. /**
  23140. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23141. */
  23142. /**
  23143. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23144. */
  23145. velocityIterations: number;
  23146. /**
  23147. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23148. */
  23149. /**
  23150. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23151. */
  23152. positionIterations: number;
  23153. /**
  23154. * The unique id of the physics imposter
  23155. * set by the physics engine when adding this impostor to the array
  23156. */
  23157. uniqueId: number;
  23158. /**
  23159. * @hidden
  23160. */
  23161. soft: boolean;
  23162. /**
  23163. * @hidden
  23164. */
  23165. segments: number;
  23166. private _joints;
  23167. /**
  23168. * Initializes the physics imposter
  23169. * @param object The physics-enabled object used as the physics imposter
  23170. * @param type The type of the physics imposter
  23171. * @param _options The options for the physics imposter
  23172. * @param _scene The Babylon scene
  23173. */
  23174. constructor(
  23175. /**
  23176. * The physics-enabled object used as the physics imposter
  23177. */
  23178. object: IPhysicsEnabledObject,
  23179. /**
  23180. * The type of the physics imposter
  23181. */
  23182. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23183. /**
  23184. * This function will completly initialize this impostor.
  23185. * It will create a new body - but only if this mesh has no parent.
  23186. * If it has, this impostor will not be used other than to define the impostor
  23187. * of the child mesh.
  23188. * @hidden
  23189. */
  23190. _init(): void;
  23191. private _getPhysicsParent;
  23192. /**
  23193. * Should a new body be generated.
  23194. * @returns boolean specifying if body initialization is required
  23195. */
  23196. isBodyInitRequired(): boolean;
  23197. /**
  23198. * Sets the updated scaling
  23199. * @param updated Specifies if the scaling is updated
  23200. */
  23201. setScalingUpdated(): void;
  23202. /**
  23203. * Force a regeneration of this or the parent's impostor's body.
  23204. * Use under cautious - This will remove all joints already implemented.
  23205. */
  23206. forceUpdate(): void;
  23207. /**
  23208. * Gets the body that holds this impostor. Either its own, or its parent.
  23209. */
  23210. /**
  23211. * Set the physics body. Used mainly by the physics engine/plugin
  23212. */
  23213. physicsBody: any;
  23214. /**
  23215. * Get the parent of the physics imposter
  23216. * @returns Physics imposter or null
  23217. */
  23218. /**
  23219. * Sets the parent of the physics imposter
  23220. */
  23221. parent: Nullable<PhysicsImpostor>;
  23222. /**
  23223. * Resets the update flags
  23224. */
  23225. resetUpdateFlags(): void;
  23226. /**
  23227. * Gets the object extend size
  23228. * @returns the object extend size
  23229. */
  23230. getObjectExtendSize(): Vector3;
  23231. /**
  23232. * Gets the object center
  23233. * @returns The object center
  23234. */
  23235. getObjectCenter(): Vector3;
  23236. /**
  23237. * Get a specific parametes from the options parameter
  23238. * @param paramName The object parameter name
  23239. * @returns The object parameter
  23240. */
  23241. getParam(paramName: string): any;
  23242. /**
  23243. * Sets a specific parameter in the options given to the physics plugin
  23244. * @param paramName The parameter name
  23245. * @param value The value of the parameter
  23246. */
  23247. setParam(paramName: string, value: number): void;
  23248. /**
  23249. * Specifically change the body's mass option. Won't recreate the physics body object
  23250. * @param mass The mass of the physics imposter
  23251. */
  23252. setMass(mass: number): void;
  23253. /**
  23254. * Gets the linear velocity
  23255. * @returns linear velocity or null
  23256. */
  23257. getLinearVelocity(): Nullable<Vector3>;
  23258. /**
  23259. * Sets the linear velocity
  23260. * @param velocity linear velocity or null
  23261. */
  23262. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23263. /**
  23264. * Gets the angular velocity
  23265. * @returns angular velocity or null
  23266. */
  23267. getAngularVelocity(): Nullable<Vector3>;
  23268. /**
  23269. * Sets the angular velocity
  23270. * @param velocity The velocity or null
  23271. */
  23272. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23273. /**
  23274. * Execute a function with the physics plugin native code
  23275. * Provide a function the will have two variables - the world object and the physics body object
  23276. * @param func The function to execute with the physics plugin native code
  23277. */
  23278. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23279. /**
  23280. * Register a function that will be executed before the physics world is stepping forward
  23281. * @param func The function to execute before the physics world is stepped forward
  23282. */
  23283. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23284. /**
  23285. * Unregister a function that will be executed before the physics world is stepping forward
  23286. * @param func The function to execute before the physics world is stepped forward
  23287. */
  23288. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23289. /**
  23290. * Register a function that will be executed after the physics step
  23291. * @param func The function to execute after physics step
  23292. */
  23293. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23294. /**
  23295. * Unregisters a function that will be executed after the physics step
  23296. * @param func The function to execute after physics step
  23297. */
  23298. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23299. /**
  23300. * register a function that will be executed when this impostor collides against a different body
  23301. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23302. * @param func Callback that is executed on collision
  23303. */
  23304. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23305. /**
  23306. * Unregisters the physics imposter on contact
  23307. * @param collideAgainst The physics object to collide against
  23308. * @param func Callback to execute on collision
  23309. */
  23310. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23311. private _tmpQuat;
  23312. private _tmpQuat2;
  23313. /**
  23314. * Get the parent rotation
  23315. * @returns The parent rotation
  23316. */
  23317. getParentsRotation(): Quaternion;
  23318. /**
  23319. * this function is executed by the physics engine.
  23320. */
  23321. beforeStep: () => void;
  23322. /**
  23323. * this function is executed by the physics engine
  23324. */
  23325. afterStep: () => void;
  23326. /**
  23327. * Legacy collision detection event support
  23328. */
  23329. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23330. /**
  23331. * event and body object due to cannon's event-based architecture.
  23332. */
  23333. onCollide: (e: {
  23334. body: any;
  23335. }) => void;
  23336. /**
  23337. * Apply a force
  23338. * @param force The force to apply
  23339. * @param contactPoint The contact point for the force
  23340. * @returns The physics imposter
  23341. */
  23342. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23343. /**
  23344. * Apply an impulse
  23345. * @param force The impulse force
  23346. * @param contactPoint The contact point for the impulse force
  23347. * @returns The physics imposter
  23348. */
  23349. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23350. /**
  23351. * A help function to create a joint
  23352. * @param otherImpostor A physics imposter used to create a joint
  23353. * @param jointType The type of joint
  23354. * @param jointData The data for the joint
  23355. * @returns The physics imposter
  23356. */
  23357. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23358. /**
  23359. * Add a joint to this impostor with a different impostor
  23360. * @param otherImpostor A physics imposter used to add a joint
  23361. * @param joint The joint to add
  23362. * @returns The physics imposter
  23363. */
  23364. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23365. /**
  23366. * Add an anchor to a cloth impostor
  23367. * @param otherImpostor rigid impostor to anchor to
  23368. * @param width ratio across width from 0 to 1
  23369. * @param height ratio up height from 0 to 1
  23370. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23371. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23372. * @returns impostor the soft imposter
  23373. */
  23374. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23375. /**
  23376. * Add a hook to a rope impostor
  23377. * @param otherImpostor rigid impostor to anchor to
  23378. * @param length ratio across rope from 0 to 1
  23379. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23380. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23381. * @returns impostor the rope imposter
  23382. */
  23383. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23384. /**
  23385. * Will keep this body still, in a sleep mode.
  23386. * @returns the physics imposter
  23387. */
  23388. sleep(): PhysicsImpostor;
  23389. /**
  23390. * Wake the body up.
  23391. * @returns The physics imposter
  23392. */
  23393. wakeUp(): PhysicsImpostor;
  23394. /**
  23395. * Clones the physics imposter
  23396. * @param newObject The physics imposter clones to this physics-enabled object
  23397. * @returns A nullable physics imposter
  23398. */
  23399. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23400. /**
  23401. * Disposes the physics imposter
  23402. */
  23403. dispose(): void;
  23404. /**
  23405. * Sets the delta position
  23406. * @param position The delta position amount
  23407. */
  23408. setDeltaPosition(position: Vector3): void;
  23409. /**
  23410. * Sets the delta rotation
  23411. * @param rotation The delta rotation amount
  23412. */
  23413. setDeltaRotation(rotation: Quaternion): void;
  23414. /**
  23415. * Gets the box size of the physics imposter and stores the result in the input parameter
  23416. * @param result Stores the box size
  23417. * @returns The physics imposter
  23418. */
  23419. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23420. /**
  23421. * Gets the radius of the physics imposter
  23422. * @returns Radius of the physics imposter
  23423. */
  23424. getRadius(): number;
  23425. /**
  23426. * Sync a bone with this impostor
  23427. * @param bone The bone to sync to the impostor.
  23428. * @param boneMesh The mesh that the bone is influencing.
  23429. * @param jointPivot The pivot of the joint / bone in local space.
  23430. * @param distToJoint Optional distance from the impostor to the joint.
  23431. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23432. */
  23433. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23434. /**
  23435. * Sync impostor to a bone
  23436. * @param bone The bone that the impostor will be synced to.
  23437. * @param boneMesh The mesh that the bone is influencing.
  23438. * @param jointPivot The pivot of the joint / bone in local space.
  23439. * @param distToJoint Optional distance from the impostor to the joint.
  23440. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23441. * @param boneAxis Optional vector3 axis the bone is aligned with
  23442. */
  23443. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23444. /**
  23445. * No-Imposter type
  23446. */
  23447. static NoImpostor: number;
  23448. /**
  23449. * Sphere-Imposter type
  23450. */
  23451. static SphereImpostor: number;
  23452. /**
  23453. * Box-Imposter type
  23454. */
  23455. static BoxImpostor: number;
  23456. /**
  23457. * Plane-Imposter type
  23458. */
  23459. static PlaneImpostor: number;
  23460. /**
  23461. * Mesh-imposter type
  23462. */
  23463. static MeshImpostor: number;
  23464. /**
  23465. * Capsule-Impostor type (Ammo.js plugin only)
  23466. */
  23467. static CapsuleImpostor: number;
  23468. /**
  23469. * Cylinder-Imposter type
  23470. */
  23471. static CylinderImpostor: number;
  23472. /**
  23473. * Particle-Imposter type
  23474. */
  23475. static ParticleImpostor: number;
  23476. /**
  23477. * Heightmap-Imposter type
  23478. */
  23479. static HeightmapImpostor: number;
  23480. /**
  23481. * ConvexHull-Impostor type (Ammo.js plugin only)
  23482. */
  23483. static ConvexHullImpostor: number;
  23484. /**
  23485. * Rope-Imposter type
  23486. */
  23487. static RopeImpostor: number;
  23488. /**
  23489. * Cloth-Imposter type
  23490. */
  23491. static ClothImpostor: number;
  23492. /**
  23493. * Softbody-Imposter type
  23494. */
  23495. static SoftbodyImpostor: number;
  23496. }
  23497. }
  23498. declare module BABYLON {
  23499. /**
  23500. * @hidden
  23501. **/
  23502. export class _CreationDataStorage {
  23503. closePath?: boolean;
  23504. closeArray?: boolean;
  23505. idx: number[];
  23506. dashSize: number;
  23507. gapSize: number;
  23508. path3D: Path3D;
  23509. pathArray: Vector3[][];
  23510. arc: number;
  23511. radius: number;
  23512. cap: number;
  23513. tessellation: number;
  23514. }
  23515. /**
  23516. * @hidden
  23517. **/
  23518. class _InstanceDataStorage {
  23519. visibleInstances: any;
  23520. batchCache: _InstancesBatch;
  23521. instancesBufferSize: number;
  23522. instancesBuffer: Nullable<Buffer>;
  23523. instancesData: Float32Array;
  23524. overridenInstanceCount: number;
  23525. isFrozen: boolean;
  23526. previousBatch: Nullable<_InstancesBatch>;
  23527. hardwareInstancedRendering: boolean;
  23528. sideOrientation: number;
  23529. }
  23530. /**
  23531. * @hidden
  23532. **/
  23533. export class _InstancesBatch {
  23534. mustReturn: boolean;
  23535. visibleInstances: Nullable<InstancedMesh[]>[];
  23536. renderSelf: boolean[];
  23537. hardwareInstancedRendering: boolean[];
  23538. }
  23539. /**
  23540. * Class used to represent renderable models
  23541. */
  23542. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23543. /**
  23544. * Mesh side orientation : usually the external or front surface
  23545. */
  23546. static readonly FRONTSIDE: number;
  23547. /**
  23548. * Mesh side orientation : usually the internal or back surface
  23549. */
  23550. static readonly BACKSIDE: number;
  23551. /**
  23552. * Mesh side orientation : both internal and external or front and back surfaces
  23553. */
  23554. static readonly DOUBLESIDE: number;
  23555. /**
  23556. * Mesh side orientation : by default, `FRONTSIDE`
  23557. */
  23558. static readonly DEFAULTSIDE: number;
  23559. /**
  23560. * Mesh cap setting : no cap
  23561. */
  23562. static readonly NO_CAP: number;
  23563. /**
  23564. * Mesh cap setting : one cap at the beginning of the mesh
  23565. */
  23566. static readonly CAP_START: number;
  23567. /**
  23568. * Mesh cap setting : one cap at the end of the mesh
  23569. */
  23570. static readonly CAP_END: number;
  23571. /**
  23572. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23573. */
  23574. static readonly CAP_ALL: number;
  23575. /**
  23576. * Mesh pattern setting : no flip or rotate
  23577. */
  23578. static readonly NO_FLIP: number;
  23579. /**
  23580. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23581. */
  23582. static readonly FLIP_TILE: number;
  23583. /**
  23584. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23585. */
  23586. static readonly ROTATE_TILE: number;
  23587. /**
  23588. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23589. */
  23590. static readonly FLIP_ROW: number;
  23591. /**
  23592. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23593. */
  23594. static readonly ROTATE_ROW: number;
  23595. /**
  23596. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23597. */
  23598. static readonly FLIP_N_ROTATE_TILE: number;
  23599. /**
  23600. * Mesh pattern setting : rotate pattern and rotate
  23601. */
  23602. static readonly FLIP_N_ROTATE_ROW: number;
  23603. /**
  23604. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23605. */
  23606. static readonly CENTER: number;
  23607. /**
  23608. * Mesh tile positioning : part tiles on left
  23609. */
  23610. static readonly LEFT: number;
  23611. /**
  23612. * Mesh tile positioning : part tiles on right
  23613. */
  23614. static readonly RIGHT: number;
  23615. /**
  23616. * Mesh tile positioning : part tiles on top
  23617. */
  23618. static readonly TOP: number;
  23619. /**
  23620. * Mesh tile positioning : part tiles on bottom
  23621. */
  23622. static readonly BOTTOM: number;
  23623. /**
  23624. * Gets the default side orientation.
  23625. * @param orientation the orientation to value to attempt to get
  23626. * @returns the default orientation
  23627. * @hidden
  23628. */
  23629. static _GetDefaultSideOrientation(orientation?: number): number;
  23630. private _internalMeshDataInfo;
  23631. /**
  23632. * An event triggered before rendering the mesh
  23633. */
  23634. readonly onBeforeRenderObservable: Observable<Mesh>;
  23635. /**
  23636. * An event triggered before binding the mesh
  23637. */
  23638. readonly onBeforeBindObservable: Observable<Mesh>;
  23639. /**
  23640. * An event triggered after rendering the mesh
  23641. */
  23642. readonly onAfterRenderObservable: Observable<Mesh>;
  23643. /**
  23644. * An event triggered before drawing the mesh
  23645. */
  23646. readonly onBeforeDrawObservable: Observable<Mesh>;
  23647. private _onBeforeDrawObserver;
  23648. /**
  23649. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23650. */
  23651. onBeforeDraw: () => void;
  23652. readonly hasInstances: boolean;
  23653. /**
  23654. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23655. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23656. */
  23657. delayLoadState: number;
  23658. /**
  23659. * Gets the list of instances created from this mesh
  23660. * it is not supposed to be modified manually.
  23661. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23662. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23663. */
  23664. instances: InstancedMesh[];
  23665. /**
  23666. * Gets the file containing delay loading data for this mesh
  23667. */
  23668. delayLoadingFile: string;
  23669. /** @hidden */
  23670. _binaryInfo: any;
  23671. /**
  23672. * User defined function used to change how LOD level selection is done
  23673. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23674. */
  23675. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23676. /**
  23677. * Gets or sets the morph target manager
  23678. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23679. */
  23680. morphTargetManager: Nullable<MorphTargetManager>;
  23681. /** @hidden */
  23682. _creationDataStorage: Nullable<_CreationDataStorage>;
  23683. /** @hidden */
  23684. _geometry: Nullable<Geometry>;
  23685. /** @hidden */
  23686. _delayInfo: Array<string>;
  23687. /** @hidden */
  23688. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23689. /** @hidden */
  23690. _instanceDataStorage: _InstanceDataStorage;
  23691. private _effectiveMaterial;
  23692. /** @hidden */
  23693. _shouldGenerateFlatShading: boolean;
  23694. /** @hidden */
  23695. _originalBuilderSideOrientation: number;
  23696. /**
  23697. * Use this property to change the original side orientation defined at construction time
  23698. */
  23699. overrideMaterialSideOrientation: Nullable<number>;
  23700. /**
  23701. * Gets the source mesh (the one used to clone this one from)
  23702. */
  23703. readonly source: Nullable<Mesh>;
  23704. /**
  23705. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23706. */
  23707. isUnIndexed: boolean;
  23708. /**
  23709. * @constructor
  23710. * @param name The value used by scene.getMeshByName() to do a lookup.
  23711. * @param scene The scene to add this mesh to.
  23712. * @param parent The parent of this mesh, if it has one
  23713. * @param source An optional Mesh from which geometry is shared, cloned.
  23714. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23715. * When false, achieved by calling a clone(), also passing False.
  23716. * This will make creation of children, recursive.
  23717. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23718. */
  23719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23720. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23721. /**
  23722. * Gets the class name
  23723. * @returns the string "Mesh".
  23724. */
  23725. getClassName(): string;
  23726. /** @hidden */
  23727. readonly _isMesh: boolean;
  23728. /**
  23729. * Returns a description of this mesh
  23730. * @param fullDetails define if full details about this mesh must be used
  23731. * @returns a descriptive string representing this mesh
  23732. */
  23733. toString(fullDetails?: boolean): string;
  23734. /** @hidden */
  23735. _unBindEffect(): void;
  23736. /**
  23737. * Gets a boolean indicating if this mesh has LOD
  23738. */
  23739. readonly hasLODLevels: boolean;
  23740. /**
  23741. * Gets the list of MeshLODLevel associated with the current mesh
  23742. * @returns an array of MeshLODLevel
  23743. */
  23744. getLODLevels(): MeshLODLevel[];
  23745. private _sortLODLevels;
  23746. /**
  23747. * Add a mesh as LOD level triggered at the given distance.
  23748. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23749. * @param distance The distance from the center of the object to show this level
  23750. * @param mesh The mesh to be added as LOD level (can be null)
  23751. * @return This mesh (for chaining)
  23752. */
  23753. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23754. /**
  23755. * Returns the LOD level mesh at the passed distance or null if not found.
  23756. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23757. * @param distance The distance from the center of the object to show this level
  23758. * @returns a Mesh or `null`
  23759. */
  23760. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23761. /**
  23762. * Remove a mesh from the LOD array
  23763. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23764. * @param mesh defines the mesh to be removed
  23765. * @return This mesh (for chaining)
  23766. */
  23767. removeLODLevel(mesh: Mesh): Mesh;
  23768. /**
  23769. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23770. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23771. * @param camera defines the camera to use to compute distance
  23772. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23773. * @return This mesh (for chaining)
  23774. */
  23775. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23776. /**
  23777. * Gets the mesh internal Geometry object
  23778. */
  23779. readonly geometry: Nullable<Geometry>;
  23780. /**
  23781. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23782. * @returns the total number of vertices
  23783. */
  23784. getTotalVertices(): number;
  23785. /**
  23786. * Returns the content of an associated vertex buffer
  23787. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23788. * - VertexBuffer.PositionKind
  23789. * - VertexBuffer.UVKind
  23790. * - VertexBuffer.UV2Kind
  23791. * - VertexBuffer.UV3Kind
  23792. * - VertexBuffer.UV4Kind
  23793. * - VertexBuffer.UV5Kind
  23794. * - VertexBuffer.UV6Kind
  23795. * - VertexBuffer.ColorKind
  23796. * - VertexBuffer.MatricesIndicesKind
  23797. * - VertexBuffer.MatricesIndicesExtraKind
  23798. * - VertexBuffer.MatricesWeightsKind
  23799. * - VertexBuffer.MatricesWeightsExtraKind
  23800. * @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
  23801. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23802. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23803. */
  23804. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23805. /**
  23806. * Returns the mesh VertexBuffer object from the requested `kind`
  23807. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23808. * - VertexBuffer.PositionKind
  23809. * - VertexBuffer.NormalKind
  23810. * - VertexBuffer.UVKind
  23811. * - VertexBuffer.UV2Kind
  23812. * - VertexBuffer.UV3Kind
  23813. * - VertexBuffer.UV4Kind
  23814. * - VertexBuffer.UV5Kind
  23815. * - VertexBuffer.UV6Kind
  23816. * - VertexBuffer.ColorKind
  23817. * - VertexBuffer.MatricesIndicesKind
  23818. * - VertexBuffer.MatricesIndicesExtraKind
  23819. * - VertexBuffer.MatricesWeightsKind
  23820. * - VertexBuffer.MatricesWeightsExtraKind
  23821. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23822. */
  23823. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23824. /**
  23825. * Tests if a specific vertex buffer is associated with this mesh
  23826. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23827. * - VertexBuffer.PositionKind
  23828. * - VertexBuffer.NormalKind
  23829. * - VertexBuffer.UVKind
  23830. * - VertexBuffer.UV2Kind
  23831. * - VertexBuffer.UV3Kind
  23832. * - VertexBuffer.UV4Kind
  23833. * - VertexBuffer.UV5Kind
  23834. * - VertexBuffer.UV6Kind
  23835. * - VertexBuffer.ColorKind
  23836. * - VertexBuffer.MatricesIndicesKind
  23837. * - VertexBuffer.MatricesIndicesExtraKind
  23838. * - VertexBuffer.MatricesWeightsKind
  23839. * - VertexBuffer.MatricesWeightsExtraKind
  23840. * @returns a boolean
  23841. */
  23842. isVerticesDataPresent(kind: string): boolean;
  23843. /**
  23844. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23845. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23846. * - VertexBuffer.PositionKind
  23847. * - VertexBuffer.UVKind
  23848. * - VertexBuffer.UV2Kind
  23849. * - VertexBuffer.UV3Kind
  23850. * - VertexBuffer.UV4Kind
  23851. * - VertexBuffer.UV5Kind
  23852. * - VertexBuffer.UV6Kind
  23853. * - VertexBuffer.ColorKind
  23854. * - VertexBuffer.MatricesIndicesKind
  23855. * - VertexBuffer.MatricesIndicesExtraKind
  23856. * - VertexBuffer.MatricesWeightsKind
  23857. * - VertexBuffer.MatricesWeightsExtraKind
  23858. * @returns a boolean
  23859. */
  23860. isVertexBufferUpdatable(kind: string): boolean;
  23861. /**
  23862. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23863. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23864. * - VertexBuffer.PositionKind
  23865. * - VertexBuffer.NormalKind
  23866. * - VertexBuffer.UVKind
  23867. * - VertexBuffer.UV2Kind
  23868. * - VertexBuffer.UV3Kind
  23869. * - VertexBuffer.UV4Kind
  23870. * - VertexBuffer.UV5Kind
  23871. * - VertexBuffer.UV6Kind
  23872. * - VertexBuffer.ColorKind
  23873. * - VertexBuffer.MatricesIndicesKind
  23874. * - VertexBuffer.MatricesIndicesExtraKind
  23875. * - VertexBuffer.MatricesWeightsKind
  23876. * - VertexBuffer.MatricesWeightsExtraKind
  23877. * @returns an array of strings
  23878. */
  23879. getVerticesDataKinds(): string[];
  23880. /**
  23881. * Returns a positive integer : the total number of indices in this mesh geometry.
  23882. * @returns the numner of indices or zero if the mesh has no geometry.
  23883. */
  23884. getTotalIndices(): number;
  23885. /**
  23886. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23887. * @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.
  23888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23889. * @returns the indices array or an empty array if the mesh has no geometry
  23890. */
  23891. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23892. readonly isBlocked: boolean;
  23893. /**
  23894. * Determine if the current mesh is ready to be rendered
  23895. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23896. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23897. * @returns true if all associated assets are ready (material, textures, shaders)
  23898. */
  23899. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23900. /**
  23901. * 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.
  23902. */
  23903. readonly areNormalsFrozen: boolean;
  23904. /**
  23905. * 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.
  23906. * @returns the current mesh
  23907. */
  23908. freezeNormals(): Mesh;
  23909. /**
  23910. * 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
  23911. * @returns the current mesh
  23912. */
  23913. unfreezeNormals(): Mesh;
  23914. /**
  23915. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23916. */
  23917. overridenInstanceCount: number;
  23918. /** @hidden */
  23919. _preActivate(): Mesh;
  23920. /** @hidden */
  23921. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23922. /** @hidden */
  23923. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23924. /**
  23925. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23926. * This means the mesh underlying bounding box and sphere are recomputed.
  23927. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23928. * @returns the current mesh
  23929. */
  23930. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23931. /** @hidden */
  23932. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23933. /**
  23934. * This function will subdivide the mesh into multiple submeshes
  23935. * @param count defines the expected number of submeshes
  23936. */
  23937. subdivide(count: number): void;
  23938. /**
  23939. * Copy a FloatArray into a specific associated vertex buffer
  23940. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23941. * - VertexBuffer.PositionKind
  23942. * - VertexBuffer.UVKind
  23943. * - VertexBuffer.UV2Kind
  23944. * - VertexBuffer.UV3Kind
  23945. * - VertexBuffer.UV4Kind
  23946. * - VertexBuffer.UV5Kind
  23947. * - VertexBuffer.UV6Kind
  23948. * - VertexBuffer.ColorKind
  23949. * - VertexBuffer.MatricesIndicesKind
  23950. * - VertexBuffer.MatricesIndicesExtraKind
  23951. * - VertexBuffer.MatricesWeightsKind
  23952. * - VertexBuffer.MatricesWeightsExtraKind
  23953. * @param data defines the data source
  23954. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23955. * @param stride defines the data stride size (can be null)
  23956. * @returns the current mesh
  23957. */
  23958. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23959. /**
  23960. * Delete a vertex buffer associated with this mesh
  23961. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  23962. * - VertexBuffer.PositionKind
  23963. * - VertexBuffer.UVKind
  23964. * - VertexBuffer.UV2Kind
  23965. * - VertexBuffer.UV3Kind
  23966. * - VertexBuffer.UV4Kind
  23967. * - VertexBuffer.UV5Kind
  23968. * - VertexBuffer.UV6Kind
  23969. * - VertexBuffer.ColorKind
  23970. * - VertexBuffer.MatricesIndicesKind
  23971. * - VertexBuffer.MatricesIndicesExtraKind
  23972. * - VertexBuffer.MatricesWeightsKind
  23973. * - VertexBuffer.MatricesWeightsExtraKind
  23974. */
  23975. removeVerticesData(kind: string): void;
  23976. /**
  23977. * Flags an associated vertex buffer as updatable
  23978. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23979. * - VertexBuffer.PositionKind
  23980. * - VertexBuffer.UVKind
  23981. * - VertexBuffer.UV2Kind
  23982. * - VertexBuffer.UV3Kind
  23983. * - VertexBuffer.UV4Kind
  23984. * - VertexBuffer.UV5Kind
  23985. * - VertexBuffer.UV6Kind
  23986. * - VertexBuffer.ColorKind
  23987. * - VertexBuffer.MatricesIndicesKind
  23988. * - VertexBuffer.MatricesIndicesExtraKind
  23989. * - VertexBuffer.MatricesWeightsKind
  23990. * - VertexBuffer.MatricesWeightsExtraKind
  23991. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23992. */
  23993. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23994. /**
  23995. * Sets the mesh global Vertex Buffer
  23996. * @param buffer defines the buffer to use
  23997. * @returns the current mesh
  23998. */
  23999. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24000. /**
  24001. * Update a specific associated vertex buffer
  24002. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24003. * - VertexBuffer.PositionKind
  24004. * - VertexBuffer.UVKind
  24005. * - VertexBuffer.UV2Kind
  24006. * - VertexBuffer.UV3Kind
  24007. * - VertexBuffer.UV4Kind
  24008. * - VertexBuffer.UV5Kind
  24009. * - VertexBuffer.UV6Kind
  24010. * - VertexBuffer.ColorKind
  24011. * - VertexBuffer.MatricesIndicesKind
  24012. * - VertexBuffer.MatricesIndicesExtraKind
  24013. * - VertexBuffer.MatricesWeightsKind
  24014. * - VertexBuffer.MatricesWeightsExtraKind
  24015. * @param data defines the data source
  24016. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24017. * @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)
  24018. * @returns the current mesh
  24019. */
  24020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24021. /**
  24022. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24023. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24024. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24025. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24026. * @returns the current mesh
  24027. */
  24028. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24029. /**
  24030. * Creates a un-shared specific occurence of the geometry for the mesh.
  24031. * @returns the current mesh
  24032. */
  24033. makeGeometryUnique(): Mesh;
  24034. /**
  24035. * Set the index buffer of this mesh
  24036. * @param indices defines the source data
  24037. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24038. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24039. * @returns the current mesh
  24040. */
  24041. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24042. /**
  24043. * Update the current index buffer
  24044. * @param indices defines the source data
  24045. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24046. * @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)
  24047. * @returns the current mesh
  24048. */
  24049. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24050. /**
  24051. * Invert the geometry to move from a right handed system to a left handed one.
  24052. * @returns the current mesh
  24053. */
  24054. toLeftHanded(): Mesh;
  24055. /** @hidden */
  24056. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24057. /** @hidden */
  24058. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24059. /**
  24060. * Registers for this mesh a javascript function called just before the rendering process
  24061. * @param func defines the function to call before rendering this mesh
  24062. * @returns the current mesh
  24063. */
  24064. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24065. /**
  24066. * Disposes a previously registered javascript function called before the rendering
  24067. * @param func defines the function to remove
  24068. * @returns the current mesh
  24069. */
  24070. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24071. /**
  24072. * Registers for this mesh a javascript function called just after the rendering is complete
  24073. * @param func defines the function to call after rendering this mesh
  24074. * @returns the current mesh
  24075. */
  24076. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24077. /**
  24078. * Disposes a previously registered javascript function called after the rendering.
  24079. * @param func defines the function to remove
  24080. * @returns the current mesh
  24081. */
  24082. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24083. /** @hidden */
  24084. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24085. /** @hidden */
  24086. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24087. /** @hidden */
  24088. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24089. /** @hidden */
  24090. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24091. /** @hidden */
  24092. _rebuild(): void;
  24093. /** @hidden */
  24094. _freeze(): void;
  24095. /** @hidden */
  24096. _unFreeze(): void;
  24097. /**
  24098. * 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
  24099. * @param subMesh defines the subMesh to render
  24100. * @param enableAlphaMode defines if alpha mode can be changed
  24101. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24102. * @returns the current mesh
  24103. */
  24104. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24105. private _onBeforeDraw;
  24106. /**
  24107. * Renormalize the mesh and patch it up if there are no weights
  24108. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24109. * However in the case of zero weights then we set just a single influence to 1.
  24110. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24111. */
  24112. cleanMatrixWeights(): void;
  24113. private normalizeSkinFourWeights;
  24114. private normalizeSkinWeightsAndExtra;
  24115. /**
  24116. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24117. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24118. * the user know there was an issue with importing the mesh
  24119. * @returns a validation object with skinned, valid and report string
  24120. */
  24121. validateSkinning(): {
  24122. skinned: boolean;
  24123. valid: boolean;
  24124. report: string;
  24125. };
  24126. /** @hidden */
  24127. _checkDelayState(): Mesh;
  24128. private _queueLoad;
  24129. /**
  24130. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24131. * A mesh is in the frustum if its bounding box intersects the frustum
  24132. * @param frustumPlanes defines the frustum to test
  24133. * @returns true if the mesh is in the frustum planes
  24134. */
  24135. isInFrustum(frustumPlanes: Plane[]): boolean;
  24136. /**
  24137. * Sets the mesh material by the material or multiMaterial `id` property
  24138. * @param id is a string identifying the material or the multiMaterial
  24139. * @returns the current mesh
  24140. */
  24141. setMaterialByID(id: string): Mesh;
  24142. /**
  24143. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24144. * @returns an array of IAnimatable
  24145. */
  24146. getAnimatables(): IAnimatable[];
  24147. /**
  24148. * Modifies the mesh geometry according to the passed transformation matrix.
  24149. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24150. * The mesh normals are modified using the same transformation.
  24151. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24152. * @param transform defines the transform matrix to use
  24153. * @see http://doc.babylonjs.com/resources/baking_transformations
  24154. * @returns the current mesh
  24155. */
  24156. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24157. /**
  24158. * Modifies the mesh geometry according to its own current World Matrix.
  24159. * The mesh World Matrix is then reset.
  24160. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24161. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24162. * @see http://doc.babylonjs.com/resources/baking_transformations
  24163. * @returns the current mesh
  24164. */
  24165. bakeCurrentTransformIntoVertices(): Mesh;
  24166. /** @hidden */
  24167. readonly _positions: Nullable<Vector3[]>;
  24168. /** @hidden */
  24169. _resetPointsArrayCache(): Mesh;
  24170. /** @hidden */
  24171. _generatePointsArray(): boolean;
  24172. /**
  24173. * Returns a new Mesh object generated from the current mesh properties.
  24174. * This method must not get confused with createInstance()
  24175. * @param name is a string, the name given to the new mesh
  24176. * @param newParent can be any Node object (default `null`)
  24177. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24178. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24179. * @returns a new mesh
  24180. */
  24181. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24182. /**
  24183. * Releases resources associated with this mesh.
  24184. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24185. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24186. */
  24187. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24188. /** @hidden */
  24189. _disposeInstanceSpecificData(): void;
  24190. /**
  24191. * Modifies the mesh geometry according to a displacement map.
  24192. * 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.
  24193. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24194. * @param url is a string, the URL from the image file is to be downloaded.
  24195. * @param minHeight is the lower limit of the displacement.
  24196. * @param maxHeight is the upper limit of the displacement.
  24197. * @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.
  24198. * @param uvOffset is an optional vector2 used to offset UV.
  24199. * @param uvScale is an optional vector2 used to scale UV.
  24200. * @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.
  24201. * @returns the Mesh.
  24202. */
  24203. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24204. /**
  24205. * Modifies the mesh geometry according to a displacementMap buffer.
  24206. * 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.
  24207. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24208. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24209. * @param heightMapWidth is the width of the buffer image.
  24210. * @param heightMapHeight is the height of the buffer image.
  24211. * @param minHeight is the lower limit of the displacement.
  24212. * @param maxHeight is the upper limit of the displacement.
  24213. * @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.
  24214. * @param uvOffset is an optional vector2 used to offset UV.
  24215. * @param uvScale is an optional vector2 used to scale UV.
  24216. * @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.
  24217. * @returns the Mesh.
  24218. */
  24219. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24220. /**
  24221. * Modify the mesh to get a flat shading rendering.
  24222. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24223. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24224. * @returns current mesh
  24225. */
  24226. convertToFlatShadedMesh(): Mesh;
  24227. /**
  24228. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24229. * In other words, more vertices, no more indices and a single bigger VBO.
  24230. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24231. * @returns current mesh
  24232. */
  24233. convertToUnIndexedMesh(): Mesh;
  24234. /**
  24235. * Inverses facet orientations.
  24236. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24237. * @param flipNormals will also inverts the normals
  24238. * @returns current mesh
  24239. */
  24240. flipFaces(flipNormals?: boolean): Mesh;
  24241. /**
  24242. * Increase the number of facets and hence vertices in a mesh
  24243. * Vertex normals are interpolated from existing vertex normals
  24244. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24245. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24246. */
  24247. increaseVertices(numberPerEdge: number): void;
  24248. /**
  24249. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24250. * This will undo any application of covertToFlatShadedMesh
  24251. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24252. */
  24253. forceSharedVertices(): void;
  24254. /** @hidden */
  24255. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24256. /** @hidden */
  24257. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24258. /**
  24259. * Creates a new InstancedMesh object from the mesh model.
  24260. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24261. * @param name defines the name of the new instance
  24262. * @returns a new InstancedMesh
  24263. */
  24264. createInstance(name: string): InstancedMesh;
  24265. /**
  24266. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24267. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24268. * @returns the current mesh
  24269. */
  24270. synchronizeInstances(): Mesh;
  24271. /**
  24272. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24273. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24274. * This should be used together with the simplification to avoid disappearing triangles.
  24275. * @param successCallback an optional success callback to be called after the optimization finished.
  24276. * @returns the current mesh
  24277. */
  24278. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24279. /**
  24280. * Serialize current mesh
  24281. * @param serializationObject defines the object which will receive the serialization data
  24282. */
  24283. serialize(serializationObject: any): void;
  24284. /** @hidden */
  24285. _syncGeometryWithMorphTargetManager(): void;
  24286. /** @hidden */
  24287. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24288. /**
  24289. * Returns a new Mesh object parsed from the source provided.
  24290. * @param parsedMesh is the source
  24291. * @param scene defines the hosting scene
  24292. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24293. * @returns a new Mesh
  24294. */
  24295. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24296. /**
  24297. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24298. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24299. * @param name defines the name of the mesh to create
  24300. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24301. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24302. * @param closePath creates a seam between the first and the last points of each path of the path array
  24303. * @param offset is taken in account only if the `pathArray` is containing a single path
  24304. * @param scene defines the hosting scene
  24305. * @param updatable defines if the mesh must be flagged as updatable
  24306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24307. * @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)
  24308. * @returns a new Mesh
  24309. */
  24310. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24311. /**
  24312. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24313. * @param name defines the name of the mesh to create
  24314. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24315. * @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
  24316. * @param scene defines the hosting scene
  24317. * @param updatable defines if the mesh must be flagged as updatable
  24318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24319. * @returns a new Mesh
  24320. */
  24321. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24322. /**
  24323. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24324. * @param name defines the name of the mesh to create
  24325. * @param size sets the size (float) of each box side (default 1)
  24326. * @param scene defines the hosting scene
  24327. * @param updatable defines if the mesh must be flagged as updatable
  24328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24329. * @returns a new Mesh
  24330. */
  24331. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24332. /**
  24333. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24334. * @param name defines the name of the mesh to create
  24335. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24336. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24337. * @param scene defines the hosting scene
  24338. * @param updatable defines if the mesh must be flagged as updatable
  24339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24340. * @returns a new Mesh
  24341. */
  24342. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24343. /**
  24344. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24345. * @param name defines the name of the mesh to create
  24346. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24347. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24348. * @param scene defines the hosting scene
  24349. * @returns a new Mesh
  24350. */
  24351. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24352. /**
  24353. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24354. * @param name defines the name of the mesh to create
  24355. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24356. * @param diameterTop set the top cap diameter (floats, default 1)
  24357. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24358. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24359. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24360. * @param scene defines the hosting scene
  24361. * @param updatable defines if the mesh must be flagged as updatable
  24362. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24363. * @returns a new Mesh
  24364. */
  24365. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24366. /**
  24367. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24368. * @param name defines the name of the mesh to create
  24369. * @param diameter sets the diameter size (float) of the torus (default 1)
  24370. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24371. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24372. * @param scene defines the hosting scene
  24373. * @param updatable defines if the mesh must be flagged as updatable
  24374. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24375. * @returns a new Mesh
  24376. */
  24377. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24378. /**
  24379. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24380. * @param name defines the name of the mesh to create
  24381. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24382. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24383. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24384. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24385. * @param p the number of windings on X axis (positive integers, default 2)
  24386. * @param q the number of windings on Y axis (positive integers, default 3)
  24387. * @param scene defines the hosting scene
  24388. * @param updatable defines if the mesh must be flagged as updatable
  24389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24390. * @returns a new Mesh
  24391. */
  24392. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24393. /**
  24394. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24395. * @param name defines the name of the mesh to create
  24396. * @param points is an array successive Vector3
  24397. * @param scene defines the hosting scene
  24398. * @param updatable defines if the mesh must be flagged as updatable
  24399. * @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).
  24400. * @returns a new Mesh
  24401. */
  24402. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24403. /**
  24404. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24405. * @param name defines the name of the mesh to create
  24406. * @param points is an array successive Vector3
  24407. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24408. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24409. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24410. * @param scene defines the hosting scene
  24411. * @param updatable defines if the mesh must be flagged as updatable
  24412. * @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)
  24413. * @returns a new Mesh
  24414. */
  24415. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24416. /**
  24417. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24418. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24419. * 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.
  24420. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24421. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24422. * Remember you can only change the shape positions, not their number when updating a polygon.
  24423. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24424. * @param name defines the name of the mesh to create
  24425. * @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
  24426. * @param scene defines the hosting scene
  24427. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24428. * @param updatable defines if the mesh must be flagged as updatable
  24429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24430. * @param earcutInjection can be used to inject your own earcut reference
  24431. * @returns a new Mesh
  24432. */
  24433. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24434. /**
  24435. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24436. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24437. * @param name defines the name of the mesh to create
  24438. * @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
  24439. * @param depth defines the height of extrusion
  24440. * @param scene defines the hosting scene
  24441. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24442. * @param updatable defines if the mesh must be flagged as updatable
  24443. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24444. * @param earcutInjection can be used to inject your own earcut reference
  24445. * @returns a new Mesh
  24446. */
  24447. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24448. /**
  24449. * Creates an extruded shape mesh.
  24450. * 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
  24451. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24453. * @param name defines the name of the mesh to create
  24454. * @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
  24455. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24456. * @param scale is the value to scale the shape
  24457. * @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
  24458. * @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
  24459. * @param scene defines the hosting scene
  24460. * @param updatable defines if the mesh must be flagged as updatable
  24461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24462. * @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)
  24463. * @returns a new Mesh
  24464. */
  24465. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24466. /**
  24467. * Creates an custom extruded shape mesh.
  24468. * The custom extrusion is a parametric shape.
  24469. * It has no predefined shape. Its final shape will depend on the input parameters.
  24470. * Please consider using the same method from the MeshBuilder class instead
  24471. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24472. * @param name defines the name of the mesh to create
  24473. * @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
  24474. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24475. * @param scaleFunction is a custom Javascript function called on each path point
  24476. * @param rotationFunction is a custom Javascript function called on each path point
  24477. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24478. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24479. * @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
  24480. * @param scene defines the hosting scene
  24481. * @param updatable defines if the mesh must be flagged as updatable
  24482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24483. * @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)
  24484. * @returns a new Mesh
  24485. */
  24486. 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;
  24487. /**
  24488. * Creates lathe mesh.
  24489. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24490. * Please consider using the same method from the MeshBuilder class instead
  24491. * @param name defines the name of the mesh to create
  24492. * @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
  24493. * @param radius is the radius value of the lathe
  24494. * @param tessellation is the side number of the lathe.
  24495. * @param scene defines the hosting scene
  24496. * @param updatable defines if the mesh must be flagged as updatable
  24497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24498. * @returns a new Mesh
  24499. */
  24500. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24501. /**
  24502. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24503. * @param name defines the name of the mesh to create
  24504. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24505. * @param scene defines the hosting scene
  24506. * @param updatable defines if the mesh must be flagged as updatable
  24507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24508. * @returns a new Mesh
  24509. */
  24510. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24511. /**
  24512. * Creates a ground mesh.
  24513. * Please consider using the same method from the MeshBuilder class instead
  24514. * @param name defines the name of the mesh to create
  24515. * @param width set the width of the ground
  24516. * @param height set the height of the ground
  24517. * @param subdivisions sets the number of subdivisions per side
  24518. * @param scene defines the hosting scene
  24519. * @param updatable defines if the mesh must be flagged as updatable
  24520. * @returns a new Mesh
  24521. */
  24522. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24523. /**
  24524. * Creates a tiled ground mesh.
  24525. * Please consider using the same method from the MeshBuilder class instead
  24526. * @param name defines the name of the mesh to create
  24527. * @param xmin set the ground minimum X coordinate
  24528. * @param zmin set the ground minimum Y coordinate
  24529. * @param xmax set the ground maximum X coordinate
  24530. * @param zmax set the ground maximum Z coordinate
  24531. * @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
  24532. * @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
  24533. * @param scene defines the hosting scene
  24534. * @param updatable defines if the mesh must be flagged as updatable
  24535. * @returns a new Mesh
  24536. */
  24537. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24538. w: number;
  24539. h: number;
  24540. }, precision: {
  24541. w: number;
  24542. h: number;
  24543. }, scene: Scene, updatable?: boolean): Mesh;
  24544. /**
  24545. * Creates a ground mesh from a height map.
  24546. * Please consider using the same method from the MeshBuilder class instead
  24547. * @see http://doc.babylonjs.com/babylon101/height_map
  24548. * @param name defines the name of the mesh to create
  24549. * @param url sets the URL of the height map image resource
  24550. * @param width set the ground width size
  24551. * @param height set the ground height size
  24552. * @param subdivisions sets the number of subdivision per side
  24553. * @param minHeight is the minimum altitude on the ground
  24554. * @param maxHeight is the maximum altitude on the ground
  24555. * @param scene defines the hosting scene
  24556. * @param updatable defines if the mesh must be flagged as updatable
  24557. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24558. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24559. * @returns a new Mesh
  24560. */
  24561. 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;
  24562. /**
  24563. * Creates a tube mesh.
  24564. * The tube is a parametric shape.
  24565. * It has no predefined shape. Its final shape will depend on the input parameters.
  24566. * Please consider using the same method from the MeshBuilder class instead
  24567. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24568. * @param name defines the name of the mesh to create
  24569. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24570. * @param radius sets the tube radius size
  24571. * @param tessellation is the number of sides on the tubular surface
  24572. * @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
  24573. * @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
  24574. * @param scene defines the hosting scene
  24575. * @param updatable defines if the mesh must be flagged as updatable
  24576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24577. * @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)
  24578. * @returns a new Mesh
  24579. */
  24580. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24581. (i: number, distance: number): number;
  24582. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24583. /**
  24584. * Creates a polyhedron mesh.
  24585. * Please consider using the same method from the MeshBuilder class instead.
  24586. * * 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
  24587. * * The parameter `size` (positive float, default 1) sets the polygon size
  24588. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24589. * * 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`
  24590. * * 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
  24591. * * 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)`)
  24592. * * 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
  24593. * * 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
  24594. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24595. * * 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
  24596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24597. * @param name defines the name of the mesh to create
  24598. * @param options defines the options used to create the mesh
  24599. * @param scene defines the hosting scene
  24600. * @returns a new Mesh
  24601. */
  24602. static CreatePolyhedron(name: string, options: {
  24603. type?: number;
  24604. size?: number;
  24605. sizeX?: number;
  24606. sizeY?: number;
  24607. sizeZ?: number;
  24608. custom?: any;
  24609. faceUV?: Vector4[];
  24610. faceColors?: Color4[];
  24611. updatable?: boolean;
  24612. sideOrientation?: number;
  24613. }, scene: Scene): Mesh;
  24614. /**
  24615. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24616. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24617. * * 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`)
  24618. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24619. * * 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
  24620. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24621. * * 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
  24622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24623. * @param name defines the name of the mesh
  24624. * @param options defines the options used to create the mesh
  24625. * @param scene defines the hosting scene
  24626. * @returns a new Mesh
  24627. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24628. */
  24629. static CreateIcoSphere(name: string, options: {
  24630. radius?: number;
  24631. flat?: boolean;
  24632. subdivisions?: number;
  24633. sideOrientation?: number;
  24634. updatable?: boolean;
  24635. }, scene: Scene): Mesh;
  24636. /**
  24637. * Creates a decal mesh.
  24638. * Please consider using the same method from the MeshBuilder class instead.
  24639. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24640. * @param name defines the name of the mesh
  24641. * @param sourceMesh defines the mesh receiving the decal
  24642. * @param position sets the position of the decal in world coordinates
  24643. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24644. * @param size sets the decal scaling
  24645. * @param angle sets the angle to rotate the decal
  24646. * @returns a new Mesh
  24647. */
  24648. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24649. /**
  24650. * Prepare internal position array for software CPU skinning
  24651. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24652. */
  24653. setPositionsForCPUSkinning(): Float32Array;
  24654. /**
  24655. * Prepare internal normal array for software CPU skinning
  24656. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24657. */
  24658. setNormalsForCPUSkinning(): Float32Array;
  24659. /**
  24660. * Updates the vertex buffer by applying transformation from the bones
  24661. * @param skeleton defines the skeleton to apply to current mesh
  24662. * @returns the current mesh
  24663. */
  24664. applySkeleton(skeleton: Skeleton): Mesh;
  24665. /**
  24666. * 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
  24667. * @param meshes defines the list of meshes to scan
  24668. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24669. */
  24670. static MinMax(meshes: AbstractMesh[]): {
  24671. min: Vector3;
  24672. max: Vector3;
  24673. };
  24674. /**
  24675. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24676. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24677. * @returns a vector3
  24678. */
  24679. static Center(meshesOrMinMaxVector: {
  24680. min: Vector3;
  24681. max: Vector3;
  24682. } | AbstractMesh[]): Vector3;
  24683. /**
  24684. * Merge the array of meshes into a single mesh for performance reasons.
  24685. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24686. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24687. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24688. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24689. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24690. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24691. * @returns a new mesh
  24692. */
  24693. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24694. /** @hidden */
  24695. addInstance(instance: InstancedMesh): void;
  24696. /** @hidden */
  24697. removeInstance(instance: InstancedMesh): void;
  24698. }
  24699. }
  24700. declare module BABYLON {
  24701. /**
  24702. * This is the base class of all the camera used in the application.
  24703. * @see http://doc.babylonjs.com/features/cameras
  24704. */
  24705. export class Camera extends Node {
  24706. /** @hidden */
  24707. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24708. /**
  24709. * This is the default projection mode used by the cameras.
  24710. * It helps recreating a feeling of perspective and better appreciate depth.
  24711. * This is the best way to simulate real life cameras.
  24712. */
  24713. static readonly PERSPECTIVE_CAMERA: number;
  24714. /**
  24715. * This helps creating camera with an orthographic mode.
  24716. * 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.
  24717. */
  24718. static readonly ORTHOGRAPHIC_CAMERA: number;
  24719. /**
  24720. * This is the default FOV mode for perspective cameras.
  24721. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24722. */
  24723. static readonly FOVMODE_VERTICAL_FIXED: number;
  24724. /**
  24725. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24726. */
  24727. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24728. /**
  24729. * This specifies ther is no need for a camera rig.
  24730. * Basically only one eye is rendered corresponding to the camera.
  24731. */
  24732. static readonly RIG_MODE_NONE: number;
  24733. /**
  24734. * Simulates a camera Rig with one blue eye and one red eye.
  24735. * This can be use with 3d blue and red glasses.
  24736. */
  24737. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24738. /**
  24739. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24740. */
  24741. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24742. /**
  24743. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24744. */
  24745. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24746. /**
  24747. * Defines that both eyes of the camera will be rendered over under each other.
  24748. */
  24749. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24750. /**
  24751. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24752. */
  24753. static readonly RIG_MODE_VR: number;
  24754. /**
  24755. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24756. */
  24757. static readonly RIG_MODE_WEBVR: number;
  24758. /**
  24759. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24760. */
  24761. static readonly RIG_MODE_CUSTOM: number;
  24762. /**
  24763. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24764. */
  24765. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24766. /**
  24767. * Define the input manager associated with the camera.
  24768. */
  24769. inputs: CameraInputsManager<Camera>;
  24770. /** @hidden */
  24771. _position: Vector3;
  24772. /**
  24773. * Define the current local position of the camera in the scene
  24774. */
  24775. position: Vector3;
  24776. /**
  24777. * The vector the camera should consider as up.
  24778. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24779. */
  24780. upVector: Vector3;
  24781. /**
  24782. * Define the current limit on the left side for an orthographic camera
  24783. * In scene unit
  24784. */
  24785. orthoLeft: Nullable<number>;
  24786. /**
  24787. * Define the current limit on the right side for an orthographic camera
  24788. * In scene unit
  24789. */
  24790. orthoRight: Nullable<number>;
  24791. /**
  24792. * Define the current limit on the bottom side for an orthographic camera
  24793. * In scene unit
  24794. */
  24795. orthoBottom: Nullable<number>;
  24796. /**
  24797. * Define the current limit on the top side for an orthographic camera
  24798. * In scene unit
  24799. */
  24800. orthoTop: Nullable<number>;
  24801. /**
  24802. * Field Of View is set in Radians. (default is 0.8)
  24803. */
  24804. fov: number;
  24805. /**
  24806. * Define the minimum distance the camera can see from.
  24807. * This is important to note that the depth buffer are not infinite and the closer it starts
  24808. * the more your scene might encounter depth fighting issue.
  24809. */
  24810. minZ: number;
  24811. /**
  24812. * Define the maximum distance the camera can see to.
  24813. * This is important to note that the depth buffer are not infinite and the further it end
  24814. * the more your scene might encounter depth fighting issue.
  24815. */
  24816. maxZ: number;
  24817. /**
  24818. * Define the default inertia of the camera.
  24819. * This helps giving a smooth feeling to the camera movement.
  24820. */
  24821. inertia: number;
  24822. /**
  24823. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24824. */
  24825. mode: number;
  24826. /**
  24827. * Define wether the camera is intermediate.
  24828. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24829. */
  24830. isIntermediate: boolean;
  24831. /**
  24832. * Define the viewport of the camera.
  24833. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24834. */
  24835. viewport: Viewport;
  24836. /**
  24837. * Restricts the camera to viewing objects with the same layerMask.
  24838. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24839. */
  24840. layerMask: number;
  24841. /**
  24842. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24843. */
  24844. fovMode: number;
  24845. /**
  24846. * Rig mode of the camera.
  24847. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24848. * This is normally controlled byt the camera themselves as internal use.
  24849. */
  24850. cameraRigMode: number;
  24851. /**
  24852. * Defines the distance between both "eyes" in case of a RIG
  24853. */
  24854. interaxialDistance: number;
  24855. /**
  24856. * Defines if stereoscopic rendering is done side by side or over under.
  24857. */
  24858. isStereoscopicSideBySide: boolean;
  24859. /**
  24860. * 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
  24861. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24862. * else in the scene. (Eg. security camera)
  24863. *
  24864. * 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)
  24865. */
  24866. customRenderTargets: RenderTargetTexture[];
  24867. /**
  24868. * When set, the camera will render to this render target instead of the default canvas
  24869. *
  24870. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24871. */
  24872. outputRenderTarget: Nullable<RenderTargetTexture>;
  24873. /**
  24874. * Observable triggered when the camera view matrix has changed.
  24875. */
  24876. onViewMatrixChangedObservable: Observable<Camera>;
  24877. /**
  24878. * Observable triggered when the camera Projection matrix has changed.
  24879. */
  24880. onProjectionMatrixChangedObservable: Observable<Camera>;
  24881. /**
  24882. * Observable triggered when the inputs have been processed.
  24883. */
  24884. onAfterCheckInputsObservable: Observable<Camera>;
  24885. /**
  24886. * Observable triggered when reset has been called and applied to the camera.
  24887. */
  24888. onRestoreStateObservable: Observable<Camera>;
  24889. /** @hidden */
  24890. _cameraRigParams: any;
  24891. /** @hidden */
  24892. _rigCameras: Camera[];
  24893. /** @hidden */
  24894. _rigPostProcess: Nullable<PostProcess>;
  24895. protected _webvrViewMatrix: Matrix;
  24896. /** @hidden */
  24897. _skipRendering: boolean;
  24898. /** @hidden */
  24899. _projectionMatrix: Matrix;
  24900. /** @hidden */
  24901. _postProcesses: Nullable<PostProcess>[];
  24902. /** @hidden */
  24903. _activeMeshes: SmartArray<AbstractMesh>;
  24904. protected _globalPosition: Vector3;
  24905. /** @hidden */
  24906. _computedViewMatrix: Matrix;
  24907. private _doNotComputeProjectionMatrix;
  24908. private _transformMatrix;
  24909. private _frustumPlanes;
  24910. private _refreshFrustumPlanes;
  24911. private _storedFov;
  24912. private _stateStored;
  24913. /**
  24914. * Instantiates a new camera object.
  24915. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24916. * @see http://doc.babylonjs.com/features/cameras
  24917. * @param name Defines the name of the camera in the scene
  24918. * @param position Defines the position of the camera
  24919. * @param scene Defines the scene the camera belongs too
  24920. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24921. */
  24922. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24923. /**
  24924. * Store current camera state (fov, position, etc..)
  24925. * @returns the camera
  24926. */
  24927. storeState(): Camera;
  24928. /**
  24929. * Restores the camera state values if it has been stored. You must call storeState() first
  24930. */
  24931. protected _restoreStateValues(): boolean;
  24932. /**
  24933. * Restored camera state. You must call storeState() first.
  24934. * @returns true if restored and false otherwise
  24935. */
  24936. restoreState(): boolean;
  24937. /**
  24938. * Gets the class name of the camera.
  24939. * @returns the class name
  24940. */
  24941. getClassName(): string;
  24942. /** @hidden */
  24943. readonly _isCamera: boolean;
  24944. /**
  24945. * Gets a string representation of the camera useful for debug purpose.
  24946. * @param fullDetails Defines that a more verboe level of logging is required
  24947. * @returns the string representation
  24948. */
  24949. toString(fullDetails?: boolean): string;
  24950. /**
  24951. * Gets the current world space position of the camera.
  24952. */
  24953. readonly globalPosition: Vector3;
  24954. /**
  24955. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24956. * @returns the active meshe list
  24957. */
  24958. getActiveMeshes(): SmartArray<AbstractMesh>;
  24959. /**
  24960. * Check wether a mesh is part of the current active mesh list of the camera
  24961. * @param mesh Defines the mesh to check
  24962. * @returns true if active, false otherwise
  24963. */
  24964. isActiveMesh(mesh: Mesh): boolean;
  24965. /**
  24966. * Is this camera ready to be used/rendered
  24967. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24968. * @return true if the camera is ready
  24969. */
  24970. isReady(completeCheck?: boolean): boolean;
  24971. /** @hidden */
  24972. _initCache(): void;
  24973. /** @hidden */
  24974. _updateCache(ignoreParentClass?: boolean): void;
  24975. /** @hidden */
  24976. _isSynchronized(): boolean;
  24977. /** @hidden */
  24978. _isSynchronizedViewMatrix(): boolean;
  24979. /** @hidden */
  24980. _isSynchronizedProjectionMatrix(): boolean;
  24981. /**
  24982. * Attach the input controls to a specific dom element to get the input from.
  24983. * @param element Defines the element the controls should be listened from
  24984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24985. */
  24986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24987. /**
  24988. * Detach the current controls from the specified dom element.
  24989. * @param element Defines the element to stop listening the inputs from
  24990. */
  24991. detachControl(element: HTMLElement): void;
  24992. /**
  24993. * Update the camera state according to the different inputs gathered during the frame.
  24994. */
  24995. update(): void;
  24996. /** @hidden */
  24997. _checkInputs(): void;
  24998. /** @hidden */
  24999. readonly rigCameras: Camera[];
  25000. /**
  25001. * Gets the post process used by the rig cameras
  25002. */
  25003. readonly rigPostProcess: Nullable<PostProcess>;
  25004. /**
  25005. * Internal, gets the first post proces.
  25006. * @returns the first post process to be run on this camera.
  25007. */
  25008. _getFirstPostProcess(): Nullable<PostProcess>;
  25009. private _cascadePostProcessesToRigCams;
  25010. /**
  25011. * Attach a post process to the camera.
  25012. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25013. * @param postProcess The post process to attach to the camera
  25014. * @param insertAt The position of the post process in case several of them are in use in the scene
  25015. * @returns the position the post process has been inserted at
  25016. */
  25017. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25018. /**
  25019. * Detach a post process to the camera.
  25020. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25021. * @param postProcess The post process to detach from the camera
  25022. */
  25023. detachPostProcess(postProcess: PostProcess): void;
  25024. /**
  25025. * Gets the current world matrix of the camera
  25026. */
  25027. getWorldMatrix(): Matrix;
  25028. /** @hidden */
  25029. _getViewMatrix(): Matrix;
  25030. /**
  25031. * Gets the current view matrix of the camera.
  25032. * @param force forces the camera to recompute the matrix without looking at the cached state
  25033. * @returns the view matrix
  25034. */
  25035. getViewMatrix(force?: boolean): Matrix;
  25036. /**
  25037. * Freeze the projection matrix.
  25038. * It will prevent the cache check of the camera projection compute and can speed up perf
  25039. * if no parameter of the camera are meant to change
  25040. * @param projection Defines manually a projection if necessary
  25041. */
  25042. freezeProjectionMatrix(projection?: Matrix): void;
  25043. /**
  25044. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25045. */
  25046. unfreezeProjectionMatrix(): void;
  25047. /**
  25048. * Gets the current projection matrix of the camera.
  25049. * @param force forces the camera to recompute the matrix without looking at the cached state
  25050. * @returns the projection matrix
  25051. */
  25052. getProjectionMatrix(force?: boolean): Matrix;
  25053. /**
  25054. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25055. * @returns a Matrix
  25056. */
  25057. getTransformationMatrix(): Matrix;
  25058. private _updateFrustumPlanes;
  25059. /**
  25060. * Checks if a cullable object (mesh...) is in the camera frustum
  25061. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25062. * @param target The object to check
  25063. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25064. * @returns true if the object is in frustum otherwise false
  25065. */
  25066. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25067. /**
  25068. * Checks if a cullable object (mesh...) is in the camera frustum
  25069. * Unlike isInFrustum this cheks the full bounding box
  25070. * @param target The object to check
  25071. * @returns true if the object is in frustum otherwise false
  25072. */
  25073. isCompletelyInFrustum(target: ICullable): boolean;
  25074. /**
  25075. * Gets a ray in the forward direction from the camera.
  25076. * @param length Defines the length of the ray to create
  25077. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25078. * @param origin Defines the start point of the ray which defaults to the camera position
  25079. * @returns the forward ray
  25080. */
  25081. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25082. /**
  25083. * Releases resources associated with this node.
  25084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25086. */
  25087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25088. /** @hidden */
  25089. _isLeftCamera: boolean;
  25090. /**
  25091. * Gets the left camera of a rig setup in case of Rigged Camera
  25092. */
  25093. readonly isLeftCamera: boolean;
  25094. /** @hidden */
  25095. _isRightCamera: boolean;
  25096. /**
  25097. * Gets the right camera of a rig setup in case of Rigged Camera
  25098. */
  25099. readonly isRightCamera: boolean;
  25100. /**
  25101. * Gets the left camera of a rig setup in case of Rigged Camera
  25102. */
  25103. readonly leftCamera: Nullable<FreeCamera>;
  25104. /**
  25105. * Gets the right camera of a rig setup in case of Rigged Camera
  25106. */
  25107. readonly rightCamera: Nullable<FreeCamera>;
  25108. /**
  25109. * Gets the left camera target of a rig setup in case of Rigged Camera
  25110. * @returns the target position
  25111. */
  25112. getLeftTarget(): Nullable<Vector3>;
  25113. /**
  25114. * Gets the right camera target of a rig setup in case of Rigged Camera
  25115. * @returns the target position
  25116. */
  25117. getRightTarget(): Nullable<Vector3>;
  25118. /**
  25119. * @hidden
  25120. */
  25121. setCameraRigMode(mode: number, rigParams: any): void;
  25122. /** @hidden */
  25123. static _setStereoscopicRigMode(camera: Camera): void;
  25124. /** @hidden */
  25125. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25126. /** @hidden */
  25127. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25128. /** @hidden */
  25129. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25130. /** @hidden */
  25131. _getVRProjectionMatrix(): Matrix;
  25132. protected _updateCameraRotationMatrix(): void;
  25133. protected _updateWebVRCameraRotationMatrix(): void;
  25134. /**
  25135. * This function MUST be overwritten by the different WebVR cameras available.
  25136. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25137. * @hidden
  25138. */
  25139. _getWebVRProjectionMatrix(): Matrix;
  25140. /**
  25141. * This function MUST be overwritten by the different WebVR cameras available.
  25142. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25143. * @hidden
  25144. */
  25145. _getWebVRViewMatrix(): Matrix;
  25146. /** @hidden */
  25147. setCameraRigParameter(name: string, value: any): void;
  25148. /**
  25149. * needs to be overridden by children so sub has required properties to be copied
  25150. * @hidden
  25151. */
  25152. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25153. /**
  25154. * May need to be overridden by children
  25155. * @hidden
  25156. */
  25157. _updateRigCameras(): void;
  25158. /** @hidden */
  25159. _setupInputs(): void;
  25160. /**
  25161. * Serialiaze the camera setup to a json represention
  25162. * @returns the JSON representation
  25163. */
  25164. serialize(): any;
  25165. /**
  25166. * Clones the current camera.
  25167. * @param name The cloned camera name
  25168. * @returns the cloned camera
  25169. */
  25170. clone(name: string): Camera;
  25171. /**
  25172. * Gets the direction of the camera relative to a given local axis.
  25173. * @param localAxis Defines the reference axis to provide a relative direction.
  25174. * @return the direction
  25175. */
  25176. getDirection(localAxis: Vector3): Vector3;
  25177. /**
  25178. * Returns the current camera absolute rotation
  25179. */
  25180. readonly absoluteRotation: Quaternion;
  25181. /**
  25182. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25183. * @param localAxis Defines the reference axis to provide a relative direction.
  25184. * @param result Defines the vector to store the result in
  25185. */
  25186. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25187. /**
  25188. * Gets a camera constructor for a given camera type
  25189. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25190. * @param name The name of the camera the result will be able to instantiate
  25191. * @param scene The scene the result will construct the camera in
  25192. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25193. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25194. * @returns a factory method to construc the camera
  25195. */
  25196. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25197. /**
  25198. * Compute the world matrix of the camera.
  25199. * @returns the camera workd matrix
  25200. */
  25201. computeWorldMatrix(): Matrix;
  25202. /**
  25203. * Parse a JSON and creates the camera from the parsed information
  25204. * @param parsedCamera The JSON to parse
  25205. * @param scene The scene to instantiate the camera in
  25206. * @returns the newly constructed camera
  25207. */
  25208. static Parse(parsedCamera: any, scene: Scene): Camera;
  25209. }
  25210. }
  25211. declare module BABYLON {
  25212. /**
  25213. * Class containing static functions to help procedurally build meshes
  25214. */
  25215. export class DiscBuilder {
  25216. /**
  25217. * Creates a plane polygonal mesh. By default, this is a disc
  25218. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25219. * * 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
  25220. * * 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
  25221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25222. * * 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
  25223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25224. * @param name defines the name of the mesh
  25225. * @param options defines the options used to create the mesh
  25226. * @param scene defines the hosting scene
  25227. * @returns the plane polygonal mesh
  25228. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25229. */
  25230. static CreateDisc(name: string, options: {
  25231. radius?: number;
  25232. tessellation?: number;
  25233. arc?: number;
  25234. updatable?: boolean;
  25235. sideOrientation?: number;
  25236. frontUVs?: Vector4;
  25237. backUVs?: Vector4;
  25238. }, scene?: Nullable<Scene>): Mesh;
  25239. }
  25240. }
  25241. declare module BABYLON {
  25242. /**
  25243. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25244. *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.
  25245. * The SPS is also a particle system. It provides some methods to manage the particles.
  25246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25247. *
  25248. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25249. */
  25250. export class SolidParticleSystem implements IDisposable {
  25251. /**
  25252. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25253. * Example : var p = SPS.particles[i];
  25254. */
  25255. particles: SolidParticle[];
  25256. /**
  25257. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25258. */
  25259. nbParticles: number;
  25260. /**
  25261. * If the particles must ever face the camera (default false). Useful for planar particles.
  25262. */
  25263. billboard: boolean;
  25264. /**
  25265. * Recompute normals when adding a shape
  25266. */
  25267. recomputeNormals: boolean;
  25268. /**
  25269. * This a counter ofr your own usage. It's not set by any SPS functions.
  25270. */
  25271. counter: number;
  25272. /**
  25273. * The SPS name. This name is also given to the underlying mesh.
  25274. */
  25275. name: string;
  25276. /**
  25277. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25278. */
  25279. mesh: Mesh;
  25280. /**
  25281. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25282. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25283. */
  25284. vars: any;
  25285. /**
  25286. * This array is populated when the SPS is set as 'pickable'.
  25287. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25288. * Each element of this array is an object `{idx: int, faceId: int}`.
  25289. * `idx` is the picked particle index in the `SPS.particles` array
  25290. * `faceId` is the picked face index counted within this particle.
  25291. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25292. */
  25293. pickedParticles: {
  25294. idx: number;
  25295. faceId: number;
  25296. }[];
  25297. /**
  25298. * This array is populated when `enableDepthSort` is set to true.
  25299. * Each element of this array is an instance of the class DepthSortedParticle.
  25300. */
  25301. depthSortedParticles: DepthSortedParticle[];
  25302. /**
  25303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25304. * @hidden
  25305. */
  25306. _bSphereOnly: boolean;
  25307. /**
  25308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25309. * @hidden
  25310. */
  25311. _bSphereRadiusFactor: number;
  25312. private _scene;
  25313. private _positions;
  25314. private _indices;
  25315. private _normals;
  25316. private _colors;
  25317. private _uvs;
  25318. private _indices32;
  25319. private _positions32;
  25320. private _normals32;
  25321. private _fixedNormal32;
  25322. private _colors32;
  25323. private _uvs32;
  25324. private _index;
  25325. private _updatable;
  25326. private _pickable;
  25327. private _isVisibilityBoxLocked;
  25328. private _alwaysVisible;
  25329. private _depthSort;
  25330. private _expandable;
  25331. private _shapeCounter;
  25332. private _copy;
  25333. private _color;
  25334. private _computeParticleColor;
  25335. private _computeParticleTexture;
  25336. private _computeParticleRotation;
  25337. private _computeParticleVertex;
  25338. private _computeBoundingBox;
  25339. private _depthSortParticles;
  25340. private _camera;
  25341. private _mustUnrotateFixedNormals;
  25342. private _particlesIntersect;
  25343. private _needs32Bits;
  25344. private _isNotBuilt;
  25345. /**
  25346. * Creates a SPS (Solid Particle System) object.
  25347. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25348. * @param scene (Scene) is the scene in which the SPS is added.
  25349. * @param options defines the options of the sps e.g.
  25350. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25351. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25352. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25353. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25354. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25355. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25356. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25357. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25358. */
  25359. constructor(name: string, scene: Scene, options?: {
  25360. updatable?: boolean;
  25361. isPickable?: boolean;
  25362. enableDepthSort?: boolean;
  25363. particleIntersection?: boolean;
  25364. boundingSphereOnly?: boolean;
  25365. bSphereRadiusFactor?: number;
  25366. expandable?: boolean;
  25367. });
  25368. /**
  25369. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25370. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25371. * @returns the created mesh
  25372. */
  25373. buildMesh(): Mesh;
  25374. /**
  25375. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25376. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25377. * Thus the particles generated from `digest()` have their property `position` set yet.
  25378. * @param mesh ( Mesh ) is the mesh to be digested
  25379. * @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
  25380. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25381. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25382. * @returns the current SPS
  25383. */
  25384. digest(mesh: Mesh, options?: {
  25385. facetNb?: number;
  25386. number?: number;
  25387. delta?: number;
  25388. }): SolidParticleSystem;
  25389. private _unrotateFixedNormals;
  25390. private _resetCopy;
  25391. private _meshBuilder;
  25392. private _posToShape;
  25393. private _uvsToShapeUV;
  25394. private _addParticle;
  25395. /**
  25396. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25397. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25398. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25399. * @param nb (positive integer) the number of particles to be created from this model
  25400. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25401. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25402. * @returns the number of shapes in the system
  25403. */
  25404. addShape(mesh: Mesh, nb: number, options?: {
  25405. positionFunction?: any;
  25406. vertexFunction?: any;
  25407. }): number;
  25408. private _rebuildParticle;
  25409. /**
  25410. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25411. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  25412. * @returns the SPS.
  25413. */
  25414. rebuildMesh(reset?: boolean): SolidParticleSystem;
  25415. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  25416. * Returns an array with the removed particles.
  25417. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  25418. * The SPS can't be empty so at least one particle needs to remain in place.
  25419. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  25420. * @param start index of the first particle to remove
  25421. * @param end index of the last particle to remove (included)
  25422. * @returns an array populated with the removed particles
  25423. */
  25424. removeParticles(start: number, end: number): SolidParticle[];
  25425. /**
  25426. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25427. * This method calls `updateParticle()` for each particle of the SPS.
  25428. * For an animated SPS, it is usually called within the render loop.
  25429. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  25430. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25431. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25432. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25433. * @returns the SPS.
  25434. */
  25435. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25436. /**
  25437. * Disposes the SPS.
  25438. */
  25439. dispose(): void;
  25440. /**
  25441. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25442. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25443. * @returns the SPS.
  25444. */
  25445. refreshVisibleSize(): SolidParticleSystem;
  25446. /**
  25447. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25448. * @param size the size (float) of the visibility box
  25449. * note : this doesn't lock the SPS mesh bounding box.
  25450. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25451. */
  25452. setVisibilityBox(size: number): void;
  25453. /**
  25454. * Gets whether the SPS as always visible or not
  25455. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25456. */
  25457. /**
  25458. * Sets the SPS as always visible or not
  25459. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25460. */
  25461. isAlwaysVisible: boolean;
  25462. /**
  25463. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25465. */
  25466. /**
  25467. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25468. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25469. */
  25470. isVisibilityBoxLocked: boolean;
  25471. /**
  25472. * Tells to `setParticles()` to compute the particle rotations or not.
  25473. * Default value : true. The SPS is faster when it's set to false.
  25474. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25475. */
  25476. /**
  25477. * Gets if `setParticles()` computes the particle rotations or not.
  25478. * Default value : true. The SPS is faster when it's set to false.
  25479. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25480. */
  25481. computeParticleRotation: boolean;
  25482. /**
  25483. * Tells to `setParticles()` to compute the particle colors or not.
  25484. * Default value : true. The SPS is faster when it's set to false.
  25485. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25486. */
  25487. /**
  25488. * Gets if `setParticles()` computes the particle colors or not.
  25489. * Default value : true. The SPS is faster when it's set to false.
  25490. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25491. */
  25492. computeParticleColor: boolean;
  25493. /**
  25494. * Gets if `setParticles()` computes the particle textures or not.
  25495. * Default value : true. The SPS is faster when it's set to false.
  25496. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25497. */
  25498. computeParticleTexture: boolean;
  25499. /**
  25500. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25501. * Default value : false. The SPS is faster when it's set to false.
  25502. * Note : the particle custom vertex positions aren't stored values.
  25503. */
  25504. /**
  25505. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25506. * Default value : false. The SPS is faster when it's set to false.
  25507. * Note : the particle custom vertex positions aren't stored values.
  25508. */
  25509. computeParticleVertex: boolean;
  25510. /**
  25511. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25512. */
  25513. /**
  25514. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25515. */
  25516. computeBoundingBox: boolean;
  25517. /**
  25518. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25519. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25520. * Default : `true`
  25521. */
  25522. /**
  25523. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25525. * Default : `true`
  25526. */
  25527. depthSortParticles: boolean;
  25528. /**
  25529. * Gets if the SPS is created as expandable at construction time.
  25530. * Default : `false`
  25531. */
  25532. readonly expandable: boolean;
  25533. /**
  25534. * This function does nothing. It may be overwritten to set all the particle first values.
  25535. * The SPS doesn't call this function, you may have to call it by your own.
  25536. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25537. */
  25538. initParticles(): void;
  25539. /**
  25540. * This function does nothing. It may be overwritten to recycle a particle.
  25541. * The SPS doesn't call this function, you may have to call it by your own.
  25542. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25543. * @param particle The particle to recycle
  25544. * @returns the recycled particle
  25545. */
  25546. recycleParticle(particle: SolidParticle): SolidParticle;
  25547. /**
  25548. * Updates a particle : this function should be overwritten by the user.
  25549. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25550. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25551. * @example : just set a particle position or velocity and recycle conditions
  25552. * @param particle The particle to update
  25553. * @returns the updated particle
  25554. */
  25555. updateParticle(particle: SolidParticle): SolidParticle;
  25556. /**
  25557. * Updates a vertex of a particle : it can be overwritten by the user.
  25558. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25559. * @param particle the current particle
  25560. * @param vertex the current index of the current particle
  25561. * @param pt the index of the current vertex in the particle shape
  25562. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25563. * @example : just set a vertex particle position
  25564. * @returns the updated vertex
  25565. */
  25566. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25567. /**
  25568. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25569. * This does nothing and may be overwritten by the user.
  25570. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25571. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25572. * @param update the boolean update value actually passed to setParticles()
  25573. */
  25574. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25575. /**
  25576. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25577. * This will be passed three parameters.
  25578. * This does nothing and may be overwritten by the user.
  25579. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25580. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25581. * @param update the boolean update value actually passed to setParticles()
  25582. */
  25583. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25584. }
  25585. }
  25586. declare module BABYLON {
  25587. /**
  25588. * Represents one particle of a solid particle system.
  25589. */
  25590. export class SolidParticle {
  25591. /**
  25592. * particle global index
  25593. */
  25594. idx: number;
  25595. /**
  25596. * The color of the particle
  25597. */
  25598. color: Nullable<Color4>;
  25599. /**
  25600. * The world space position of the particle.
  25601. */
  25602. position: Vector3;
  25603. /**
  25604. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25605. */
  25606. rotation: Vector3;
  25607. /**
  25608. * The world space rotation quaternion of the particle.
  25609. */
  25610. rotationQuaternion: Nullable<Quaternion>;
  25611. /**
  25612. * The scaling of the particle.
  25613. */
  25614. scaling: Vector3;
  25615. /**
  25616. * The uvs of the particle.
  25617. */
  25618. uvs: Vector4;
  25619. /**
  25620. * The current speed of the particle.
  25621. */
  25622. velocity: Vector3;
  25623. /**
  25624. * The pivot point in the particle local space.
  25625. */
  25626. pivot: Vector3;
  25627. /**
  25628. * Must the particle be translated from its pivot point in its local space ?
  25629. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25630. * Default : false
  25631. */
  25632. translateFromPivot: boolean;
  25633. /**
  25634. * Is the particle active or not ?
  25635. */
  25636. alive: boolean;
  25637. /**
  25638. * Is the particle visible or not ?
  25639. */
  25640. isVisible: boolean;
  25641. /**
  25642. * Index of this particle in the global "positions" array (Internal use)
  25643. * @hidden
  25644. */
  25645. _pos: number;
  25646. /**
  25647. * @hidden Index of this particle in the global "indices" array (Internal use)
  25648. */
  25649. _ind: number;
  25650. /**
  25651. * @hidden ModelShape of this particle (Internal use)
  25652. */
  25653. _model: ModelShape;
  25654. /**
  25655. * ModelShape id of this particle
  25656. */
  25657. shapeId: number;
  25658. /**
  25659. * Index of the particle in its shape id
  25660. */
  25661. idxInShape: number;
  25662. /**
  25663. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25664. */
  25665. _modelBoundingInfo: BoundingInfo;
  25666. /**
  25667. * @hidden Particle BoundingInfo object (Internal use)
  25668. */
  25669. _boundingInfo: BoundingInfo;
  25670. /**
  25671. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25672. */
  25673. _sps: SolidParticleSystem;
  25674. /**
  25675. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25676. */
  25677. _stillInvisible: boolean;
  25678. /**
  25679. * @hidden Last computed particle rotation matrix
  25680. */
  25681. _rotationMatrix: number[];
  25682. /**
  25683. * Parent particle Id, if any.
  25684. * Default null.
  25685. */
  25686. parentId: Nullable<number>;
  25687. /**
  25688. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25689. * The possible values are :
  25690. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25691. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25693. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25694. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25695. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25696. * */
  25697. cullingStrategy: number;
  25698. /**
  25699. * @hidden Internal global position in the SPS.
  25700. */
  25701. _globalPosition: Vector3;
  25702. /**
  25703. * Creates a Solid Particle object.
  25704. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25705. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25706. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25707. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25708. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25709. * @param shapeId (integer) is the model shape identifier in the SPS.
  25710. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25711. * @param sps defines the sps it is associated to
  25712. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25713. */
  25714. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25715. /**
  25716. * Legacy support, changed scale to scaling
  25717. */
  25718. /**
  25719. * Legacy support, changed scale to scaling
  25720. */
  25721. scale: Vector3;
  25722. /**
  25723. * Legacy support, changed quaternion to rotationQuaternion
  25724. */
  25725. /**
  25726. * Legacy support, changed quaternion to rotationQuaternion
  25727. */
  25728. quaternion: Nullable<Quaternion>;
  25729. /**
  25730. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25731. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25732. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25733. * @returns true if it intersects
  25734. */
  25735. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25736. /**
  25737. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25738. * A particle is in the frustum if its bounding box intersects the frustum
  25739. * @param frustumPlanes defines the frustum to test
  25740. * @returns true if the particle is in the frustum planes
  25741. */
  25742. isInFrustum(frustumPlanes: Plane[]): boolean;
  25743. /**
  25744. * get the rotation matrix of the particle
  25745. * @hidden
  25746. */
  25747. getRotationMatrix(m: Matrix): void;
  25748. }
  25749. /**
  25750. * Represents the shape of the model used by one particle of a solid particle system.
  25751. * SPS internal tool, don't use it manually.
  25752. */
  25753. export class ModelShape {
  25754. /**
  25755. * The shape id
  25756. * @hidden
  25757. */
  25758. shapeID: number;
  25759. /**
  25760. * flat array of model positions (internal use)
  25761. * @hidden
  25762. */
  25763. _shape: Vector3[];
  25764. /**
  25765. * flat array of model UVs (internal use)
  25766. * @hidden
  25767. */
  25768. _shapeUV: number[];
  25769. /**
  25770. * color array of the model
  25771. * @hidden
  25772. */
  25773. _shapeColors: number[];
  25774. /**
  25775. * indices array of the model
  25776. * @hidden
  25777. */
  25778. _indices: number[];
  25779. /**
  25780. * normals array of the model
  25781. * @hidden
  25782. */
  25783. _normals: number[];
  25784. /**
  25785. * length of the shape in the model indices array (internal use)
  25786. * @hidden
  25787. */
  25788. _indicesLength: number;
  25789. /**
  25790. * Custom position function (internal use)
  25791. * @hidden
  25792. */
  25793. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25794. /**
  25795. * Custom vertex function (internal use)
  25796. * @hidden
  25797. */
  25798. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25799. /**
  25800. * 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.
  25801. * SPS internal tool, don't use it manually.
  25802. * @hidden
  25803. */
  25804. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25805. }
  25806. /**
  25807. * Represents a Depth Sorted Particle in the solid particle system.
  25808. */
  25809. export class DepthSortedParticle {
  25810. /**
  25811. * Index of the particle in the "indices" array
  25812. */
  25813. ind: number;
  25814. /**
  25815. * Length of the particle shape in the "indices" array
  25816. */
  25817. indicesLength: number;
  25818. /**
  25819. * Squared distance from the particle to the camera
  25820. */
  25821. sqDistance: number;
  25822. }
  25823. }
  25824. declare module BABYLON {
  25825. /**
  25826. * @hidden
  25827. */
  25828. export class _MeshCollisionData {
  25829. _checkCollisions: boolean;
  25830. _collisionMask: number;
  25831. _collisionGroup: number;
  25832. _collider: Nullable<Collider>;
  25833. _oldPositionForCollisions: Vector3;
  25834. _diffPositionForCollisions: Vector3;
  25835. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25836. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25837. }
  25838. }
  25839. declare module BABYLON {
  25840. /** @hidden */
  25841. class _FacetDataStorage {
  25842. facetPositions: Vector3[];
  25843. facetNormals: Vector3[];
  25844. facetPartitioning: number[][];
  25845. facetNb: number;
  25846. partitioningSubdivisions: number;
  25847. partitioningBBoxRatio: number;
  25848. facetDataEnabled: boolean;
  25849. facetParameters: any;
  25850. bbSize: Vector3;
  25851. subDiv: {
  25852. max: number;
  25853. X: number;
  25854. Y: number;
  25855. Z: number;
  25856. };
  25857. facetDepthSort: boolean;
  25858. facetDepthSortEnabled: boolean;
  25859. depthSortedIndices: IndicesArray;
  25860. depthSortedFacets: {
  25861. ind: number;
  25862. sqDistance: number;
  25863. }[];
  25864. facetDepthSortFunction: (f1: {
  25865. ind: number;
  25866. sqDistance: number;
  25867. }, f2: {
  25868. ind: number;
  25869. sqDistance: number;
  25870. }) => number;
  25871. facetDepthSortFrom: Vector3;
  25872. facetDepthSortOrigin: Vector3;
  25873. invertedMatrix: Matrix;
  25874. }
  25875. /**
  25876. * @hidden
  25877. **/
  25878. class _InternalAbstractMeshDataInfo {
  25879. _hasVertexAlpha: boolean;
  25880. _useVertexColors: boolean;
  25881. _numBoneInfluencers: number;
  25882. _applyFog: boolean;
  25883. _receiveShadows: boolean;
  25884. _facetData: _FacetDataStorage;
  25885. _visibility: number;
  25886. _skeleton: Nullable<Skeleton>;
  25887. _layerMask: number;
  25888. _computeBonesUsingShaders: boolean;
  25889. _isActive: boolean;
  25890. _onlyForInstances: boolean;
  25891. _isActiveIntermediate: boolean;
  25892. _onlyForInstancesIntermediate: boolean;
  25893. _actAsRegularMesh: boolean;
  25894. }
  25895. /**
  25896. * Class used to store all common mesh properties
  25897. */
  25898. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25899. /** No occlusion */
  25900. static OCCLUSION_TYPE_NONE: number;
  25901. /** Occlusion set to optimisitic */
  25902. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25903. /** Occlusion set to strict */
  25904. static OCCLUSION_TYPE_STRICT: number;
  25905. /** Use an accurante occlusion algorithm */
  25906. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25907. /** Use a conservative occlusion algorithm */
  25908. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25909. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25910. * Test order :
  25911. * Is the bounding sphere outside the frustum ?
  25912. * If not, are the bounding box vertices outside the frustum ?
  25913. * It not, then the cullable object is in the frustum.
  25914. */
  25915. static readonly CULLINGSTRATEGY_STANDARD: number;
  25916. /** Culling strategy : Bounding Sphere Only.
  25917. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25918. * It's also less accurate than the standard because some not visible objects can still be selected.
  25919. * Test : is the bounding sphere outside the frustum ?
  25920. * If not, then the cullable object is in the frustum.
  25921. */
  25922. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25923. /** Culling strategy : Optimistic Inclusion.
  25924. * This in an inclusion test first, then the standard exclusion test.
  25925. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25926. * 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.
  25927. * Anyway, it's as accurate as the standard strategy.
  25928. * Test :
  25929. * Is the cullable object bounding sphere center in the frustum ?
  25930. * If not, apply the default culling strategy.
  25931. */
  25932. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25933. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25934. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25935. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25936. * 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.
  25937. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25938. * Test :
  25939. * Is the cullable object bounding sphere center in the frustum ?
  25940. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25941. */
  25942. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25943. /**
  25944. * No billboard
  25945. */
  25946. static readonly BILLBOARDMODE_NONE: number;
  25947. /** Billboard on X axis */
  25948. static readonly BILLBOARDMODE_X: number;
  25949. /** Billboard on Y axis */
  25950. static readonly BILLBOARDMODE_Y: number;
  25951. /** Billboard on Z axis */
  25952. static readonly BILLBOARDMODE_Z: number;
  25953. /** Billboard on all axes */
  25954. static readonly BILLBOARDMODE_ALL: number;
  25955. /** Billboard on using position instead of orientation */
  25956. static readonly BILLBOARDMODE_USE_POSITION: number;
  25957. /** @hidden */
  25958. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25959. /**
  25960. * The culling strategy to use to check whether the mesh must be rendered or not.
  25961. * This value can be changed at any time and will be used on the next render mesh selection.
  25962. * The possible values are :
  25963. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25964. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25967. * Please read each static variable documentation to get details about the culling process.
  25968. * */
  25969. cullingStrategy: number;
  25970. /**
  25971. * Gets the number of facets in the mesh
  25972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25973. */
  25974. readonly facetNb: number;
  25975. /**
  25976. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25978. */
  25979. partitioningSubdivisions: number;
  25980. /**
  25981. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25982. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25984. */
  25985. partitioningBBoxRatio: number;
  25986. /**
  25987. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25988. * Works only for updatable meshes.
  25989. * Doesn't work with multi-materials
  25990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25991. */
  25992. mustDepthSortFacets: boolean;
  25993. /**
  25994. * The location (Vector3) where the facet depth sort must be computed from.
  25995. * By default, the active camera position.
  25996. * Used only when facet depth sort is enabled
  25997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25998. */
  25999. facetDepthSortFrom: Vector3;
  26000. /**
  26001. * gets a boolean indicating if facetData is enabled
  26002. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26003. */
  26004. readonly isFacetDataEnabled: boolean;
  26005. /** @hidden */
  26006. _updateNonUniformScalingState(value: boolean): boolean;
  26007. /**
  26008. * An event triggered when this mesh collides with another one
  26009. */
  26010. onCollideObservable: Observable<AbstractMesh>;
  26011. /** Set a function to call when this mesh collides with another one */
  26012. onCollide: () => void;
  26013. /**
  26014. * An event triggered when the collision's position changes
  26015. */
  26016. onCollisionPositionChangeObservable: Observable<Vector3>;
  26017. /** Set a function to call when the collision's position changes */
  26018. onCollisionPositionChange: () => void;
  26019. /**
  26020. * An event triggered when material is changed
  26021. */
  26022. onMaterialChangedObservable: Observable<AbstractMesh>;
  26023. /**
  26024. * Gets or sets the orientation for POV movement & rotation
  26025. */
  26026. definedFacingForward: boolean;
  26027. /** @hidden */
  26028. _occlusionQuery: Nullable<WebGLQuery>;
  26029. /** @hidden */
  26030. _renderingGroup: Nullable<RenderingGroup>;
  26031. /**
  26032. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26033. */
  26034. /**
  26035. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26036. */
  26037. visibility: number;
  26038. /** Gets or sets the alpha index used to sort transparent meshes
  26039. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26040. */
  26041. alphaIndex: number;
  26042. /**
  26043. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26044. */
  26045. isVisible: boolean;
  26046. /**
  26047. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26048. */
  26049. isPickable: boolean;
  26050. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26051. showSubMeshesBoundingBox: boolean;
  26052. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26054. */
  26055. isBlocker: boolean;
  26056. /**
  26057. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26058. */
  26059. enablePointerMoveEvents: boolean;
  26060. /**
  26061. * Specifies the rendering group id for this mesh (0 by default)
  26062. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26063. */
  26064. renderingGroupId: number;
  26065. private _material;
  26066. /** Gets or sets current material */
  26067. material: Nullable<Material>;
  26068. /**
  26069. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26070. * @see http://doc.babylonjs.com/babylon101/shadows
  26071. */
  26072. receiveShadows: boolean;
  26073. /** Defines color to use when rendering outline */
  26074. outlineColor: Color3;
  26075. /** Define width to use when rendering outline */
  26076. outlineWidth: number;
  26077. /** Defines color to use when rendering overlay */
  26078. overlayColor: Color3;
  26079. /** Defines alpha to use when rendering overlay */
  26080. overlayAlpha: number;
  26081. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26082. hasVertexAlpha: boolean;
  26083. /** 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) */
  26084. useVertexColors: boolean;
  26085. /**
  26086. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26087. */
  26088. computeBonesUsingShaders: boolean;
  26089. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26090. numBoneInfluencers: number;
  26091. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26092. applyFog: boolean;
  26093. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26094. useOctreeForRenderingSelection: boolean;
  26095. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26096. useOctreeForPicking: boolean;
  26097. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26098. useOctreeForCollisions: boolean;
  26099. /**
  26100. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26101. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26102. */
  26103. layerMask: number;
  26104. /**
  26105. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26106. */
  26107. alwaysSelectAsActiveMesh: boolean;
  26108. /**
  26109. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26110. */
  26111. doNotSyncBoundingInfo: boolean;
  26112. /**
  26113. * Gets or sets the current action manager
  26114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26115. */
  26116. actionManager: Nullable<AbstractActionManager>;
  26117. private _meshCollisionData;
  26118. /**
  26119. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26121. */
  26122. ellipsoid: Vector3;
  26123. /**
  26124. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26126. */
  26127. ellipsoidOffset: Vector3;
  26128. /**
  26129. * Gets or sets a collision mask used to mask collisions (default is -1).
  26130. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26131. */
  26132. collisionMask: number;
  26133. /**
  26134. * Gets or sets the current collision group mask (-1 by default).
  26135. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26136. */
  26137. collisionGroup: number;
  26138. /**
  26139. * Defines edge width used when edgesRenderer is enabled
  26140. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26141. */
  26142. edgesWidth: number;
  26143. /**
  26144. * Defines edge color used when edgesRenderer is enabled
  26145. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26146. */
  26147. edgesColor: Color4;
  26148. /** @hidden */
  26149. _edgesRenderer: Nullable<IEdgesRenderer>;
  26150. /** @hidden */
  26151. _masterMesh: Nullable<AbstractMesh>;
  26152. /** @hidden */
  26153. _boundingInfo: Nullable<BoundingInfo>;
  26154. /** @hidden */
  26155. _renderId: number;
  26156. /**
  26157. * Gets or sets the list of subMeshes
  26158. * @see http://doc.babylonjs.com/how_to/multi_materials
  26159. */
  26160. subMeshes: SubMesh[];
  26161. /** @hidden */
  26162. _intersectionsInProgress: AbstractMesh[];
  26163. /** @hidden */
  26164. _unIndexed: boolean;
  26165. /** @hidden */
  26166. _lightSources: Light[];
  26167. /** Gets the list of lights affecting that mesh */
  26168. readonly lightSources: Light[];
  26169. /** @hidden */
  26170. readonly _positions: Nullable<Vector3[]>;
  26171. /** @hidden */
  26172. _waitingData: {
  26173. lods: Nullable<any>;
  26174. actions: Nullable<any>;
  26175. freezeWorldMatrix: Nullable<boolean>;
  26176. };
  26177. /** @hidden */
  26178. _bonesTransformMatrices: Nullable<Float32Array>;
  26179. /** @hidden */
  26180. _transformMatrixTexture: Nullable<RawTexture>;
  26181. /**
  26182. * Gets or sets a skeleton to apply skining transformations
  26183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26184. */
  26185. skeleton: Nullable<Skeleton>;
  26186. /**
  26187. * An event triggered when the mesh is rebuilt.
  26188. */
  26189. onRebuildObservable: Observable<AbstractMesh>;
  26190. /**
  26191. * Creates a new AbstractMesh
  26192. * @param name defines the name of the mesh
  26193. * @param scene defines the hosting scene
  26194. */
  26195. constructor(name: string, scene?: Nullable<Scene>);
  26196. /**
  26197. * Returns the string "AbstractMesh"
  26198. * @returns "AbstractMesh"
  26199. */
  26200. getClassName(): string;
  26201. /**
  26202. * Gets a string representation of the current mesh
  26203. * @param fullDetails defines a boolean indicating if full details must be included
  26204. * @returns a string representation of the current mesh
  26205. */
  26206. toString(fullDetails?: boolean): string;
  26207. /**
  26208. * @hidden
  26209. */
  26210. protected _getEffectiveParent(): Nullable<Node>;
  26211. /** @hidden */
  26212. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26213. /** @hidden */
  26214. _rebuild(): void;
  26215. /** @hidden */
  26216. _resyncLightSources(): void;
  26217. /** @hidden */
  26218. _resyncLighSource(light: Light): void;
  26219. /** @hidden */
  26220. _unBindEffect(): void;
  26221. /** @hidden */
  26222. _removeLightSource(light: Light, dispose: boolean): void;
  26223. private _markSubMeshesAsDirty;
  26224. /** @hidden */
  26225. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26226. /** @hidden */
  26227. _markSubMeshesAsAttributesDirty(): void;
  26228. /** @hidden */
  26229. _markSubMeshesAsMiscDirty(): void;
  26230. /**
  26231. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26232. */
  26233. scaling: Vector3;
  26234. /**
  26235. * Returns true if the mesh is blocked. Implemented by child classes
  26236. */
  26237. readonly isBlocked: boolean;
  26238. /**
  26239. * Returns the mesh itself by default. Implemented by child classes
  26240. * @param camera defines the camera to use to pick the right LOD level
  26241. * @returns the currentAbstractMesh
  26242. */
  26243. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26244. /**
  26245. * Returns 0 by default. Implemented by child classes
  26246. * @returns an integer
  26247. */
  26248. getTotalVertices(): number;
  26249. /**
  26250. * Returns a positive integer : the total number of indices in this mesh geometry.
  26251. * @returns the numner of indices or zero if the mesh has no geometry.
  26252. */
  26253. getTotalIndices(): number;
  26254. /**
  26255. * Returns null by default. Implemented by child classes
  26256. * @returns null
  26257. */
  26258. getIndices(): Nullable<IndicesArray>;
  26259. /**
  26260. * Returns the array of the requested vertex data kind. Implemented by child classes
  26261. * @param kind defines the vertex data kind to use
  26262. * @returns null
  26263. */
  26264. getVerticesData(kind: string): Nullable<FloatArray>;
  26265. /**
  26266. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26267. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26268. * Note that a new underlying VertexBuffer object is created each call.
  26269. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26270. * @param kind defines vertex data kind:
  26271. * * VertexBuffer.PositionKind
  26272. * * VertexBuffer.UVKind
  26273. * * VertexBuffer.UV2Kind
  26274. * * VertexBuffer.UV3Kind
  26275. * * VertexBuffer.UV4Kind
  26276. * * VertexBuffer.UV5Kind
  26277. * * VertexBuffer.UV6Kind
  26278. * * VertexBuffer.ColorKind
  26279. * * VertexBuffer.MatricesIndicesKind
  26280. * * VertexBuffer.MatricesIndicesExtraKind
  26281. * * VertexBuffer.MatricesWeightsKind
  26282. * * VertexBuffer.MatricesWeightsExtraKind
  26283. * @param data defines the data source
  26284. * @param updatable defines if the data must be flagged as updatable (or static)
  26285. * @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
  26286. * @returns the current mesh
  26287. */
  26288. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26289. /**
  26290. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26291. * If the mesh has no geometry, it is simply returned as it is.
  26292. * @param kind defines vertex data kind:
  26293. * * VertexBuffer.PositionKind
  26294. * * VertexBuffer.UVKind
  26295. * * VertexBuffer.UV2Kind
  26296. * * VertexBuffer.UV3Kind
  26297. * * VertexBuffer.UV4Kind
  26298. * * VertexBuffer.UV5Kind
  26299. * * VertexBuffer.UV6Kind
  26300. * * VertexBuffer.ColorKind
  26301. * * VertexBuffer.MatricesIndicesKind
  26302. * * VertexBuffer.MatricesIndicesExtraKind
  26303. * * VertexBuffer.MatricesWeightsKind
  26304. * * VertexBuffer.MatricesWeightsExtraKind
  26305. * @param data defines the data source
  26306. * @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
  26307. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26308. * @returns the current mesh
  26309. */
  26310. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26311. /**
  26312. * Sets the mesh indices,
  26313. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26314. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26315. * @param totalVertices Defines the total number of vertices
  26316. * @returns the current mesh
  26317. */
  26318. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26319. /**
  26320. * Gets a boolean indicating if specific vertex data is present
  26321. * @param kind defines the vertex data kind to use
  26322. * @returns true is data kind is present
  26323. */
  26324. isVerticesDataPresent(kind: string): boolean;
  26325. /**
  26326. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26327. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26328. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26329. * @returns a BoundingInfo
  26330. */
  26331. getBoundingInfo(): BoundingInfo;
  26332. /**
  26333. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26334. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26335. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26336. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26337. * @returns the current mesh
  26338. */
  26339. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26340. /**
  26341. * Overwrite the current bounding info
  26342. * @param boundingInfo defines the new bounding info
  26343. * @returns the current mesh
  26344. */
  26345. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26346. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26347. readonly useBones: boolean;
  26348. /** @hidden */
  26349. _preActivate(): void;
  26350. /** @hidden */
  26351. _preActivateForIntermediateRendering(renderId: number): void;
  26352. /** @hidden */
  26353. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26354. /** @hidden */
  26355. _postActivate(): void;
  26356. /** @hidden */
  26357. _freeze(): void;
  26358. /** @hidden */
  26359. _unFreeze(): void;
  26360. /**
  26361. * Gets the current world matrix
  26362. * @returns a Matrix
  26363. */
  26364. getWorldMatrix(): Matrix;
  26365. /** @hidden */
  26366. _getWorldMatrixDeterminant(): number;
  26367. /**
  26368. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26369. */
  26370. readonly isAnInstance: boolean;
  26371. /**
  26372. * Gets a boolean indicating if this mesh has instances
  26373. */
  26374. readonly hasInstances: boolean;
  26375. /**
  26376. * Perform relative position change from the point of view of behind the front of the mesh.
  26377. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26378. * Supports definition of mesh facing forward or backward
  26379. * @param amountRight defines the distance on the right axis
  26380. * @param amountUp defines the distance on the up axis
  26381. * @param amountForward defines the distance on the forward axis
  26382. * @returns the current mesh
  26383. */
  26384. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26385. /**
  26386. * Calculate relative position change from the point of view of behind the front of the mesh.
  26387. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26388. * Supports definition of mesh facing forward or backward
  26389. * @param amountRight defines the distance on the right axis
  26390. * @param amountUp defines the distance on the up axis
  26391. * @param amountForward defines the distance on the forward axis
  26392. * @returns the new displacement vector
  26393. */
  26394. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26395. /**
  26396. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26397. * Supports definition of mesh facing forward or backward
  26398. * @param flipBack defines the flip
  26399. * @param twirlClockwise defines the twirl
  26400. * @param tiltRight defines the tilt
  26401. * @returns the current mesh
  26402. */
  26403. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26404. /**
  26405. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26406. * Supports definition of mesh facing forward or backward.
  26407. * @param flipBack defines the flip
  26408. * @param twirlClockwise defines the twirl
  26409. * @param tiltRight defines the tilt
  26410. * @returns the new rotation vector
  26411. */
  26412. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26413. /**
  26414. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26415. * This means the mesh underlying bounding box and sphere are recomputed.
  26416. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26417. * @returns the current mesh
  26418. */
  26419. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26420. /** @hidden */
  26421. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26422. /** @hidden */
  26423. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26424. /** @hidden */
  26425. _updateBoundingInfo(): AbstractMesh;
  26426. /** @hidden */
  26427. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26428. /** @hidden */
  26429. protected _afterComputeWorldMatrix(): void;
  26430. /** @hidden */
  26431. readonly _effectiveMesh: AbstractMesh;
  26432. /**
  26433. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26434. * A mesh is in the frustum if its bounding box intersects the frustum
  26435. * @param frustumPlanes defines the frustum to test
  26436. * @returns true if the mesh is in the frustum planes
  26437. */
  26438. isInFrustum(frustumPlanes: Plane[]): boolean;
  26439. /**
  26440. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26441. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26442. * @param frustumPlanes defines the frustum to test
  26443. * @returns true if the mesh is completely in the frustum planes
  26444. */
  26445. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26446. /**
  26447. * True if the mesh intersects another mesh or a SolidParticle object
  26448. * @param mesh defines a target mesh or SolidParticle to test
  26449. * @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)
  26450. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26451. * @returns true if there is an intersection
  26452. */
  26453. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26454. /**
  26455. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26456. * @param point defines the point to test
  26457. * @returns true if there is an intersection
  26458. */
  26459. intersectsPoint(point: Vector3): boolean;
  26460. /**
  26461. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26463. */
  26464. checkCollisions: boolean;
  26465. /**
  26466. * Gets Collider object used to compute collisions (not physics)
  26467. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26468. */
  26469. readonly collider: Nullable<Collider>;
  26470. /**
  26471. * Move the mesh using collision engine
  26472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26473. * @param displacement defines the requested displacement vector
  26474. * @returns the current mesh
  26475. */
  26476. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26477. private _onCollisionPositionChange;
  26478. /** @hidden */
  26479. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26480. /** @hidden */
  26481. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26482. /** @hidden */
  26483. _checkCollision(collider: Collider): AbstractMesh;
  26484. /** @hidden */
  26485. _generatePointsArray(): boolean;
  26486. /**
  26487. * Checks if the passed Ray intersects with the mesh
  26488. * @param ray defines the ray to use
  26489. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26490. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26491. * @returns the picking info
  26492. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26493. */
  26494. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26495. /**
  26496. * Clones the current mesh
  26497. * @param name defines the mesh name
  26498. * @param newParent defines the new mesh parent
  26499. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26500. * @returns the new mesh
  26501. */
  26502. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26503. /**
  26504. * Disposes all the submeshes of the current meshnp
  26505. * @returns the current mesh
  26506. */
  26507. releaseSubMeshes(): AbstractMesh;
  26508. /**
  26509. * Releases resources associated with this abstract mesh.
  26510. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26511. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26512. */
  26513. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26514. /**
  26515. * Adds the passed mesh as a child to the current mesh
  26516. * @param mesh defines the child mesh
  26517. * @returns the current mesh
  26518. */
  26519. addChild(mesh: AbstractMesh): AbstractMesh;
  26520. /**
  26521. * Removes the passed mesh from the current mesh children list
  26522. * @param mesh defines the child mesh
  26523. * @returns the current mesh
  26524. */
  26525. removeChild(mesh: AbstractMesh): AbstractMesh;
  26526. /** @hidden */
  26527. private _initFacetData;
  26528. /**
  26529. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26530. * This method can be called within the render loop.
  26531. * 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
  26532. * @returns the current mesh
  26533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26534. */
  26535. updateFacetData(): AbstractMesh;
  26536. /**
  26537. * Returns the facetLocalNormals array.
  26538. * The normals are expressed in the mesh local spac
  26539. * @returns an array of Vector3
  26540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26541. */
  26542. getFacetLocalNormals(): Vector3[];
  26543. /**
  26544. * Returns the facetLocalPositions array.
  26545. * The facet positions are expressed in the mesh local space
  26546. * @returns an array of Vector3
  26547. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26548. */
  26549. getFacetLocalPositions(): Vector3[];
  26550. /**
  26551. * Returns the facetLocalPartioning array
  26552. * @returns an array of array of numbers
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26554. */
  26555. getFacetLocalPartitioning(): number[][];
  26556. /**
  26557. * Returns the i-th facet position in the world system.
  26558. * This method allocates a new Vector3 per call
  26559. * @param i defines the facet index
  26560. * @returns a new Vector3
  26561. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26562. */
  26563. getFacetPosition(i: number): Vector3;
  26564. /**
  26565. * Sets the reference Vector3 with the i-th facet position in the world system
  26566. * @param i defines the facet index
  26567. * @param ref defines the target vector
  26568. * @returns the current mesh
  26569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26570. */
  26571. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26572. /**
  26573. * Returns the i-th facet normal in the world system.
  26574. * This method allocates a new Vector3 per call
  26575. * @param i defines the facet index
  26576. * @returns a new Vector3
  26577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26578. */
  26579. getFacetNormal(i: number): Vector3;
  26580. /**
  26581. * Sets the reference Vector3 with the i-th facet normal in the world system
  26582. * @param i defines the facet index
  26583. * @param ref defines the target vector
  26584. * @returns the current mesh
  26585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26586. */
  26587. getFacetNormalToRef(i: number, ref: Vector3): this;
  26588. /**
  26589. * 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)
  26590. * @param x defines x coordinate
  26591. * @param y defines y coordinate
  26592. * @param z defines z coordinate
  26593. * @returns the array of facet indexes
  26594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26595. */
  26596. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26597. /**
  26598. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26599. * @param projected sets as the (x,y,z) world projection on the facet
  26600. * @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
  26601. * @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
  26602. * @param x defines x coordinate
  26603. * @param y defines y coordinate
  26604. * @param z defines z coordinate
  26605. * @returns the face index if found (or null instead)
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26607. */
  26608. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26609. /**
  26610. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26611. * @param projected sets as the (x,y,z) local projection on the facet
  26612. * @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
  26613. * @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
  26614. * @param x defines x coordinate
  26615. * @param y defines y coordinate
  26616. * @param z defines z coordinate
  26617. * @returns the face index if found (or null instead)
  26618. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26619. */
  26620. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26621. /**
  26622. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26623. * @returns the parameters
  26624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26625. */
  26626. getFacetDataParameters(): any;
  26627. /**
  26628. * Disables the feature FacetData and frees the related memory
  26629. * @returns the current mesh
  26630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26631. */
  26632. disableFacetData(): AbstractMesh;
  26633. /**
  26634. * Updates the AbstractMesh indices array
  26635. * @param indices defines the data source
  26636. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26637. * @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)
  26638. * @returns the current mesh
  26639. */
  26640. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26641. /**
  26642. * Creates new normals data for the mesh
  26643. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26644. * @returns the current mesh
  26645. */
  26646. createNormals(updatable: boolean): AbstractMesh;
  26647. /**
  26648. * Align the mesh with a normal
  26649. * @param normal defines the normal to use
  26650. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26651. * @returns the current mesh
  26652. */
  26653. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26654. /** @hidden */
  26655. _checkOcclusionQuery(): boolean;
  26656. /**
  26657. * Disables the mesh edge rendering mode
  26658. * @returns the currentAbstractMesh
  26659. */
  26660. disableEdgesRendering(): AbstractMesh;
  26661. /**
  26662. * Enables the edge rendering mode on the mesh.
  26663. * This mode makes the mesh edges visible
  26664. * @param epsilon defines the maximal distance between two angles to detect a face
  26665. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26666. * @returns the currentAbstractMesh
  26667. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26668. */
  26669. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26670. }
  26671. }
  26672. declare module BABYLON {
  26673. /**
  26674. * Interface used to define ActionEvent
  26675. */
  26676. export interface IActionEvent {
  26677. /** The mesh or sprite that triggered the action */
  26678. source: any;
  26679. /** The X mouse cursor position at the time of the event */
  26680. pointerX: number;
  26681. /** The Y mouse cursor position at the time of the event */
  26682. pointerY: number;
  26683. /** The mesh that is currently pointed at (can be null) */
  26684. meshUnderPointer: Nullable<AbstractMesh>;
  26685. /** the original (browser) event that triggered the ActionEvent */
  26686. sourceEvent?: any;
  26687. /** additional data for the event */
  26688. additionalData?: any;
  26689. }
  26690. /**
  26691. * ActionEvent is the event being sent when an action is triggered.
  26692. */
  26693. export class ActionEvent implements IActionEvent {
  26694. /** The mesh or sprite that triggered the action */
  26695. source: any;
  26696. /** The X mouse cursor position at the time of the event */
  26697. pointerX: number;
  26698. /** The Y mouse cursor position at the time of the event */
  26699. pointerY: number;
  26700. /** The mesh that is currently pointed at (can be null) */
  26701. meshUnderPointer: Nullable<AbstractMesh>;
  26702. /** the original (browser) event that triggered the ActionEvent */
  26703. sourceEvent?: any;
  26704. /** additional data for the event */
  26705. additionalData?: any;
  26706. /**
  26707. * Creates a new ActionEvent
  26708. * @param source The mesh or sprite that triggered the action
  26709. * @param pointerX The X mouse cursor position at the time of the event
  26710. * @param pointerY The Y mouse cursor position at the time of the event
  26711. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26712. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26713. * @param additionalData additional data for the event
  26714. */
  26715. constructor(
  26716. /** The mesh or sprite that triggered the action */
  26717. source: any,
  26718. /** The X mouse cursor position at the time of the event */
  26719. pointerX: number,
  26720. /** The Y mouse cursor position at the time of the event */
  26721. pointerY: number,
  26722. /** The mesh that is currently pointed at (can be null) */
  26723. meshUnderPointer: Nullable<AbstractMesh>,
  26724. /** the original (browser) event that triggered the ActionEvent */
  26725. sourceEvent?: any,
  26726. /** additional data for the event */
  26727. additionalData?: any);
  26728. /**
  26729. * Helper function to auto-create an ActionEvent from a source mesh.
  26730. * @param source The source mesh that triggered the event
  26731. * @param evt The original (browser) event
  26732. * @param additionalData additional data for the event
  26733. * @returns the new ActionEvent
  26734. */
  26735. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26736. /**
  26737. * Helper function to auto-create an ActionEvent from a source sprite
  26738. * @param source The source sprite that triggered the event
  26739. * @param scene Scene associated with the sprite
  26740. * @param evt The original (browser) event
  26741. * @param additionalData additional data for the event
  26742. * @returns the new ActionEvent
  26743. */
  26744. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26745. /**
  26746. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26747. * @param scene the scene where the event occurred
  26748. * @param evt The original (browser) event
  26749. * @returns the new ActionEvent
  26750. */
  26751. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26752. /**
  26753. * Helper function to auto-create an ActionEvent from a primitive
  26754. * @param prim defines the target primitive
  26755. * @param pointerPos defines the pointer position
  26756. * @param evt The original (browser) event
  26757. * @param additionalData additional data for the event
  26758. * @returns the new ActionEvent
  26759. */
  26760. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26761. }
  26762. }
  26763. declare module BABYLON {
  26764. /**
  26765. * Abstract class used to decouple action Manager from scene and meshes.
  26766. * Do not instantiate.
  26767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26768. */
  26769. export abstract class AbstractActionManager implements IDisposable {
  26770. /** Gets the list of active triggers */
  26771. static Triggers: {
  26772. [key: string]: number;
  26773. };
  26774. /** Gets the cursor to use when hovering items */
  26775. hoverCursor: string;
  26776. /** Gets the list of actions */
  26777. actions: IAction[];
  26778. /**
  26779. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26780. */
  26781. isRecursive: boolean;
  26782. /**
  26783. * Releases all associated resources
  26784. */
  26785. abstract dispose(): void;
  26786. /**
  26787. * Does this action manager has pointer triggers
  26788. */
  26789. abstract readonly hasPointerTriggers: boolean;
  26790. /**
  26791. * Does this action manager has pick triggers
  26792. */
  26793. abstract readonly hasPickTriggers: boolean;
  26794. /**
  26795. * Process a specific trigger
  26796. * @param trigger defines the trigger to process
  26797. * @param evt defines the event details to be processed
  26798. */
  26799. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26800. /**
  26801. * Does this action manager handles actions of any of the given triggers
  26802. * @param triggers defines the triggers to be tested
  26803. * @return a boolean indicating whether one (or more) of the triggers is handled
  26804. */
  26805. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26806. /**
  26807. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26808. * speed.
  26809. * @param triggerA defines the trigger to be tested
  26810. * @param triggerB defines the trigger to be tested
  26811. * @return a boolean indicating whether one (or more) of the triggers is handled
  26812. */
  26813. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26814. /**
  26815. * Does this action manager handles actions of a given trigger
  26816. * @param trigger defines the trigger to be tested
  26817. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26818. * @return whether the trigger is handled
  26819. */
  26820. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26821. /**
  26822. * Serialize this manager to a JSON object
  26823. * @param name defines the property name to store this manager
  26824. * @returns a JSON representation of this manager
  26825. */
  26826. abstract serialize(name: string): any;
  26827. /**
  26828. * Registers an action to this action manager
  26829. * @param action defines the action to be registered
  26830. * @return the action amended (prepared) after registration
  26831. */
  26832. abstract registerAction(action: IAction): Nullable<IAction>;
  26833. /**
  26834. * Unregisters an action to this action manager
  26835. * @param action defines the action to be unregistered
  26836. * @return a boolean indicating whether the action has been unregistered
  26837. */
  26838. abstract unregisterAction(action: IAction): Boolean;
  26839. /**
  26840. * Does exist one action manager with at least one trigger
  26841. **/
  26842. static readonly HasTriggers: boolean;
  26843. /**
  26844. * Does exist one action manager with at least one pick trigger
  26845. **/
  26846. static readonly HasPickTriggers: boolean;
  26847. /**
  26848. * Does exist one action manager that handles actions of a given trigger
  26849. * @param trigger defines the trigger to be tested
  26850. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26851. **/
  26852. static HasSpecificTrigger(trigger: number): boolean;
  26853. }
  26854. }
  26855. declare module BABYLON {
  26856. /**
  26857. * Defines how a node can be built from a string name.
  26858. */
  26859. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26860. /**
  26861. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26862. */
  26863. export class Node implements IBehaviorAware<Node> {
  26864. /** @hidden */
  26865. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26866. private static _NodeConstructors;
  26867. /**
  26868. * Add a new node constructor
  26869. * @param type defines the type name of the node to construct
  26870. * @param constructorFunc defines the constructor function
  26871. */
  26872. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26873. /**
  26874. * Returns a node constructor based on type name
  26875. * @param type defines the type name
  26876. * @param name defines the new node name
  26877. * @param scene defines the hosting scene
  26878. * @param options defines optional options to transmit to constructors
  26879. * @returns the new constructor or null
  26880. */
  26881. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26882. /**
  26883. * Gets or sets the name of the node
  26884. */
  26885. name: string;
  26886. /**
  26887. * Gets or sets the id of the node
  26888. */
  26889. id: string;
  26890. /**
  26891. * Gets or sets the unique id of the node
  26892. */
  26893. uniqueId: number;
  26894. /**
  26895. * Gets or sets a string used to store user defined state for the node
  26896. */
  26897. state: string;
  26898. /**
  26899. * Gets or sets an object used to store user defined information for the node
  26900. */
  26901. metadata: any;
  26902. /**
  26903. * For internal use only. Please do not use.
  26904. */
  26905. reservedDataStore: any;
  26906. /**
  26907. * List of inspectable custom properties (used by the Inspector)
  26908. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26909. */
  26910. inspectableCustomProperties: IInspectable[];
  26911. private _doNotSerialize;
  26912. /**
  26913. * Gets or sets a boolean used to define if the node must be serialized
  26914. */
  26915. doNotSerialize: boolean;
  26916. /** @hidden */
  26917. _isDisposed: boolean;
  26918. /**
  26919. * Gets a list of Animations associated with the node
  26920. */
  26921. animations: Animation[];
  26922. protected _ranges: {
  26923. [name: string]: Nullable<AnimationRange>;
  26924. };
  26925. /**
  26926. * Callback raised when the node is ready to be used
  26927. */
  26928. onReady: Nullable<(node: Node) => void>;
  26929. private _isEnabled;
  26930. private _isParentEnabled;
  26931. private _isReady;
  26932. /** @hidden */
  26933. _currentRenderId: number;
  26934. private _parentUpdateId;
  26935. /** @hidden */
  26936. _childUpdateId: number;
  26937. /** @hidden */
  26938. _waitingParentId: Nullable<string>;
  26939. /** @hidden */
  26940. _scene: Scene;
  26941. /** @hidden */
  26942. _cache: any;
  26943. private _parentNode;
  26944. private _children;
  26945. /** @hidden */
  26946. _worldMatrix: Matrix;
  26947. /** @hidden */
  26948. _worldMatrixDeterminant: number;
  26949. /** @hidden */
  26950. _worldMatrixDeterminantIsDirty: boolean;
  26951. /** @hidden */
  26952. private _sceneRootNodesIndex;
  26953. /**
  26954. * Gets a boolean indicating if the node has been disposed
  26955. * @returns true if the node was disposed
  26956. */
  26957. isDisposed(): boolean;
  26958. /**
  26959. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26960. * @see https://doc.babylonjs.com/how_to/parenting
  26961. */
  26962. parent: Nullable<Node>;
  26963. private addToSceneRootNodes;
  26964. private removeFromSceneRootNodes;
  26965. private _animationPropertiesOverride;
  26966. /**
  26967. * Gets or sets the animation properties override
  26968. */
  26969. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26970. /**
  26971. * Gets a string idenfifying the name of the class
  26972. * @returns "Node" string
  26973. */
  26974. getClassName(): string;
  26975. /** @hidden */
  26976. readonly _isNode: boolean;
  26977. /**
  26978. * An event triggered when the mesh is disposed
  26979. */
  26980. onDisposeObservable: Observable<Node>;
  26981. private _onDisposeObserver;
  26982. /**
  26983. * Sets a callback that will be raised when the node will be disposed
  26984. */
  26985. onDispose: () => void;
  26986. /**
  26987. * Creates a new Node
  26988. * @param name the name and id to be given to this node
  26989. * @param scene the scene this node will be added to
  26990. * @param addToRootNodes the node will be added to scene.rootNodes
  26991. */
  26992. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26993. /**
  26994. * Gets the scene of the node
  26995. * @returns a scene
  26996. */
  26997. getScene(): Scene;
  26998. /**
  26999. * Gets the engine of the node
  27000. * @returns a Engine
  27001. */
  27002. getEngine(): Engine;
  27003. private _behaviors;
  27004. /**
  27005. * Attach a behavior to the node
  27006. * @see http://doc.babylonjs.com/features/behaviour
  27007. * @param behavior defines the behavior to attach
  27008. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27009. * @returns the current Node
  27010. */
  27011. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27012. /**
  27013. * Remove an attached behavior
  27014. * @see http://doc.babylonjs.com/features/behaviour
  27015. * @param behavior defines the behavior to attach
  27016. * @returns the current Node
  27017. */
  27018. removeBehavior(behavior: Behavior<Node>): Node;
  27019. /**
  27020. * Gets the list of attached behaviors
  27021. * @see http://doc.babylonjs.com/features/behaviour
  27022. */
  27023. readonly behaviors: Behavior<Node>[];
  27024. /**
  27025. * Gets an attached behavior by name
  27026. * @param name defines the name of the behavior to look for
  27027. * @see http://doc.babylonjs.com/features/behaviour
  27028. * @returns null if behavior was not found else the requested behavior
  27029. */
  27030. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27031. /**
  27032. * Returns the latest update of the World matrix
  27033. * @returns a Matrix
  27034. */
  27035. getWorldMatrix(): Matrix;
  27036. /** @hidden */
  27037. _getWorldMatrixDeterminant(): number;
  27038. /**
  27039. * Returns directly the latest state of the mesh World matrix.
  27040. * A Matrix is returned.
  27041. */
  27042. readonly worldMatrixFromCache: Matrix;
  27043. /** @hidden */
  27044. _initCache(): void;
  27045. /** @hidden */
  27046. updateCache(force?: boolean): void;
  27047. /** @hidden */
  27048. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27049. /** @hidden */
  27050. _updateCache(ignoreParentClass?: boolean): void;
  27051. /** @hidden */
  27052. _isSynchronized(): boolean;
  27053. /** @hidden */
  27054. _markSyncedWithParent(): void;
  27055. /** @hidden */
  27056. isSynchronizedWithParent(): boolean;
  27057. /** @hidden */
  27058. isSynchronized(): boolean;
  27059. /**
  27060. * Is this node ready to be used/rendered
  27061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27062. * @return true if the node is ready
  27063. */
  27064. isReady(completeCheck?: boolean): boolean;
  27065. /**
  27066. * Is this node enabled?
  27067. * 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
  27068. * @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
  27069. * @return whether this node (and its parent) is enabled
  27070. */
  27071. isEnabled(checkAncestors?: boolean): boolean;
  27072. /** @hidden */
  27073. protected _syncParentEnabledState(): void;
  27074. /**
  27075. * Set the enabled state of this node
  27076. * @param value defines the new enabled state
  27077. */
  27078. setEnabled(value: boolean): void;
  27079. /**
  27080. * Is this node a descendant of the given node?
  27081. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27082. * @param ancestor defines the parent node to inspect
  27083. * @returns a boolean indicating if this node is a descendant of the given node
  27084. */
  27085. isDescendantOf(ancestor: Node): boolean;
  27086. /** @hidden */
  27087. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27088. /**
  27089. * Will return all nodes that have this node as ascendant
  27090. * @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
  27091. * @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
  27092. * @return all children nodes of all types
  27093. */
  27094. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27095. /**
  27096. * Get all child-meshes of this node
  27097. * @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)
  27098. * @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
  27099. * @returns an array of AbstractMesh
  27100. */
  27101. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27102. /**
  27103. * Get all direct children of this node
  27104. * @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
  27105. * @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)
  27106. * @returns an array of Node
  27107. */
  27108. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27109. /** @hidden */
  27110. _setReady(state: boolean): void;
  27111. /**
  27112. * Get an animation by name
  27113. * @param name defines the name of the animation to look for
  27114. * @returns null if not found else the requested animation
  27115. */
  27116. getAnimationByName(name: string): Nullable<Animation>;
  27117. /**
  27118. * Creates an animation range for this node
  27119. * @param name defines the name of the range
  27120. * @param from defines the starting key
  27121. * @param to defines the end key
  27122. */
  27123. createAnimationRange(name: string, from: number, to: number): void;
  27124. /**
  27125. * Delete a specific animation range
  27126. * @param name defines the name of the range to delete
  27127. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27128. */
  27129. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27130. /**
  27131. * Get an animation range by name
  27132. * @param name defines the name of the animation range to look for
  27133. * @returns null if not found else the requested animation range
  27134. */
  27135. getAnimationRange(name: string): Nullable<AnimationRange>;
  27136. /**
  27137. * Gets the list of all animation ranges defined on this node
  27138. * @returns an array
  27139. */
  27140. getAnimationRanges(): Nullable<AnimationRange>[];
  27141. /**
  27142. * Will start the animation sequence
  27143. * @param name defines the range frames for animation sequence
  27144. * @param loop defines if the animation should loop (false by default)
  27145. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27146. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27147. * @returns the object created for this animation. If range does not exist, it will return null
  27148. */
  27149. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27150. /**
  27151. * Serialize animation ranges into a JSON compatible object
  27152. * @returns serialization object
  27153. */
  27154. serializeAnimationRanges(): any;
  27155. /**
  27156. * Computes the world matrix of the node
  27157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27158. * @returns the world matrix
  27159. */
  27160. computeWorldMatrix(force?: boolean): Matrix;
  27161. /**
  27162. * Releases resources associated with this node.
  27163. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27164. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27165. */
  27166. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27167. /**
  27168. * Parse animation range data from a serialization object and store them into a given node
  27169. * @param node defines where to store the animation ranges
  27170. * @param parsedNode defines the serialization object to read data from
  27171. * @param scene defines the hosting scene
  27172. */
  27173. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27174. /**
  27175. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27176. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27177. * @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
  27178. * @returns the new bounding vectors
  27179. */
  27180. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27181. min: Vector3;
  27182. max: Vector3;
  27183. };
  27184. }
  27185. }
  27186. declare module BABYLON {
  27187. /**
  27188. * @hidden
  27189. */
  27190. export class _IAnimationState {
  27191. key: number;
  27192. repeatCount: number;
  27193. workValue?: any;
  27194. loopMode?: number;
  27195. offsetValue?: any;
  27196. highLimitValue?: any;
  27197. }
  27198. /**
  27199. * Class used to store any kind of animation
  27200. */
  27201. export class Animation {
  27202. /**Name of the animation */
  27203. name: string;
  27204. /**Property to animate */
  27205. targetProperty: string;
  27206. /**The frames per second of the animation */
  27207. framePerSecond: number;
  27208. /**The data type of the animation */
  27209. dataType: number;
  27210. /**The loop mode of the animation */
  27211. loopMode?: number | undefined;
  27212. /**Specifies if blending should be enabled */
  27213. enableBlending?: boolean | undefined;
  27214. /**
  27215. * Use matrix interpolation instead of using direct key value when animating matrices
  27216. */
  27217. static AllowMatricesInterpolation: boolean;
  27218. /**
  27219. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27220. */
  27221. static AllowMatrixDecomposeForInterpolation: boolean;
  27222. /**
  27223. * Stores the key frames of the animation
  27224. */
  27225. private _keys;
  27226. /**
  27227. * Stores the easing function of the animation
  27228. */
  27229. private _easingFunction;
  27230. /**
  27231. * @hidden Internal use only
  27232. */
  27233. _runtimeAnimations: RuntimeAnimation[];
  27234. /**
  27235. * The set of event that will be linked to this animation
  27236. */
  27237. private _events;
  27238. /**
  27239. * Stores an array of target property paths
  27240. */
  27241. targetPropertyPath: string[];
  27242. /**
  27243. * Stores the blending speed of the animation
  27244. */
  27245. blendingSpeed: number;
  27246. /**
  27247. * Stores the animation ranges for the animation
  27248. */
  27249. private _ranges;
  27250. /**
  27251. * @hidden Internal use
  27252. */
  27253. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27254. /**
  27255. * Sets up an animation
  27256. * @param property The property to animate
  27257. * @param animationType The animation type to apply
  27258. * @param framePerSecond The frames per second of the animation
  27259. * @param easingFunction The easing function used in the animation
  27260. * @returns The created animation
  27261. */
  27262. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27263. /**
  27264. * Create and start an animation on a node
  27265. * @param name defines the name of the global animation that will be run on all nodes
  27266. * @param node defines the root node where the animation will take place
  27267. * @param targetProperty defines property to animate
  27268. * @param framePerSecond defines the number of frame per second yo use
  27269. * @param totalFrame defines the number of frames in total
  27270. * @param from defines the initial value
  27271. * @param to defines the final value
  27272. * @param loopMode defines which loop mode you want to use (off by default)
  27273. * @param easingFunction defines the easing function to use (linear by default)
  27274. * @param onAnimationEnd defines the callback to call when animation end
  27275. * @returns the animatable created for this animation
  27276. */
  27277. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27278. /**
  27279. * Create and start an animation on a node and its descendants
  27280. * @param name defines the name of the global animation that will be run on all nodes
  27281. * @param node defines the root node where the animation will take place
  27282. * @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
  27283. * @param targetProperty defines property to animate
  27284. * @param framePerSecond defines the number of frame per second to use
  27285. * @param totalFrame defines the number of frames in total
  27286. * @param from defines the initial value
  27287. * @param to defines the final value
  27288. * @param loopMode defines which loop mode you want to use (off by default)
  27289. * @param easingFunction defines the easing function to use (linear by default)
  27290. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27291. * @returns the list of animatables created for all nodes
  27292. * @example https://www.babylonjs-playground.com/#MH0VLI
  27293. */
  27294. 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[]>;
  27295. /**
  27296. * Creates a new animation, merges it with the existing animations and starts it
  27297. * @param name Name of the animation
  27298. * @param node Node which contains the scene that begins the animations
  27299. * @param targetProperty Specifies which property to animate
  27300. * @param framePerSecond The frames per second of the animation
  27301. * @param totalFrame The total number of frames
  27302. * @param from The frame at the beginning of the animation
  27303. * @param to The frame at the end of the animation
  27304. * @param loopMode Specifies the loop mode of the animation
  27305. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27306. * @param onAnimationEnd Callback to run once the animation is complete
  27307. * @returns Nullable animation
  27308. */
  27309. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27310. /**
  27311. * Transition property of an host to the target Value
  27312. * @param property The property to transition
  27313. * @param targetValue The target Value of the property
  27314. * @param host The object where the property to animate belongs
  27315. * @param scene Scene used to run the animation
  27316. * @param frameRate Framerate (in frame/s) to use
  27317. * @param transition The transition type we want to use
  27318. * @param duration The duration of the animation, in milliseconds
  27319. * @param onAnimationEnd Callback trigger at the end of the animation
  27320. * @returns Nullable animation
  27321. */
  27322. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27323. /**
  27324. * Return the array of runtime animations currently using this animation
  27325. */
  27326. readonly runtimeAnimations: RuntimeAnimation[];
  27327. /**
  27328. * Specifies if any of the runtime animations are currently running
  27329. */
  27330. readonly hasRunningRuntimeAnimations: boolean;
  27331. /**
  27332. * Initializes the animation
  27333. * @param name Name of the animation
  27334. * @param targetProperty Property to animate
  27335. * @param framePerSecond The frames per second of the animation
  27336. * @param dataType The data type of the animation
  27337. * @param loopMode The loop mode of the animation
  27338. * @param enableBlending Specifies if blending should be enabled
  27339. */
  27340. constructor(
  27341. /**Name of the animation */
  27342. name: string,
  27343. /**Property to animate */
  27344. targetProperty: string,
  27345. /**The frames per second of the animation */
  27346. framePerSecond: number,
  27347. /**The data type of the animation */
  27348. dataType: number,
  27349. /**The loop mode of the animation */
  27350. loopMode?: number | undefined,
  27351. /**Specifies if blending should be enabled */
  27352. enableBlending?: boolean | undefined);
  27353. /**
  27354. * Converts the animation to a string
  27355. * @param fullDetails support for multiple levels of logging within scene loading
  27356. * @returns String form of the animation
  27357. */
  27358. toString(fullDetails?: boolean): string;
  27359. /**
  27360. * Add an event to this animation
  27361. * @param event Event to add
  27362. */
  27363. addEvent(event: AnimationEvent): void;
  27364. /**
  27365. * Remove all events found at the given frame
  27366. * @param frame The frame to remove events from
  27367. */
  27368. removeEvents(frame: number): void;
  27369. /**
  27370. * Retrieves all the events from the animation
  27371. * @returns Events from the animation
  27372. */
  27373. getEvents(): AnimationEvent[];
  27374. /**
  27375. * Creates an animation range
  27376. * @param name Name of the animation range
  27377. * @param from Starting frame of the animation range
  27378. * @param to Ending frame of the animation
  27379. */
  27380. createRange(name: string, from: number, to: number): void;
  27381. /**
  27382. * Deletes an animation range by name
  27383. * @param name Name of the animation range to delete
  27384. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27385. */
  27386. deleteRange(name: string, deleteFrames?: boolean): void;
  27387. /**
  27388. * Gets the animation range by name, or null if not defined
  27389. * @param name Name of the animation range
  27390. * @returns Nullable animation range
  27391. */
  27392. getRange(name: string): Nullable<AnimationRange>;
  27393. /**
  27394. * Gets the key frames from the animation
  27395. * @returns The key frames of the animation
  27396. */
  27397. getKeys(): Array<IAnimationKey>;
  27398. /**
  27399. * Gets the highest frame rate of the animation
  27400. * @returns Highest frame rate of the animation
  27401. */
  27402. getHighestFrame(): number;
  27403. /**
  27404. * Gets the easing function of the animation
  27405. * @returns Easing function of the animation
  27406. */
  27407. getEasingFunction(): IEasingFunction;
  27408. /**
  27409. * Sets the easing function of the animation
  27410. * @param easingFunction A custom mathematical formula for animation
  27411. */
  27412. setEasingFunction(easingFunction: EasingFunction): void;
  27413. /**
  27414. * Interpolates a scalar linearly
  27415. * @param startValue Start value of the animation curve
  27416. * @param endValue End value of the animation curve
  27417. * @param gradient Scalar amount to interpolate
  27418. * @returns Interpolated scalar value
  27419. */
  27420. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27421. /**
  27422. * Interpolates a scalar cubically
  27423. * @param startValue Start value of the animation curve
  27424. * @param outTangent End tangent of the animation
  27425. * @param endValue End value of the animation curve
  27426. * @param inTangent Start tangent of the animation curve
  27427. * @param gradient Scalar amount to interpolate
  27428. * @returns Interpolated scalar value
  27429. */
  27430. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27431. /**
  27432. * Interpolates a quaternion using a spherical linear interpolation
  27433. * @param startValue Start value of the animation curve
  27434. * @param endValue End value of the animation curve
  27435. * @param gradient Scalar amount to interpolate
  27436. * @returns Interpolated quaternion value
  27437. */
  27438. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27439. /**
  27440. * Interpolates a quaternion cubically
  27441. * @param startValue Start value of the animation curve
  27442. * @param outTangent End tangent of the animation curve
  27443. * @param endValue End value of the animation curve
  27444. * @param inTangent Start tangent of the animation curve
  27445. * @param gradient Scalar amount to interpolate
  27446. * @returns Interpolated quaternion value
  27447. */
  27448. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27449. /**
  27450. * Interpolates a Vector3 linearl
  27451. * @param startValue Start value of the animation curve
  27452. * @param endValue End value of the animation curve
  27453. * @param gradient Scalar amount to interpolate
  27454. * @returns Interpolated scalar value
  27455. */
  27456. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27457. /**
  27458. * Interpolates a Vector3 cubically
  27459. * @param startValue Start value of the animation curve
  27460. * @param outTangent End tangent of the animation
  27461. * @param endValue End value of the animation curve
  27462. * @param inTangent Start tangent of the animation curve
  27463. * @param gradient Scalar amount to interpolate
  27464. * @returns InterpolatedVector3 value
  27465. */
  27466. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27467. /**
  27468. * Interpolates a Vector2 linearly
  27469. * @param startValue Start value of the animation curve
  27470. * @param endValue End value of the animation curve
  27471. * @param gradient Scalar amount to interpolate
  27472. * @returns Interpolated Vector2 value
  27473. */
  27474. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27475. /**
  27476. * Interpolates a Vector2 cubically
  27477. * @param startValue Start value of the animation curve
  27478. * @param outTangent End tangent of the animation
  27479. * @param endValue End value of the animation curve
  27480. * @param inTangent Start tangent of the animation curve
  27481. * @param gradient Scalar amount to interpolate
  27482. * @returns Interpolated Vector2 value
  27483. */
  27484. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27485. /**
  27486. * Interpolates a size linearly
  27487. * @param startValue Start value of the animation curve
  27488. * @param endValue End value of the animation curve
  27489. * @param gradient Scalar amount to interpolate
  27490. * @returns Interpolated Size value
  27491. */
  27492. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27493. /**
  27494. * Interpolates a Color3 linearly
  27495. * @param startValue Start value of the animation curve
  27496. * @param endValue End value of the animation curve
  27497. * @param gradient Scalar amount to interpolate
  27498. * @returns Interpolated Color3 value
  27499. */
  27500. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27501. /**
  27502. * @hidden Internal use only
  27503. */
  27504. _getKeyValue(value: any): any;
  27505. /**
  27506. * @hidden Internal use only
  27507. */
  27508. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27509. /**
  27510. * Defines the function to use to interpolate matrices
  27511. * @param startValue defines the start matrix
  27512. * @param endValue defines the end matrix
  27513. * @param gradient defines the gradient between both matrices
  27514. * @param result defines an optional target matrix where to store the interpolation
  27515. * @returns the interpolated matrix
  27516. */
  27517. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27518. /**
  27519. * Makes a copy of the animation
  27520. * @returns Cloned animation
  27521. */
  27522. clone(): Animation;
  27523. /**
  27524. * Sets the key frames of the animation
  27525. * @param values The animation key frames to set
  27526. */
  27527. setKeys(values: Array<IAnimationKey>): void;
  27528. /**
  27529. * Serializes the animation to an object
  27530. * @returns Serialized object
  27531. */
  27532. serialize(): any;
  27533. /**
  27534. * Float animation type
  27535. */
  27536. private static _ANIMATIONTYPE_FLOAT;
  27537. /**
  27538. * Vector3 animation type
  27539. */
  27540. private static _ANIMATIONTYPE_VECTOR3;
  27541. /**
  27542. * Quaternion animation type
  27543. */
  27544. private static _ANIMATIONTYPE_QUATERNION;
  27545. /**
  27546. * Matrix animation type
  27547. */
  27548. private static _ANIMATIONTYPE_MATRIX;
  27549. /**
  27550. * Color3 animation type
  27551. */
  27552. private static _ANIMATIONTYPE_COLOR3;
  27553. /**
  27554. * Vector2 animation type
  27555. */
  27556. private static _ANIMATIONTYPE_VECTOR2;
  27557. /**
  27558. * Size animation type
  27559. */
  27560. private static _ANIMATIONTYPE_SIZE;
  27561. /**
  27562. * Relative Loop Mode
  27563. */
  27564. private static _ANIMATIONLOOPMODE_RELATIVE;
  27565. /**
  27566. * Cycle Loop Mode
  27567. */
  27568. private static _ANIMATIONLOOPMODE_CYCLE;
  27569. /**
  27570. * Constant Loop Mode
  27571. */
  27572. private static _ANIMATIONLOOPMODE_CONSTANT;
  27573. /**
  27574. * Get the float animation type
  27575. */
  27576. static readonly ANIMATIONTYPE_FLOAT: number;
  27577. /**
  27578. * Get the Vector3 animation type
  27579. */
  27580. static readonly ANIMATIONTYPE_VECTOR3: number;
  27581. /**
  27582. * Get the Vector2 animation type
  27583. */
  27584. static readonly ANIMATIONTYPE_VECTOR2: number;
  27585. /**
  27586. * Get the Size animation type
  27587. */
  27588. static readonly ANIMATIONTYPE_SIZE: number;
  27589. /**
  27590. * Get the Quaternion animation type
  27591. */
  27592. static readonly ANIMATIONTYPE_QUATERNION: number;
  27593. /**
  27594. * Get the Matrix animation type
  27595. */
  27596. static readonly ANIMATIONTYPE_MATRIX: number;
  27597. /**
  27598. * Get the Color3 animation type
  27599. */
  27600. static readonly ANIMATIONTYPE_COLOR3: number;
  27601. /**
  27602. * Get the Relative Loop Mode
  27603. */
  27604. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27605. /**
  27606. * Get the Cycle Loop Mode
  27607. */
  27608. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27609. /**
  27610. * Get the Constant Loop Mode
  27611. */
  27612. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27613. /** @hidden */
  27614. static _UniversalLerp(left: any, right: any, amount: number): any;
  27615. /**
  27616. * Parses an animation object and creates an animation
  27617. * @param parsedAnimation Parsed animation object
  27618. * @returns Animation object
  27619. */
  27620. static Parse(parsedAnimation: any): Animation;
  27621. /**
  27622. * Appends the serialized animations from the source animations
  27623. * @param source Source containing the animations
  27624. * @param destination Target to store the animations
  27625. */
  27626. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27627. }
  27628. }
  27629. declare module BABYLON {
  27630. /**
  27631. * Interface containing an array of animations
  27632. */
  27633. export interface IAnimatable {
  27634. /**
  27635. * Array of animations
  27636. */
  27637. animations: Nullable<Array<Animation>>;
  27638. }
  27639. }
  27640. declare module BABYLON {
  27641. /**
  27642. * This represents all the required information to add a fresnel effect on a material:
  27643. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27644. */
  27645. export class FresnelParameters {
  27646. private _isEnabled;
  27647. /**
  27648. * Define if the fresnel effect is enable or not.
  27649. */
  27650. isEnabled: boolean;
  27651. /**
  27652. * Define the color used on edges (grazing angle)
  27653. */
  27654. leftColor: Color3;
  27655. /**
  27656. * Define the color used on center
  27657. */
  27658. rightColor: Color3;
  27659. /**
  27660. * Define bias applied to computed fresnel term
  27661. */
  27662. bias: number;
  27663. /**
  27664. * Defined the power exponent applied to fresnel term
  27665. */
  27666. power: number;
  27667. /**
  27668. * Clones the current fresnel and its valuues
  27669. * @returns a clone fresnel configuration
  27670. */
  27671. clone(): FresnelParameters;
  27672. /**
  27673. * Serializes the current fresnel parameters to a JSON representation.
  27674. * @return the JSON serialization
  27675. */
  27676. serialize(): any;
  27677. /**
  27678. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27679. * @param parsedFresnelParameters Define the JSON representation
  27680. * @returns the parsed parameters
  27681. */
  27682. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27683. }
  27684. }
  27685. declare module BABYLON {
  27686. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27687. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27688. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27689. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27690. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27691. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27692. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27693. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27694. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27695. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27696. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27697. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27698. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27699. /**
  27700. * Decorator used to define property that can be serialized as reference to a camera
  27701. * @param sourceName defines the name of the property to decorate
  27702. */
  27703. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27704. /**
  27705. * Class used to help serialization objects
  27706. */
  27707. export class SerializationHelper {
  27708. /** @hidden */
  27709. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27710. /** @hidden */
  27711. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27712. /** @hidden */
  27713. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27714. /** @hidden */
  27715. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27716. /**
  27717. * Appends the serialized animations from the source animations
  27718. * @param source Source containing the animations
  27719. * @param destination Target to store the animations
  27720. */
  27721. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27722. /**
  27723. * Static function used to serialized a specific entity
  27724. * @param entity defines the entity to serialize
  27725. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27726. * @returns a JSON compatible object representing the serialization of the entity
  27727. */
  27728. static Serialize<T>(entity: T, serializationObject?: any): any;
  27729. /**
  27730. * Creates a new entity from a serialization data object
  27731. * @param creationFunction defines a function used to instanciated the new entity
  27732. * @param source defines the source serialization data
  27733. * @param scene defines the hosting scene
  27734. * @param rootUrl defines the root url for resources
  27735. * @returns a new entity
  27736. */
  27737. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27738. /**
  27739. * Clones an object
  27740. * @param creationFunction defines the function used to instanciate the new object
  27741. * @param source defines the source object
  27742. * @returns the cloned object
  27743. */
  27744. static Clone<T>(creationFunction: () => T, source: T): T;
  27745. /**
  27746. * Instanciates a new object based on a source one (some data will be shared between both object)
  27747. * @param creationFunction defines the function used to instanciate the new object
  27748. * @param source defines the source object
  27749. * @returns the new object
  27750. */
  27751. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27752. }
  27753. }
  27754. declare module BABYLON {
  27755. /**
  27756. * Class used to manipulate GUIDs
  27757. */
  27758. export class GUID {
  27759. /**
  27760. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27761. * Be aware Math.random() could cause collisions, but:
  27762. * "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"
  27763. * @returns a pseudo random id
  27764. */
  27765. static RandomId(): string;
  27766. }
  27767. }
  27768. declare module BABYLON {
  27769. /**
  27770. * Base class of all the textures in babylon.
  27771. * It groups all the common properties the materials, post process, lights... might need
  27772. * in order to make a correct use of the texture.
  27773. */
  27774. export class BaseTexture implements IAnimatable {
  27775. /**
  27776. * Default anisotropic filtering level for the application.
  27777. * It is set to 4 as a good tradeoff between perf and quality.
  27778. */
  27779. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27780. /**
  27781. * Gets or sets the unique id of the texture
  27782. */
  27783. uniqueId: number;
  27784. /**
  27785. * Define the name of the texture.
  27786. */
  27787. name: string;
  27788. /**
  27789. * Gets or sets an object used to store user defined information.
  27790. */
  27791. metadata: any;
  27792. /**
  27793. * For internal use only. Please do not use.
  27794. */
  27795. reservedDataStore: any;
  27796. private _hasAlpha;
  27797. /**
  27798. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27799. */
  27800. hasAlpha: boolean;
  27801. /**
  27802. * Defines if the alpha value should be determined via the rgb values.
  27803. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27804. */
  27805. getAlphaFromRGB: boolean;
  27806. /**
  27807. * Intensity or strength of the texture.
  27808. * It is commonly used by materials to fine tune the intensity of the texture
  27809. */
  27810. level: number;
  27811. /**
  27812. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27813. * This is part of the texture as textures usually maps to one uv set.
  27814. */
  27815. coordinatesIndex: number;
  27816. private _coordinatesMode;
  27817. /**
  27818. * How a texture is mapped.
  27819. *
  27820. * | Value | Type | Description |
  27821. * | ----- | ----------------------------------- | ----------- |
  27822. * | 0 | EXPLICIT_MODE | |
  27823. * | 1 | SPHERICAL_MODE | |
  27824. * | 2 | PLANAR_MODE | |
  27825. * | 3 | CUBIC_MODE | |
  27826. * | 4 | PROJECTION_MODE | |
  27827. * | 5 | SKYBOX_MODE | |
  27828. * | 6 | INVCUBIC_MODE | |
  27829. * | 7 | EQUIRECTANGULAR_MODE | |
  27830. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27831. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27832. */
  27833. coordinatesMode: number;
  27834. /**
  27835. * | Value | Type | Description |
  27836. * | ----- | ------------------ | ----------- |
  27837. * | 0 | CLAMP_ADDRESSMODE | |
  27838. * | 1 | WRAP_ADDRESSMODE | |
  27839. * | 2 | MIRROR_ADDRESSMODE | |
  27840. */
  27841. wrapU: number;
  27842. /**
  27843. * | Value | Type | Description |
  27844. * | ----- | ------------------ | ----------- |
  27845. * | 0 | CLAMP_ADDRESSMODE | |
  27846. * | 1 | WRAP_ADDRESSMODE | |
  27847. * | 2 | MIRROR_ADDRESSMODE | |
  27848. */
  27849. wrapV: number;
  27850. /**
  27851. * | Value | Type | Description |
  27852. * | ----- | ------------------ | ----------- |
  27853. * | 0 | CLAMP_ADDRESSMODE | |
  27854. * | 1 | WRAP_ADDRESSMODE | |
  27855. * | 2 | MIRROR_ADDRESSMODE | |
  27856. */
  27857. wrapR: number;
  27858. /**
  27859. * With compliant hardware and browser (supporting anisotropic filtering)
  27860. * this defines the level of anisotropic filtering in the texture.
  27861. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27862. */
  27863. anisotropicFilteringLevel: number;
  27864. /**
  27865. * Define if the texture is a cube texture or if false a 2d texture.
  27866. */
  27867. isCube: boolean;
  27868. /**
  27869. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27870. */
  27871. is3D: boolean;
  27872. /**
  27873. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27874. * HDR texture are usually stored in linear space.
  27875. * This only impacts the PBR and Background materials
  27876. */
  27877. gammaSpace: boolean;
  27878. /**
  27879. * Gets or sets whether or not the texture contains RGBD data.
  27880. */
  27881. isRGBD: boolean;
  27882. /**
  27883. * Is Z inverted in the texture (useful in a cube texture).
  27884. */
  27885. invertZ: boolean;
  27886. /**
  27887. * Are mip maps generated for this texture or not.
  27888. */
  27889. readonly noMipmap: boolean;
  27890. /**
  27891. * @hidden
  27892. */
  27893. lodLevelInAlpha: boolean;
  27894. /**
  27895. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27896. */
  27897. lodGenerationOffset: number;
  27898. /**
  27899. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27900. */
  27901. lodGenerationScale: number;
  27902. /**
  27903. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27904. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27905. * average roughness values.
  27906. */
  27907. linearSpecularLOD: boolean;
  27908. /**
  27909. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27910. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27911. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27912. */
  27913. irradianceTexture: Nullable<BaseTexture>;
  27914. /**
  27915. * Define if the texture is a render target.
  27916. */
  27917. isRenderTarget: boolean;
  27918. /**
  27919. * Define the unique id of the texture in the scene.
  27920. */
  27921. readonly uid: string;
  27922. /**
  27923. * Return a string representation of the texture.
  27924. * @returns the texture as a string
  27925. */
  27926. toString(): string;
  27927. /**
  27928. * Get the class name of the texture.
  27929. * @returns "BaseTexture"
  27930. */
  27931. getClassName(): string;
  27932. /**
  27933. * Define the list of animation attached to the texture.
  27934. */
  27935. animations: Animation[];
  27936. /**
  27937. * An event triggered when the texture is disposed.
  27938. */
  27939. onDisposeObservable: Observable<BaseTexture>;
  27940. private _onDisposeObserver;
  27941. /**
  27942. * Callback triggered when the texture has been disposed.
  27943. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27944. */
  27945. onDispose: () => void;
  27946. /**
  27947. * Define the current state of the loading sequence when in delayed load mode.
  27948. */
  27949. delayLoadState: number;
  27950. private _scene;
  27951. /** @hidden */
  27952. _texture: Nullable<InternalTexture>;
  27953. private _uid;
  27954. /**
  27955. * Define if the texture is preventinga material to render or not.
  27956. * If not and the texture is not ready, the engine will use a default black texture instead.
  27957. */
  27958. readonly isBlocking: boolean;
  27959. /**
  27960. * Instantiates a new BaseTexture.
  27961. * Base class of all the textures in babylon.
  27962. * It groups all the common properties the materials, post process, lights... might need
  27963. * in order to make a correct use of the texture.
  27964. * @param scene Define the scene the texture blongs to
  27965. */
  27966. constructor(scene: Nullable<Scene>);
  27967. /**
  27968. * Get the scene the texture belongs to.
  27969. * @returns the scene or null if undefined
  27970. */
  27971. getScene(): Nullable<Scene>;
  27972. /**
  27973. * Get the texture transform matrix used to offset tile the texture for istance.
  27974. * @returns the transformation matrix
  27975. */
  27976. getTextureMatrix(): Matrix;
  27977. /**
  27978. * Get the texture reflection matrix used to rotate/transform the reflection.
  27979. * @returns the reflection matrix
  27980. */
  27981. getReflectionTextureMatrix(): Matrix;
  27982. /**
  27983. * Get the underlying lower level texture from Babylon.
  27984. * @returns the insternal texture
  27985. */
  27986. getInternalTexture(): Nullable<InternalTexture>;
  27987. /**
  27988. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27989. * @returns true if ready or not blocking
  27990. */
  27991. isReadyOrNotBlocking(): boolean;
  27992. /**
  27993. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27994. * @returns true if fully ready
  27995. */
  27996. isReady(): boolean;
  27997. private _cachedSize;
  27998. /**
  27999. * Get the size of the texture.
  28000. * @returns the texture size.
  28001. */
  28002. getSize(): ISize;
  28003. /**
  28004. * Get the base size of the texture.
  28005. * It can be different from the size if the texture has been resized for POT for instance
  28006. * @returns the base size
  28007. */
  28008. getBaseSize(): ISize;
  28009. /**
  28010. * Update the sampling mode of the texture.
  28011. * Default is Trilinear mode.
  28012. *
  28013. * | Value | Type | Description |
  28014. * | ----- | ------------------ | ----------- |
  28015. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28016. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28017. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28018. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28019. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28020. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28021. * | 7 | NEAREST_LINEAR | |
  28022. * | 8 | NEAREST_NEAREST | |
  28023. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28024. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28025. * | 11 | LINEAR_LINEAR | |
  28026. * | 12 | LINEAR_NEAREST | |
  28027. *
  28028. * > _mag_: magnification filter (close to the viewer)
  28029. * > _min_: minification filter (far from the viewer)
  28030. * > _mip_: filter used between mip map levels
  28031. *@param samplingMode Define the new sampling mode of the texture
  28032. */
  28033. updateSamplingMode(samplingMode: number): void;
  28034. /**
  28035. * Scales the texture if is `canRescale()`
  28036. * @param ratio the resize factor we want to use to rescale
  28037. */
  28038. scale(ratio: number): void;
  28039. /**
  28040. * Get if the texture can rescale.
  28041. */
  28042. readonly canRescale: boolean;
  28043. /** @hidden */
  28044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28045. /** @hidden */
  28046. _rebuild(): void;
  28047. /**
  28048. * Triggers the load sequence in delayed load mode.
  28049. */
  28050. delayLoad(): void;
  28051. /**
  28052. * Clones the texture.
  28053. * @returns the cloned texture
  28054. */
  28055. clone(): Nullable<BaseTexture>;
  28056. /**
  28057. * Get the texture underlying type (INT, FLOAT...)
  28058. */
  28059. readonly textureType: number;
  28060. /**
  28061. * Get the texture underlying format (RGB, RGBA...)
  28062. */
  28063. readonly textureFormat: number;
  28064. /**
  28065. * Indicates that textures need to be re-calculated for all materials
  28066. */
  28067. protected _markAllSubMeshesAsTexturesDirty(): void;
  28068. /**
  28069. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28070. * This will returns an RGBA array buffer containing either in values (0-255) or
  28071. * float values (0-1) depending of the underlying buffer type.
  28072. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28073. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28074. * @param buffer defines a user defined buffer to fill with data (can be null)
  28075. * @returns The Array buffer containing the pixels data.
  28076. */
  28077. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28078. /**
  28079. * Release and destroy the underlying lower level texture aka internalTexture.
  28080. */
  28081. releaseInternalTexture(): void;
  28082. /** @hidden */
  28083. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28084. /** @hidden */
  28085. readonly _lodTextureMid: Nullable<BaseTexture>;
  28086. /** @hidden */
  28087. readonly _lodTextureLow: Nullable<BaseTexture>;
  28088. /**
  28089. * Dispose the texture and release its associated resources.
  28090. */
  28091. dispose(): void;
  28092. /**
  28093. * Serialize the texture into a JSON representation that can be parsed later on.
  28094. * @returns the JSON representation of the texture
  28095. */
  28096. serialize(): any;
  28097. /**
  28098. * Helper function to be called back once a list of texture contains only ready textures.
  28099. * @param textures Define the list of textures to wait for
  28100. * @param callback Define the callback triggered once the entire list will be ready
  28101. */
  28102. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28103. }
  28104. }
  28105. declare module BABYLON {
  28106. /**
  28107. * Options to be used when creating an effect.
  28108. */
  28109. export interface IEffectCreationOptions {
  28110. /**
  28111. * Atrributes that will be used in the shader.
  28112. */
  28113. attributes: string[];
  28114. /**
  28115. * Uniform varible names that will be set in the shader.
  28116. */
  28117. uniformsNames: string[];
  28118. /**
  28119. * Uniform buffer varible names that will be set in the shader.
  28120. */
  28121. uniformBuffersNames: string[];
  28122. /**
  28123. * Sampler texture variable names that will be set in the shader.
  28124. */
  28125. samplers: string[];
  28126. /**
  28127. * Define statements that will be set in the shader.
  28128. */
  28129. defines: any;
  28130. /**
  28131. * Possible fallbacks for this effect to improve performance when needed.
  28132. */
  28133. fallbacks: Nullable<IEffectFallbacks>;
  28134. /**
  28135. * Callback that will be called when the shader is compiled.
  28136. */
  28137. onCompiled: Nullable<(effect: Effect) => void>;
  28138. /**
  28139. * Callback that will be called if an error occurs during shader compilation.
  28140. */
  28141. onError: Nullable<(effect: Effect, errors: string) => void>;
  28142. /**
  28143. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28144. */
  28145. indexParameters?: any;
  28146. /**
  28147. * Max number of lights that can be used in the shader.
  28148. */
  28149. maxSimultaneousLights?: number;
  28150. /**
  28151. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28152. */
  28153. transformFeedbackVaryings?: Nullable<string[]>;
  28154. }
  28155. /**
  28156. * Effect containing vertex and fragment shader that can be executed on an object.
  28157. */
  28158. export class Effect implements IDisposable {
  28159. /**
  28160. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28161. */
  28162. static ShadersRepository: string;
  28163. /**
  28164. * Name of the effect.
  28165. */
  28166. name: any;
  28167. /**
  28168. * String container all the define statements that should be set on the shader.
  28169. */
  28170. defines: string;
  28171. /**
  28172. * Callback that will be called when the shader is compiled.
  28173. */
  28174. onCompiled: Nullable<(effect: Effect) => void>;
  28175. /**
  28176. * Callback that will be called if an error occurs during shader compilation.
  28177. */
  28178. onError: Nullable<(effect: Effect, errors: string) => void>;
  28179. /**
  28180. * Callback that will be called when effect is bound.
  28181. */
  28182. onBind: Nullable<(effect: Effect) => void>;
  28183. /**
  28184. * Unique ID of the effect.
  28185. */
  28186. uniqueId: number;
  28187. /**
  28188. * Observable that will be called when the shader is compiled.
  28189. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28190. */
  28191. onCompileObservable: Observable<Effect>;
  28192. /**
  28193. * Observable that will be called if an error occurs during shader compilation.
  28194. */
  28195. onErrorObservable: Observable<Effect>;
  28196. /** @hidden */
  28197. _onBindObservable: Nullable<Observable<Effect>>;
  28198. /**
  28199. * Observable that will be called when effect is bound.
  28200. */
  28201. readonly onBindObservable: Observable<Effect>;
  28202. /** @hidden */
  28203. _bonesComputationForcedToCPU: boolean;
  28204. private static _uniqueIdSeed;
  28205. private _engine;
  28206. private _uniformBuffersNames;
  28207. private _uniformsNames;
  28208. private _samplerList;
  28209. private _samplers;
  28210. private _isReady;
  28211. private _compilationError;
  28212. private _allFallbacksProcessed;
  28213. private _attributesNames;
  28214. private _attributes;
  28215. private _uniforms;
  28216. /**
  28217. * Key for the effect.
  28218. * @hidden
  28219. */
  28220. _key: string;
  28221. private _indexParameters;
  28222. private _fallbacks;
  28223. private _vertexSourceCode;
  28224. private _fragmentSourceCode;
  28225. private _vertexSourceCodeOverride;
  28226. private _fragmentSourceCodeOverride;
  28227. private _transformFeedbackVaryings;
  28228. /**
  28229. * Compiled shader to webGL program.
  28230. * @hidden
  28231. */
  28232. _pipelineContext: Nullable<IPipelineContext>;
  28233. private _valueCache;
  28234. private static _baseCache;
  28235. /**
  28236. * Instantiates an effect.
  28237. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28238. * @param baseName Name of the effect.
  28239. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28240. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28241. * @param samplers List of sampler variables that will be passed to the shader.
  28242. * @param engine Engine to be used to render the effect
  28243. * @param defines Define statements to be added to the shader.
  28244. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28245. * @param onCompiled Callback that will be called when the shader is compiled.
  28246. * @param onError Callback that will be called if an error occurs during shader compilation.
  28247. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28248. */
  28249. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28250. private _useFinalCode;
  28251. /**
  28252. * Unique key for this effect
  28253. */
  28254. readonly key: string;
  28255. /**
  28256. * If the effect has been compiled and prepared.
  28257. * @returns if the effect is compiled and prepared.
  28258. */
  28259. isReady(): boolean;
  28260. private _isReadyInternal;
  28261. /**
  28262. * The engine the effect was initialized with.
  28263. * @returns the engine.
  28264. */
  28265. getEngine(): Engine;
  28266. /**
  28267. * The pipeline context for this effect
  28268. * @returns the associated pipeline context
  28269. */
  28270. getPipelineContext(): Nullable<IPipelineContext>;
  28271. /**
  28272. * The set of names of attribute variables for the shader.
  28273. * @returns An array of attribute names.
  28274. */
  28275. getAttributesNames(): string[];
  28276. /**
  28277. * Returns the attribute at the given index.
  28278. * @param index The index of the attribute.
  28279. * @returns The location of the attribute.
  28280. */
  28281. getAttributeLocation(index: number): number;
  28282. /**
  28283. * Returns the attribute based on the name of the variable.
  28284. * @param name of the attribute to look up.
  28285. * @returns the attribute location.
  28286. */
  28287. getAttributeLocationByName(name: string): number;
  28288. /**
  28289. * The number of attributes.
  28290. * @returns the numnber of attributes.
  28291. */
  28292. getAttributesCount(): number;
  28293. /**
  28294. * Gets the index of a uniform variable.
  28295. * @param uniformName of the uniform to look up.
  28296. * @returns the index.
  28297. */
  28298. getUniformIndex(uniformName: string): number;
  28299. /**
  28300. * Returns the attribute based on the name of the variable.
  28301. * @param uniformName of the uniform to look up.
  28302. * @returns the location of the uniform.
  28303. */
  28304. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28305. /**
  28306. * Returns an array of sampler variable names
  28307. * @returns The array of sampler variable neames.
  28308. */
  28309. getSamplers(): string[];
  28310. /**
  28311. * The error from the last compilation.
  28312. * @returns the error string.
  28313. */
  28314. getCompilationError(): string;
  28315. /**
  28316. * Gets a boolean indicating that all fallbacks were used during compilation
  28317. * @returns true if all fallbacks were used
  28318. */
  28319. allFallbacksProcessed(): boolean;
  28320. /**
  28321. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28322. * @param func The callback to be used.
  28323. */
  28324. executeWhenCompiled(func: (effect: Effect) => void): void;
  28325. private _checkIsReady;
  28326. private _loadShader;
  28327. /**
  28328. * Recompiles the webGL program
  28329. * @param vertexSourceCode The source code for the vertex shader.
  28330. * @param fragmentSourceCode The source code for the fragment shader.
  28331. * @param onCompiled Callback called when completed.
  28332. * @param onError Callback called on error.
  28333. * @hidden
  28334. */
  28335. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28336. /**
  28337. * Prepares the effect
  28338. * @hidden
  28339. */
  28340. _prepareEffect(): void;
  28341. private _processCompilationErrors;
  28342. /**
  28343. * Checks if the effect is supported. (Must be called after compilation)
  28344. */
  28345. readonly isSupported: boolean;
  28346. /**
  28347. * Binds a texture to the engine to be used as output of the shader.
  28348. * @param channel Name of the output variable.
  28349. * @param texture Texture to bind.
  28350. * @hidden
  28351. */
  28352. _bindTexture(channel: string, texture: InternalTexture): void;
  28353. /**
  28354. * Sets a texture on the engine to be used in the shader.
  28355. * @param channel Name of the sampler variable.
  28356. * @param texture Texture to set.
  28357. */
  28358. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28359. /**
  28360. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28361. * @param channel Name of the sampler variable.
  28362. * @param texture Texture to set.
  28363. */
  28364. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28365. /**
  28366. * Sets an array of textures on the engine to be used in the shader.
  28367. * @param channel Name of the variable.
  28368. * @param textures Textures to set.
  28369. */
  28370. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28371. /**
  28372. * 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)
  28373. * @param channel Name of the sampler variable.
  28374. * @param postProcess Post process to get the input texture from.
  28375. */
  28376. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28377. /**
  28378. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28379. * 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)
  28380. * @param channel Name of the sampler variable.
  28381. * @param postProcess Post process to get the output texture from.
  28382. */
  28383. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28384. /** @hidden */
  28385. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28386. /** @hidden */
  28387. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28388. /** @hidden */
  28389. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28390. /** @hidden */
  28391. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28392. /**
  28393. * Binds a buffer to a uniform.
  28394. * @param buffer Buffer to bind.
  28395. * @param name Name of the uniform variable to bind to.
  28396. */
  28397. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28398. /**
  28399. * Binds block to a uniform.
  28400. * @param blockName Name of the block to bind.
  28401. * @param index Index to bind.
  28402. */
  28403. bindUniformBlock(blockName: string, index: number): void;
  28404. /**
  28405. * Sets an interger value on a uniform variable.
  28406. * @param uniformName Name of the variable.
  28407. * @param value Value to be set.
  28408. * @returns this effect.
  28409. */
  28410. setInt(uniformName: string, value: number): Effect;
  28411. /**
  28412. * Sets an int array on a uniform variable.
  28413. * @param uniformName Name of the variable.
  28414. * @param array array to be set.
  28415. * @returns this effect.
  28416. */
  28417. setIntArray(uniformName: string, array: Int32Array): Effect;
  28418. /**
  28419. * 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)
  28420. * @param uniformName Name of the variable.
  28421. * @param array array to be set.
  28422. * @returns this effect.
  28423. */
  28424. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28425. /**
  28426. * 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)
  28427. * @param uniformName Name of the variable.
  28428. * @param array array to be set.
  28429. * @returns this effect.
  28430. */
  28431. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28432. /**
  28433. * 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)
  28434. * @param uniformName Name of the variable.
  28435. * @param array array to be set.
  28436. * @returns this effect.
  28437. */
  28438. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28439. /**
  28440. * Sets an float array on a uniform variable.
  28441. * @param uniformName Name of the variable.
  28442. * @param array array to be set.
  28443. * @returns this effect.
  28444. */
  28445. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28446. /**
  28447. * 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)
  28448. * @param uniformName Name of the variable.
  28449. * @param array array to be set.
  28450. * @returns this effect.
  28451. */
  28452. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28453. /**
  28454. * 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)
  28455. * @param uniformName Name of the variable.
  28456. * @param array array to be set.
  28457. * @returns this effect.
  28458. */
  28459. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28460. /**
  28461. * 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)
  28462. * @param uniformName Name of the variable.
  28463. * @param array array to be set.
  28464. * @returns this effect.
  28465. */
  28466. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28467. /**
  28468. * Sets an array on a uniform variable.
  28469. * @param uniformName Name of the variable.
  28470. * @param array array to be set.
  28471. * @returns this effect.
  28472. */
  28473. setArray(uniformName: string, array: number[]): Effect;
  28474. /**
  28475. * 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)
  28476. * @param uniformName Name of the variable.
  28477. * @param array array to be set.
  28478. * @returns this effect.
  28479. */
  28480. setArray2(uniformName: string, array: number[]): Effect;
  28481. /**
  28482. * 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)
  28483. * @param uniformName Name of the variable.
  28484. * @param array array to be set.
  28485. * @returns this effect.
  28486. */
  28487. setArray3(uniformName: string, array: number[]): Effect;
  28488. /**
  28489. * 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)
  28490. * @param uniformName Name of the variable.
  28491. * @param array array to be set.
  28492. * @returns this effect.
  28493. */
  28494. setArray4(uniformName: string, array: number[]): Effect;
  28495. /**
  28496. * Sets matrices on a uniform variable.
  28497. * @param uniformName Name of the variable.
  28498. * @param matrices matrices to be set.
  28499. * @returns this effect.
  28500. */
  28501. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28502. /**
  28503. * Sets matrix on a uniform variable.
  28504. * @param uniformName Name of the variable.
  28505. * @param matrix matrix to be set.
  28506. * @returns this effect.
  28507. */
  28508. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28509. /**
  28510. * 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)
  28511. * @param uniformName Name of the variable.
  28512. * @param matrix matrix to be set.
  28513. * @returns this effect.
  28514. */
  28515. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28516. /**
  28517. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28518. * @param uniformName Name of the variable.
  28519. * @param matrix matrix to be set.
  28520. * @returns this effect.
  28521. */
  28522. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28523. /**
  28524. * Sets a float on a uniform variable.
  28525. * @param uniformName Name of the variable.
  28526. * @param value value to be set.
  28527. * @returns this effect.
  28528. */
  28529. setFloat(uniformName: string, value: number): Effect;
  28530. /**
  28531. * Sets a boolean on a uniform variable.
  28532. * @param uniformName Name of the variable.
  28533. * @param bool value to be set.
  28534. * @returns this effect.
  28535. */
  28536. setBool(uniformName: string, bool: boolean): Effect;
  28537. /**
  28538. * Sets a Vector2 on a uniform variable.
  28539. * @param uniformName Name of the variable.
  28540. * @param vector2 vector2 to be set.
  28541. * @returns this effect.
  28542. */
  28543. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28544. /**
  28545. * Sets a float2 on a uniform variable.
  28546. * @param uniformName Name of the variable.
  28547. * @param x First float in float2.
  28548. * @param y Second float in float2.
  28549. * @returns this effect.
  28550. */
  28551. setFloat2(uniformName: string, x: number, y: number): Effect;
  28552. /**
  28553. * Sets a Vector3 on a uniform variable.
  28554. * @param uniformName Name of the variable.
  28555. * @param vector3 Value to be set.
  28556. * @returns this effect.
  28557. */
  28558. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28559. /**
  28560. * Sets a float3 on a uniform variable.
  28561. * @param uniformName Name of the variable.
  28562. * @param x First float in float3.
  28563. * @param y Second float in float3.
  28564. * @param z Third float in float3.
  28565. * @returns this effect.
  28566. */
  28567. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28568. /**
  28569. * Sets a Vector4 on a uniform variable.
  28570. * @param uniformName Name of the variable.
  28571. * @param vector4 Value to be set.
  28572. * @returns this effect.
  28573. */
  28574. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28575. /**
  28576. * Sets a float4 on a uniform variable.
  28577. * @param uniformName Name of the variable.
  28578. * @param x First float in float4.
  28579. * @param y Second float in float4.
  28580. * @param z Third float in float4.
  28581. * @param w Fourth float in float4.
  28582. * @returns this effect.
  28583. */
  28584. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28585. /**
  28586. * Sets a Color3 on a uniform variable.
  28587. * @param uniformName Name of the variable.
  28588. * @param color3 Value to be set.
  28589. * @returns this effect.
  28590. */
  28591. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28592. /**
  28593. * Sets a Color4 on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param color3 Value to be set.
  28596. * @param alpha Alpha value to be set.
  28597. * @returns this effect.
  28598. */
  28599. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28600. /**
  28601. * Sets a Color4 on a uniform variable
  28602. * @param uniformName defines the name of the variable
  28603. * @param color4 defines the value to be set
  28604. * @returns this effect.
  28605. */
  28606. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28607. /** Release all associated resources */
  28608. dispose(): void;
  28609. /**
  28610. * This function will add a new shader to the shader store
  28611. * @param name the name of the shader
  28612. * @param pixelShader optional pixel shader content
  28613. * @param vertexShader optional vertex shader content
  28614. */
  28615. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28616. /**
  28617. * Store of each shader (The can be looked up using effect.key)
  28618. */
  28619. static ShadersStore: {
  28620. [key: string]: string;
  28621. };
  28622. /**
  28623. * Store of each included file for a shader (The can be looked up using effect.key)
  28624. */
  28625. static IncludesShadersStore: {
  28626. [key: string]: string;
  28627. };
  28628. /**
  28629. * Resets the cache of effects.
  28630. */
  28631. static ResetCache(): void;
  28632. }
  28633. }
  28634. declare module BABYLON {
  28635. /**
  28636. * Class used to describe the capabilities of the engine relatively to the current browser
  28637. */
  28638. export class EngineCapabilities {
  28639. /** Maximum textures units per fragment shader */
  28640. maxTexturesImageUnits: number;
  28641. /** Maximum texture units per vertex shader */
  28642. maxVertexTextureImageUnits: number;
  28643. /** Maximum textures units in the entire pipeline */
  28644. maxCombinedTexturesImageUnits: number;
  28645. /** Maximum texture size */
  28646. maxTextureSize: number;
  28647. /** Maximum cube texture size */
  28648. maxCubemapTextureSize: number;
  28649. /** Maximum render texture size */
  28650. maxRenderTextureSize: number;
  28651. /** Maximum number of vertex attributes */
  28652. maxVertexAttribs: number;
  28653. /** Maximum number of varyings */
  28654. maxVaryingVectors: number;
  28655. /** Maximum number of uniforms per vertex shader */
  28656. maxVertexUniformVectors: number;
  28657. /** Maximum number of uniforms per fragment shader */
  28658. maxFragmentUniformVectors: number;
  28659. /** Defines if standard derivates (dx/dy) are supported */
  28660. standardDerivatives: boolean;
  28661. /** Defines if s3tc texture compression is supported */
  28662. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28663. /** Defines if pvrtc texture compression is supported */
  28664. pvrtc: any;
  28665. /** Defines if etc1 texture compression is supported */
  28666. etc1: any;
  28667. /** Defines if etc2 texture compression is supported */
  28668. etc2: any;
  28669. /** Defines if astc texture compression is supported */
  28670. astc: any;
  28671. /** Defines if float textures are supported */
  28672. textureFloat: boolean;
  28673. /** Defines if vertex array objects are supported */
  28674. vertexArrayObject: boolean;
  28675. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28676. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28677. /** Gets the maximum level of anisotropy supported */
  28678. maxAnisotropy: number;
  28679. /** Defines if instancing is supported */
  28680. instancedArrays: boolean;
  28681. /** Defines if 32 bits indices are supported */
  28682. uintIndices: boolean;
  28683. /** Defines if high precision shaders are supported */
  28684. highPrecisionShaderSupported: boolean;
  28685. /** Defines if depth reading in the fragment shader is supported */
  28686. fragmentDepthSupported: boolean;
  28687. /** Defines if float texture linear filtering is supported*/
  28688. textureFloatLinearFiltering: boolean;
  28689. /** Defines if rendering to float textures is supported */
  28690. textureFloatRender: boolean;
  28691. /** Defines if half float textures are supported*/
  28692. textureHalfFloat: boolean;
  28693. /** Defines if half float texture linear filtering is supported*/
  28694. textureHalfFloatLinearFiltering: boolean;
  28695. /** Defines if rendering to half float textures is supported */
  28696. textureHalfFloatRender: boolean;
  28697. /** Defines if textureLOD shader command is supported */
  28698. textureLOD: boolean;
  28699. /** Defines if draw buffers extension is supported */
  28700. drawBuffersExtension: boolean;
  28701. /** Defines if depth textures are supported */
  28702. depthTextureExtension: boolean;
  28703. /** Defines if float color buffer are supported */
  28704. colorBufferFloat: boolean;
  28705. /** Gets disjoint timer query extension (null if not supported) */
  28706. timerQuery: EXT_disjoint_timer_query;
  28707. /** Defines if timestamp can be used with timer query */
  28708. canUseTimestampForTimerQuery: boolean;
  28709. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28710. multiview: any;
  28711. /** Function used to let the system compiles shaders in background */
  28712. parallelShaderCompile: {
  28713. COMPLETION_STATUS_KHR: number;
  28714. };
  28715. /** Max number of texture samples for MSAA */
  28716. maxMSAASamples: number;
  28717. /** Defines if the blend min max extension is supported */
  28718. blendMinMax: boolean;
  28719. }
  28720. }
  28721. declare module BABYLON {
  28722. /**
  28723. * @hidden
  28724. **/
  28725. export class DepthCullingState {
  28726. private _isDepthTestDirty;
  28727. private _isDepthMaskDirty;
  28728. private _isDepthFuncDirty;
  28729. private _isCullFaceDirty;
  28730. private _isCullDirty;
  28731. private _isZOffsetDirty;
  28732. private _isFrontFaceDirty;
  28733. private _depthTest;
  28734. private _depthMask;
  28735. private _depthFunc;
  28736. private _cull;
  28737. private _cullFace;
  28738. private _zOffset;
  28739. private _frontFace;
  28740. /**
  28741. * Initializes the state.
  28742. */
  28743. constructor();
  28744. readonly isDirty: boolean;
  28745. zOffset: number;
  28746. cullFace: Nullable<number>;
  28747. cull: Nullable<boolean>;
  28748. depthFunc: Nullable<number>;
  28749. depthMask: boolean;
  28750. depthTest: boolean;
  28751. frontFace: Nullable<number>;
  28752. reset(): void;
  28753. apply(gl: WebGLRenderingContext): void;
  28754. }
  28755. }
  28756. declare module BABYLON {
  28757. /**
  28758. * @hidden
  28759. **/
  28760. export class StencilState {
  28761. /** 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 */
  28762. static readonly ALWAYS: number;
  28763. /** Passed to stencilOperation to specify that stencil value must be kept */
  28764. static readonly KEEP: number;
  28765. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28766. static readonly REPLACE: number;
  28767. private _isStencilTestDirty;
  28768. private _isStencilMaskDirty;
  28769. private _isStencilFuncDirty;
  28770. private _isStencilOpDirty;
  28771. private _stencilTest;
  28772. private _stencilMask;
  28773. private _stencilFunc;
  28774. private _stencilFuncRef;
  28775. private _stencilFuncMask;
  28776. private _stencilOpStencilFail;
  28777. private _stencilOpDepthFail;
  28778. private _stencilOpStencilDepthPass;
  28779. readonly isDirty: boolean;
  28780. stencilFunc: number;
  28781. stencilFuncRef: number;
  28782. stencilFuncMask: number;
  28783. stencilOpStencilFail: number;
  28784. stencilOpDepthFail: number;
  28785. stencilOpStencilDepthPass: number;
  28786. stencilMask: number;
  28787. stencilTest: boolean;
  28788. constructor();
  28789. reset(): void;
  28790. apply(gl: WebGLRenderingContext): void;
  28791. }
  28792. }
  28793. declare module BABYLON {
  28794. /**
  28795. * @hidden
  28796. **/
  28797. export class AlphaState {
  28798. private _isAlphaBlendDirty;
  28799. private _isBlendFunctionParametersDirty;
  28800. private _isBlendEquationParametersDirty;
  28801. private _isBlendConstantsDirty;
  28802. private _alphaBlend;
  28803. private _blendFunctionParameters;
  28804. private _blendEquationParameters;
  28805. private _blendConstants;
  28806. /**
  28807. * Initializes the state.
  28808. */
  28809. constructor();
  28810. readonly isDirty: boolean;
  28811. alphaBlend: boolean;
  28812. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28813. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28814. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28815. reset(): void;
  28816. apply(gl: WebGLRenderingContext): void;
  28817. }
  28818. }
  28819. declare module BABYLON {
  28820. /** @hidden */
  28821. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28822. attributeProcessor(attribute: string): string;
  28823. varyingProcessor(varying: string, isFragment: boolean): string;
  28824. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28825. }
  28826. }
  28827. declare module BABYLON {
  28828. /**
  28829. * Interface for attribute information associated with buffer instanciation
  28830. */
  28831. export class InstancingAttributeInfo {
  28832. /**
  28833. * Index/offset of the attribute in the vertex shader
  28834. */
  28835. index: number;
  28836. /**
  28837. * size of the attribute, 1, 2, 3 or 4
  28838. */
  28839. attributeSize: number;
  28840. /**
  28841. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28842. * default is FLOAT
  28843. */
  28844. attribyteType: number;
  28845. /**
  28846. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28847. */
  28848. normalized: boolean;
  28849. /**
  28850. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28851. */
  28852. offset: number;
  28853. /**
  28854. * Name of the GLSL attribute, for debugging purpose only
  28855. */
  28856. attributeName: string;
  28857. }
  28858. }
  28859. declare module BABYLON {
  28860. interface ThinEngine {
  28861. /**
  28862. * Update a video texture
  28863. * @param texture defines the texture to update
  28864. * @param video defines the video element to use
  28865. * @param invertY defines if data must be stored with Y axis inverted
  28866. */
  28867. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28868. }
  28869. }
  28870. declare module BABYLON {
  28871. /**
  28872. * Settings for finer control over video usage
  28873. */
  28874. export interface VideoTextureSettings {
  28875. /**
  28876. * Applies `autoplay` to video, if specified
  28877. */
  28878. autoPlay?: boolean;
  28879. /**
  28880. * Applies `loop` to video, if specified
  28881. */
  28882. loop?: boolean;
  28883. /**
  28884. * Automatically updates internal texture from video at every frame in the render loop
  28885. */
  28886. autoUpdateTexture: boolean;
  28887. /**
  28888. * Image src displayed during the video loading or until the user interacts with the video.
  28889. */
  28890. poster?: string;
  28891. }
  28892. /**
  28893. * If you want to display a video in your scene, this is the special texture for that.
  28894. * This special texture works similar to other textures, with the exception of a few parameters.
  28895. * @see https://doc.babylonjs.com/how_to/video_texture
  28896. */
  28897. export class VideoTexture extends Texture {
  28898. /**
  28899. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28900. */
  28901. readonly autoUpdateTexture: boolean;
  28902. /**
  28903. * The video instance used by the texture internally
  28904. */
  28905. readonly video: HTMLVideoElement;
  28906. private _onUserActionRequestedObservable;
  28907. /**
  28908. * Event triggerd when a dom action is required by the user to play the video.
  28909. * This happens due to recent changes in browser policies preventing video to auto start.
  28910. */
  28911. readonly onUserActionRequestedObservable: Observable<Texture>;
  28912. private _generateMipMaps;
  28913. private _engine;
  28914. private _stillImageCaptured;
  28915. private _displayingPosterTexture;
  28916. private _settings;
  28917. private _createInternalTextureOnEvent;
  28918. private _frameId;
  28919. /**
  28920. * Creates a video texture.
  28921. * If you want to display a video in your scene, this is the special texture for that.
  28922. * This special texture works similar to other textures, with the exception of a few parameters.
  28923. * @see https://doc.babylonjs.com/how_to/video_texture
  28924. * @param name optional name, will detect from video source, if not defined
  28925. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28926. * @param scene is obviously the current scene.
  28927. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28928. * @param invertY is false by default but can be used to invert video on Y axis
  28929. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28930. * @param settings allows finer control over video usage
  28931. */
  28932. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28933. private _getName;
  28934. private _getVideo;
  28935. private _createInternalTexture;
  28936. private reset;
  28937. /**
  28938. * @hidden Internal method to initiate `update`.
  28939. */
  28940. _rebuild(): void;
  28941. /**
  28942. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28943. */
  28944. update(): void;
  28945. /**
  28946. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28947. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28948. */
  28949. updateTexture(isVisible: boolean): void;
  28950. protected _updateInternalTexture: () => void;
  28951. /**
  28952. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28953. * @param url New url.
  28954. */
  28955. updateURL(url: string): void;
  28956. /**
  28957. * Dispose the texture and release its associated resources.
  28958. */
  28959. dispose(): void;
  28960. /**
  28961. * Creates a video texture straight from a stream.
  28962. * @param scene Define the scene the texture should be created in
  28963. * @param stream Define the stream the texture should be created from
  28964. * @returns The created video texture as a promise
  28965. */
  28966. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28967. /**
  28968. * Creates a video texture straight from your WebCam video feed.
  28969. * @param scene Define the scene the texture should be created in
  28970. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28971. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28972. * @returns The created video texture as a promise
  28973. */
  28974. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28975. minWidth: number;
  28976. maxWidth: number;
  28977. minHeight: number;
  28978. maxHeight: number;
  28979. deviceId: string;
  28980. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28981. /**
  28982. * Creates a video texture straight from your WebCam video feed.
  28983. * @param scene Define the scene the texture should be created in
  28984. * @param onReady Define a callback to triggered once the texture will be ready
  28985. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28986. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28987. */
  28988. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28989. minWidth: number;
  28990. maxWidth: number;
  28991. minHeight: number;
  28992. maxHeight: number;
  28993. deviceId: string;
  28994. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28995. }
  28996. }
  28997. declare module BABYLON {
  28998. /**
  28999. * Defines the interface used by objects working like Scene
  29000. * @hidden
  29001. */
  29002. interface ISceneLike {
  29003. _addPendingData(data: any): void;
  29004. _removePendingData(data: any): void;
  29005. offlineProvider: IOfflineProvider;
  29006. }
  29007. /** Interface defining initialization parameters for Engine class */
  29008. export interface EngineOptions extends WebGLContextAttributes {
  29009. /**
  29010. * Defines if the engine should no exceed a specified device ratio
  29011. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29012. */
  29013. limitDeviceRatio?: number;
  29014. /**
  29015. * Defines if webvr should be enabled automatically
  29016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29017. */
  29018. autoEnableWebVR?: boolean;
  29019. /**
  29020. * Defines if webgl2 should be turned off even if supported
  29021. * @see http://doc.babylonjs.com/features/webgl2
  29022. */
  29023. disableWebGL2Support?: boolean;
  29024. /**
  29025. * Defines if webaudio should be initialized as well
  29026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29027. */
  29028. audioEngine?: boolean;
  29029. /**
  29030. * Defines if animations should run using a deterministic lock step
  29031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29032. */
  29033. deterministicLockstep?: boolean;
  29034. /** Defines the maximum steps to use with deterministic lock step mode */
  29035. lockstepMaxSteps?: number;
  29036. /**
  29037. * Defines that engine should ignore context lost events
  29038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29039. */
  29040. doNotHandleContextLost?: boolean;
  29041. /**
  29042. * Defines that engine should ignore modifying touch action attribute and style
  29043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29044. */
  29045. doNotHandleTouchAction?: boolean;
  29046. /**
  29047. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29048. */
  29049. useHighPrecisionFloats?: boolean;
  29050. }
  29051. /**
  29052. * The base engine class (root of all engines)
  29053. */
  29054. export class ThinEngine {
  29055. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29056. static ExceptionList: ({
  29057. key: string;
  29058. capture: string;
  29059. captureConstraint: number;
  29060. targets: string[];
  29061. } | {
  29062. key: string;
  29063. capture: null;
  29064. captureConstraint: null;
  29065. targets: string[];
  29066. })[];
  29067. /** @hidden */
  29068. static _TextureLoaders: IInternalTextureLoader[];
  29069. /**
  29070. * Returns the current npm package of the sdk
  29071. */
  29072. static readonly NpmPackage: string;
  29073. /**
  29074. * Returns the current version of the framework
  29075. */
  29076. static readonly Version: string;
  29077. /**
  29078. * Returns a string describing the current engine
  29079. */
  29080. readonly description: string;
  29081. /**
  29082. * Gets or sets the epsilon value used by collision engine
  29083. */
  29084. static CollisionsEpsilon: number;
  29085. /**
  29086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29087. */
  29088. static ShadersRepository: string;
  29089. /** @hidden */
  29090. _shaderProcessor: IShaderProcessor;
  29091. /**
  29092. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29093. */
  29094. forcePOTTextures: boolean;
  29095. /**
  29096. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29097. */
  29098. isFullscreen: boolean;
  29099. /**
  29100. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29101. */
  29102. cullBackFaces: boolean;
  29103. /**
  29104. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29105. */
  29106. renderEvenInBackground: boolean;
  29107. /**
  29108. * Gets or sets a boolean indicating that cache can be kept between frames
  29109. */
  29110. preventCacheWipeBetweenFrames: boolean;
  29111. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29112. validateShaderPrograms: boolean;
  29113. /**
  29114. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29115. */
  29116. disableUniformBuffers: boolean;
  29117. /** @hidden */
  29118. _uniformBuffers: UniformBuffer[];
  29119. /**
  29120. * Gets a boolean indicating that the engine supports uniform buffers
  29121. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29122. */
  29123. readonly supportsUniformBuffers: boolean;
  29124. /** @hidden */
  29125. _gl: WebGLRenderingContext;
  29126. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29127. protected _windowIsBackground: boolean;
  29128. protected _webGLVersion: number;
  29129. protected _highPrecisionShadersAllowed: boolean;
  29130. /** @hidden */
  29131. readonly _shouldUseHighPrecisionShader: boolean;
  29132. /**
  29133. * Gets a boolean indicating that only power of 2 textures are supported
  29134. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29135. */
  29136. readonly needPOTTextures: boolean;
  29137. /** @hidden */
  29138. _badOS: boolean;
  29139. /** @hidden */
  29140. _badDesktopOS: boolean;
  29141. private _hardwareScalingLevel;
  29142. /** @hidden */
  29143. _caps: EngineCapabilities;
  29144. private _isStencilEnable;
  29145. protected _colorWrite: boolean;
  29146. private _glVersion;
  29147. private _glRenderer;
  29148. private _glVendor;
  29149. /** @hidden */
  29150. _videoTextureSupported: boolean;
  29151. protected _renderingQueueLaunched: boolean;
  29152. protected _activeRenderLoops: (() => void)[];
  29153. /**
  29154. * Observable signaled when a context lost event is raised
  29155. */
  29156. onContextLostObservable: Observable<ThinEngine>;
  29157. /**
  29158. * Observable signaled when a context restored event is raised
  29159. */
  29160. onContextRestoredObservable: Observable<ThinEngine>;
  29161. private _onContextLost;
  29162. private _onContextRestored;
  29163. protected _contextWasLost: boolean;
  29164. /** @hidden */
  29165. _doNotHandleContextLost: boolean;
  29166. /**
  29167. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29169. */
  29170. doNotHandleContextLost: boolean;
  29171. /**
  29172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29173. */
  29174. disableVertexArrayObjects: boolean;
  29175. /** @hidden */
  29176. protected _depthCullingState: DepthCullingState;
  29177. /** @hidden */
  29178. protected _stencilState: StencilState;
  29179. /** @hidden */
  29180. protected _alphaState: AlphaState;
  29181. /** @hidden */
  29182. _internalTexturesCache: InternalTexture[];
  29183. /** @hidden */
  29184. protected _activeChannel: number;
  29185. private _currentTextureChannel;
  29186. /** @hidden */
  29187. protected _boundTexturesCache: {
  29188. [key: string]: Nullable<InternalTexture>;
  29189. };
  29190. /** @hidden */
  29191. protected _currentEffect: Nullable<Effect>;
  29192. /** @hidden */
  29193. protected _currentProgram: Nullable<WebGLProgram>;
  29194. private _compiledEffects;
  29195. private _vertexAttribArraysEnabled;
  29196. /** @hidden */
  29197. protected _cachedViewport: Nullable<IViewportLike>;
  29198. private _cachedVertexArrayObject;
  29199. /** @hidden */
  29200. protected _cachedVertexBuffers: any;
  29201. /** @hidden */
  29202. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29203. /** @hidden */
  29204. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29205. /** @hidden */
  29206. _currentRenderTarget: Nullable<InternalTexture>;
  29207. private _uintIndicesCurrentlySet;
  29208. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29209. /** @hidden */
  29210. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29211. private _currentBufferPointers;
  29212. private _currentInstanceLocations;
  29213. private _currentInstanceBuffers;
  29214. private _textureUnits;
  29215. /** @hidden */
  29216. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  29217. /** @hidden */
  29218. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  29219. /** @hidden */
  29220. _bindedRenderFunction: any;
  29221. private _vaoRecordInProgress;
  29222. private _mustWipeVertexAttributes;
  29223. private _emptyTexture;
  29224. private _emptyCubeTexture;
  29225. private _emptyTexture3D;
  29226. /** @hidden */
  29227. _frameHandler: number;
  29228. private _nextFreeTextureSlots;
  29229. private _maxSimultaneousTextures;
  29230. private _activeRequests;
  29231. protected _texturesSupported: string[];
  29232. /** @hidden */
  29233. _textureFormatInUse: Nullable<string>;
  29234. protected readonly _supportsHardwareTextureRescaling: boolean;
  29235. /**
  29236. * Gets the list of texture formats supported
  29237. */
  29238. readonly texturesSupported: Array<string>;
  29239. /**
  29240. * Gets the list of texture formats in use
  29241. */
  29242. readonly textureFormatInUse: Nullable<string>;
  29243. /**
  29244. * Gets the current viewport
  29245. */
  29246. readonly currentViewport: Nullable<IViewportLike>;
  29247. /**
  29248. * Gets the default empty texture
  29249. */
  29250. readonly emptyTexture: InternalTexture;
  29251. /**
  29252. * Gets the default empty 3D texture
  29253. */
  29254. readonly emptyTexture3D: InternalTexture;
  29255. /**
  29256. * Gets the default empty cube texture
  29257. */
  29258. readonly emptyCubeTexture: InternalTexture;
  29259. /**
  29260. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29261. */
  29262. readonly premultipliedAlpha: boolean;
  29263. /**
  29264. * Observable event triggered before each texture is initialized
  29265. */
  29266. onBeforeTextureInitObservable: Observable<Texture>;
  29267. /**
  29268. * Creates a new engine
  29269. * @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
  29270. * @param antialias defines enable antialiasing (default: false)
  29271. * @param options defines further options to be sent to the getContext() function
  29272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29273. */
  29274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29275. private _rebuildInternalTextures;
  29276. private _rebuildEffects;
  29277. /**
  29278. * Gets a boolean indicating if all created effects are ready
  29279. * @returns true if all effects are ready
  29280. */
  29281. areAllEffectsReady(): boolean;
  29282. protected _rebuildBuffers(): void;
  29283. private _initGLContext;
  29284. /**
  29285. * Gets version of the current webGL context
  29286. */
  29287. readonly webGLVersion: number;
  29288. /**
  29289. * Gets a string idenfifying the name of the class
  29290. * @returns "Engine" string
  29291. */
  29292. getClassName(): string;
  29293. /**
  29294. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29295. */
  29296. readonly isStencilEnable: boolean;
  29297. /** @hidden */
  29298. _prepareWorkingCanvas(): void;
  29299. /**
  29300. * Reset the texture cache to empty state
  29301. */
  29302. resetTextureCache(): void;
  29303. /**
  29304. * Gets an object containing information about the current webGL context
  29305. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29306. */
  29307. getGlInfo(): {
  29308. vendor: string;
  29309. renderer: string;
  29310. version: string;
  29311. };
  29312. /**
  29313. * Defines the hardware scaling level.
  29314. * By default the hardware scaling level is computed from the window device ratio.
  29315. * 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.
  29316. * @param level defines the level to use
  29317. */
  29318. setHardwareScalingLevel(level: number): void;
  29319. /**
  29320. * Gets the current hardware scaling level.
  29321. * By default the hardware scaling level is computed from the window device ratio.
  29322. * 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.
  29323. * @returns a number indicating the current hardware scaling level
  29324. */
  29325. getHardwareScalingLevel(): number;
  29326. /**
  29327. * Gets the list of loaded textures
  29328. * @returns an array containing all loaded textures
  29329. */
  29330. getLoadedTexturesCache(): InternalTexture[];
  29331. /**
  29332. * Gets the object containing all engine capabilities
  29333. * @returns the EngineCapabilities object
  29334. */
  29335. getCaps(): EngineCapabilities;
  29336. /**
  29337. * stop executing a render loop function and remove it from the execution array
  29338. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29339. */
  29340. stopRenderLoop(renderFunction?: () => void): void;
  29341. /** @hidden */
  29342. _renderLoop(): void;
  29343. /**
  29344. * Gets the HTML canvas attached with the current webGL context
  29345. * @returns a HTML canvas
  29346. */
  29347. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29348. /**
  29349. * Gets host window
  29350. * @returns the host window object
  29351. */
  29352. getHostWindow(): Nullable<Window>;
  29353. /**
  29354. * Gets the current render width
  29355. * @param useScreen defines if screen size must be used (or the current render target if any)
  29356. * @returns a number defining the current render width
  29357. */
  29358. getRenderWidth(useScreen?: boolean): number;
  29359. /**
  29360. * Gets the current render height
  29361. * @param useScreen defines if screen size must be used (or the current render target if any)
  29362. * @returns a number defining the current render height
  29363. */
  29364. getRenderHeight(useScreen?: boolean): number;
  29365. /**
  29366. * Can be used to override the current requestAnimationFrame requester.
  29367. * @hidden
  29368. */
  29369. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29370. /**
  29371. * Register and execute a render loop. The engine can have more than one render function
  29372. * @param renderFunction defines the function to continuously execute
  29373. */
  29374. runRenderLoop(renderFunction: () => void): void;
  29375. /**
  29376. * Clear the current render buffer or the current render target (if any is set up)
  29377. * @param color defines the color to use
  29378. * @param backBuffer defines if the back buffer must be cleared
  29379. * @param depth defines if the depth buffer must be cleared
  29380. * @param stencil defines if the stencil buffer must be cleared
  29381. */
  29382. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29383. private _viewportCached;
  29384. /** @hidden */
  29385. _viewport(x: number, y: number, width: number, height: number): void;
  29386. /**
  29387. * Set the WebGL's viewport
  29388. * @param viewport defines the viewport element to be used
  29389. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29390. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29391. */
  29392. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29393. /**
  29394. * Begin a new frame
  29395. */
  29396. beginFrame(): void;
  29397. /**
  29398. * Enf the current frame
  29399. */
  29400. endFrame(): void;
  29401. /**
  29402. * Resize the view according to the canvas' size
  29403. */
  29404. resize(): void;
  29405. /**
  29406. * Force a specific size of the canvas
  29407. * @param width defines the new canvas' width
  29408. * @param height defines the new canvas' height
  29409. */
  29410. setSize(width: number, height: number): void;
  29411. /**
  29412. * Binds the frame buffer to the specified texture.
  29413. * @param texture The texture to render to or null for the default canvas
  29414. * @param faceIndex The face of the texture to render to in case of cube texture
  29415. * @param requiredWidth The width of the target to render to
  29416. * @param requiredHeight The height of the target to render to
  29417. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29418. * @param depthStencilTexture The depth stencil texture to use to render
  29419. * @param lodLevel defines le lod level to bind to the frame buffer
  29420. */
  29421. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29422. /** @hidden */
  29423. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29424. /**
  29425. * Unbind the current render target texture from the webGL context
  29426. * @param texture defines the render target texture to unbind
  29427. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29428. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29429. */
  29430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29431. /**
  29432. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29433. */
  29434. flushFramebuffer(): void;
  29435. /**
  29436. * Unbind the current render target and bind the default framebuffer
  29437. */
  29438. restoreDefaultFramebuffer(): void;
  29439. private _resetVertexBufferBinding;
  29440. /**
  29441. * Creates a vertex buffer
  29442. * @param data the data for the vertex buffer
  29443. * @returns the new WebGL static buffer
  29444. */
  29445. createVertexBuffer(data: DataArray): DataBuffer;
  29446. private _createVertexBuffer;
  29447. /**
  29448. * Creates a dynamic vertex buffer
  29449. * @param data the data for the dynamic vertex buffer
  29450. * @returns the new WebGL dynamic buffer
  29451. */
  29452. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29453. /**
  29454. * Updates a dynamic vertex buffer.
  29455. * @param vertexBuffer the vertex buffer to update
  29456. * @param data the data used to update the vertex buffer
  29457. * @param byteOffset the byte offset of the data
  29458. * @param byteLength the byte length of the data
  29459. */
  29460. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29461. protected _resetIndexBufferBinding(): void;
  29462. /**
  29463. * Creates a new index buffer
  29464. * @param indices defines the content of the index buffer
  29465. * @param updatable defines if the index buffer must be updatable
  29466. * @returns a new webGL buffer
  29467. */
  29468. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29469. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29470. /**
  29471. * Bind a webGL buffer to the webGL context
  29472. * @param buffer defines the buffer to bind
  29473. */
  29474. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29475. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  29476. private bindBuffer;
  29477. /**
  29478. * update the bound buffer with the given data
  29479. * @param data defines the data to update
  29480. */
  29481. updateArrayBuffer(data: Float32Array): void;
  29482. private _vertexAttribPointer;
  29483. private _bindIndexBufferWithCache;
  29484. private _bindVertexBuffersAttributes;
  29485. /**
  29486. * Records a vertex array object
  29487. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29488. * @param vertexBuffers defines the list of vertex buffers to store
  29489. * @param indexBuffer defines the index buffer to store
  29490. * @param effect defines the effect to store
  29491. * @returns the new vertex array object
  29492. */
  29493. recordVertexArrayObject(vertexBuffers: {
  29494. [key: string]: VertexBuffer;
  29495. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29496. /**
  29497. * Bind a specific vertex array object
  29498. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29499. * @param vertexArrayObject defines the vertex array object to bind
  29500. * @param indexBuffer defines the index buffer to bind
  29501. */
  29502. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29503. /**
  29504. * Bind webGl buffers directly to the webGL context
  29505. * @param vertexBuffer defines the vertex buffer to bind
  29506. * @param indexBuffer defines the index buffer to bind
  29507. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29508. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29509. * @param effect defines the effect associated with the vertex buffer
  29510. */
  29511. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29512. private _unbindVertexArrayObject;
  29513. /**
  29514. * Bind a list of vertex buffers to the webGL context
  29515. * @param vertexBuffers defines the list of vertex buffers to bind
  29516. * @param indexBuffer defines the index buffer to bind
  29517. * @param effect defines the effect associated with the vertex buffers
  29518. */
  29519. bindBuffers(vertexBuffers: {
  29520. [key: string]: Nullable<VertexBuffer>;
  29521. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29522. /**
  29523. * Unbind all instance attributes
  29524. */
  29525. unbindInstanceAttributes(): void;
  29526. /**
  29527. * Release and free the memory of a vertex array object
  29528. * @param vao defines the vertex array object to delete
  29529. */
  29530. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29531. /** @hidden */
  29532. _releaseBuffer(buffer: DataBuffer): boolean;
  29533. protected _deleteBuffer(buffer: DataBuffer): void;
  29534. /**
  29535. * Creates a webGL buffer to use with instanciation
  29536. * @param capacity defines the size of the buffer
  29537. * @returns the webGL buffer
  29538. */
  29539. createInstancesBuffer(capacity: number): DataBuffer;
  29540. /**
  29541. * Delete a webGL buffer used with instanciation
  29542. * @param buffer defines the webGL buffer to delete
  29543. */
  29544. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29545. /**
  29546. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29547. * @param instancesBuffer defines the webGL buffer to update and bind
  29548. * @param data defines the data to store in the buffer
  29549. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29550. */
  29551. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29552. /**
  29553. * Apply all cached states (depth, culling, stencil and alpha)
  29554. */
  29555. applyStates(): void;
  29556. /**
  29557. * Send a draw order
  29558. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29559. * @param indexStart defines the starting index
  29560. * @param indexCount defines the number of index to draw
  29561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29562. */
  29563. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29564. /**
  29565. * Draw a list of points
  29566. * @param verticesStart defines the index of first vertex to draw
  29567. * @param verticesCount defines the count of vertices to draw
  29568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29569. */
  29570. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29571. /**
  29572. * Draw a list of unindexed primitives
  29573. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29574. * @param verticesStart defines the index of first vertex to draw
  29575. * @param verticesCount defines the count of vertices to draw
  29576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29577. */
  29578. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29579. /**
  29580. * Draw a list of indexed primitives
  29581. * @param fillMode defines the primitive to use
  29582. * @param indexStart defines the starting index
  29583. * @param indexCount defines the number of index to draw
  29584. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29585. */
  29586. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29587. /**
  29588. * Draw a list of unindexed primitives
  29589. * @param fillMode defines the primitive to use
  29590. * @param verticesStart defines the index of first vertex to draw
  29591. * @param verticesCount defines the count of vertices to draw
  29592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29593. */
  29594. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29595. private _drawMode;
  29596. /** @hidden */
  29597. protected _reportDrawCall(): void;
  29598. /** @hidden */
  29599. _releaseEffect(effect: Effect): void;
  29600. /** @hidden */
  29601. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29602. /**
  29603. * Create a new effect (used to store vertex/fragment shaders)
  29604. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29605. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  29606. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29607. * @param samplers defines an array of string used to represent textures
  29608. * @param defines defines the string containing the defines to use to compile the shaders
  29609. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29610. * @param onCompiled defines a function to call when the effect creation is successful
  29611. * @param onError defines a function to call when the effect creation has failed
  29612. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29613. * @returns the new Effect
  29614. */
  29615. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29616. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29617. private _compileShader;
  29618. private _compileRawShader;
  29619. /**
  29620. * Directly creates a webGL program
  29621. * @param pipelineContext defines the pipeline context to attach to
  29622. * @param vertexCode defines the vertex shader code to use
  29623. * @param fragmentCode defines the fragment shader code to use
  29624. * @param context defines the webGL context to use (if not set, the current one will be used)
  29625. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29626. * @returns the new webGL program
  29627. */
  29628. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29629. /**
  29630. * Creates a webGL program
  29631. * @param pipelineContext defines the pipeline context to attach to
  29632. * @param vertexCode defines the vertex shader code to use
  29633. * @param fragmentCode defines the fragment shader code to use
  29634. * @param defines defines the string containing the defines to use to compile the shaders
  29635. * @param context defines the webGL context to use (if not set, the current one will be used)
  29636. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29637. * @returns the new webGL program
  29638. */
  29639. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29640. /**
  29641. * Creates a new pipeline context
  29642. * @returns the new pipeline
  29643. */
  29644. createPipelineContext(): IPipelineContext;
  29645. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29646. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29647. /** @hidden */
  29648. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29649. /** @hidden */
  29650. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29651. /** @hidden */
  29652. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29653. /**
  29654. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29655. * @param pipelineContext defines the pipeline context to use
  29656. * @param uniformsNames defines the list of uniform names
  29657. * @returns an array of webGL uniform locations
  29658. */
  29659. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29660. /**
  29661. * Gets the lsit of active attributes for a given webGL program
  29662. * @param pipelineContext defines the pipeline context to use
  29663. * @param attributesNames defines the list of attribute names to get
  29664. * @returns an array of indices indicating the offset of each attribute
  29665. */
  29666. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29667. /**
  29668. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29669. * @param effect defines the effect to activate
  29670. */
  29671. enableEffect(effect: Nullable<Effect>): void;
  29672. /**
  29673. * Set the value of an uniform to an array of int32
  29674. * @param uniform defines the webGL uniform location where to store the value
  29675. * @param array defines the array of int32 to store
  29676. */
  29677. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29678. /**
  29679. * Set the value of an uniform to an array of int32 (stored as vec2)
  29680. * @param uniform defines the webGL uniform location where to store the value
  29681. * @param array defines the array of int32 to store
  29682. */
  29683. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29684. /**
  29685. * Set the value of an uniform to an array of int32 (stored as vec3)
  29686. * @param uniform defines the webGL uniform location where to store the value
  29687. * @param array defines the array of int32 to store
  29688. */
  29689. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29690. /**
  29691. * Set the value of an uniform to an array of int32 (stored as vec4)
  29692. * @param uniform defines the webGL uniform location where to store the value
  29693. * @param array defines the array of int32 to store
  29694. */
  29695. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29696. /**
  29697. * Set the value of an uniform to an array of float32
  29698. * @param uniform defines the webGL uniform location where to store the value
  29699. * @param array defines the array of float32 to store
  29700. */
  29701. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29702. /**
  29703. * Set the value of an uniform to an array of float32 (stored as vec2)
  29704. * @param uniform defines the webGL uniform location where to store the value
  29705. * @param array defines the array of float32 to store
  29706. */
  29707. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29708. /**
  29709. * Set the value of an uniform to an array of float32 (stored as vec3)
  29710. * @param uniform defines the webGL uniform location where to store the value
  29711. * @param array defines the array of float32 to store
  29712. */
  29713. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29714. /**
  29715. * Set the value of an uniform to an array of float32 (stored as vec4)
  29716. * @param uniform defines the webGL uniform location where to store the value
  29717. * @param array defines the array of float32 to store
  29718. */
  29719. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29720. /**
  29721. * Set the value of an uniform to an array of number
  29722. * @param uniform defines the webGL uniform location where to store the value
  29723. * @param array defines the array of number to store
  29724. */
  29725. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29726. /**
  29727. * Set the value of an uniform to an array of number (stored as vec2)
  29728. * @param uniform defines the webGL uniform location where to store the value
  29729. * @param array defines the array of number to store
  29730. */
  29731. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29732. /**
  29733. * Set the value of an uniform to an array of number (stored as vec3)
  29734. * @param uniform defines the webGL uniform location where to store the value
  29735. * @param array defines the array of number to store
  29736. */
  29737. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29738. /**
  29739. * Set the value of an uniform to an array of number (stored as vec4)
  29740. * @param uniform defines the webGL uniform location where to store the value
  29741. * @param array defines the array of number to store
  29742. */
  29743. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29744. /**
  29745. * Set the value of an uniform to an array of float32 (stored as matrices)
  29746. * @param uniform defines the webGL uniform location where to store the value
  29747. * @param matrices defines the array of float32 to store
  29748. */
  29749. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29750. /**
  29751. * Set the value of an uniform to a matrix (3x3)
  29752. * @param uniform defines the webGL uniform location where to store the value
  29753. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29754. */
  29755. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29756. /**
  29757. * Set the value of an uniform to a matrix (2x2)
  29758. * @param uniform defines the webGL uniform location where to store the value
  29759. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29760. */
  29761. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29762. /**
  29763. * Set the value of an uniform to a number (int)
  29764. * @param uniform defines the webGL uniform location where to store the value
  29765. * @param value defines the int number to store
  29766. */
  29767. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29768. /**
  29769. * Set the value of an uniform to a number (float)
  29770. * @param uniform defines the webGL uniform location where to store the value
  29771. * @param value defines the float number to store
  29772. */
  29773. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29774. /**
  29775. * Set the value of an uniform to a vec2
  29776. * @param uniform defines the webGL uniform location where to store the value
  29777. * @param x defines the 1st component of the value
  29778. * @param y defines the 2nd component of the value
  29779. */
  29780. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29781. /**
  29782. * Set the value of an uniform to a vec3
  29783. * @param uniform defines the webGL uniform location where to store the value
  29784. * @param x defines the 1st component of the value
  29785. * @param y defines the 2nd component of the value
  29786. * @param z defines the 3rd component of the value
  29787. */
  29788. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29789. /**
  29790. * Set the value of an uniform to a boolean
  29791. * @param uniform defines the webGL uniform location where to store the value
  29792. * @param bool defines the boolean to store
  29793. */
  29794. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29795. /**
  29796. * Set the value of an uniform to a vec4
  29797. * @param uniform defines the webGL uniform location where to store the value
  29798. * @param x defines the 1st component of the value
  29799. * @param y defines the 2nd component of the value
  29800. * @param z defines the 3rd component of the value
  29801. * @param w defines the 4th component of the value
  29802. */
  29803. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29804. /**
  29805. * Sets a Color4 on a uniform variable
  29806. * @param uniform defines the uniform location
  29807. * @param color4 defines the value to be set
  29808. */
  29809. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29810. /**
  29811. * Gets the depth culling state manager
  29812. */
  29813. readonly depthCullingState: DepthCullingState;
  29814. /**
  29815. * Gets the alpha state manager
  29816. */
  29817. readonly alphaState: AlphaState;
  29818. /**
  29819. * Gets the stencil state manager
  29820. */
  29821. readonly stencilState: StencilState;
  29822. /**
  29823. * Clears the list of texture accessible through engine.
  29824. * This can help preventing texture load conflict due to name collision.
  29825. */
  29826. clearInternalTexturesCache(): void;
  29827. /**
  29828. * Force the entire cache to be cleared
  29829. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29830. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29831. */
  29832. wipeCaches(bruteForce?: boolean): void;
  29833. /** @hidden */
  29834. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29835. min: number;
  29836. mag: number;
  29837. };
  29838. /** @hidden */
  29839. _createTexture(): WebGLTexture;
  29840. /**
  29841. * Usually called from Texture.ts.
  29842. * Passed information to create a WebGLTexture
  29843. * @param urlArg defines a value which contains one of the following:
  29844. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29845. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29846. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29847. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29848. * @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)
  29849. * @param scene needed for loading to the correct scene
  29850. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29851. * @param onLoad optional callback to be called upon successful completion
  29852. * @param onError optional callback to be called upon failure
  29853. * @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
  29854. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29855. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29856. * @param forcedExtension defines the extension to use to pick the right loader
  29857. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29858. * @param mimeType defines an optional mime type
  29859. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29860. */
  29861. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  29862. /**
  29863. * @hidden
  29864. */
  29865. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29866. /**
  29867. * Creates a raw texture
  29868. * @param data defines the data to store in the texture
  29869. * @param width defines the width of the texture
  29870. * @param height defines the height of the texture
  29871. * @param format defines the format of the data
  29872. * @param generateMipMaps defines if the engine should generate the mip levels
  29873. * @param invertY defines if data must be stored with Y axis inverted
  29874. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29875. * @param compression defines the compression used (null by default)
  29876. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29877. * @returns the raw texture inside an InternalTexture
  29878. */
  29879. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29880. /**
  29881. * Creates a new raw cube texture
  29882. * @param data defines the array of data to use to create each face
  29883. * @param size defines the size of the textures
  29884. * @param format defines the format of the data
  29885. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29886. * @param generateMipMaps defines if the engine should generate the mip levels
  29887. * @param invertY defines if data must be stored with Y axis inverted
  29888. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29889. * @param compression defines the compression used (null by default)
  29890. * @returns the cube texture as an InternalTexture
  29891. */
  29892. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29893. /**
  29894. * Creates a new raw 3D texture
  29895. * @param data defines the data used to create the texture
  29896. * @param width defines the width of the texture
  29897. * @param height defines the height of the texture
  29898. * @param depth defines the depth of the texture
  29899. * @param format defines the format of the texture
  29900. * @param generateMipMaps defines if the engine must generate mip levels
  29901. * @param invertY defines if data must be stored with Y axis inverted
  29902. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29903. * @param compression defines the compressed used (can be null)
  29904. * @param textureType defines the compressed used (can be null)
  29905. * @returns a new raw 3D texture (stored in an InternalTexture)
  29906. */
  29907. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29908. private _unpackFlipYCached;
  29909. /**
  29910. * In case you are sharing the context with other applications, it might
  29911. * be interested to not cache the unpack flip y state to ensure a consistent
  29912. * value would be set.
  29913. */
  29914. enableUnpackFlipYCached: boolean;
  29915. /** @hidden */
  29916. _unpackFlipY(value: boolean): void;
  29917. /** @hidden */
  29918. _getUnpackAlignement(): number;
  29919. /**
  29920. * Update the sampling mode of a given texture
  29921. * @param samplingMode defines the required sampling mode
  29922. * @param texture defines the texture to update
  29923. */
  29924. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29925. /**
  29926. * Updates a depth texture Comparison Mode and Function.
  29927. * If the comparison Function is equal to 0, the mode will be set to none.
  29928. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29929. * @param texture The texture to set the comparison function for
  29930. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29931. */
  29932. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29933. /** @hidden */
  29934. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29935. width: number;
  29936. height: number;
  29937. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29938. /**
  29939. * Creates a depth stencil texture.
  29940. * This is only available in WebGL 2 or with the depth texture extension available.
  29941. * @param size The size of face edge in the texture.
  29942. * @param options The options defining the texture.
  29943. * @returns The texture
  29944. */
  29945. createDepthStencilTexture(size: number | {
  29946. width: number;
  29947. height: number;
  29948. }, options: DepthTextureCreationOptions): InternalTexture;
  29949. /**
  29950. * Creates a depth stencil texture.
  29951. * This is only available in WebGL 2 or with the depth texture extension available.
  29952. * @param size The size of face edge in the texture.
  29953. * @param options The options defining the texture.
  29954. * @returns The texture
  29955. */
  29956. private _createDepthStencilTexture;
  29957. /** @hidden */
  29958. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29959. /** @hidden */
  29960. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29961. /** @hidden */
  29962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29963. /** @hidden */
  29964. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  29965. /**
  29966. * @hidden
  29967. */
  29968. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29969. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29970. private _prepareWebGLTexture;
  29971. /** @hidden */
  29972. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29973. /** @hidden */
  29974. _releaseFramebufferObjects(texture: InternalTexture): void;
  29975. /** @hidden */
  29976. _releaseTexture(texture: InternalTexture): void;
  29977. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29978. protected _setProgram(program: WebGLProgram): void;
  29979. protected _boundUniforms: {
  29980. [key: number]: WebGLUniformLocation;
  29981. };
  29982. /**
  29983. * Binds an effect to the webGL context
  29984. * @param effect defines the effect to bind
  29985. */
  29986. bindSamplers(effect: Effect): void;
  29987. private _activateCurrentTexture;
  29988. /** @hidden */
  29989. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29990. /** @hidden */
  29991. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29992. /**
  29993. * Unbind all textures from the webGL context
  29994. */
  29995. unbindAllTextures(): void;
  29996. /**
  29997. * Sets a texture to the according uniform.
  29998. * @param channel The texture channel
  29999. * @param uniform The uniform to set
  30000. * @param texture The texture to apply
  30001. */
  30002. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30003. private _bindSamplerUniformToChannel;
  30004. private _getTextureWrapMode;
  30005. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30006. /**
  30007. * Sets an array of texture to the webGL context
  30008. * @param channel defines the channel where the texture array must be set
  30009. * @param uniform defines the associated uniform location
  30010. * @param textures defines the array of textures to bind
  30011. */
  30012. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30013. /** @hidden */
  30014. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30015. private _setTextureParameterFloat;
  30016. private _setTextureParameterInteger;
  30017. /**
  30018. * Unbind all vertex attributes from the webGL context
  30019. */
  30020. unbindAllAttributes(): void;
  30021. /**
  30022. * 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
  30023. */
  30024. releaseEffects(): void;
  30025. /**
  30026. * Dispose and release all associated resources
  30027. */
  30028. dispose(): void;
  30029. /**
  30030. * Attach a new callback raised when context lost event is fired
  30031. * @param callback defines the callback to call
  30032. */
  30033. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30034. /**
  30035. * Attach a new callback raised when context restored event is fired
  30036. * @param callback defines the callback to call
  30037. */
  30038. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30039. /**
  30040. * Get the current error code of the webGL context
  30041. * @returns the error code
  30042. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30043. */
  30044. getError(): number;
  30045. private _canRenderToFloatFramebuffer;
  30046. private _canRenderToHalfFloatFramebuffer;
  30047. private _canRenderToFramebuffer;
  30048. /** @hidden */
  30049. _getWebGLTextureType(type: number): number;
  30050. /** @hidden */
  30051. _getInternalFormat(format: number): number;
  30052. /** @hidden */
  30053. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30054. /** @hidden */
  30055. _getRGBAMultiSampleBufferFormat(type: number): number;
  30056. /** @hidden */
  30057. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30058. /**
  30059. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30060. * @returns true if the engine can be created
  30061. * @ignorenaming
  30062. */
  30063. static isSupported(): boolean;
  30064. /**
  30065. * Find the next highest power of two.
  30066. * @param x Number to start search from.
  30067. * @return Next highest power of two.
  30068. */
  30069. static CeilingPOT(x: number): number;
  30070. /**
  30071. * Find the next lowest power of two.
  30072. * @param x Number to start search from.
  30073. * @return Next lowest power of two.
  30074. */
  30075. static FloorPOT(x: number): number;
  30076. /**
  30077. * Find the nearest power of two.
  30078. * @param x Number to start search from.
  30079. * @return Next nearest power of two.
  30080. */
  30081. static NearestPOT(x: number): number;
  30082. /**
  30083. * Get the closest exponent of two
  30084. * @param value defines the value to approximate
  30085. * @param max defines the maximum value to return
  30086. * @param mode defines how to define the closest value
  30087. * @returns closest exponent of two of the given value
  30088. */
  30089. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30090. /**
  30091. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30092. * @param func - the function to be called
  30093. * @param requester - the object that will request the next frame. Falls back to window.
  30094. * @returns frame number
  30095. */
  30096. static QueueNewFrame(func: () => void, requester?: any): number;
  30097. }
  30098. }
  30099. declare module BABYLON {
  30100. /**
  30101. * Class representing spherical harmonics coefficients to the 3rd degree
  30102. */
  30103. export class SphericalHarmonics {
  30104. /**
  30105. * Defines whether or not the harmonics have been prescaled for rendering.
  30106. */
  30107. preScaled: boolean;
  30108. /**
  30109. * The l0,0 coefficients of the spherical harmonics
  30110. */
  30111. l00: Vector3;
  30112. /**
  30113. * The l1,-1 coefficients of the spherical harmonics
  30114. */
  30115. l1_1: Vector3;
  30116. /**
  30117. * The l1,0 coefficients of the spherical harmonics
  30118. */
  30119. l10: Vector3;
  30120. /**
  30121. * The l1,1 coefficients of the spherical harmonics
  30122. */
  30123. l11: Vector3;
  30124. /**
  30125. * The l2,-2 coefficients of the spherical harmonics
  30126. */
  30127. l2_2: Vector3;
  30128. /**
  30129. * The l2,-1 coefficients of the spherical harmonics
  30130. */
  30131. l2_1: Vector3;
  30132. /**
  30133. * The l2,0 coefficients of the spherical harmonics
  30134. */
  30135. l20: Vector3;
  30136. /**
  30137. * The l2,1 coefficients of the spherical harmonics
  30138. */
  30139. l21: Vector3;
  30140. /**
  30141. * The l2,2 coefficients of the spherical harmonics
  30142. */
  30143. l22: Vector3;
  30144. /**
  30145. * Adds a light to the spherical harmonics
  30146. * @param direction the direction of the light
  30147. * @param color the color of the light
  30148. * @param deltaSolidAngle the delta solid angle of the light
  30149. */
  30150. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30151. /**
  30152. * Scales the spherical harmonics by the given amount
  30153. * @param scale the amount to scale
  30154. */
  30155. scaleInPlace(scale: number): void;
  30156. /**
  30157. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30158. *
  30159. * ```
  30160. * E_lm = A_l * L_lm
  30161. * ```
  30162. *
  30163. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30164. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30165. * the scaling factors are given in equation 9.
  30166. */
  30167. convertIncidentRadianceToIrradiance(): void;
  30168. /**
  30169. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30170. *
  30171. * ```
  30172. * L = (1/pi) * E * rho
  30173. * ```
  30174. *
  30175. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30176. */
  30177. convertIrradianceToLambertianRadiance(): void;
  30178. /**
  30179. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30180. * required operations at run time.
  30181. *
  30182. * This is simply done by scaling back the SH with Ylm constants parameter.
  30183. * The trigonometric part being applied by the shader at run time.
  30184. */
  30185. preScaleForRendering(): void;
  30186. /**
  30187. * Constructs a spherical harmonics from an array.
  30188. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30189. * @returns the spherical harmonics
  30190. */
  30191. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30192. /**
  30193. * Gets the spherical harmonics from polynomial
  30194. * @param polynomial the spherical polynomial
  30195. * @returns the spherical harmonics
  30196. */
  30197. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30198. }
  30199. /**
  30200. * Class representing spherical polynomial coefficients to the 3rd degree
  30201. */
  30202. export class SphericalPolynomial {
  30203. private _harmonics;
  30204. /**
  30205. * The spherical harmonics used to create the polynomials.
  30206. */
  30207. readonly preScaledHarmonics: SphericalHarmonics;
  30208. /**
  30209. * The x coefficients of the spherical polynomial
  30210. */
  30211. x: Vector3;
  30212. /**
  30213. * The y coefficients of the spherical polynomial
  30214. */
  30215. y: Vector3;
  30216. /**
  30217. * The z coefficients of the spherical polynomial
  30218. */
  30219. z: Vector3;
  30220. /**
  30221. * The xx coefficients of the spherical polynomial
  30222. */
  30223. xx: Vector3;
  30224. /**
  30225. * The yy coefficients of the spherical polynomial
  30226. */
  30227. yy: Vector3;
  30228. /**
  30229. * The zz coefficients of the spherical polynomial
  30230. */
  30231. zz: Vector3;
  30232. /**
  30233. * The xy coefficients of the spherical polynomial
  30234. */
  30235. xy: Vector3;
  30236. /**
  30237. * The yz coefficients of the spherical polynomial
  30238. */
  30239. yz: Vector3;
  30240. /**
  30241. * The zx coefficients of the spherical polynomial
  30242. */
  30243. zx: Vector3;
  30244. /**
  30245. * Adds an ambient color to the spherical polynomial
  30246. * @param color the color to add
  30247. */
  30248. addAmbient(color: Color3): void;
  30249. /**
  30250. * Scales the spherical polynomial by the given amount
  30251. * @param scale the amount to scale
  30252. */
  30253. scaleInPlace(scale: number): void;
  30254. /**
  30255. * Gets the spherical polynomial from harmonics
  30256. * @param harmonics the spherical harmonics
  30257. * @returns the spherical polynomial
  30258. */
  30259. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30260. /**
  30261. * Constructs a spherical polynomial from an array.
  30262. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30263. * @returns the spherical polynomial
  30264. */
  30265. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30266. }
  30267. }
  30268. declare module BABYLON {
  30269. /**
  30270. * Defines the source of the internal texture
  30271. */
  30272. export enum InternalTextureSource {
  30273. /**
  30274. * The source of the texture data is unknown
  30275. */
  30276. Unknown = 0,
  30277. /**
  30278. * Texture data comes from an URL
  30279. */
  30280. Url = 1,
  30281. /**
  30282. * Texture data is only used for temporary storage
  30283. */
  30284. Temp = 2,
  30285. /**
  30286. * Texture data comes from raw data (ArrayBuffer)
  30287. */
  30288. Raw = 3,
  30289. /**
  30290. * Texture content is dynamic (video or dynamic texture)
  30291. */
  30292. Dynamic = 4,
  30293. /**
  30294. * Texture content is generated by rendering to it
  30295. */
  30296. RenderTarget = 5,
  30297. /**
  30298. * Texture content is part of a multi render target process
  30299. */
  30300. MultiRenderTarget = 6,
  30301. /**
  30302. * Texture data comes from a cube data file
  30303. */
  30304. Cube = 7,
  30305. /**
  30306. * Texture data comes from a raw cube data
  30307. */
  30308. CubeRaw = 8,
  30309. /**
  30310. * Texture data come from a prefiltered cube data file
  30311. */
  30312. CubePrefiltered = 9,
  30313. /**
  30314. * Texture content is raw 3D data
  30315. */
  30316. Raw3D = 10,
  30317. /**
  30318. * Texture content is a depth texture
  30319. */
  30320. Depth = 11,
  30321. /**
  30322. * Texture data comes from a raw cube data encoded with RGBD
  30323. */
  30324. CubeRawRGBD = 12
  30325. }
  30326. /**
  30327. * Class used to store data associated with WebGL texture data for the engine
  30328. * This class should not be used directly
  30329. */
  30330. export class InternalTexture {
  30331. /** @hidden */
  30332. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30333. /**
  30334. * Defines if the texture is ready
  30335. */
  30336. isReady: boolean;
  30337. /**
  30338. * Defines if the texture is a cube texture
  30339. */
  30340. isCube: boolean;
  30341. /**
  30342. * Defines if the texture contains 3D data
  30343. */
  30344. is3D: boolean;
  30345. /**
  30346. * Defines if the texture contains multiview data
  30347. */
  30348. isMultiview: boolean;
  30349. /**
  30350. * Gets the URL used to load this texture
  30351. */
  30352. url: string;
  30353. /**
  30354. * Gets the sampling mode of the texture
  30355. */
  30356. samplingMode: number;
  30357. /**
  30358. * Gets a boolean indicating if the texture needs mipmaps generation
  30359. */
  30360. generateMipMaps: boolean;
  30361. /**
  30362. * Gets the number of samples used by the texture (WebGL2+ only)
  30363. */
  30364. samples: number;
  30365. /**
  30366. * Gets the type of the texture (int, float...)
  30367. */
  30368. type: number;
  30369. /**
  30370. * Gets the format of the texture (RGB, RGBA...)
  30371. */
  30372. format: number;
  30373. /**
  30374. * Observable called when the texture is loaded
  30375. */
  30376. onLoadedObservable: Observable<InternalTexture>;
  30377. /**
  30378. * Gets the width of the texture
  30379. */
  30380. width: number;
  30381. /**
  30382. * Gets the height of the texture
  30383. */
  30384. height: number;
  30385. /**
  30386. * Gets the depth of the texture
  30387. */
  30388. depth: number;
  30389. /**
  30390. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30391. */
  30392. baseWidth: number;
  30393. /**
  30394. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30395. */
  30396. baseHeight: number;
  30397. /**
  30398. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30399. */
  30400. baseDepth: number;
  30401. /**
  30402. * Gets a boolean indicating if the texture is inverted on Y axis
  30403. */
  30404. invertY: boolean;
  30405. /** @hidden */
  30406. _invertVScale: boolean;
  30407. /** @hidden */
  30408. _associatedChannel: number;
  30409. /** @hidden */
  30410. _source: InternalTextureSource;
  30411. /** @hidden */
  30412. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  30413. /** @hidden */
  30414. _bufferView: Nullable<ArrayBufferView>;
  30415. /** @hidden */
  30416. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30417. /** @hidden */
  30418. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30419. /** @hidden */
  30420. _size: number;
  30421. /** @hidden */
  30422. _extension: string;
  30423. /** @hidden */
  30424. _files: Nullable<string[]>;
  30425. /** @hidden */
  30426. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30427. /** @hidden */
  30428. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30429. /** @hidden */
  30430. _framebuffer: Nullable<WebGLFramebuffer>;
  30431. /** @hidden */
  30432. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30433. /** @hidden */
  30434. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30435. /** @hidden */
  30436. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30437. /** @hidden */
  30438. _attachments: Nullable<number[]>;
  30439. /** @hidden */
  30440. _cachedCoordinatesMode: Nullable<number>;
  30441. /** @hidden */
  30442. _cachedWrapU: Nullable<number>;
  30443. /** @hidden */
  30444. _cachedWrapV: Nullable<number>;
  30445. /** @hidden */
  30446. _cachedWrapR: Nullable<number>;
  30447. /** @hidden */
  30448. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30449. /** @hidden */
  30450. _isDisabled: boolean;
  30451. /** @hidden */
  30452. _compression: Nullable<string>;
  30453. /** @hidden */
  30454. _generateStencilBuffer: boolean;
  30455. /** @hidden */
  30456. _generateDepthBuffer: boolean;
  30457. /** @hidden */
  30458. _comparisonFunction: number;
  30459. /** @hidden */
  30460. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30461. /** @hidden */
  30462. _lodGenerationScale: number;
  30463. /** @hidden */
  30464. _lodGenerationOffset: number;
  30465. /** @hidden */
  30466. _colorTextureArray: Nullable<WebGLTexture>;
  30467. /** @hidden */
  30468. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30469. /** @hidden */
  30470. _lodTextureHigh: Nullable<BaseTexture>;
  30471. /** @hidden */
  30472. _lodTextureMid: Nullable<BaseTexture>;
  30473. /** @hidden */
  30474. _lodTextureLow: Nullable<BaseTexture>;
  30475. /** @hidden */
  30476. _isRGBD: boolean;
  30477. /** @hidden */
  30478. _linearSpecularLOD: boolean;
  30479. /** @hidden */
  30480. _irradianceTexture: Nullable<BaseTexture>;
  30481. /** @hidden */
  30482. _webGLTexture: Nullable<WebGLTexture>;
  30483. /** @hidden */
  30484. _references: number;
  30485. private _engine;
  30486. /**
  30487. * Gets the Engine the texture belongs to.
  30488. * @returns The babylon engine
  30489. */
  30490. getEngine(): ThinEngine;
  30491. /**
  30492. * Gets the data source type of the texture
  30493. */
  30494. readonly source: InternalTextureSource;
  30495. /**
  30496. * Creates a new InternalTexture
  30497. * @param engine defines the engine to use
  30498. * @param source defines the type of data that will be used
  30499. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30500. */
  30501. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  30502. /**
  30503. * Increments the number of references (ie. the number of Texture that point to it)
  30504. */
  30505. incrementReferences(): void;
  30506. /**
  30507. * Change the size of the texture (not the size of the content)
  30508. * @param width defines the new width
  30509. * @param height defines the new height
  30510. * @param depth defines the new depth (1 by default)
  30511. */
  30512. updateSize(width: int, height: int, depth?: int): void;
  30513. /** @hidden */
  30514. _rebuild(): void;
  30515. /** @hidden */
  30516. _swapAndDie(target: InternalTexture): void;
  30517. /**
  30518. * Dispose the current allocated resources
  30519. */
  30520. dispose(): void;
  30521. }
  30522. }
  30523. declare module BABYLON {
  30524. /**
  30525. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30527. */
  30528. export class Analyser {
  30529. /**
  30530. * Gets or sets the smoothing
  30531. * @ignorenaming
  30532. */
  30533. SMOOTHING: number;
  30534. /**
  30535. * Gets or sets the FFT table size
  30536. * @ignorenaming
  30537. */
  30538. FFT_SIZE: number;
  30539. /**
  30540. * Gets or sets the bar graph amplitude
  30541. * @ignorenaming
  30542. */
  30543. BARGRAPHAMPLITUDE: number;
  30544. /**
  30545. * Gets or sets the position of the debug canvas
  30546. * @ignorenaming
  30547. */
  30548. DEBUGCANVASPOS: {
  30549. x: number;
  30550. y: number;
  30551. };
  30552. /**
  30553. * Gets or sets the debug canvas size
  30554. * @ignorenaming
  30555. */
  30556. DEBUGCANVASSIZE: {
  30557. width: number;
  30558. height: number;
  30559. };
  30560. private _byteFreqs;
  30561. private _byteTime;
  30562. private _floatFreqs;
  30563. private _webAudioAnalyser;
  30564. private _debugCanvas;
  30565. private _debugCanvasContext;
  30566. private _scene;
  30567. private _registerFunc;
  30568. private _audioEngine;
  30569. /**
  30570. * Creates a new analyser
  30571. * @param scene defines hosting scene
  30572. */
  30573. constructor(scene: Scene);
  30574. /**
  30575. * Get the number of data values you will have to play with for the visualization
  30576. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30577. * @returns a number
  30578. */
  30579. getFrequencyBinCount(): number;
  30580. /**
  30581. * Gets the current frequency data as a byte array
  30582. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30583. * @returns a Uint8Array
  30584. */
  30585. getByteFrequencyData(): Uint8Array;
  30586. /**
  30587. * Gets the current waveform as a byte array
  30588. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30589. * @returns a Uint8Array
  30590. */
  30591. getByteTimeDomainData(): Uint8Array;
  30592. /**
  30593. * Gets the current frequency data as a float array
  30594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30595. * @returns a Float32Array
  30596. */
  30597. getFloatFrequencyData(): Float32Array;
  30598. /**
  30599. * Renders the debug canvas
  30600. */
  30601. drawDebugCanvas(): void;
  30602. /**
  30603. * Stops rendering the debug canvas and removes it
  30604. */
  30605. stopDebugCanvas(): void;
  30606. /**
  30607. * Connects two audio nodes
  30608. * @param inputAudioNode defines first node to connect
  30609. * @param outputAudioNode defines second node to connect
  30610. */
  30611. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30612. /**
  30613. * Releases all associated resources
  30614. */
  30615. dispose(): void;
  30616. }
  30617. }
  30618. declare module BABYLON {
  30619. /**
  30620. * This represents an audio engine and it is responsible
  30621. * to play, synchronize and analyse sounds throughout the application.
  30622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30623. */
  30624. export interface IAudioEngine extends IDisposable {
  30625. /**
  30626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30627. */
  30628. readonly canUseWebAudio: boolean;
  30629. /**
  30630. * Gets the current AudioContext if available.
  30631. */
  30632. readonly audioContext: Nullable<AudioContext>;
  30633. /**
  30634. * The master gain node defines the global audio volume of your audio engine.
  30635. */
  30636. readonly masterGain: GainNode;
  30637. /**
  30638. * Gets whether or not mp3 are supported by your browser.
  30639. */
  30640. readonly isMP3supported: boolean;
  30641. /**
  30642. * Gets whether or not ogg are supported by your browser.
  30643. */
  30644. readonly isOGGsupported: boolean;
  30645. /**
  30646. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30647. * @ignoreNaming
  30648. */
  30649. WarnedWebAudioUnsupported: boolean;
  30650. /**
  30651. * Defines if the audio engine relies on a custom unlocked button.
  30652. * In this case, the embedded button will not be displayed.
  30653. */
  30654. useCustomUnlockedButton: boolean;
  30655. /**
  30656. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30657. */
  30658. readonly unlocked: boolean;
  30659. /**
  30660. * Event raised when audio has been unlocked on the browser.
  30661. */
  30662. onAudioUnlockedObservable: Observable<AudioEngine>;
  30663. /**
  30664. * Event raised when audio has been locked on the browser.
  30665. */
  30666. onAudioLockedObservable: Observable<AudioEngine>;
  30667. /**
  30668. * Flags the audio engine in Locked state.
  30669. * This happens due to new browser policies preventing audio to autoplay.
  30670. */
  30671. lock(): void;
  30672. /**
  30673. * Unlocks the audio engine once a user action has been done on the dom.
  30674. * This is helpful to resume play once browser policies have been satisfied.
  30675. */
  30676. unlock(): void;
  30677. }
  30678. /**
  30679. * This represents the default audio engine used in babylon.
  30680. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30682. */
  30683. export class AudioEngine implements IAudioEngine {
  30684. private _audioContext;
  30685. private _audioContextInitialized;
  30686. private _muteButton;
  30687. private _hostElement;
  30688. /**
  30689. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30690. */
  30691. canUseWebAudio: boolean;
  30692. /**
  30693. * The master gain node defines the global audio volume of your audio engine.
  30694. */
  30695. masterGain: GainNode;
  30696. /**
  30697. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30698. * @ignoreNaming
  30699. */
  30700. WarnedWebAudioUnsupported: boolean;
  30701. /**
  30702. * Gets whether or not mp3 are supported by your browser.
  30703. */
  30704. isMP3supported: boolean;
  30705. /**
  30706. * Gets whether or not ogg are supported by your browser.
  30707. */
  30708. isOGGsupported: boolean;
  30709. /**
  30710. * Gets whether audio has been unlocked on the device.
  30711. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30712. * a user interaction has happened.
  30713. */
  30714. unlocked: boolean;
  30715. /**
  30716. * Defines if the audio engine relies on a custom unlocked button.
  30717. * In this case, the embedded button will not be displayed.
  30718. */
  30719. useCustomUnlockedButton: boolean;
  30720. /**
  30721. * Event raised when audio has been unlocked on the browser.
  30722. */
  30723. onAudioUnlockedObservable: Observable<AudioEngine>;
  30724. /**
  30725. * Event raised when audio has been locked on the browser.
  30726. */
  30727. onAudioLockedObservable: Observable<AudioEngine>;
  30728. /**
  30729. * Gets the current AudioContext if available.
  30730. */
  30731. readonly audioContext: Nullable<AudioContext>;
  30732. private _connectedAnalyser;
  30733. /**
  30734. * Instantiates a new audio engine.
  30735. *
  30736. * There should be only one per page as some browsers restrict the number
  30737. * of audio contexts you can create.
  30738. * @param hostElement defines the host element where to display the mute icon if necessary
  30739. */
  30740. constructor(hostElement?: Nullable<HTMLElement>);
  30741. /**
  30742. * Flags the audio engine in Locked state.
  30743. * This happens due to new browser policies preventing audio to autoplay.
  30744. */
  30745. lock(): void;
  30746. /**
  30747. * Unlocks the audio engine once a user action has been done on the dom.
  30748. * This is helpful to resume play once browser policies have been satisfied.
  30749. */
  30750. unlock(): void;
  30751. private _resumeAudioContext;
  30752. private _initializeAudioContext;
  30753. private _tryToRun;
  30754. private _triggerRunningState;
  30755. private _triggerSuspendedState;
  30756. private _displayMuteButton;
  30757. private _moveButtonToTopLeft;
  30758. private _onResize;
  30759. private _hideMuteButton;
  30760. /**
  30761. * Destroy and release the resources associated with the audio ccontext.
  30762. */
  30763. dispose(): void;
  30764. /**
  30765. * Gets the global volume sets on the master gain.
  30766. * @returns the global volume if set or -1 otherwise
  30767. */
  30768. getGlobalVolume(): number;
  30769. /**
  30770. * Sets the global volume of your experience (sets on the master gain).
  30771. * @param newVolume Defines the new global volume of the application
  30772. */
  30773. setGlobalVolume(newVolume: number): void;
  30774. /**
  30775. * Connect the audio engine to an audio analyser allowing some amazing
  30776. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30778. * @param analyser The analyser to connect to the engine
  30779. */
  30780. connectToAnalyser(analyser: Analyser): void;
  30781. }
  30782. }
  30783. declare module BABYLON {
  30784. /**
  30785. * Interface used to present a loading screen while loading a scene
  30786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30787. */
  30788. export interface ILoadingScreen {
  30789. /**
  30790. * Function called to display the loading screen
  30791. */
  30792. displayLoadingUI: () => void;
  30793. /**
  30794. * Function called to hide the loading screen
  30795. */
  30796. hideLoadingUI: () => void;
  30797. /**
  30798. * Gets or sets the color to use for the background
  30799. */
  30800. loadingUIBackgroundColor: string;
  30801. /**
  30802. * Gets or sets the text to display while loading
  30803. */
  30804. loadingUIText: string;
  30805. }
  30806. /**
  30807. * Class used for the default loading screen
  30808. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30809. */
  30810. export class DefaultLoadingScreen implements ILoadingScreen {
  30811. private _renderingCanvas;
  30812. private _loadingText;
  30813. private _loadingDivBackgroundColor;
  30814. private _loadingDiv;
  30815. private _loadingTextDiv;
  30816. /** Gets or sets the logo url to use for the default loading screen */
  30817. static DefaultLogoUrl: string;
  30818. /** Gets or sets the spinner url to use for the default loading screen */
  30819. static DefaultSpinnerUrl: string;
  30820. /**
  30821. * Creates a new default loading screen
  30822. * @param _renderingCanvas defines the canvas used to render the scene
  30823. * @param _loadingText defines the default text to display
  30824. * @param _loadingDivBackgroundColor defines the default background color
  30825. */
  30826. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30827. /**
  30828. * Function called to display the loading screen
  30829. */
  30830. displayLoadingUI(): void;
  30831. /**
  30832. * Function called to hide the loading screen
  30833. */
  30834. hideLoadingUI(): void;
  30835. /**
  30836. * Gets or sets the text to display while loading
  30837. */
  30838. loadingUIText: string;
  30839. /**
  30840. * Gets or sets the color to use for the background
  30841. */
  30842. loadingUIBackgroundColor: string;
  30843. private _resizeLoadingUI;
  30844. }
  30845. }
  30846. declare module BABYLON {
  30847. /**
  30848. * Interface for any object that can request an animation frame
  30849. */
  30850. export interface ICustomAnimationFrameRequester {
  30851. /**
  30852. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30853. */
  30854. renderFunction?: Function;
  30855. /**
  30856. * Called to request the next frame to render to
  30857. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30858. */
  30859. requestAnimationFrame: Function;
  30860. /**
  30861. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30862. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30863. */
  30864. requestID?: number;
  30865. }
  30866. }
  30867. declare module BABYLON {
  30868. /**
  30869. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30870. */
  30871. export class PerformanceMonitor {
  30872. private _enabled;
  30873. private _rollingFrameTime;
  30874. private _lastFrameTimeMs;
  30875. /**
  30876. * constructor
  30877. * @param frameSampleSize The number of samples required to saturate the sliding window
  30878. */
  30879. constructor(frameSampleSize?: number);
  30880. /**
  30881. * Samples current frame
  30882. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30883. */
  30884. sampleFrame(timeMs?: number): void;
  30885. /**
  30886. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30887. */
  30888. readonly averageFrameTime: number;
  30889. /**
  30890. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30891. */
  30892. readonly averageFrameTimeVariance: number;
  30893. /**
  30894. * Returns the frame time of the most recent frame
  30895. */
  30896. readonly instantaneousFrameTime: number;
  30897. /**
  30898. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30899. */
  30900. readonly averageFPS: number;
  30901. /**
  30902. * Returns the average framerate in frames per second using the most recent frame time
  30903. */
  30904. readonly instantaneousFPS: number;
  30905. /**
  30906. * Returns true if enough samples have been taken to completely fill the sliding window
  30907. */
  30908. readonly isSaturated: boolean;
  30909. /**
  30910. * Enables contributions to the sliding window sample set
  30911. */
  30912. enable(): void;
  30913. /**
  30914. * Disables contributions to the sliding window sample set
  30915. * Samples will not be interpolated over the disabled period
  30916. */
  30917. disable(): void;
  30918. /**
  30919. * Returns true if sampling is enabled
  30920. */
  30921. readonly isEnabled: boolean;
  30922. /**
  30923. * Resets performance monitor
  30924. */
  30925. reset(): void;
  30926. }
  30927. /**
  30928. * RollingAverage
  30929. *
  30930. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30931. */
  30932. export class RollingAverage {
  30933. /**
  30934. * Current average
  30935. */
  30936. average: number;
  30937. /**
  30938. * Current variance
  30939. */
  30940. variance: number;
  30941. protected _samples: Array<number>;
  30942. protected _sampleCount: number;
  30943. protected _pos: number;
  30944. protected _m2: number;
  30945. /**
  30946. * constructor
  30947. * @param length The number of samples required to saturate the sliding window
  30948. */
  30949. constructor(length: number);
  30950. /**
  30951. * Adds a sample to the sample set
  30952. * @param v The sample value
  30953. */
  30954. add(v: number): void;
  30955. /**
  30956. * Returns previously added values or null if outside of history or outside the sliding window domain
  30957. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30958. * @return Value previously recorded with add() or null if outside of range
  30959. */
  30960. history(i: number): number;
  30961. /**
  30962. * Returns true if enough samples have been taken to completely fill the sliding window
  30963. * @return true if sample-set saturated
  30964. */
  30965. isSaturated(): boolean;
  30966. /**
  30967. * Resets the rolling average (equivalent to 0 samples taken so far)
  30968. */
  30969. reset(): void;
  30970. /**
  30971. * Wraps a value around the sample range boundaries
  30972. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30973. * @return Wrapped position in sample range
  30974. */
  30975. protected _wrapPosition(i: number): number;
  30976. }
  30977. }
  30978. declare module BABYLON {
  30979. /**
  30980. * This class is used to track a performance counter which is number based.
  30981. * The user has access to many properties which give statistics of different nature.
  30982. *
  30983. * The implementer can track two kinds of Performance Counter: time and count.
  30984. * 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.
  30985. * 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.
  30986. */
  30987. export class PerfCounter {
  30988. /**
  30989. * Gets or sets a global boolean to turn on and off all the counters
  30990. */
  30991. static Enabled: boolean;
  30992. /**
  30993. * Returns the smallest value ever
  30994. */
  30995. readonly min: number;
  30996. /**
  30997. * Returns the biggest value ever
  30998. */
  30999. readonly max: number;
  31000. /**
  31001. * Returns the average value since the performance counter is running
  31002. */
  31003. readonly average: number;
  31004. /**
  31005. * Returns the average value of the last second the counter was monitored
  31006. */
  31007. readonly lastSecAverage: number;
  31008. /**
  31009. * Returns the current value
  31010. */
  31011. readonly current: number;
  31012. /**
  31013. * Gets the accumulated total
  31014. */
  31015. readonly total: number;
  31016. /**
  31017. * Gets the total value count
  31018. */
  31019. readonly count: number;
  31020. /**
  31021. * Creates a new counter
  31022. */
  31023. constructor();
  31024. /**
  31025. * Call this method to start monitoring a new frame.
  31026. * 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.
  31027. */
  31028. fetchNewFrame(): void;
  31029. /**
  31030. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31031. * @param newCount the count value to add to the monitored count
  31032. * @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.
  31033. */
  31034. addCount(newCount: number, fetchResult: boolean): void;
  31035. /**
  31036. * Start monitoring this performance counter
  31037. */
  31038. beginMonitoring(): void;
  31039. /**
  31040. * Compute the time lapsed since the previous beginMonitoring() call.
  31041. * @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
  31042. */
  31043. endMonitoring(newFrame?: boolean): void;
  31044. private _fetchResult;
  31045. private _startMonitoringTime;
  31046. private _min;
  31047. private _max;
  31048. private _average;
  31049. private _current;
  31050. private _totalValueCount;
  31051. private _totalAccumulated;
  31052. private _lastSecAverage;
  31053. private _lastSecAccumulated;
  31054. private _lastSecTime;
  31055. private _lastSecValueCount;
  31056. }
  31057. }
  31058. declare module BABYLON {
  31059. /**
  31060. * Defines the interface used by display changed events
  31061. */
  31062. export interface IDisplayChangedEventArgs {
  31063. /** Gets the vrDisplay object (if any) */
  31064. vrDisplay: Nullable<any>;
  31065. /** Gets a boolean indicating if webVR is supported */
  31066. vrSupported: boolean;
  31067. }
  31068. /**
  31069. * Defines the interface used by objects containing a viewport (like a camera)
  31070. */
  31071. interface IViewportOwnerLike {
  31072. /**
  31073. * Gets or sets the viewport
  31074. */
  31075. viewport: IViewportLike;
  31076. }
  31077. /**
  31078. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31079. */
  31080. export class Engine extends ThinEngine {
  31081. /** Defines that alpha blending is disabled */
  31082. static readonly ALPHA_DISABLE: number;
  31083. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31084. static readonly ALPHA_ADD: number;
  31085. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31086. static readonly ALPHA_COMBINE: number;
  31087. /** Defines that alpha blending to DEST - SRC * DEST */
  31088. static readonly ALPHA_SUBTRACT: number;
  31089. /** Defines that alpha blending to SRC * DEST */
  31090. static readonly ALPHA_MULTIPLY: number;
  31091. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31092. static readonly ALPHA_MAXIMIZED: number;
  31093. /** Defines that alpha blending to SRC + DEST */
  31094. static readonly ALPHA_ONEONE: number;
  31095. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31096. static readonly ALPHA_PREMULTIPLIED: number;
  31097. /**
  31098. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31099. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31100. */
  31101. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31102. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31103. static readonly ALPHA_INTERPOLATE: number;
  31104. /**
  31105. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31106. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31107. */
  31108. static readonly ALPHA_SCREENMODE: number;
  31109. /** Defines that the ressource is not delayed*/
  31110. static readonly DELAYLOADSTATE_NONE: number;
  31111. /** Defines that the ressource was successfully delay loaded */
  31112. static readonly DELAYLOADSTATE_LOADED: number;
  31113. /** Defines that the ressource is currently delay loading */
  31114. static readonly DELAYLOADSTATE_LOADING: number;
  31115. /** Defines that the ressource is delayed and has not started loading */
  31116. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31117. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31118. static readonly NEVER: number;
  31119. /** 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 */
  31120. static readonly ALWAYS: number;
  31121. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31122. static readonly LESS: number;
  31123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31124. static readonly EQUAL: number;
  31125. /** 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 */
  31126. static readonly LEQUAL: number;
  31127. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31128. static readonly GREATER: number;
  31129. /** 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 */
  31130. static readonly GEQUAL: number;
  31131. /** 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 */
  31132. static readonly NOTEQUAL: number;
  31133. /** Passed to stencilOperation to specify that stencil value must be kept */
  31134. static readonly KEEP: number;
  31135. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31136. static readonly REPLACE: number;
  31137. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31138. static readonly INCR: number;
  31139. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31140. static readonly DECR: number;
  31141. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31142. static readonly INVERT: number;
  31143. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31144. static readonly INCR_WRAP: number;
  31145. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31146. static readonly DECR_WRAP: number;
  31147. /** Texture is not repeating outside of 0..1 UVs */
  31148. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31149. /** Texture is repeating outside of 0..1 UVs */
  31150. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31151. /** Texture is repeating and mirrored */
  31152. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31153. /** ALPHA */
  31154. static readonly TEXTUREFORMAT_ALPHA: number;
  31155. /** LUMINANCE */
  31156. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31157. /** LUMINANCE_ALPHA */
  31158. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31159. /** RGB */
  31160. static readonly TEXTUREFORMAT_RGB: number;
  31161. /** RGBA */
  31162. static readonly TEXTUREFORMAT_RGBA: number;
  31163. /** RED */
  31164. static readonly TEXTUREFORMAT_RED: number;
  31165. /** RED (2nd reference) */
  31166. static readonly TEXTUREFORMAT_R: number;
  31167. /** RG */
  31168. static readonly TEXTUREFORMAT_RG: number;
  31169. /** RED_INTEGER */
  31170. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31171. /** RED_INTEGER (2nd reference) */
  31172. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31173. /** RG_INTEGER */
  31174. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31175. /** RGB_INTEGER */
  31176. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31177. /** RGBA_INTEGER */
  31178. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31179. /** UNSIGNED_BYTE */
  31180. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31181. /** UNSIGNED_BYTE (2nd reference) */
  31182. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31183. /** FLOAT */
  31184. static readonly TEXTURETYPE_FLOAT: number;
  31185. /** HALF_FLOAT */
  31186. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31187. /** BYTE */
  31188. static readonly TEXTURETYPE_BYTE: number;
  31189. /** SHORT */
  31190. static readonly TEXTURETYPE_SHORT: number;
  31191. /** UNSIGNED_SHORT */
  31192. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31193. /** INT */
  31194. static readonly TEXTURETYPE_INT: number;
  31195. /** UNSIGNED_INT */
  31196. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31197. /** UNSIGNED_SHORT_4_4_4_4 */
  31198. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31199. /** UNSIGNED_SHORT_5_5_5_1 */
  31200. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31201. /** UNSIGNED_SHORT_5_6_5 */
  31202. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31203. /** UNSIGNED_INT_2_10_10_10_REV */
  31204. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31205. /** UNSIGNED_INT_24_8 */
  31206. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31207. /** UNSIGNED_INT_10F_11F_11F_REV */
  31208. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31209. /** UNSIGNED_INT_5_9_9_9_REV */
  31210. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31211. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31212. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31213. /** nearest is mag = nearest and min = nearest and mip = linear */
  31214. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31215. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31216. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31217. /** Trilinear is mag = linear and min = linear and mip = linear */
  31218. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31219. /** nearest is mag = nearest and min = nearest and mip = linear */
  31220. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31221. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31222. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31223. /** Trilinear is mag = linear and min = linear and mip = linear */
  31224. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31225. /** mag = nearest and min = nearest and mip = nearest */
  31226. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31227. /** mag = nearest and min = linear and mip = nearest */
  31228. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31229. /** mag = nearest and min = linear and mip = linear */
  31230. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31231. /** mag = nearest and min = linear and mip = none */
  31232. static readonly TEXTURE_NEAREST_LINEAR: number;
  31233. /** mag = nearest and min = nearest and mip = none */
  31234. static readonly TEXTURE_NEAREST_NEAREST: number;
  31235. /** mag = linear and min = nearest and mip = nearest */
  31236. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31237. /** mag = linear and min = nearest and mip = linear */
  31238. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31239. /** mag = linear and min = linear and mip = none */
  31240. static readonly TEXTURE_LINEAR_LINEAR: number;
  31241. /** mag = linear and min = nearest and mip = none */
  31242. static readonly TEXTURE_LINEAR_NEAREST: number;
  31243. /** Explicit coordinates mode */
  31244. static readonly TEXTURE_EXPLICIT_MODE: number;
  31245. /** Spherical coordinates mode */
  31246. static readonly TEXTURE_SPHERICAL_MODE: number;
  31247. /** Planar coordinates mode */
  31248. static readonly TEXTURE_PLANAR_MODE: number;
  31249. /** Cubic coordinates mode */
  31250. static readonly TEXTURE_CUBIC_MODE: number;
  31251. /** Projection coordinates mode */
  31252. static readonly TEXTURE_PROJECTION_MODE: number;
  31253. /** Skybox coordinates mode */
  31254. static readonly TEXTURE_SKYBOX_MODE: number;
  31255. /** Inverse Cubic coordinates mode */
  31256. static readonly TEXTURE_INVCUBIC_MODE: number;
  31257. /** Equirectangular coordinates mode */
  31258. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31259. /** Equirectangular Fixed coordinates mode */
  31260. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31261. /** Equirectangular Fixed Mirrored coordinates mode */
  31262. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31263. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31264. static readonly SCALEMODE_FLOOR: number;
  31265. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31266. static readonly SCALEMODE_NEAREST: number;
  31267. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31268. static readonly SCALEMODE_CEILING: number;
  31269. /**
  31270. * Returns the current npm package of the sdk
  31271. */
  31272. static readonly NpmPackage: string;
  31273. /**
  31274. * Returns the current version of the framework
  31275. */
  31276. static readonly Version: string;
  31277. /** Gets the list of created engines */
  31278. static readonly Instances: Engine[];
  31279. /**
  31280. * Gets the latest created engine
  31281. */
  31282. static readonly LastCreatedEngine: Nullable<Engine>;
  31283. /**
  31284. * Gets the latest created scene
  31285. */
  31286. static readonly LastCreatedScene: Nullable<Scene>;
  31287. /**
  31288. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31289. * @param flag defines which part of the materials must be marked as dirty
  31290. * @param predicate defines a predicate used to filter which materials should be affected
  31291. */
  31292. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31293. /**
  31294. * Method called to create the default loading screen.
  31295. * This can be overriden in your own app.
  31296. * @param canvas The rendering canvas element
  31297. * @returns The loading screen
  31298. */
  31299. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31300. /**
  31301. * Method called to create the default rescale post process on each engine.
  31302. */
  31303. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31304. /**
  31305. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31306. **/
  31307. enableOfflineSupport: boolean;
  31308. /**
  31309. * 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)
  31310. **/
  31311. disableManifestCheck: boolean;
  31312. /**
  31313. * Gets the list of created scenes
  31314. */
  31315. scenes: Scene[];
  31316. /**
  31317. * Event raised when a new scene is created
  31318. */
  31319. onNewSceneAddedObservable: Observable<Scene>;
  31320. /**
  31321. * Gets the list of created postprocesses
  31322. */
  31323. postProcesses: PostProcess[];
  31324. /**
  31325. * Gets a boolean indicating if the pointer is currently locked
  31326. */
  31327. isPointerLock: boolean;
  31328. /**
  31329. * Observable event triggered each time the rendering canvas is resized
  31330. */
  31331. onResizeObservable: Observable<Engine>;
  31332. /**
  31333. * Observable event triggered each time the canvas loses focus
  31334. */
  31335. onCanvasBlurObservable: Observable<Engine>;
  31336. /**
  31337. * Observable event triggered each time the canvas gains focus
  31338. */
  31339. onCanvasFocusObservable: Observable<Engine>;
  31340. /**
  31341. * Observable event triggered each time the canvas receives pointerout event
  31342. */
  31343. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31344. /**
  31345. * Observable raised when the engine begins a new frame
  31346. */
  31347. onBeginFrameObservable: Observable<Engine>;
  31348. /**
  31349. * If set, will be used to request the next animation frame for the render loop
  31350. */
  31351. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31352. /**
  31353. * Observable raised when the engine ends the current frame
  31354. */
  31355. onEndFrameObservable: Observable<Engine>;
  31356. /**
  31357. * Observable raised when the engine is about to compile a shader
  31358. */
  31359. onBeforeShaderCompilationObservable: Observable<Engine>;
  31360. /**
  31361. * Observable raised when the engine has jsut compiled a shader
  31362. */
  31363. onAfterShaderCompilationObservable: Observable<Engine>;
  31364. /**
  31365. * Gets the audio engine
  31366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31367. * @ignorenaming
  31368. */
  31369. static audioEngine: IAudioEngine;
  31370. /**
  31371. * Default AudioEngine factory responsible of creating the Audio Engine.
  31372. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31373. */
  31374. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31375. /**
  31376. * Default offline support factory responsible of creating a tool used to store data locally.
  31377. * By default, this will create a Database object if the workload has been embedded.
  31378. */
  31379. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31380. private _loadingScreen;
  31381. private _pointerLockRequested;
  31382. private _dummyFramebuffer;
  31383. private _rescalePostProcess;
  31384. /** @hidden */
  31385. protected _alphaMode: number;
  31386. /** @hidden */
  31387. protected _alphaEquation: number;
  31388. private _deterministicLockstep;
  31389. private _lockstepMaxSteps;
  31390. protected readonly _supportsHardwareTextureRescaling: boolean;
  31391. private _fps;
  31392. private _deltaTime;
  31393. /** @hidden */
  31394. _drawCalls: PerfCounter;
  31395. /**
  31396. * Turn this value on if you want to pause FPS computation when in background
  31397. */
  31398. disablePerformanceMonitorInBackground: boolean;
  31399. private _performanceMonitor;
  31400. /**
  31401. * Gets the performance monitor attached to this engine
  31402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31403. */
  31404. readonly performanceMonitor: PerformanceMonitor;
  31405. private _onFocus;
  31406. private _onBlur;
  31407. private _onCanvasPointerOut;
  31408. private _onCanvasBlur;
  31409. private _onCanvasFocus;
  31410. private _onFullscreenChange;
  31411. private _onPointerLockChange;
  31412. /**
  31413. * Creates a new engine
  31414. * @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
  31415. * @param antialias defines enable antialiasing (default: false)
  31416. * @param options defines further options to be sent to the getContext() function
  31417. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31418. */
  31419. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31420. /**
  31421. * Gets current aspect ratio
  31422. * @param viewportOwner defines the camera to use to get the aspect ratio
  31423. * @param useScreen defines if screen size must be used (or the current render target if any)
  31424. * @returns a number defining the aspect ratio
  31425. */
  31426. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31427. /**
  31428. * Gets current screen aspect ratio
  31429. * @returns a number defining the aspect ratio
  31430. */
  31431. getScreenAspectRatio(): number;
  31432. /**
  31433. * Gets host document
  31434. * @returns the host document object
  31435. */
  31436. getHostDocument(): Document;
  31437. /**
  31438. * Gets the client rect of the HTML canvas attached with the current webGL context
  31439. * @returns a client rectanglee
  31440. */
  31441. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31442. /**
  31443. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31444. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31445. * @returns true if engine is in deterministic lock step mode
  31446. */
  31447. isDeterministicLockStep(): boolean;
  31448. /**
  31449. * Gets the max steps when engine is running in deterministic lock step
  31450. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31451. * @returns the max steps
  31452. */
  31453. getLockstepMaxSteps(): number;
  31454. /**
  31455. * Force the mipmap generation for the given render target texture
  31456. * @param texture defines the render target texture to use
  31457. */
  31458. generateMipMapsForCubemap(texture: InternalTexture): void;
  31459. /** States */
  31460. /**
  31461. * Set various states to the webGL context
  31462. * @param culling defines backface culling state
  31463. * @param zOffset defines the value to apply to zOffset (0 by default)
  31464. * @param force defines if states must be applied even if cache is up to date
  31465. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31466. */
  31467. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31468. /**
  31469. * Set the z offset to apply to current rendering
  31470. * @param value defines the offset to apply
  31471. */
  31472. setZOffset(value: number): void;
  31473. /**
  31474. * Gets the current value of the zOffset
  31475. * @returns the current zOffset state
  31476. */
  31477. getZOffset(): number;
  31478. /**
  31479. * Enable or disable depth buffering
  31480. * @param enable defines the state to set
  31481. */
  31482. setDepthBuffer(enable: boolean): void;
  31483. /**
  31484. * Gets a boolean indicating if depth writing is enabled
  31485. * @returns the current depth writing state
  31486. */
  31487. getDepthWrite(): boolean;
  31488. /**
  31489. * Enable or disable depth writing
  31490. * @param enable defines the state to set
  31491. */
  31492. setDepthWrite(enable: boolean): void;
  31493. /**
  31494. * Enable or disable color writing
  31495. * @param enable defines the state to set
  31496. */
  31497. setColorWrite(enable: boolean): void;
  31498. /**
  31499. * Gets a boolean indicating if color writing is enabled
  31500. * @returns the current color writing state
  31501. */
  31502. getColorWrite(): boolean;
  31503. /**
  31504. * Sets alpha constants used by some alpha blending modes
  31505. * @param r defines the red component
  31506. * @param g defines the green component
  31507. * @param b defines the blue component
  31508. * @param a defines the alpha component
  31509. */
  31510. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31511. /**
  31512. * Sets the current alpha mode
  31513. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31514. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31516. */
  31517. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31518. /**
  31519. * Gets the current alpha mode
  31520. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31521. * @returns the current alpha mode
  31522. */
  31523. getAlphaMode(): number;
  31524. /**
  31525. * Sets the current alpha equation
  31526. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31527. */
  31528. setAlphaEquation(equation: number): void;
  31529. /**
  31530. * Gets the current alpha equation.
  31531. * @returns the current alpha equation
  31532. */
  31533. getAlphaEquation(): number;
  31534. /**
  31535. * Gets a boolean indicating if stencil buffer is enabled
  31536. * @returns the current stencil buffer state
  31537. */
  31538. getStencilBuffer(): boolean;
  31539. /**
  31540. * Enable or disable the stencil buffer
  31541. * @param enable defines if the stencil buffer must be enabled or disabled
  31542. */
  31543. setStencilBuffer(enable: boolean): void;
  31544. /**
  31545. * Gets the current stencil mask
  31546. * @returns a number defining the new stencil mask to use
  31547. */
  31548. getStencilMask(): number;
  31549. /**
  31550. * Sets the current stencil mask
  31551. * @param mask defines the new stencil mask to use
  31552. */
  31553. setStencilMask(mask: number): void;
  31554. /**
  31555. * Gets the current stencil function
  31556. * @returns a number defining the stencil function to use
  31557. */
  31558. getStencilFunction(): number;
  31559. /**
  31560. * Gets the current stencil reference value
  31561. * @returns a number defining the stencil reference value to use
  31562. */
  31563. getStencilFunctionReference(): number;
  31564. /**
  31565. * Gets the current stencil mask
  31566. * @returns a number defining the stencil mask to use
  31567. */
  31568. getStencilFunctionMask(): number;
  31569. /**
  31570. * Sets the current stencil function
  31571. * @param stencilFunc defines the new stencil function to use
  31572. */
  31573. setStencilFunction(stencilFunc: number): void;
  31574. /**
  31575. * Sets the current stencil reference
  31576. * @param reference defines the new stencil reference to use
  31577. */
  31578. setStencilFunctionReference(reference: number): void;
  31579. /**
  31580. * Sets the current stencil mask
  31581. * @param mask defines the new stencil mask to use
  31582. */
  31583. setStencilFunctionMask(mask: number): void;
  31584. /**
  31585. * Gets the current stencil operation when stencil fails
  31586. * @returns a number defining stencil operation to use when stencil fails
  31587. */
  31588. getStencilOperationFail(): number;
  31589. /**
  31590. * Gets the current stencil operation when depth fails
  31591. * @returns a number defining stencil operation to use when depth fails
  31592. */
  31593. getStencilOperationDepthFail(): number;
  31594. /**
  31595. * Gets the current stencil operation when stencil passes
  31596. * @returns a number defining stencil operation to use when stencil passes
  31597. */
  31598. getStencilOperationPass(): number;
  31599. /**
  31600. * Sets the stencil operation to use when stencil fails
  31601. * @param operation defines the stencil operation to use when stencil fails
  31602. */
  31603. setStencilOperationFail(operation: number): void;
  31604. /**
  31605. * Sets the stencil operation to use when depth fails
  31606. * @param operation defines the stencil operation to use when depth fails
  31607. */
  31608. setStencilOperationDepthFail(operation: number): void;
  31609. /**
  31610. * Sets the stencil operation to use when stencil passes
  31611. * @param operation defines the stencil operation to use when stencil passes
  31612. */
  31613. setStencilOperationPass(operation: number): void;
  31614. /**
  31615. * Sets a boolean indicating if the dithering state is enabled or disabled
  31616. * @param value defines the dithering state
  31617. */
  31618. setDitheringState(value: boolean): void;
  31619. /**
  31620. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31621. * @param value defines the rasterizer state
  31622. */
  31623. setRasterizerState(value: boolean): void;
  31624. /**
  31625. * Gets the current depth function
  31626. * @returns a number defining the depth function
  31627. */
  31628. getDepthFunction(): Nullable<number>;
  31629. /**
  31630. * Sets the current depth function
  31631. * @param depthFunc defines the function to use
  31632. */
  31633. setDepthFunction(depthFunc: number): void;
  31634. /**
  31635. * Sets the current depth function to GREATER
  31636. */
  31637. setDepthFunctionToGreater(): void;
  31638. /**
  31639. * Sets the current depth function to GEQUAL
  31640. */
  31641. setDepthFunctionToGreaterOrEqual(): void;
  31642. /**
  31643. * Sets the current depth function to LESS
  31644. */
  31645. setDepthFunctionToLess(): void;
  31646. /**
  31647. * Sets the current depth function to LEQUAL
  31648. */
  31649. setDepthFunctionToLessOrEqual(): void;
  31650. private _cachedStencilBuffer;
  31651. private _cachedStencilFunction;
  31652. private _cachedStencilMask;
  31653. private _cachedStencilOperationPass;
  31654. private _cachedStencilOperationFail;
  31655. private _cachedStencilOperationDepthFail;
  31656. private _cachedStencilReference;
  31657. /**
  31658. * Caches the the state of the stencil buffer
  31659. */
  31660. cacheStencilState(): void;
  31661. /**
  31662. * Restores the state of the stencil buffer
  31663. */
  31664. restoreStencilState(): void;
  31665. /**
  31666. * Directly set the WebGL Viewport
  31667. * @param x defines the x coordinate of the viewport (in screen space)
  31668. * @param y defines the y coordinate of the viewport (in screen space)
  31669. * @param width defines the width of the viewport (in screen space)
  31670. * @param height defines the height of the viewport (in screen space)
  31671. * @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
  31672. */
  31673. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31674. /**
  31675. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31676. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31677. * @param y defines the y-coordinate of the corner of the clear rectangle
  31678. * @param width defines the width of the clear rectangle
  31679. * @param height defines the height of the clear rectangle
  31680. * @param clearColor defines the clear color
  31681. */
  31682. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31683. /**
  31684. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31685. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31686. * @param y defines the y-coordinate of the corner of the clear rectangle
  31687. * @param width defines the width of the clear rectangle
  31688. * @param height defines the height of the clear rectangle
  31689. */
  31690. enableScissor(x: number, y: number, width: number, height: number): void;
  31691. /**
  31692. * Disable previously set scissor test rectangle
  31693. */
  31694. disableScissor(): void;
  31695. protected _reportDrawCall(): void;
  31696. /**
  31697. * Initializes a webVR display and starts listening to display change events
  31698. * The onVRDisplayChangedObservable will be notified upon these changes
  31699. * @returns The onVRDisplayChangedObservable
  31700. */
  31701. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31702. /** @hidden */
  31703. _prepareVRComponent(): void;
  31704. /** @hidden */
  31705. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31706. /** @hidden */
  31707. _submitVRFrame(): void;
  31708. /**
  31709. * Call this function to leave webVR mode
  31710. * Will do nothing if webVR is not supported or if there is no webVR device
  31711. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31712. */
  31713. disableVR(): void;
  31714. /**
  31715. * Gets a boolean indicating that the system is in VR mode and is presenting
  31716. * @returns true if VR mode is engaged
  31717. */
  31718. isVRPresenting(): boolean;
  31719. /** @hidden */
  31720. _requestVRFrame(): void;
  31721. /** @hidden */
  31722. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31723. /**
  31724. * Gets the source code of the vertex shader associated with a specific webGL program
  31725. * @param program defines the program to use
  31726. * @returns a string containing the source code of the vertex shader associated with the program
  31727. */
  31728. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31729. /**
  31730. * Gets the source code of the fragment shader associated with a specific webGL program
  31731. * @param program defines the program to use
  31732. * @returns a string containing the source code of the fragment shader associated with the program
  31733. */
  31734. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31735. /**
  31736. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31737. * @param x defines the x coordinate of the rectangle where pixels must be read
  31738. * @param y defines the y coordinate of the rectangle where pixels must be read
  31739. * @param width defines the width of the rectangle where pixels must be read
  31740. * @param height defines the height of the rectangle where pixels must be read
  31741. * @returns a Uint8Array containing RGBA colors
  31742. */
  31743. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31744. /**
  31745. * Sets a depth stencil texture from a render target to the according uniform.
  31746. * @param channel The texture channel
  31747. * @param uniform The uniform to set
  31748. * @param texture The render target texture containing the depth stencil texture to apply
  31749. */
  31750. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31751. /**
  31752. * Sets a texture to the webGL context from a postprocess
  31753. * @param channel defines the channel to use
  31754. * @param postProcess defines the source postprocess
  31755. */
  31756. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31757. /**
  31758. * Binds the output of the passed in post process to the texture channel specified
  31759. * @param channel The channel the texture should be bound to
  31760. * @param postProcess The post process which's output should be bound
  31761. */
  31762. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31763. /** @hidden */
  31764. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31765. protected _rebuildBuffers(): void;
  31766. _renderLoop(): void;
  31767. /**
  31768. * Toggle full screen mode
  31769. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31770. */
  31771. switchFullscreen(requestPointerLock: boolean): void;
  31772. /**
  31773. * Enters full screen mode
  31774. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31775. */
  31776. enterFullscreen(requestPointerLock: boolean): void;
  31777. /**
  31778. * Exits full screen mode
  31779. */
  31780. exitFullscreen(): void;
  31781. /**
  31782. * Enters Pointerlock mode
  31783. */
  31784. enterPointerlock(): void;
  31785. /**
  31786. * Exits Pointerlock mode
  31787. */
  31788. exitPointerlock(): void;
  31789. /**
  31790. * Begin a new frame
  31791. */
  31792. beginFrame(): void;
  31793. /**
  31794. * Enf the current frame
  31795. */
  31796. endFrame(): void;
  31797. resize(): void;
  31798. /**
  31799. * Set the compressed texture format to use, based on the formats you have, and the formats
  31800. * supported by the hardware / browser.
  31801. *
  31802. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31803. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31804. * to API arguments needed to compressed textures. This puts the burden on the container
  31805. * generator to house the arcane code for determining these for current & future formats.
  31806. *
  31807. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31808. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31809. *
  31810. * Note: The result of this call is not taken into account when a texture is base64.
  31811. *
  31812. * @param formatsAvailable defines the list of those format families you have created
  31813. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31814. *
  31815. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31816. * @returns The extension selected.
  31817. */
  31818. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31819. /**
  31820. * Force a specific size of the canvas
  31821. * @param width defines the new canvas' width
  31822. * @param height defines the new canvas' height
  31823. */
  31824. setSize(width: number, height: number): void;
  31825. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31826. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31827. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31828. _releaseTexture(texture: InternalTexture): void;
  31829. /**
  31830. * @hidden
  31831. * Rescales a texture
  31832. * @param source input texutre
  31833. * @param destination destination texture
  31834. * @param scene scene to use to render the resize
  31835. * @param internalFormat format to use when resizing
  31836. * @param onComplete callback to be called when resize has completed
  31837. */
  31838. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31839. /**
  31840. * Gets the current framerate
  31841. * @returns a number representing the framerate
  31842. */
  31843. getFps(): number;
  31844. /**
  31845. * Gets the time spent between current and previous frame
  31846. * @returns a number representing the delta time in ms
  31847. */
  31848. getDeltaTime(): number;
  31849. private _measureFps;
  31850. /**
  31851. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31852. * @param renderTarget The render target to set the frame buffer for
  31853. */
  31854. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31855. /**
  31856. * Update a dynamic index buffer
  31857. * @param indexBuffer defines the target index buffer
  31858. * @param indices defines the data to update
  31859. * @param offset defines the offset in the target index buffer where update should start
  31860. */
  31861. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31862. /**
  31863. * Updates the sample count of a render target texture
  31864. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31865. * @param texture defines the texture to update
  31866. * @param samples defines the sample count to set
  31867. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31868. */
  31869. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31870. /** @hidden */
  31871. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31872. dispose(): void;
  31873. private _disableTouchAction;
  31874. /**
  31875. * Display the loading screen
  31876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31877. */
  31878. displayLoadingUI(): void;
  31879. /**
  31880. * Hide the loading screen
  31881. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31882. */
  31883. hideLoadingUI(): void;
  31884. /**
  31885. * Gets the current loading screen object
  31886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31887. */
  31888. /**
  31889. * Sets the current loading screen object
  31890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31891. */
  31892. loadingScreen: ILoadingScreen;
  31893. /**
  31894. * Sets the current loading screen text
  31895. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31896. */
  31897. loadingUIText: string;
  31898. /**
  31899. * Sets the current loading screen background color
  31900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31901. */
  31902. loadingUIBackgroundColor: string;
  31903. /** Pointerlock and fullscreen */
  31904. /**
  31905. * Ask the browser to promote the current element to pointerlock mode
  31906. * @param element defines the DOM element to promote
  31907. */
  31908. static _RequestPointerlock(element: HTMLElement): void;
  31909. /**
  31910. * Asks the browser to exit pointerlock mode
  31911. */
  31912. static _ExitPointerlock(): void;
  31913. /**
  31914. * Ask the browser to promote the current element to fullscreen rendering mode
  31915. * @param element defines the DOM element to promote
  31916. */
  31917. static _RequestFullscreen(element: HTMLElement): void;
  31918. /**
  31919. * Asks the browser to exit fullscreen mode
  31920. */
  31921. static _ExitFullscreen(): void;
  31922. }
  31923. }
  31924. declare module BABYLON {
  31925. /**
  31926. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31927. * during the life time of the application.
  31928. */
  31929. export class EngineStore {
  31930. /** Gets the list of created engines */
  31931. static Instances: Engine[];
  31932. /** @hidden */
  31933. static _LastCreatedScene: Nullable<Scene>;
  31934. /**
  31935. * Gets the latest created engine
  31936. */
  31937. static readonly LastCreatedEngine: Nullable<Engine>;
  31938. /**
  31939. * Gets the latest created scene
  31940. */
  31941. static readonly LastCreatedScene: Nullable<Scene>;
  31942. /**
  31943. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31944. * @ignorenaming
  31945. */
  31946. static UseFallbackTexture: boolean;
  31947. /**
  31948. * Texture content used if a texture cannot loaded
  31949. * @ignorenaming
  31950. */
  31951. static FallbackTexture: string;
  31952. }
  31953. }
  31954. declare module BABYLON {
  31955. /**
  31956. * Helper class that provides a small promise polyfill
  31957. */
  31958. export class PromisePolyfill {
  31959. /**
  31960. * Static function used to check if the polyfill is required
  31961. * If this is the case then the function will inject the polyfill to window.Promise
  31962. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31963. */
  31964. static Apply(force?: boolean): void;
  31965. }
  31966. }
  31967. declare module BABYLON {
  31968. /**
  31969. * Interface for screenshot methods with describe argument called `size` as object with options
  31970. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31971. */
  31972. export interface IScreenshotSize {
  31973. /**
  31974. * number in pixels for canvas height
  31975. */
  31976. height?: number;
  31977. /**
  31978. * multiplier allowing render at a higher or lower resolution
  31979. * If value is defined then height and width will be ignored and taken from camera
  31980. */
  31981. precision?: number;
  31982. /**
  31983. * number in pixels for canvas width
  31984. */
  31985. width?: number;
  31986. }
  31987. }
  31988. declare module BABYLON {
  31989. interface IColor4Like {
  31990. r: float;
  31991. g: float;
  31992. b: float;
  31993. a: float;
  31994. }
  31995. /**
  31996. * Class containing a set of static utilities functions
  31997. */
  31998. export class Tools {
  31999. /**
  32000. * Gets or sets the base URL to use to load assets
  32001. */
  32002. static BaseUrl: string;
  32003. /**
  32004. * Enable/Disable Custom HTTP Request Headers globally.
  32005. * default = false
  32006. * @see CustomRequestHeaders
  32007. */
  32008. static UseCustomRequestHeaders: boolean;
  32009. /**
  32010. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32011. * i.e. when loading files, where the server/service expects an Authorization header
  32012. */
  32013. static CustomRequestHeaders: {
  32014. [key: string]: string;
  32015. };
  32016. /**
  32017. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32018. */
  32019. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32020. /**
  32021. * Default behaviour for cors in the application.
  32022. * It can be a string if the expected behavior is identical in the entire app.
  32023. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32024. */
  32025. static CorsBehavior: string | ((url: string | string[]) => string);
  32026. /**
  32027. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32028. * @ignorenaming
  32029. */
  32030. static UseFallbackTexture: boolean;
  32031. /**
  32032. * Use this object to register external classes like custom textures or material
  32033. * to allow the laoders to instantiate them
  32034. */
  32035. static RegisteredExternalClasses: {
  32036. [key: string]: Object;
  32037. };
  32038. /**
  32039. * Texture content used if a texture cannot loaded
  32040. * @ignorenaming
  32041. */
  32042. static fallbackTexture: string;
  32043. /**
  32044. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32045. * @param u defines the coordinate on X axis
  32046. * @param v defines the coordinate on Y axis
  32047. * @param width defines the width of the source data
  32048. * @param height defines the height of the source data
  32049. * @param pixels defines the source byte array
  32050. * @param color defines the output color
  32051. */
  32052. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32053. /**
  32054. * Interpolates between a and b via alpha
  32055. * @param a The lower value (returned when alpha = 0)
  32056. * @param b The upper value (returned when alpha = 1)
  32057. * @param alpha The interpolation-factor
  32058. * @return The mixed value
  32059. */
  32060. static Mix(a: number, b: number, alpha: number): number;
  32061. /**
  32062. * Tries to instantiate a new object from a given class name
  32063. * @param className defines the class name to instantiate
  32064. * @returns the new object or null if the system was not able to do the instantiation
  32065. */
  32066. static Instantiate(className: string): any;
  32067. /**
  32068. * Provides a slice function that will work even on IE
  32069. * @param data defines the array to slice
  32070. * @param start defines the start of the data (optional)
  32071. * @param end defines the end of the data (optional)
  32072. * @returns the new sliced array
  32073. */
  32074. static Slice<T>(data: T, start?: number, end?: number): T;
  32075. /**
  32076. * Polyfill for setImmediate
  32077. * @param action defines the action to execute after the current execution block
  32078. */
  32079. static SetImmediate(action: () => void): void;
  32080. /**
  32081. * Function indicating if a number is an exponent of 2
  32082. * @param value defines the value to test
  32083. * @returns true if the value is an exponent of 2
  32084. */
  32085. static IsExponentOfTwo(value: number): boolean;
  32086. private static _tmpFloatArray;
  32087. /**
  32088. * Returns the nearest 32-bit single precision float representation of a Number
  32089. * @param value A Number. If the parameter is of a different type, it will get converted
  32090. * to a number or to NaN if it cannot be converted
  32091. * @returns number
  32092. */
  32093. static FloatRound(value: number): number;
  32094. /**
  32095. * Extracts the filename from a path
  32096. * @param path defines the path to use
  32097. * @returns the filename
  32098. */
  32099. static GetFilename(path: string): string;
  32100. /**
  32101. * Extracts the "folder" part of a path (everything before the filename).
  32102. * @param uri The URI to extract the info from
  32103. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32104. * @returns The "folder" part of the path
  32105. */
  32106. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32107. /**
  32108. * Extracts text content from a DOM element hierarchy
  32109. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32110. */
  32111. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32112. /**
  32113. * Convert an angle in radians to degrees
  32114. * @param angle defines the angle to convert
  32115. * @returns the angle in degrees
  32116. */
  32117. static ToDegrees(angle: number): number;
  32118. /**
  32119. * Convert an angle in degrees to radians
  32120. * @param angle defines the angle to convert
  32121. * @returns the angle in radians
  32122. */
  32123. static ToRadians(angle: number): number;
  32124. /**
  32125. * Encode a buffer to a base64 string
  32126. * @param buffer defines the buffer to encode
  32127. * @returns the encoded string
  32128. */
  32129. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32130. /**
  32131. * Returns an array if obj is not an array
  32132. * @param obj defines the object to evaluate as an array
  32133. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32134. * @returns either obj directly if obj is an array or a new array containing obj
  32135. */
  32136. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32137. /**
  32138. * Gets the pointer prefix to use
  32139. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32140. */
  32141. static GetPointerPrefix(): string;
  32142. /**
  32143. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32144. * @param url define the url we are trying
  32145. * @param element define the dom element where to configure the cors policy
  32146. */
  32147. static SetCorsBehavior(url: string | string[], element: {
  32148. crossOrigin: string | null;
  32149. }): void;
  32150. /**
  32151. * Removes unwanted characters from an url
  32152. * @param url defines the url to clean
  32153. * @returns the cleaned url
  32154. */
  32155. static CleanUrl(url: string): string;
  32156. /**
  32157. * Gets or sets a function used to pre-process url before using them to load assets
  32158. */
  32159. static PreprocessUrl: (url: string) => string;
  32160. /**
  32161. * Loads an image as an HTMLImageElement.
  32162. * @param input url string, ArrayBuffer, or Blob to load
  32163. * @param onLoad callback called when the image successfully loads
  32164. * @param onError callback called when the image fails to load
  32165. * @param offlineProvider offline provider for caching
  32166. * @param mimeType optional mime type
  32167. * @returns the HTMLImageElement of the loaded image
  32168. */
  32169. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32170. /**
  32171. * Loads a file from a url
  32172. * @param url url string, ArrayBuffer, or Blob to load
  32173. * @param onSuccess callback called when the file successfully loads
  32174. * @param onProgress callback called while file is loading (if the server supports this mode)
  32175. * @param offlineProvider defines the offline provider for caching
  32176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32177. * @param onError callback called when the file fails to load
  32178. * @returns a file request object
  32179. */
  32180. 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;
  32181. /**
  32182. * Loads a file from a url
  32183. * @param url the file url to load
  32184. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32185. */
  32186. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32187. /**
  32188. * Load a script (identified by an url). When the url returns, the
  32189. * content of this file is added into a new script element, attached to the DOM (body element)
  32190. * @param scriptUrl defines the url of the script to laod
  32191. * @param onSuccess defines the callback called when the script is loaded
  32192. * @param onError defines the callback to call if an error occurs
  32193. * @param scriptId defines the id of the script element
  32194. */
  32195. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32196. /**
  32197. * Load an asynchronous script (identified by an url). When the url returns, the
  32198. * content of this file is added into a new script element, attached to the DOM (body element)
  32199. * @param scriptUrl defines the url of the script to laod
  32200. * @param scriptId defines the id of the script element
  32201. * @returns a promise request object
  32202. */
  32203. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32204. /**
  32205. * Loads a file from a blob
  32206. * @param fileToLoad defines the blob to use
  32207. * @param callback defines the callback to call when data is loaded
  32208. * @param progressCallback defines the callback to call during loading process
  32209. * @returns a file request object
  32210. */
  32211. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32212. /**
  32213. * Reads a file from a File object
  32214. * @param file defines the file to load
  32215. * @param onSuccess defines the callback to call when data is loaded
  32216. * @param onProgress defines the callback to call during loading process
  32217. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32218. * @param onError defines the callback to call when an error occurs
  32219. * @returns a file request object
  32220. */
  32221. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  32222. /**
  32223. * Creates a data url from a given string content
  32224. * @param content defines the content to convert
  32225. * @returns the new data url link
  32226. */
  32227. static FileAsURL(content: string): string;
  32228. /**
  32229. * Format the given number to a specific decimal format
  32230. * @param value defines the number to format
  32231. * @param decimals defines the number of decimals to use
  32232. * @returns the formatted string
  32233. */
  32234. static Format(value: number, decimals?: number): string;
  32235. /**
  32236. * Tries to copy an object by duplicating every property
  32237. * @param source defines the source object
  32238. * @param destination defines the target object
  32239. * @param doNotCopyList defines a list of properties to avoid
  32240. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32241. */
  32242. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32243. /**
  32244. * Gets a boolean indicating if the given object has no own property
  32245. * @param obj defines the object to test
  32246. * @returns true if object has no own property
  32247. */
  32248. static IsEmpty(obj: any): boolean;
  32249. /**
  32250. * Function used to register events at window level
  32251. * @param windowElement defines the Window object to use
  32252. * @param events defines the events to register
  32253. */
  32254. static RegisterTopRootEvents(windowElement: Window, events: {
  32255. name: string;
  32256. handler: Nullable<(e: FocusEvent) => any>;
  32257. }[]): void;
  32258. /**
  32259. * Function used to unregister events from window level
  32260. * @param windowElement defines the Window object to use
  32261. * @param events defines the events to unregister
  32262. */
  32263. static UnregisterTopRootEvents(windowElement: Window, events: {
  32264. name: string;
  32265. handler: Nullable<(e: FocusEvent) => any>;
  32266. }[]): void;
  32267. /**
  32268. * @ignore
  32269. */
  32270. static _ScreenshotCanvas: HTMLCanvasElement;
  32271. /**
  32272. * Dumps the current bound framebuffer
  32273. * @param width defines the rendering width
  32274. * @param height defines the rendering height
  32275. * @param engine defines the hosting engine
  32276. * @param successCallback defines the callback triggered once the data are available
  32277. * @param mimeType defines the mime type of the result
  32278. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32279. */
  32280. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32281. /**
  32282. * Converts the canvas data to blob.
  32283. * This acts as a polyfill for browsers not supporting the to blob function.
  32284. * @param canvas Defines the canvas to extract the data from
  32285. * @param successCallback Defines the callback triggered once the data are available
  32286. * @param mimeType Defines the mime type of the result
  32287. */
  32288. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32289. /**
  32290. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32291. * @param successCallback defines the callback triggered once the data are available
  32292. * @param mimeType defines the mime type of the result
  32293. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32294. */
  32295. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32296. /**
  32297. * Downloads a blob in the browser
  32298. * @param blob defines the blob to download
  32299. * @param fileName defines the name of the downloaded file
  32300. */
  32301. static Download(blob: Blob, fileName: string): void;
  32302. /**
  32303. * Captures a screenshot of the current rendering
  32304. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32305. * @param engine defines the rendering engine
  32306. * @param camera defines the source camera
  32307. * @param size This parameter can be set to a single number or to an object with the
  32308. * following (optional) properties: precision, width, height. If a single number is passed,
  32309. * it will be used for both width and height. If an object is passed, the screenshot size
  32310. * will be derived from the parameters. The precision property is a multiplier allowing
  32311. * rendering at a higher or lower resolution
  32312. * @param successCallback defines the callback receives a single parameter which contains the
  32313. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32314. * src parameter of an <img> to display it
  32315. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32316. * Check your browser for supported MIME types
  32317. */
  32318. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32319. /**
  32320. * Captures a screenshot of the current rendering
  32321. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32322. * @param engine defines the rendering engine
  32323. * @param camera defines the source camera
  32324. * @param size This parameter can be set to a single number or to an object with the
  32325. * following (optional) properties: precision, width, height. If a single number is passed,
  32326. * it will be used for both width and height. If an object is passed, the screenshot size
  32327. * will be derived from the parameters. The precision property is a multiplier allowing
  32328. * rendering at a higher or lower resolution
  32329. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32330. * Check your browser for supported MIME types
  32331. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32332. * to the src parameter of an <img> to display it
  32333. */
  32334. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32335. /**
  32336. * Generates an image screenshot from the specified camera.
  32337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32338. * @param engine The engine to use for rendering
  32339. * @param camera The camera to use for rendering
  32340. * @param size This parameter can be set to a single number or to an object with the
  32341. * following (optional) properties: precision, width, height. If a single number is passed,
  32342. * it will be used for both width and height. If an object is passed, the screenshot size
  32343. * will be derived from the parameters. The precision property is a multiplier allowing
  32344. * rendering at a higher or lower resolution
  32345. * @param successCallback The callback receives a single parameter which contains the
  32346. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32347. * src parameter of an <img> to display it
  32348. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32349. * Check your browser for supported MIME types
  32350. * @param samples Texture samples (default: 1)
  32351. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32352. * @param fileName A name for for the downloaded file.
  32353. */
  32354. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32355. /**
  32356. * Generates an image screenshot from the specified camera.
  32357. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32358. * @param engine The engine to use for rendering
  32359. * @param camera The camera to use for rendering
  32360. * @param size This parameter can be set to a single number or to an object with the
  32361. * following (optional) properties: precision, width, height. If a single number is passed,
  32362. * it will be used for both width and height. If an object is passed, the screenshot size
  32363. * will be derived from the parameters. The precision property is a multiplier allowing
  32364. * rendering at a higher or lower resolution
  32365. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32366. * Check your browser for supported MIME types
  32367. * @param samples Texture samples (default: 1)
  32368. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32369. * @param fileName A name for for the downloaded file.
  32370. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32371. * to the src parameter of an <img> to display it
  32372. */
  32373. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32374. /**
  32375. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32376. * Be aware Math.random() could cause collisions, but:
  32377. * "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"
  32378. * @returns a pseudo random id
  32379. */
  32380. static RandomId(): string;
  32381. /**
  32382. * Test if the given uri is a base64 string
  32383. * @param uri The uri to test
  32384. * @return True if the uri is a base64 string or false otherwise
  32385. */
  32386. static IsBase64(uri: string): boolean;
  32387. /**
  32388. * Decode the given base64 uri.
  32389. * @param uri The uri to decode
  32390. * @return The decoded base64 data.
  32391. */
  32392. static DecodeBase64(uri: string): ArrayBuffer;
  32393. /**
  32394. * Gets the absolute url.
  32395. * @param url the input url
  32396. * @return the absolute url
  32397. */
  32398. static GetAbsoluteUrl(url: string): string;
  32399. /**
  32400. * No log
  32401. */
  32402. static readonly NoneLogLevel: number;
  32403. /**
  32404. * Only message logs
  32405. */
  32406. static readonly MessageLogLevel: number;
  32407. /**
  32408. * Only warning logs
  32409. */
  32410. static readonly WarningLogLevel: number;
  32411. /**
  32412. * Only error logs
  32413. */
  32414. static readonly ErrorLogLevel: number;
  32415. /**
  32416. * All logs
  32417. */
  32418. static readonly AllLogLevel: number;
  32419. /**
  32420. * Gets a value indicating the number of loading errors
  32421. * @ignorenaming
  32422. */
  32423. static readonly errorsCount: number;
  32424. /**
  32425. * Callback called when a new log is added
  32426. */
  32427. static OnNewCacheEntry: (entry: string) => void;
  32428. /**
  32429. * Log a message to the console
  32430. * @param message defines the message to log
  32431. */
  32432. static Log(message: string): void;
  32433. /**
  32434. * Write a warning message to the console
  32435. * @param message defines the message to log
  32436. */
  32437. static Warn(message: string): void;
  32438. /**
  32439. * Write an error message to the console
  32440. * @param message defines the message to log
  32441. */
  32442. static Error(message: string): void;
  32443. /**
  32444. * Gets current log cache (list of logs)
  32445. */
  32446. static readonly LogCache: string;
  32447. /**
  32448. * Clears the log cache
  32449. */
  32450. static ClearLogCache(): void;
  32451. /**
  32452. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32453. */
  32454. static LogLevels: number;
  32455. /**
  32456. * Checks if the window object exists
  32457. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32458. */
  32459. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32460. /**
  32461. * No performance log
  32462. */
  32463. static readonly PerformanceNoneLogLevel: number;
  32464. /**
  32465. * Use user marks to log performance
  32466. */
  32467. static readonly PerformanceUserMarkLogLevel: number;
  32468. /**
  32469. * Log performance to the console
  32470. */
  32471. static readonly PerformanceConsoleLogLevel: number;
  32472. private static _performance;
  32473. /**
  32474. * Sets the current performance log level
  32475. */
  32476. static PerformanceLogLevel: number;
  32477. private static _StartPerformanceCounterDisabled;
  32478. private static _EndPerformanceCounterDisabled;
  32479. private static _StartUserMark;
  32480. private static _EndUserMark;
  32481. private static _StartPerformanceConsole;
  32482. private static _EndPerformanceConsole;
  32483. /**
  32484. * Starts a performance counter
  32485. */
  32486. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32487. /**
  32488. * Ends a specific performance coutner
  32489. */
  32490. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32491. /**
  32492. * Gets either window.performance.now() if supported or Date.now() else
  32493. */
  32494. static readonly Now: number;
  32495. /**
  32496. * This method will return the name of the class used to create the instance of the given object.
  32497. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32498. * @param object the object to get the class name from
  32499. * @param isType defines if the object is actually a type
  32500. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32501. */
  32502. static GetClassName(object: any, isType?: boolean): string;
  32503. /**
  32504. * Gets the first element of an array satisfying a given predicate
  32505. * @param array defines the array to browse
  32506. * @param predicate defines the predicate to use
  32507. * @returns null if not found or the element
  32508. */
  32509. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32510. /**
  32511. * This method will return the name of the full name of the class, including its owning module (if any).
  32512. * 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).
  32513. * @param object the object to get the class name from
  32514. * @param isType defines if the object is actually a type
  32515. * @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.
  32516. * @ignorenaming
  32517. */
  32518. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32519. /**
  32520. * Returns a promise that resolves after the given amount of time.
  32521. * @param delay Number of milliseconds to delay
  32522. * @returns Promise that resolves after the given amount of time
  32523. */
  32524. static DelayAsync(delay: number): Promise<void>;
  32525. }
  32526. /**
  32527. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32528. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32529. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32530. * @param name The name of the class, case should be preserved
  32531. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32532. */
  32533. export function className(name: string, module?: string): (target: Object) => void;
  32534. /**
  32535. * An implementation of a loop for asynchronous functions.
  32536. */
  32537. export class AsyncLoop {
  32538. /**
  32539. * Defines the number of iterations for the loop
  32540. */
  32541. iterations: number;
  32542. /**
  32543. * Defines the current index of the loop.
  32544. */
  32545. index: number;
  32546. private _done;
  32547. private _fn;
  32548. private _successCallback;
  32549. /**
  32550. * Constructor.
  32551. * @param iterations the number of iterations.
  32552. * @param func the function to run each iteration
  32553. * @param successCallback the callback that will be called upon succesful execution
  32554. * @param offset starting offset.
  32555. */
  32556. constructor(
  32557. /**
  32558. * Defines the number of iterations for the loop
  32559. */
  32560. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32561. /**
  32562. * Execute the next iteration. Must be called after the last iteration was finished.
  32563. */
  32564. executeNext(): void;
  32565. /**
  32566. * Break the loop and run the success callback.
  32567. */
  32568. breakLoop(): void;
  32569. /**
  32570. * Create and run an async loop.
  32571. * @param iterations the number of iterations.
  32572. * @param fn the function to run each iteration
  32573. * @param successCallback the callback that will be called upon succesful execution
  32574. * @param offset starting offset.
  32575. * @returns the created async loop object
  32576. */
  32577. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32578. /**
  32579. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32580. * @param iterations total number of iterations
  32581. * @param syncedIterations number of synchronous iterations in each async iteration.
  32582. * @param fn the function to call each iteration.
  32583. * @param callback a success call back that will be called when iterating stops.
  32584. * @param breakFunction a break condition (optional)
  32585. * @param timeout timeout settings for the setTimeout function. default - 0.
  32586. * @returns the created async loop object
  32587. */
  32588. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32589. }
  32590. }
  32591. declare module BABYLON {
  32592. /**
  32593. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32594. * The underlying implementation relies on an associative array to ensure the best performances.
  32595. * The value can be anything including 'null' but except 'undefined'
  32596. */
  32597. export class StringDictionary<T> {
  32598. /**
  32599. * This will clear this dictionary and copy the content from the 'source' one.
  32600. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32601. * @param source the dictionary to take the content from and copy to this dictionary
  32602. */
  32603. copyFrom(source: StringDictionary<T>): void;
  32604. /**
  32605. * Get a value based from its key
  32606. * @param key the given key to get the matching value from
  32607. * @return the value if found, otherwise undefined is returned
  32608. */
  32609. get(key: string): T | undefined;
  32610. /**
  32611. * Get a value from its key or add it if it doesn't exist.
  32612. * This method will ensure you that a given key/data will be present in the dictionary.
  32613. * @param key the given key to get the matching value from
  32614. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32615. * The factory will only be invoked if there's no data for the given key.
  32616. * @return the value corresponding to the key.
  32617. */
  32618. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32619. /**
  32620. * Get a value from its key if present in the dictionary otherwise add it
  32621. * @param key the key to get the value from
  32622. * @param val if there's no such key/value pair in the dictionary add it with this value
  32623. * @return the value corresponding to the key
  32624. */
  32625. getOrAdd(key: string, val: T): T;
  32626. /**
  32627. * Check if there's a given key in the dictionary
  32628. * @param key the key to check for
  32629. * @return true if the key is present, false otherwise
  32630. */
  32631. contains(key: string): boolean;
  32632. /**
  32633. * Add a new key and its corresponding value
  32634. * @param key the key to add
  32635. * @param value the value corresponding to the key
  32636. * @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
  32637. */
  32638. add(key: string, value: T): boolean;
  32639. /**
  32640. * Update a specific value associated to a key
  32641. * @param key defines the key to use
  32642. * @param value defines the value to store
  32643. * @returns true if the value was updated (or false if the key was not found)
  32644. */
  32645. set(key: string, value: T): boolean;
  32646. /**
  32647. * Get the element of the given key and remove it from the dictionary
  32648. * @param key defines the key to search
  32649. * @returns the value associated with the key or null if not found
  32650. */
  32651. getAndRemove(key: string): Nullable<T>;
  32652. /**
  32653. * Remove a key/value from the dictionary.
  32654. * @param key the key to remove
  32655. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32656. */
  32657. remove(key: string): boolean;
  32658. /**
  32659. * Clear the whole content of the dictionary
  32660. */
  32661. clear(): void;
  32662. /**
  32663. * Gets the current count
  32664. */
  32665. readonly count: number;
  32666. /**
  32667. * Execute a callback on each key/val of the dictionary.
  32668. * Note that you can remove any element in this dictionary in the callback implementation
  32669. * @param callback the callback to execute on a given key/value pair
  32670. */
  32671. forEach(callback: (key: string, val: T) => void): void;
  32672. /**
  32673. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32674. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32675. * Note that you can remove any element in this dictionary in the callback implementation
  32676. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32677. * @returns the first item
  32678. */
  32679. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32680. private _count;
  32681. private _data;
  32682. }
  32683. }
  32684. declare module BABYLON {
  32685. /** @hidden */
  32686. export interface ICollisionCoordinator {
  32687. createCollider(): Collider;
  32688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32689. init(scene: Scene): void;
  32690. }
  32691. /** @hidden */
  32692. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32693. private _scene;
  32694. private _scaledPosition;
  32695. private _scaledVelocity;
  32696. private _finalPosition;
  32697. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32698. createCollider(): Collider;
  32699. init(scene: Scene): void;
  32700. private _collideWithWorld;
  32701. }
  32702. }
  32703. declare module BABYLON {
  32704. /**
  32705. * Class used to manage all inputs for the scene.
  32706. */
  32707. export class InputManager {
  32708. /** The distance in pixel that you have to move to prevent some events */
  32709. static DragMovementThreshold: number;
  32710. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32711. static LongPressDelay: number;
  32712. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32713. static DoubleClickDelay: number;
  32714. /** If you need to check double click without raising a single click at first click, enable this flag */
  32715. static ExclusiveDoubleClickMode: boolean;
  32716. private _wheelEventName;
  32717. private _onPointerMove;
  32718. private _onPointerDown;
  32719. private _onPointerUp;
  32720. private _initClickEvent;
  32721. private _initActionManager;
  32722. private _delayedSimpleClick;
  32723. private _delayedSimpleClickTimeout;
  32724. private _previousDelayedSimpleClickTimeout;
  32725. private _meshPickProceed;
  32726. private _previousButtonPressed;
  32727. private _currentPickResult;
  32728. private _previousPickResult;
  32729. private _totalPointersPressed;
  32730. private _doubleClickOccured;
  32731. private _pointerOverMesh;
  32732. private _pickedDownMesh;
  32733. private _pickedUpMesh;
  32734. private _pointerX;
  32735. private _pointerY;
  32736. private _unTranslatedPointerX;
  32737. private _unTranslatedPointerY;
  32738. private _startingPointerPosition;
  32739. private _previousStartingPointerPosition;
  32740. private _startingPointerTime;
  32741. private _previousStartingPointerTime;
  32742. private _pointerCaptures;
  32743. private _onKeyDown;
  32744. private _onKeyUp;
  32745. private _onCanvasFocusObserver;
  32746. private _onCanvasBlurObserver;
  32747. private _scene;
  32748. /**
  32749. * Creates a new InputManager
  32750. * @param scene defines the hosting scene
  32751. */
  32752. constructor(scene: Scene);
  32753. /**
  32754. * Gets the mesh that is currently under the pointer
  32755. */
  32756. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32757. /**
  32758. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32759. */
  32760. readonly unTranslatedPointer: Vector2;
  32761. /**
  32762. * Gets or sets the current on-screen X position of the pointer
  32763. */
  32764. pointerX: number;
  32765. /**
  32766. * Gets or sets the current on-screen Y position of the pointer
  32767. */
  32768. pointerY: number;
  32769. private _updatePointerPosition;
  32770. private _processPointerMove;
  32771. private _setRayOnPointerInfo;
  32772. private _checkPrePointerObservable;
  32773. /**
  32774. * Use this method to simulate a pointer move on a mesh
  32775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32778. */
  32779. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32780. /**
  32781. * Use this method to simulate a pointer down on a mesh
  32782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32785. */
  32786. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32787. private _processPointerDown;
  32788. /** @hidden */
  32789. _isPointerSwiping(): boolean;
  32790. /**
  32791. * Use this method to simulate a pointer up on a mesh
  32792. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32793. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32794. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32795. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32796. */
  32797. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32798. private _processPointerUp;
  32799. /**
  32800. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32801. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32802. * @returns true if the pointer was captured
  32803. */
  32804. isPointerCaptured(pointerId?: number): boolean;
  32805. /**
  32806. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32807. * @param attachUp defines if you want to attach events to pointerup
  32808. * @param attachDown defines if you want to attach events to pointerdown
  32809. * @param attachMove defines if you want to attach events to pointermove
  32810. */
  32811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32812. /**
  32813. * Detaches all event handlers
  32814. */
  32815. detachControl(): void;
  32816. /**
  32817. * Force the value of meshUnderPointer
  32818. * @param mesh defines the mesh to use
  32819. */
  32820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32821. /**
  32822. * Gets the mesh under the pointer
  32823. * @returns a Mesh or null if no mesh is under the pointer
  32824. */
  32825. getPointerOverMesh(): Nullable<AbstractMesh>;
  32826. }
  32827. }
  32828. declare module BABYLON {
  32829. /**
  32830. * Helper class used to generate session unique ID
  32831. */
  32832. export class UniqueIdGenerator {
  32833. private static _UniqueIdCounter;
  32834. /**
  32835. * Gets an unique (relatively to the current scene) Id
  32836. */
  32837. static readonly UniqueId: number;
  32838. }
  32839. }
  32840. declare module BABYLON {
  32841. /**
  32842. * This class defines the direct association between an animation and a target
  32843. */
  32844. export class TargetedAnimation {
  32845. /**
  32846. * Animation to perform
  32847. */
  32848. animation: Animation;
  32849. /**
  32850. * Target to animate
  32851. */
  32852. target: any;
  32853. /**
  32854. * Serialize the object
  32855. * @returns the JSON object representing the current entity
  32856. */
  32857. serialize(): any;
  32858. }
  32859. /**
  32860. * Use this class to create coordinated animations on multiple targets
  32861. */
  32862. export class AnimationGroup implements IDisposable {
  32863. /** The name of the animation group */
  32864. name: string;
  32865. private _scene;
  32866. private _targetedAnimations;
  32867. private _animatables;
  32868. private _from;
  32869. private _to;
  32870. private _isStarted;
  32871. private _isPaused;
  32872. private _speedRatio;
  32873. private _loopAnimation;
  32874. /**
  32875. * Gets or sets the unique id of the node
  32876. */
  32877. uniqueId: number;
  32878. /**
  32879. * This observable will notify when one animation have ended
  32880. */
  32881. onAnimationEndObservable: Observable<TargetedAnimation>;
  32882. /**
  32883. * Observer raised when one animation loops
  32884. */
  32885. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32886. /**
  32887. * This observable will notify when all animations have ended.
  32888. */
  32889. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32890. /**
  32891. * This observable will notify when all animations have paused.
  32892. */
  32893. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32894. /**
  32895. * This observable will notify when all animations are playing.
  32896. */
  32897. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32898. /**
  32899. * Gets the first frame
  32900. */
  32901. readonly from: number;
  32902. /**
  32903. * Gets the last frame
  32904. */
  32905. readonly to: number;
  32906. /**
  32907. * Define if the animations are started
  32908. */
  32909. readonly isStarted: boolean;
  32910. /**
  32911. * Gets a value indicating that the current group is playing
  32912. */
  32913. readonly isPlaying: boolean;
  32914. /**
  32915. * Gets or sets the speed ratio to use for all animations
  32916. */
  32917. /**
  32918. * Gets or sets the speed ratio to use for all animations
  32919. */
  32920. speedRatio: number;
  32921. /**
  32922. * Gets or sets if all animations should loop or not
  32923. */
  32924. loopAnimation: boolean;
  32925. /**
  32926. * Gets the targeted animations for this animation group
  32927. */
  32928. readonly targetedAnimations: Array<TargetedAnimation>;
  32929. /**
  32930. * returning the list of animatables controlled by this animation group.
  32931. */
  32932. readonly animatables: Array<Animatable>;
  32933. /**
  32934. * Instantiates a new Animation Group.
  32935. * This helps managing several animations at once.
  32936. * @see http://doc.babylonjs.com/how_to/group
  32937. * @param name Defines the name of the group
  32938. * @param scene Defines the scene the group belongs to
  32939. */
  32940. constructor(
  32941. /** The name of the animation group */
  32942. name: string, scene?: Nullable<Scene>);
  32943. /**
  32944. * Add an animation (with its target) in the group
  32945. * @param animation defines the animation we want to add
  32946. * @param target defines the target of the animation
  32947. * @returns the TargetedAnimation object
  32948. */
  32949. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32950. /**
  32951. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32952. * It can add constant keys at begin or end
  32953. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32954. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32955. * @returns the animation group
  32956. */
  32957. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32958. /**
  32959. * Start all animations on given targets
  32960. * @param loop defines if animations must loop
  32961. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32962. * @param from defines the from key (optional)
  32963. * @param to defines the to key (optional)
  32964. * @returns the current animation group
  32965. */
  32966. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32967. /**
  32968. * Pause all animations
  32969. * @returns the animation group
  32970. */
  32971. pause(): AnimationGroup;
  32972. /**
  32973. * Play all animations to initial state
  32974. * This function will start() the animations if they were not started or will restart() them if they were paused
  32975. * @param loop defines if animations must loop
  32976. * @returns the animation group
  32977. */
  32978. play(loop?: boolean): AnimationGroup;
  32979. /**
  32980. * Reset all animations to initial state
  32981. * @returns the animation group
  32982. */
  32983. reset(): AnimationGroup;
  32984. /**
  32985. * Restart animations from key 0
  32986. * @returns the animation group
  32987. */
  32988. restart(): AnimationGroup;
  32989. /**
  32990. * Stop all animations
  32991. * @returns the animation group
  32992. */
  32993. stop(): AnimationGroup;
  32994. /**
  32995. * Set animation weight for all animatables
  32996. * @param weight defines the weight to use
  32997. * @return the animationGroup
  32998. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32999. */
  33000. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33001. /**
  33002. * Synchronize and normalize all animatables with a source animatable
  33003. * @param root defines the root animatable to synchronize with
  33004. * @return the animationGroup
  33005. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33006. */
  33007. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33008. /**
  33009. * Goes to a specific frame in this animation group
  33010. * @param frame the frame number to go to
  33011. * @return the animationGroup
  33012. */
  33013. goToFrame(frame: number): AnimationGroup;
  33014. /**
  33015. * Dispose all associated resources
  33016. */
  33017. dispose(): void;
  33018. private _checkAnimationGroupEnded;
  33019. /**
  33020. * Clone the current animation group and returns a copy
  33021. * @param newName defines the name of the new group
  33022. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33023. * @returns the new aniamtion group
  33024. */
  33025. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33026. /**
  33027. * Serializes the animationGroup to an object
  33028. * @returns Serialized object
  33029. */
  33030. serialize(): any;
  33031. /**
  33032. * Returns a new AnimationGroup object parsed from the source provided.
  33033. * @param parsedAnimationGroup defines the source
  33034. * @param scene defines the scene that will receive the animationGroup
  33035. * @returns a new AnimationGroup
  33036. */
  33037. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33038. /**
  33039. * Returns the string "AnimationGroup"
  33040. * @returns "AnimationGroup"
  33041. */
  33042. getClassName(): string;
  33043. /**
  33044. * Creates a detailled string about the object
  33045. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33046. * @returns a string representing the object
  33047. */
  33048. toString(fullDetails?: boolean): string;
  33049. }
  33050. }
  33051. declare module BABYLON {
  33052. /**
  33053. * Define an interface for all classes that will hold resources
  33054. */
  33055. export interface IDisposable {
  33056. /**
  33057. * Releases all held resources
  33058. */
  33059. dispose(): void;
  33060. }
  33061. /** Interface defining initialization parameters for Scene class */
  33062. export interface SceneOptions {
  33063. /**
  33064. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33065. * It will improve performance when the number of geometries becomes important.
  33066. */
  33067. useGeometryUniqueIdsMap?: boolean;
  33068. /**
  33069. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33071. */
  33072. useMaterialMeshMap?: boolean;
  33073. /**
  33074. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33076. */
  33077. useClonedMeshhMap?: boolean;
  33078. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33079. virtual?: boolean;
  33080. }
  33081. /**
  33082. * Represents a scene to be rendered by the engine.
  33083. * @see http://doc.babylonjs.com/features/scene
  33084. */
  33085. export class Scene extends AbstractScene implements IAnimatable {
  33086. /** The fog is deactivated */
  33087. static readonly FOGMODE_NONE: number;
  33088. /** The fog density is following an exponential function */
  33089. static readonly FOGMODE_EXP: number;
  33090. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33091. static readonly FOGMODE_EXP2: number;
  33092. /** The fog density is following a linear function. */
  33093. static readonly FOGMODE_LINEAR: number;
  33094. /**
  33095. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33096. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33097. */
  33098. static MinDeltaTime: number;
  33099. /**
  33100. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33102. */
  33103. static MaxDeltaTime: number;
  33104. /**
  33105. * Factory used to create the default material.
  33106. * @param name The name of the material to create
  33107. * @param scene The scene to create the material for
  33108. * @returns The default material
  33109. */
  33110. static DefaultMaterialFactory(scene: Scene): Material;
  33111. /**
  33112. * Factory used to create the a collision coordinator.
  33113. * @returns The collision coordinator
  33114. */
  33115. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33116. /** @hidden */
  33117. _inputManager: InputManager;
  33118. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33119. cameraToUseForPointers: Nullable<Camera>;
  33120. /** @hidden */
  33121. readonly _isScene: boolean;
  33122. /**
  33123. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33124. */
  33125. autoClear: boolean;
  33126. /**
  33127. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33128. */
  33129. autoClearDepthAndStencil: boolean;
  33130. /**
  33131. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33132. */
  33133. clearColor: Color4;
  33134. /**
  33135. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33136. */
  33137. ambientColor: Color3;
  33138. /**
  33139. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33140. * It should only be one of the following (if not the default embedded one):
  33141. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33142. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33143. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33144. * The material properties need to be setup according to the type of texture in use.
  33145. */
  33146. environmentBRDFTexture: BaseTexture;
  33147. /** @hidden */
  33148. protected _environmentTexture: Nullable<BaseTexture>;
  33149. /**
  33150. * Texture used in all pbr material as the reflection texture.
  33151. * As in the majority of the scene they are the same (exception for multi room and so on),
  33152. * this is easier to reference from here than from all the materials.
  33153. */
  33154. /**
  33155. * Texture used in all pbr material as the reflection texture.
  33156. * As in the majority of the scene they are the same (exception for multi room and so on),
  33157. * this is easier to set here than in all the materials.
  33158. */
  33159. environmentTexture: Nullable<BaseTexture>;
  33160. /** @hidden */
  33161. protected _environmentIntensity: number;
  33162. /**
  33163. * Intensity of the environment in all pbr material.
  33164. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33165. * As in the majority of the scene they are the same (exception for multi room and so on),
  33166. * this is easier to reference from here than from all the materials.
  33167. */
  33168. /**
  33169. * Intensity of the environment in all pbr material.
  33170. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33171. * As in the majority of the scene they are the same (exception for multi room and so on),
  33172. * this is easier to set here than in all the materials.
  33173. */
  33174. environmentIntensity: number;
  33175. /** @hidden */
  33176. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33177. /**
  33178. * Default image processing configuration used either in the rendering
  33179. * Forward main pass or through the imageProcessingPostProcess if present.
  33180. * As in the majority of the scene they are the same (exception for multi camera),
  33181. * this is easier to reference from here than from all the materials and post process.
  33182. *
  33183. * No setter as we it is a shared configuration, you can set the values instead.
  33184. */
  33185. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33186. private _forceWireframe;
  33187. /**
  33188. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33189. */
  33190. forceWireframe: boolean;
  33191. private _forcePointsCloud;
  33192. /**
  33193. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33194. */
  33195. forcePointsCloud: boolean;
  33196. /**
  33197. * Gets or sets the active clipplane 1
  33198. */
  33199. clipPlane: Nullable<Plane>;
  33200. /**
  33201. * Gets or sets the active clipplane 2
  33202. */
  33203. clipPlane2: Nullable<Plane>;
  33204. /**
  33205. * Gets or sets the active clipplane 3
  33206. */
  33207. clipPlane3: Nullable<Plane>;
  33208. /**
  33209. * Gets or sets the active clipplane 4
  33210. */
  33211. clipPlane4: Nullable<Plane>;
  33212. /**
  33213. * Gets or sets a boolean indicating if animations are enabled
  33214. */
  33215. animationsEnabled: boolean;
  33216. private _animationPropertiesOverride;
  33217. /**
  33218. * Gets or sets the animation properties override
  33219. */
  33220. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33221. /**
  33222. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33223. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33224. */
  33225. useConstantAnimationDeltaTime: boolean;
  33226. /**
  33227. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33228. * Please note that it requires to run a ray cast through the scene on every frame
  33229. */
  33230. constantlyUpdateMeshUnderPointer: boolean;
  33231. /**
  33232. * Defines the HTML cursor to use when hovering over interactive elements
  33233. */
  33234. hoverCursor: string;
  33235. /**
  33236. * Defines the HTML default cursor to use (empty by default)
  33237. */
  33238. defaultCursor: string;
  33239. /**
  33240. * Defines wether cursors are handled by the scene.
  33241. */
  33242. doNotHandleCursors: boolean;
  33243. /**
  33244. * This is used to call preventDefault() on pointer down
  33245. * in order to block unwanted artifacts like system double clicks
  33246. */
  33247. preventDefaultOnPointerDown: boolean;
  33248. /**
  33249. * This is used to call preventDefault() on pointer up
  33250. * in order to block unwanted artifacts like system double clicks
  33251. */
  33252. preventDefaultOnPointerUp: boolean;
  33253. /**
  33254. * Gets or sets user defined metadata
  33255. */
  33256. metadata: any;
  33257. /**
  33258. * For internal use only. Please do not use.
  33259. */
  33260. reservedDataStore: any;
  33261. /**
  33262. * Gets the name of the plugin used to load this scene (null by default)
  33263. */
  33264. loadingPluginName: string;
  33265. /**
  33266. * Use this array to add regular expressions used to disable offline support for specific urls
  33267. */
  33268. disableOfflineSupportExceptionRules: RegExp[];
  33269. /**
  33270. * An event triggered when the scene is disposed.
  33271. */
  33272. onDisposeObservable: Observable<Scene>;
  33273. private _onDisposeObserver;
  33274. /** Sets a function to be executed when this scene is disposed. */
  33275. onDispose: () => void;
  33276. /**
  33277. * An event triggered before rendering the scene (right after animations and physics)
  33278. */
  33279. onBeforeRenderObservable: Observable<Scene>;
  33280. private _onBeforeRenderObserver;
  33281. /** Sets a function to be executed before rendering this scene */
  33282. beforeRender: Nullable<() => void>;
  33283. /**
  33284. * An event triggered after rendering the scene
  33285. */
  33286. onAfterRenderObservable: Observable<Scene>;
  33287. /**
  33288. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33289. */
  33290. onAfterRenderCameraObservable: Observable<Camera>;
  33291. private _onAfterRenderObserver;
  33292. /** Sets a function to be executed after rendering this scene */
  33293. afterRender: Nullable<() => void>;
  33294. /**
  33295. * An event triggered before animating the scene
  33296. */
  33297. onBeforeAnimationsObservable: Observable<Scene>;
  33298. /**
  33299. * An event triggered after animations processing
  33300. */
  33301. onAfterAnimationsObservable: Observable<Scene>;
  33302. /**
  33303. * An event triggered before draw calls are ready to be sent
  33304. */
  33305. onBeforeDrawPhaseObservable: Observable<Scene>;
  33306. /**
  33307. * An event triggered after draw calls have been sent
  33308. */
  33309. onAfterDrawPhaseObservable: Observable<Scene>;
  33310. /**
  33311. * An event triggered when the scene is ready
  33312. */
  33313. onReadyObservable: Observable<Scene>;
  33314. /**
  33315. * An event triggered before rendering a camera
  33316. */
  33317. onBeforeCameraRenderObservable: Observable<Camera>;
  33318. private _onBeforeCameraRenderObserver;
  33319. /** Sets a function to be executed before rendering a camera*/
  33320. beforeCameraRender: () => void;
  33321. /**
  33322. * An event triggered after rendering a camera
  33323. */
  33324. onAfterCameraRenderObservable: Observable<Camera>;
  33325. private _onAfterCameraRenderObserver;
  33326. /** Sets a function to be executed after rendering a camera*/
  33327. afterCameraRender: () => void;
  33328. /**
  33329. * An event triggered when active meshes evaluation is about to start
  33330. */
  33331. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33332. /**
  33333. * An event triggered when active meshes evaluation is done
  33334. */
  33335. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33336. /**
  33337. * An event triggered when particles rendering is about to start
  33338. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33339. */
  33340. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33341. /**
  33342. * An event triggered when particles rendering is done
  33343. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33344. */
  33345. onAfterParticlesRenderingObservable: Observable<Scene>;
  33346. /**
  33347. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33348. */
  33349. onDataLoadedObservable: Observable<Scene>;
  33350. /**
  33351. * An event triggered when a camera is created
  33352. */
  33353. onNewCameraAddedObservable: Observable<Camera>;
  33354. /**
  33355. * An event triggered when a camera is removed
  33356. */
  33357. onCameraRemovedObservable: Observable<Camera>;
  33358. /**
  33359. * An event triggered when a light is created
  33360. */
  33361. onNewLightAddedObservable: Observable<Light>;
  33362. /**
  33363. * An event triggered when a light is removed
  33364. */
  33365. onLightRemovedObservable: Observable<Light>;
  33366. /**
  33367. * An event triggered when a geometry is created
  33368. */
  33369. onNewGeometryAddedObservable: Observable<Geometry>;
  33370. /**
  33371. * An event triggered when a geometry is removed
  33372. */
  33373. onGeometryRemovedObservable: Observable<Geometry>;
  33374. /**
  33375. * An event triggered when a transform node is created
  33376. */
  33377. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33378. /**
  33379. * An event triggered when a transform node is removed
  33380. */
  33381. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33382. /**
  33383. * An event triggered when a mesh is created
  33384. */
  33385. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33386. /**
  33387. * An event triggered when a mesh is removed
  33388. */
  33389. onMeshRemovedObservable: Observable<AbstractMesh>;
  33390. /**
  33391. * An event triggered when a skeleton is created
  33392. */
  33393. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33394. /**
  33395. * An event triggered when a skeleton is removed
  33396. */
  33397. onSkeletonRemovedObservable: Observable<Skeleton>;
  33398. /**
  33399. * An event triggered when a material is created
  33400. */
  33401. onNewMaterialAddedObservable: Observable<Material>;
  33402. /**
  33403. * An event triggered when a material is removed
  33404. */
  33405. onMaterialRemovedObservable: Observable<Material>;
  33406. /**
  33407. * An event triggered when a texture is created
  33408. */
  33409. onNewTextureAddedObservable: Observable<BaseTexture>;
  33410. /**
  33411. * An event triggered when a texture is removed
  33412. */
  33413. onTextureRemovedObservable: Observable<BaseTexture>;
  33414. /**
  33415. * An event triggered when render targets are about to be rendered
  33416. * Can happen multiple times per frame.
  33417. */
  33418. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33419. /**
  33420. * An event triggered when render targets were rendered.
  33421. * Can happen multiple times per frame.
  33422. */
  33423. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33424. /**
  33425. * An event triggered before calculating deterministic simulation step
  33426. */
  33427. onBeforeStepObservable: Observable<Scene>;
  33428. /**
  33429. * An event triggered after calculating deterministic simulation step
  33430. */
  33431. onAfterStepObservable: Observable<Scene>;
  33432. /**
  33433. * An event triggered when the activeCamera property is updated
  33434. */
  33435. onActiveCameraChanged: Observable<Scene>;
  33436. /**
  33437. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33438. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33439. * 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)
  33440. */
  33441. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33442. /**
  33443. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33444. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33445. * 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)
  33446. */
  33447. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33448. /**
  33449. * This Observable will when a mesh has been imported into the scene.
  33450. */
  33451. onMeshImportedObservable: Observable<AbstractMesh>;
  33452. /**
  33453. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33454. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33455. */
  33456. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33457. /** @hidden */
  33458. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33459. /**
  33460. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33461. */
  33462. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33463. /**
  33464. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33465. */
  33466. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33467. /**
  33468. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33469. */
  33470. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33471. /** Callback called when a pointer move is detected */
  33472. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33473. /** Callback called when a pointer down is detected */
  33474. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33475. /** Callback called when a pointer up is detected */
  33476. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33477. /** Callback called when a pointer pick is detected */
  33478. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33479. /**
  33480. * 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).
  33481. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33482. */
  33483. onPrePointerObservable: Observable<PointerInfoPre>;
  33484. /**
  33485. * Observable event triggered each time an input event is received from the rendering canvas
  33486. */
  33487. onPointerObservable: Observable<PointerInfo>;
  33488. /**
  33489. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33490. */
  33491. readonly unTranslatedPointer: Vector2;
  33492. /**
  33493. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33494. */
  33495. static DragMovementThreshold: number;
  33496. /**
  33497. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33498. */
  33499. static LongPressDelay: number;
  33500. /**
  33501. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33502. */
  33503. static DoubleClickDelay: number;
  33504. /** If you need to check double click without raising a single click at first click, enable this flag */
  33505. static ExclusiveDoubleClickMode: boolean;
  33506. /** @hidden */
  33507. _mirroredCameraPosition: Nullable<Vector3>;
  33508. /**
  33509. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33510. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33511. */
  33512. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33513. /**
  33514. * Observable event triggered each time an keyboard event is received from the hosting window
  33515. */
  33516. onKeyboardObservable: Observable<KeyboardInfo>;
  33517. private _useRightHandedSystem;
  33518. /**
  33519. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33520. */
  33521. useRightHandedSystem: boolean;
  33522. private _timeAccumulator;
  33523. private _currentStepId;
  33524. private _currentInternalStep;
  33525. /**
  33526. * Sets the step Id used by deterministic lock step
  33527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33528. * @param newStepId defines the step Id
  33529. */
  33530. setStepId(newStepId: number): void;
  33531. /**
  33532. * Gets the step Id used by deterministic lock step
  33533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33534. * @returns the step Id
  33535. */
  33536. getStepId(): number;
  33537. /**
  33538. * Gets the internal step used by deterministic lock step
  33539. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33540. * @returns the internal step
  33541. */
  33542. getInternalStep(): number;
  33543. private _fogEnabled;
  33544. /**
  33545. * Gets or sets a boolean indicating if fog is enabled on this scene
  33546. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33547. * (Default is true)
  33548. */
  33549. fogEnabled: boolean;
  33550. private _fogMode;
  33551. /**
  33552. * Gets or sets the fog mode to use
  33553. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33554. * | mode | value |
  33555. * | --- | --- |
  33556. * | FOGMODE_NONE | 0 |
  33557. * | FOGMODE_EXP | 1 |
  33558. * | FOGMODE_EXP2 | 2 |
  33559. * | FOGMODE_LINEAR | 3 |
  33560. */
  33561. fogMode: number;
  33562. /**
  33563. * Gets or sets the fog color to use
  33564. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33565. * (Default is Color3(0.2, 0.2, 0.3))
  33566. */
  33567. fogColor: Color3;
  33568. /**
  33569. * Gets or sets the fog density to use
  33570. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33571. * (Default is 0.1)
  33572. */
  33573. fogDensity: number;
  33574. /**
  33575. * Gets or sets the fog start distance to use
  33576. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33577. * (Default is 0)
  33578. */
  33579. fogStart: number;
  33580. /**
  33581. * Gets or sets the fog end distance to use
  33582. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33583. * (Default is 1000)
  33584. */
  33585. fogEnd: number;
  33586. private _shadowsEnabled;
  33587. /**
  33588. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33589. */
  33590. shadowsEnabled: boolean;
  33591. private _lightsEnabled;
  33592. /**
  33593. * Gets or sets a boolean indicating if lights are enabled on this scene
  33594. */
  33595. lightsEnabled: boolean;
  33596. /** All of the active cameras added to this scene. */
  33597. activeCameras: Camera[];
  33598. /** @hidden */
  33599. _activeCamera: Nullable<Camera>;
  33600. /** Gets or sets the current active camera */
  33601. activeCamera: Nullable<Camera>;
  33602. private _defaultMaterial;
  33603. /** The default material used on meshes when no material is affected */
  33604. /** The default material used on meshes when no material is affected */
  33605. defaultMaterial: Material;
  33606. private _texturesEnabled;
  33607. /**
  33608. * Gets or sets a boolean indicating if textures are enabled on this scene
  33609. */
  33610. texturesEnabled: boolean;
  33611. /**
  33612. * Gets or sets a boolean indicating if particles are enabled on this scene
  33613. */
  33614. particlesEnabled: boolean;
  33615. /**
  33616. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33617. */
  33618. spritesEnabled: boolean;
  33619. private _skeletonsEnabled;
  33620. /**
  33621. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33622. */
  33623. skeletonsEnabled: boolean;
  33624. /**
  33625. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33626. */
  33627. lensFlaresEnabled: boolean;
  33628. /**
  33629. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33631. */
  33632. collisionsEnabled: boolean;
  33633. private _collisionCoordinator;
  33634. /** @hidden */
  33635. readonly collisionCoordinator: ICollisionCoordinator;
  33636. /**
  33637. * Defines the gravity applied to this scene (used only for collisions)
  33638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33639. */
  33640. gravity: Vector3;
  33641. /**
  33642. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33643. */
  33644. postProcessesEnabled: boolean;
  33645. /**
  33646. * The list of postprocesses added to the scene
  33647. */
  33648. postProcesses: PostProcess[];
  33649. /**
  33650. * Gets the current postprocess manager
  33651. */
  33652. postProcessManager: PostProcessManager;
  33653. /**
  33654. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33655. */
  33656. renderTargetsEnabled: boolean;
  33657. /**
  33658. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33659. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33660. */
  33661. dumpNextRenderTargets: boolean;
  33662. /**
  33663. * The list of user defined render targets added to the scene
  33664. */
  33665. customRenderTargets: RenderTargetTexture[];
  33666. /**
  33667. * Defines if texture loading must be delayed
  33668. * If true, textures will only be loaded when they need to be rendered
  33669. */
  33670. useDelayedTextureLoading: boolean;
  33671. /**
  33672. * Gets the list of meshes imported to the scene through SceneLoader
  33673. */
  33674. importedMeshesFiles: String[];
  33675. /**
  33676. * Gets or sets a boolean indicating if probes are enabled on this scene
  33677. */
  33678. probesEnabled: boolean;
  33679. /**
  33680. * Gets or sets the current offline provider to use to store scene data
  33681. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33682. */
  33683. offlineProvider: IOfflineProvider;
  33684. /**
  33685. * Gets or sets the action manager associated with the scene
  33686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33687. */
  33688. actionManager: AbstractActionManager;
  33689. private _meshesForIntersections;
  33690. /**
  33691. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33692. */
  33693. proceduralTexturesEnabled: boolean;
  33694. private _engine;
  33695. private _totalVertices;
  33696. /** @hidden */
  33697. _activeIndices: PerfCounter;
  33698. /** @hidden */
  33699. _activeParticles: PerfCounter;
  33700. /** @hidden */
  33701. _activeBones: PerfCounter;
  33702. private _animationRatio;
  33703. /** @hidden */
  33704. _animationTimeLast: number;
  33705. /** @hidden */
  33706. _animationTime: number;
  33707. /**
  33708. * Gets or sets a general scale for animation speed
  33709. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33710. */
  33711. animationTimeScale: number;
  33712. /** @hidden */
  33713. _cachedMaterial: Nullable<Material>;
  33714. /** @hidden */
  33715. _cachedEffect: Nullable<Effect>;
  33716. /** @hidden */
  33717. _cachedVisibility: Nullable<number>;
  33718. private _renderId;
  33719. private _frameId;
  33720. private _executeWhenReadyTimeoutId;
  33721. private _intermediateRendering;
  33722. private _viewUpdateFlag;
  33723. private _projectionUpdateFlag;
  33724. /** @hidden */
  33725. _toBeDisposed: Nullable<IDisposable>[];
  33726. private _activeRequests;
  33727. /** @hidden */
  33728. _pendingData: any[];
  33729. private _isDisposed;
  33730. /**
  33731. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33732. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33733. */
  33734. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33735. private _activeMeshes;
  33736. private _processedMaterials;
  33737. private _renderTargets;
  33738. /** @hidden */
  33739. _activeParticleSystems: SmartArray<IParticleSystem>;
  33740. private _activeSkeletons;
  33741. private _softwareSkinnedMeshes;
  33742. private _renderingManager;
  33743. /** @hidden */
  33744. _activeAnimatables: Animatable[];
  33745. private _transformMatrix;
  33746. private _sceneUbo;
  33747. /** @hidden */
  33748. _viewMatrix: Matrix;
  33749. private _projectionMatrix;
  33750. /** @hidden */
  33751. _forcedViewPosition: Nullable<Vector3>;
  33752. /** @hidden */
  33753. _frustumPlanes: Plane[];
  33754. /**
  33755. * Gets the list of frustum planes (built from the active camera)
  33756. */
  33757. readonly frustumPlanes: Plane[];
  33758. /**
  33759. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33760. * This is useful if there are more lights that the maximum simulteanous authorized
  33761. */
  33762. requireLightSorting: boolean;
  33763. /** @hidden */
  33764. readonly useMaterialMeshMap: boolean;
  33765. /** @hidden */
  33766. readonly useClonedMeshhMap: boolean;
  33767. private _externalData;
  33768. private _uid;
  33769. /**
  33770. * @hidden
  33771. * Backing store of defined scene components.
  33772. */
  33773. _components: ISceneComponent[];
  33774. /**
  33775. * @hidden
  33776. * Backing store of defined scene components.
  33777. */
  33778. _serializableComponents: ISceneSerializableComponent[];
  33779. /**
  33780. * List of components to register on the next registration step.
  33781. */
  33782. private _transientComponents;
  33783. /**
  33784. * Registers the transient components if needed.
  33785. */
  33786. private _registerTransientComponents;
  33787. /**
  33788. * @hidden
  33789. * Add a component to the scene.
  33790. * Note that the ccomponent could be registered on th next frame if this is called after
  33791. * the register component stage.
  33792. * @param component Defines the component to add to the scene
  33793. */
  33794. _addComponent(component: ISceneComponent): void;
  33795. /**
  33796. * @hidden
  33797. * Gets a component from the scene.
  33798. * @param name defines the name of the component to retrieve
  33799. * @returns the component or null if not present
  33800. */
  33801. _getComponent(name: string): Nullable<ISceneComponent>;
  33802. /**
  33803. * @hidden
  33804. * Defines the actions happening before camera updates.
  33805. */
  33806. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33807. /**
  33808. * @hidden
  33809. * Defines the actions happening before clear the canvas.
  33810. */
  33811. _beforeClearStage: Stage<SimpleStageAction>;
  33812. /**
  33813. * @hidden
  33814. * Defines the actions when collecting render targets for the frame.
  33815. */
  33816. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33817. /**
  33818. * @hidden
  33819. * Defines the actions happening for one camera in the frame.
  33820. */
  33821. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33822. /**
  33823. * @hidden
  33824. * Defines the actions happening during the per mesh ready checks.
  33825. */
  33826. _isReadyForMeshStage: Stage<MeshStageAction>;
  33827. /**
  33828. * @hidden
  33829. * Defines the actions happening before evaluate active mesh checks.
  33830. */
  33831. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33832. /**
  33833. * @hidden
  33834. * Defines the actions happening during the evaluate sub mesh checks.
  33835. */
  33836. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33837. /**
  33838. * @hidden
  33839. * Defines the actions happening during the active mesh stage.
  33840. */
  33841. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33842. /**
  33843. * @hidden
  33844. * Defines the actions happening during the per camera render target step.
  33845. */
  33846. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33847. /**
  33848. * @hidden
  33849. * Defines the actions happening just before the active camera is drawing.
  33850. */
  33851. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33852. /**
  33853. * @hidden
  33854. * Defines the actions happening just before a render target is drawing.
  33855. */
  33856. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33857. /**
  33858. * @hidden
  33859. * Defines the actions happening just before a rendering group is drawing.
  33860. */
  33861. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33862. /**
  33863. * @hidden
  33864. * Defines the actions happening just before a mesh is drawing.
  33865. */
  33866. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33867. /**
  33868. * @hidden
  33869. * Defines the actions happening just after a mesh has been drawn.
  33870. */
  33871. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33872. /**
  33873. * @hidden
  33874. * Defines the actions happening just after a rendering group has been drawn.
  33875. */
  33876. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33877. /**
  33878. * @hidden
  33879. * Defines the actions happening just after the active camera has been drawn.
  33880. */
  33881. _afterCameraDrawStage: Stage<CameraStageAction>;
  33882. /**
  33883. * @hidden
  33884. * Defines the actions happening just after a render target has been drawn.
  33885. */
  33886. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33887. /**
  33888. * @hidden
  33889. * Defines the actions happening just after rendering all cameras and computing intersections.
  33890. */
  33891. _afterRenderStage: Stage<SimpleStageAction>;
  33892. /**
  33893. * @hidden
  33894. * Defines the actions happening when a pointer move event happens.
  33895. */
  33896. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33897. /**
  33898. * @hidden
  33899. * Defines the actions happening when a pointer down event happens.
  33900. */
  33901. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33902. /**
  33903. * @hidden
  33904. * Defines the actions happening when a pointer up event happens.
  33905. */
  33906. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33907. /**
  33908. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33909. */
  33910. private geometriesByUniqueId;
  33911. /**
  33912. * Creates a new Scene
  33913. * @param engine defines the engine to use to render this scene
  33914. * @param options defines the scene options
  33915. */
  33916. constructor(engine: Engine, options?: SceneOptions);
  33917. /**
  33918. * Gets a string idenfifying the name of the class
  33919. * @returns "Scene" string
  33920. */
  33921. getClassName(): string;
  33922. private _defaultMeshCandidates;
  33923. /**
  33924. * @hidden
  33925. */
  33926. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33927. private _defaultSubMeshCandidates;
  33928. /**
  33929. * @hidden
  33930. */
  33931. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33932. /**
  33933. * Sets the default candidate providers for the scene.
  33934. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33935. * and getCollidingSubMeshCandidates to their default function
  33936. */
  33937. setDefaultCandidateProviders(): void;
  33938. /**
  33939. * Gets the mesh that is currently under the pointer
  33940. */
  33941. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33942. /**
  33943. * Gets or sets the current on-screen X position of the pointer
  33944. */
  33945. pointerX: number;
  33946. /**
  33947. * Gets or sets the current on-screen Y position of the pointer
  33948. */
  33949. pointerY: number;
  33950. /**
  33951. * Gets the cached material (ie. the latest rendered one)
  33952. * @returns the cached material
  33953. */
  33954. getCachedMaterial(): Nullable<Material>;
  33955. /**
  33956. * Gets the cached effect (ie. the latest rendered one)
  33957. * @returns the cached effect
  33958. */
  33959. getCachedEffect(): Nullable<Effect>;
  33960. /**
  33961. * Gets the cached visibility state (ie. the latest rendered one)
  33962. * @returns the cached visibility state
  33963. */
  33964. getCachedVisibility(): Nullable<number>;
  33965. /**
  33966. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33967. * @param material defines the current material
  33968. * @param effect defines the current effect
  33969. * @param visibility defines the current visibility state
  33970. * @returns true if one parameter is not cached
  33971. */
  33972. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33973. /**
  33974. * Gets the engine associated with the scene
  33975. * @returns an Engine
  33976. */
  33977. getEngine(): Engine;
  33978. /**
  33979. * Gets the total number of vertices rendered per frame
  33980. * @returns the total number of vertices rendered per frame
  33981. */
  33982. getTotalVertices(): number;
  33983. /**
  33984. * Gets the performance counter for total vertices
  33985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33986. */
  33987. readonly totalVerticesPerfCounter: PerfCounter;
  33988. /**
  33989. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33990. * @returns the total number of active indices rendered per frame
  33991. */
  33992. getActiveIndices(): number;
  33993. /**
  33994. * Gets the performance counter for active indices
  33995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33996. */
  33997. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33998. /**
  33999. * Gets the total number of active particles rendered per frame
  34000. * @returns the total number of active particles rendered per frame
  34001. */
  34002. getActiveParticles(): number;
  34003. /**
  34004. * Gets the performance counter for active particles
  34005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34006. */
  34007. readonly activeParticlesPerfCounter: PerfCounter;
  34008. /**
  34009. * Gets the total number of active bones rendered per frame
  34010. * @returns the total number of active bones rendered per frame
  34011. */
  34012. getActiveBones(): number;
  34013. /**
  34014. * Gets the performance counter for active bones
  34015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34016. */
  34017. readonly activeBonesPerfCounter: PerfCounter;
  34018. /**
  34019. * Gets the array of active meshes
  34020. * @returns an array of AbstractMesh
  34021. */
  34022. getActiveMeshes(): SmartArray<AbstractMesh>;
  34023. /**
  34024. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34025. * @returns a number
  34026. */
  34027. getAnimationRatio(): number;
  34028. /**
  34029. * Gets an unique Id for the current render phase
  34030. * @returns a number
  34031. */
  34032. getRenderId(): number;
  34033. /**
  34034. * Gets an unique Id for the current frame
  34035. * @returns a number
  34036. */
  34037. getFrameId(): number;
  34038. /** Call this function if you want to manually increment the render Id*/
  34039. incrementRenderId(): void;
  34040. private _createUbo;
  34041. /**
  34042. * Use this method to simulate a pointer move on a mesh
  34043. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34044. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34045. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34046. * @returns the current scene
  34047. */
  34048. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34049. /**
  34050. * Use this method to simulate a pointer down on a mesh
  34051. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34052. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34053. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34054. * @returns the current scene
  34055. */
  34056. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34057. /**
  34058. * Use this method to simulate a pointer up on a mesh
  34059. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34060. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34061. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34062. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34063. * @returns the current scene
  34064. */
  34065. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34066. /**
  34067. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34068. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34069. * @returns true if the pointer was captured
  34070. */
  34071. isPointerCaptured(pointerId?: number): boolean;
  34072. /**
  34073. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34074. * @param attachUp defines if you want to attach events to pointerup
  34075. * @param attachDown defines if you want to attach events to pointerdown
  34076. * @param attachMove defines if you want to attach events to pointermove
  34077. */
  34078. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34079. /** Detaches all event handlers*/
  34080. detachControl(): void;
  34081. /**
  34082. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34083. * Delay loaded resources are not taking in account
  34084. * @return true if all required resources are ready
  34085. */
  34086. isReady(): boolean;
  34087. /** Resets all cached information relative to material (including effect and visibility) */
  34088. resetCachedMaterial(): void;
  34089. /**
  34090. * Registers a function to be called before every frame render
  34091. * @param func defines the function to register
  34092. */
  34093. registerBeforeRender(func: () => void): void;
  34094. /**
  34095. * Unregisters a function called before every frame render
  34096. * @param func defines the function to unregister
  34097. */
  34098. unregisterBeforeRender(func: () => void): void;
  34099. /**
  34100. * Registers a function to be called after every frame render
  34101. * @param func defines the function to register
  34102. */
  34103. registerAfterRender(func: () => void): void;
  34104. /**
  34105. * Unregisters a function called after every frame render
  34106. * @param func defines the function to unregister
  34107. */
  34108. unregisterAfterRender(func: () => void): void;
  34109. private _executeOnceBeforeRender;
  34110. /**
  34111. * The provided function will run before render once and will be disposed afterwards.
  34112. * A timeout delay can be provided so that the function will be executed in N ms.
  34113. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34114. * @param func The function to be executed.
  34115. * @param timeout optional delay in ms
  34116. */
  34117. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34118. /** @hidden */
  34119. _addPendingData(data: any): void;
  34120. /** @hidden */
  34121. _removePendingData(data: any): void;
  34122. /**
  34123. * Returns the number of items waiting to be loaded
  34124. * @returns the number of items waiting to be loaded
  34125. */
  34126. getWaitingItemsCount(): number;
  34127. /**
  34128. * Returns a boolean indicating if the scene is still loading data
  34129. */
  34130. readonly isLoading: boolean;
  34131. /**
  34132. * Registers a function to be executed when the scene is ready
  34133. * @param {Function} func - the function to be executed
  34134. */
  34135. executeWhenReady(func: () => void): void;
  34136. /**
  34137. * Returns a promise that resolves when the scene is ready
  34138. * @returns A promise that resolves when the scene is ready
  34139. */
  34140. whenReadyAsync(): Promise<void>;
  34141. /** @hidden */
  34142. _checkIsReady(): void;
  34143. /**
  34144. * Gets all animatable attached to the scene
  34145. */
  34146. readonly animatables: Animatable[];
  34147. /**
  34148. * Resets the last animation time frame.
  34149. * Useful to override when animations start running when loading a scene for the first time.
  34150. */
  34151. resetLastAnimationTimeFrame(): void;
  34152. /**
  34153. * Gets the current view matrix
  34154. * @returns a Matrix
  34155. */
  34156. getViewMatrix(): Matrix;
  34157. /**
  34158. * Gets the current projection matrix
  34159. * @returns a Matrix
  34160. */
  34161. getProjectionMatrix(): Matrix;
  34162. /**
  34163. * Gets the current transform matrix
  34164. * @returns a Matrix made of View * Projection
  34165. */
  34166. getTransformMatrix(): Matrix;
  34167. /**
  34168. * Sets the current transform matrix
  34169. * @param viewL defines the View matrix to use
  34170. * @param projectionL defines the Projection matrix to use
  34171. * @param viewR defines the right View matrix to use (if provided)
  34172. * @param projectionR defines the right Projection matrix to use (if provided)
  34173. */
  34174. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34175. /**
  34176. * Gets the uniform buffer used to store scene data
  34177. * @returns a UniformBuffer
  34178. */
  34179. getSceneUniformBuffer(): UniformBuffer;
  34180. /**
  34181. * Gets an unique (relatively to the current scene) Id
  34182. * @returns an unique number for the scene
  34183. */
  34184. getUniqueId(): number;
  34185. /**
  34186. * Add a mesh to the list of scene's meshes
  34187. * @param newMesh defines the mesh to add
  34188. * @param recursive if all child meshes should also be added to the scene
  34189. */
  34190. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34191. /**
  34192. * Remove a mesh for the list of scene's meshes
  34193. * @param toRemove defines the mesh to remove
  34194. * @param recursive if all child meshes should also be removed from the scene
  34195. * @returns the index where the mesh was in the mesh list
  34196. */
  34197. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34198. /**
  34199. * Add a transform node to the list of scene's transform nodes
  34200. * @param newTransformNode defines the transform node to add
  34201. */
  34202. addTransformNode(newTransformNode: TransformNode): void;
  34203. /**
  34204. * Remove a transform node for the list of scene's transform nodes
  34205. * @param toRemove defines the transform node to remove
  34206. * @returns the index where the transform node was in the transform node list
  34207. */
  34208. removeTransformNode(toRemove: TransformNode): number;
  34209. /**
  34210. * Remove a skeleton for the list of scene's skeletons
  34211. * @param toRemove defines the skeleton to remove
  34212. * @returns the index where the skeleton was in the skeleton list
  34213. */
  34214. removeSkeleton(toRemove: Skeleton): number;
  34215. /**
  34216. * Remove a morph target for the list of scene's morph targets
  34217. * @param toRemove defines the morph target to remove
  34218. * @returns the index where the morph target was in the morph target list
  34219. */
  34220. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34221. /**
  34222. * Remove a light for the list of scene's lights
  34223. * @param toRemove defines the light to remove
  34224. * @returns the index where the light was in the light list
  34225. */
  34226. removeLight(toRemove: Light): number;
  34227. /**
  34228. * Remove a camera for the list of scene's cameras
  34229. * @param toRemove defines the camera to remove
  34230. * @returns the index where the camera was in the camera list
  34231. */
  34232. removeCamera(toRemove: Camera): number;
  34233. /**
  34234. * Remove a particle system for the list of scene's particle systems
  34235. * @param toRemove defines the particle system to remove
  34236. * @returns the index where the particle system was in the particle system list
  34237. */
  34238. removeParticleSystem(toRemove: IParticleSystem): number;
  34239. /**
  34240. * Remove a animation for the list of scene's animations
  34241. * @param toRemove defines the animation to remove
  34242. * @returns the index where the animation was in the animation list
  34243. */
  34244. removeAnimation(toRemove: Animation): number;
  34245. /**
  34246. * Will stop the animation of the given target
  34247. * @param target - the target
  34248. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34249. * @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)
  34250. */
  34251. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34252. /**
  34253. * Removes the given animation group from this scene.
  34254. * @param toRemove The animation group to remove
  34255. * @returns The index of the removed animation group
  34256. */
  34257. removeAnimationGroup(toRemove: AnimationGroup): number;
  34258. /**
  34259. * Removes the given multi-material from this scene.
  34260. * @param toRemove The multi-material to remove
  34261. * @returns The index of the removed multi-material
  34262. */
  34263. removeMultiMaterial(toRemove: MultiMaterial): number;
  34264. /**
  34265. * Removes the given material from this scene.
  34266. * @param toRemove The material to remove
  34267. * @returns The index of the removed material
  34268. */
  34269. removeMaterial(toRemove: Material): number;
  34270. /**
  34271. * Removes the given action manager from this scene.
  34272. * @param toRemove The action manager to remove
  34273. * @returns The index of the removed action manager
  34274. */
  34275. removeActionManager(toRemove: AbstractActionManager): number;
  34276. /**
  34277. * Removes the given texture from this scene.
  34278. * @param toRemove The texture to remove
  34279. * @returns The index of the removed texture
  34280. */
  34281. removeTexture(toRemove: BaseTexture): number;
  34282. /**
  34283. * Adds the given light to this scene
  34284. * @param newLight The light to add
  34285. */
  34286. addLight(newLight: Light): void;
  34287. /**
  34288. * Sorts the list list based on light priorities
  34289. */
  34290. sortLightsByPriority(): void;
  34291. /**
  34292. * Adds the given camera to this scene
  34293. * @param newCamera The camera to add
  34294. */
  34295. addCamera(newCamera: Camera): void;
  34296. /**
  34297. * Adds the given skeleton to this scene
  34298. * @param newSkeleton The skeleton to add
  34299. */
  34300. addSkeleton(newSkeleton: Skeleton): void;
  34301. /**
  34302. * Adds the given particle system to this scene
  34303. * @param newParticleSystem The particle system to add
  34304. */
  34305. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34306. /**
  34307. * Adds the given animation to this scene
  34308. * @param newAnimation The animation to add
  34309. */
  34310. addAnimation(newAnimation: Animation): void;
  34311. /**
  34312. * Adds the given animation group to this scene.
  34313. * @param newAnimationGroup The animation group to add
  34314. */
  34315. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34316. /**
  34317. * Adds the given multi-material to this scene
  34318. * @param newMultiMaterial The multi-material to add
  34319. */
  34320. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34321. /**
  34322. * Adds the given material to this scene
  34323. * @param newMaterial The material to add
  34324. */
  34325. addMaterial(newMaterial: Material): void;
  34326. /**
  34327. * Adds the given morph target to this scene
  34328. * @param newMorphTargetManager The morph target to add
  34329. */
  34330. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34331. /**
  34332. * Adds the given geometry to this scene
  34333. * @param newGeometry The geometry to add
  34334. */
  34335. addGeometry(newGeometry: Geometry): void;
  34336. /**
  34337. * Adds the given action manager to this scene
  34338. * @param newActionManager The action manager to add
  34339. */
  34340. addActionManager(newActionManager: AbstractActionManager): void;
  34341. /**
  34342. * Adds the given texture to this scene.
  34343. * @param newTexture The texture to add
  34344. */
  34345. addTexture(newTexture: BaseTexture): void;
  34346. /**
  34347. * Switch active camera
  34348. * @param newCamera defines the new active camera
  34349. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34350. */
  34351. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34352. /**
  34353. * sets the active camera of the scene using its ID
  34354. * @param id defines the camera's ID
  34355. * @return the new active camera or null if none found.
  34356. */
  34357. setActiveCameraByID(id: string): Nullable<Camera>;
  34358. /**
  34359. * sets the active camera of the scene using its name
  34360. * @param name defines the camera's name
  34361. * @returns the new active camera or null if none found.
  34362. */
  34363. setActiveCameraByName(name: string): Nullable<Camera>;
  34364. /**
  34365. * get an animation group using its name
  34366. * @param name defines the material's name
  34367. * @return the animation group or null if none found.
  34368. */
  34369. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34370. /**
  34371. * Get a material using its unique id
  34372. * @param uniqueId defines the material's unique id
  34373. * @return the material or null if none found.
  34374. */
  34375. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34376. /**
  34377. * get a material using its id
  34378. * @param id defines the material's ID
  34379. * @return the material or null if none found.
  34380. */
  34381. getMaterialByID(id: string): Nullable<Material>;
  34382. /**
  34383. * Gets a the last added material using a given id
  34384. * @param id defines the material's ID
  34385. * @return the last material with the given id or null if none found.
  34386. */
  34387. getLastMaterialByID(id: string): Nullable<Material>;
  34388. /**
  34389. * Gets a material using its name
  34390. * @param name defines the material's name
  34391. * @return the material or null if none found.
  34392. */
  34393. getMaterialByName(name: string): Nullable<Material>;
  34394. /**
  34395. * Get a texture using its unique id
  34396. * @param uniqueId defines the texture's unique id
  34397. * @return the texture or null if none found.
  34398. */
  34399. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34400. /**
  34401. * Gets a camera using its id
  34402. * @param id defines the id to look for
  34403. * @returns the camera or null if not found
  34404. */
  34405. getCameraByID(id: string): Nullable<Camera>;
  34406. /**
  34407. * Gets a camera using its unique id
  34408. * @param uniqueId defines the unique id to look for
  34409. * @returns the camera or null if not found
  34410. */
  34411. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34412. /**
  34413. * Gets a camera using its name
  34414. * @param name defines the camera's name
  34415. * @return the camera or null if none found.
  34416. */
  34417. getCameraByName(name: string): Nullable<Camera>;
  34418. /**
  34419. * Gets a bone using its id
  34420. * @param id defines the bone's id
  34421. * @return the bone or null if not found
  34422. */
  34423. getBoneByID(id: string): Nullable<Bone>;
  34424. /**
  34425. * Gets a bone using its id
  34426. * @param name defines the bone's name
  34427. * @return the bone or null if not found
  34428. */
  34429. getBoneByName(name: string): Nullable<Bone>;
  34430. /**
  34431. * Gets a light node using its name
  34432. * @param name defines the the light's name
  34433. * @return the light or null if none found.
  34434. */
  34435. getLightByName(name: string): Nullable<Light>;
  34436. /**
  34437. * Gets a light node using its id
  34438. * @param id defines the light's id
  34439. * @return the light or null if none found.
  34440. */
  34441. getLightByID(id: string): Nullable<Light>;
  34442. /**
  34443. * Gets a light node using its scene-generated unique ID
  34444. * @param uniqueId defines the light's unique id
  34445. * @return the light or null if none found.
  34446. */
  34447. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34448. /**
  34449. * Gets a particle system by id
  34450. * @param id defines the particle system id
  34451. * @return the corresponding system or null if none found
  34452. */
  34453. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34454. /**
  34455. * Gets a geometry using its ID
  34456. * @param id defines the geometry's id
  34457. * @return the geometry or null if none found.
  34458. */
  34459. getGeometryByID(id: string): Nullable<Geometry>;
  34460. private _getGeometryByUniqueID;
  34461. /**
  34462. * Add a new geometry to this scene
  34463. * @param geometry defines the geometry to be added to the scene.
  34464. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34465. * @return a boolean defining if the geometry was added or not
  34466. */
  34467. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34468. /**
  34469. * Removes an existing geometry
  34470. * @param geometry defines the geometry to be removed from the scene
  34471. * @return a boolean defining if the geometry was removed or not
  34472. */
  34473. removeGeometry(geometry: Geometry): boolean;
  34474. /**
  34475. * Gets the list of geometries attached to the scene
  34476. * @returns an array of Geometry
  34477. */
  34478. getGeometries(): Geometry[];
  34479. /**
  34480. * Gets the first added mesh found of a given ID
  34481. * @param id defines the id to search for
  34482. * @return the mesh found or null if not found at all
  34483. */
  34484. getMeshByID(id: string): Nullable<AbstractMesh>;
  34485. /**
  34486. * Gets a list of meshes using their id
  34487. * @param id defines the id to search for
  34488. * @returns a list of meshes
  34489. */
  34490. getMeshesByID(id: string): Array<AbstractMesh>;
  34491. /**
  34492. * Gets the first added transform node found of a given ID
  34493. * @param id defines the id to search for
  34494. * @return the found transform node or null if not found at all.
  34495. */
  34496. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34497. /**
  34498. * Gets a transform node with its auto-generated unique id
  34499. * @param uniqueId efines the unique id to search for
  34500. * @return the found transform node or null if not found at all.
  34501. */
  34502. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34503. /**
  34504. * Gets a list of transform nodes using their id
  34505. * @param id defines the id to search for
  34506. * @returns a list of transform nodes
  34507. */
  34508. getTransformNodesByID(id: string): Array<TransformNode>;
  34509. /**
  34510. * Gets a mesh with its auto-generated unique id
  34511. * @param uniqueId defines the unique id to search for
  34512. * @return the found mesh or null if not found at all.
  34513. */
  34514. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34515. /**
  34516. * Gets a the last added mesh using a given id
  34517. * @param id defines the id to search for
  34518. * @return the found mesh or null if not found at all.
  34519. */
  34520. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34521. /**
  34522. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34523. * @param id defines the id to search for
  34524. * @return the found node or null if not found at all
  34525. */
  34526. getLastEntryByID(id: string): Nullable<Node>;
  34527. /**
  34528. * Gets a node (Mesh, Camera, Light) using a given id
  34529. * @param id defines the id to search for
  34530. * @return the found node or null if not found at all
  34531. */
  34532. getNodeByID(id: string): Nullable<Node>;
  34533. /**
  34534. * Gets a node (Mesh, Camera, Light) using a given name
  34535. * @param name defines the name to search for
  34536. * @return the found node or null if not found at all.
  34537. */
  34538. getNodeByName(name: string): Nullable<Node>;
  34539. /**
  34540. * Gets a mesh using a given name
  34541. * @param name defines the name to search for
  34542. * @return the found mesh or null if not found at all.
  34543. */
  34544. getMeshByName(name: string): Nullable<AbstractMesh>;
  34545. /**
  34546. * Gets a transform node using a given name
  34547. * @param name defines the name to search for
  34548. * @return the found transform node or null if not found at all.
  34549. */
  34550. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34551. /**
  34552. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34553. * @param id defines the id to search for
  34554. * @return the found skeleton or null if not found at all.
  34555. */
  34556. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34557. /**
  34558. * Gets a skeleton using a given auto generated unique id
  34559. * @param uniqueId defines the unique id to search for
  34560. * @return the found skeleton or null if not found at all.
  34561. */
  34562. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34563. /**
  34564. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34565. * @param id defines the id to search for
  34566. * @return the found skeleton or null if not found at all.
  34567. */
  34568. getSkeletonById(id: string): Nullable<Skeleton>;
  34569. /**
  34570. * Gets a skeleton using a given name
  34571. * @param name defines the name to search for
  34572. * @return the found skeleton or null if not found at all.
  34573. */
  34574. getSkeletonByName(name: string): Nullable<Skeleton>;
  34575. /**
  34576. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34577. * @param id defines the id to search for
  34578. * @return the found morph target manager or null if not found at all.
  34579. */
  34580. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34581. /**
  34582. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34583. * @param id defines the id to search for
  34584. * @return the found morph target or null if not found at all.
  34585. */
  34586. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34587. /**
  34588. * Gets a boolean indicating if the given mesh is active
  34589. * @param mesh defines the mesh to look for
  34590. * @returns true if the mesh is in the active list
  34591. */
  34592. isActiveMesh(mesh: AbstractMesh): boolean;
  34593. /**
  34594. * Return a unique id as a string which can serve as an identifier for the scene
  34595. */
  34596. readonly uid: string;
  34597. /**
  34598. * Add an externaly attached data from its key.
  34599. * This method call will fail and return false, if such key already exists.
  34600. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34601. * @param key the unique key that identifies the data
  34602. * @param data the data object to associate to the key for this Engine instance
  34603. * @return true if no such key were already present and the data was added successfully, false otherwise
  34604. */
  34605. addExternalData<T>(key: string, data: T): boolean;
  34606. /**
  34607. * Get an externaly attached data from its key
  34608. * @param key the unique key that identifies the data
  34609. * @return the associated data, if present (can be null), or undefined if not present
  34610. */
  34611. getExternalData<T>(key: string): Nullable<T>;
  34612. /**
  34613. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34614. * @param key the unique key that identifies the data
  34615. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34616. * @return the associated data, can be null if the factory returned null.
  34617. */
  34618. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34619. /**
  34620. * Remove an externaly attached data from the Engine instance
  34621. * @param key the unique key that identifies the data
  34622. * @return true if the data was successfully removed, false if it doesn't exist
  34623. */
  34624. removeExternalData(key: string): boolean;
  34625. private _evaluateSubMesh;
  34626. /**
  34627. * Clear the processed materials smart array preventing retention point in material dispose.
  34628. */
  34629. freeProcessedMaterials(): void;
  34630. private _preventFreeActiveMeshesAndRenderingGroups;
  34631. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34632. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34633. * when disposing several meshes in a row or a hierarchy of meshes.
  34634. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34635. */
  34636. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34637. /**
  34638. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34639. */
  34640. freeActiveMeshes(): void;
  34641. /**
  34642. * Clear the info related to rendering groups preventing retention points during dispose.
  34643. */
  34644. freeRenderingGroups(): void;
  34645. /** @hidden */
  34646. _isInIntermediateRendering(): boolean;
  34647. /**
  34648. * Lambda returning the list of potentially active meshes.
  34649. */
  34650. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34651. /**
  34652. * Lambda returning the list of potentially active sub meshes.
  34653. */
  34654. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34655. /**
  34656. * Lambda returning the list of potentially intersecting sub meshes.
  34657. */
  34658. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34659. /**
  34660. * Lambda returning the list of potentially colliding sub meshes.
  34661. */
  34662. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34663. private _activeMeshesFrozen;
  34664. /**
  34665. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34666. * @returns the current scene
  34667. */
  34668. freezeActiveMeshes(): Scene;
  34669. /**
  34670. * Use this function to restart evaluating active meshes on every frame
  34671. * @returns the current scene
  34672. */
  34673. unfreezeActiveMeshes(): Scene;
  34674. private _evaluateActiveMeshes;
  34675. private _activeMesh;
  34676. /**
  34677. * Update the transform matrix to update from the current active camera
  34678. * @param force defines a boolean used to force the update even if cache is up to date
  34679. */
  34680. updateTransformMatrix(force?: boolean): void;
  34681. private _bindFrameBuffer;
  34682. /** @hidden */
  34683. _allowPostProcessClearColor: boolean;
  34684. /** @hidden */
  34685. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34686. private _processSubCameras;
  34687. private _checkIntersections;
  34688. /** @hidden */
  34689. _advancePhysicsEngineStep(step: number): void;
  34690. /**
  34691. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34692. */
  34693. getDeterministicFrameTime: () => number;
  34694. /** @hidden */
  34695. _animate(): void;
  34696. /** Execute all animations (for a frame) */
  34697. animate(): void;
  34698. /**
  34699. * Render the scene
  34700. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34701. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34702. */
  34703. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34704. /**
  34705. * Freeze all materials
  34706. * A frozen material will not be updatable but should be faster to render
  34707. */
  34708. freezeMaterials(): void;
  34709. /**
  34710. * Unfreeze all materials
  34711. * A frozen material will not be updatable but should be faster to render
  34712. */
  34713. unfreezeMaterials(): void;
  34714. /**
  34715. * Releases all held ressources
  34716. */
  34717. dispose(): void;
  34718. /**
  34719. * Gets if the scene is already disposed
  34720. */
  34721. readonly isDisposed: boolean;
  34722. /**
  34723. * Call this function to reduce memory footprint of the scene.
  34724. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34725. */
  34726. clearCachedVertexData(): void;
  34727. /**
  34728. * This function will remove the local cached buffer data from texture.
  34729. * It will save memory but will prevent the texture from being rebuilt
  34730. */
  34731. cleanCachedTextureBuffer(): void;
  34732. /**
  34733. * Get the world extend vectors with an optional filter
  34734. *
  34735. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34736. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34737. */
  34738. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34739. min: Vector3;
  34740. max: Vector3;
  34741. };
  34742. /**
  34743. * Creates a ray that can be used to pick in the scene
  34744. * @param x defines the x coordinate of the origin (on-screen)
  34745. * @param y defines the y coordinate of the origin (on-screen)
  34746. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34747. * @param camera defines the camera to use for the picking
  34748. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34749. * @returns a Ray
  34750. */
  34751. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34752. /**
  34753. * Creates a ray that can be used to pick in the scene
  34754. * @param x defines the x coordinate of the origin (on-screen)
  34755. * @param y defines the y coordinate of the origin (on-screen)
  34756. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34757. * @param result defines the ray where to store the picking ray
  34758. * @param camera defines the camera to use for the picking
  34759. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34760. * @returns the current scene
  34761. */
  34762. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34763. /**
  34764. * Creates a ray that can be used to pick in the scene
  34765. * @param x defines the x coordinate of the origin (on-screen)
  34766. * @param y defines the y coordinate of the origin (on-screen)
  34767. * @param camera defines the camera to use for the picking
  34768. * @returns a Ray
  34769. */
  34770. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34771. /**
  34772. * Creates a ray that can be used to pick in the scene
  34773. * @param x defines the x coordinate of the origin (on-screen)
  34774. * @param y defines the y coordinate of the origin (on-screen)
  34775. * @param result defines the ray where to store the picking ray
  34776. * @param camera defines the camera to use for the picking
  34777. * @returns the current scene
  34778. */
  34779. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34780. /** Launch a ray to try to pick a mesh in the scene
  34781. * @param x position on screen
  34782. * @param y position on screen
  34783. * @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
  34784. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34785. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34786. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34787. * @returns a PickingInfo
  34788. */
  34789. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34790. /** Use the given ray to pick a mesh in the scene
  34791. * @param ray The ray to use to pick meshes
  34792. * @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
  34793. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34795. * @returns a PickingInfo
  34796. */
  34797. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34798. /**
  34799. * Launch a ray to try to pick a mesh in the scene
  34800. * @param x X position on screen
  34801. * @param y Y position on screen
  34802. * @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
  34803. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34804. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34805. * @returns an array of PickingInfo
  34806. */
  34807. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34808. /**
  34809. * Launch a ray to try to pick a mesh in the scene
  34810. * @param ray Ray to use
  34811. * @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
  34812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34813. * @returns an array of PickingInfo
  34814. */
  34815. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34816. /**
  34817. * Force the value of meshUnderPointer
  34818. * @param mesh defines the mesh to use
  34819. */
  34820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34821. /**
  34822. * Gets the mesh under the pointer
  34823. * @returns a Mesh or null if no mesh is under the pointer
  34824. */
  34825. getPointerOverMesh(): Nullable<AbstractMesh>;
  34826. /** @hidden */
  34827. _rebuildGeometries(): void;
  34828. /** @hidden */
  34829. _rebuildTextures(): void;
  34830. private _getByTags;
  34831. /**
  34832. * Get a list of meshes by tags
  34833. * @param tagsQuery defines the tags query to use
  34834. * @param forEach defines a predicate used to filter results
  34835. * @returns an array of Mesh
  34836. */
  34837. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34838. /**
  34839. * Get a list of cameras by tags
  34840. * @param tagsQuery defines the tags query to use
  34841. * @param forEach defines a predicate used to filter results
  34842. * @returns an array of Camera
  34843. */
  34844. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34845. /**
  34846. * Get a list of lights by tags
  34847. * @param tagsQuery defines the tags query to use
  34848. * @param forEach defines a predicate used to filter results
  34849. * @returns an array of Light
  34850. */
  34851. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34852. /**
  34853. * Get a list of materials by tags
  34854. * @param tagsQuery defines the tags query to use
  34855. * @param forEach defines a predicate used to filter results
  34856. * @returns an array of Material
  34857. */
  34858. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34859. /**
  34860. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34861. * This allowed control for front to back rendering or reversly depending of the special needs.
  34862. *
  34863. * @param renderingGroupId The rendering group id corresponding to its index
  34864. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34865. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34866. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34867. */
  34868. 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;
  34869. /**
  34870. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34871. *
  34872. * @param renderingGroupId The rendering group id corresponding to its index
  34873. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34874. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34875. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34876. */
  34877. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34878. /**
  34879. * Gets the current auto clear configuration for one rendering group of the rendering
  34880. * manager.
  34881. * @param index the rendering group index to get the information for
  34882. * @returns The auto clear setup for the requested rendering group
  34883. */
  34884. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34885. private _blockMaterialDirtyMechanism;
  34886. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34887. blockMaterialDirtyMechanism: boolean;
  34888. /**
  34889. * Will flag all materials as dirty to trigger new shader compilation
  34890. * @param flag defines the flag used to specify which material part must be marked as dirty
  34891. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34892. */
  34893. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34894. /** @hidden */
  34895. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  34896. /** @hidden */
  34897. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34898. /** @hidden */
  34899. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  34900. /** @hidden */
  34901. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  34902. /** @hidden */
  34903. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34904. /** @hidden */
  34905. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34906. }
  34907. }
  34908. declare module BABYLON {
  34909. /**
  34910. * Set of assets to keep when moving a scene into an asset container.
  34911. */
  34912. export class KeepAssets extends AbstractScene {
  34913. }
  34914. /**
  34915. * Container with a set of assets that can be added or removed from a scene.
  34916. */
  34917. export class AssetContainer extends AbstractScene {
  34918. /**
  34919. * The scene the AssetContainer belongs to.
  34920. */
  34921. scene: Scene;
  34922. /**
  34923. * Instantiates an AssetContainer.
  34924. * @param scene The scene the AssetContainer belongs to.
  34925. */
  34926. constructor(scene: Scene);
  34927. /**
  34928. * Adds all the assets from the container to the scene.
  34929. */
  34930. addAllToScene(): void;
  34931. /**
  34932. * Removes all the assets in the container from the scene
  34933. */
  34934. removeAllFromScene(): void;
  34935. /**
  34936. * Disposes all the assets in the container
  34937. */
  34938. dispose(): void;
  34939. private _moveAssets;
  34940. /**
  34941. * Removes all the assets contained in the scene and adds them to the container.
  34942. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34943. */
  34944. moveAllFromScene(keepAssets?: KeepAssets): void;
  34945. /**
  34946. * 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.
  34947. * @returns the root mesh
  34948. */
  34949. createRootMesh(): Mesh;
  34950. }
  34951. }
  34952. declare module BABYLON {
  34953. /**
  34954. * Defines how the parser contract is defined.
  34955. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34956. */
  34957. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34958. /**
  34959. * Defines how the individual parser contract is defined.
  34960. * These parser can parse an individual asset
  34961. */
  34962. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34963. /**
  34964. * Base class of the scene acting as a container for the different elements composing a scene.
  34965. * This class is dynamically extended by the different components of the scene increasing
  34966. * flexibility and reducing coupling
  34967. */
  34968. export abstract class AbstractScene {
  34969. /**
  34970. * Stores the list of available parsers in the application.
  34971. */
  34972. private static _BabylonFileParsers;
  34973. /**
  34974. * Stores the list of available individual parsers in the application.
  34975. */
  34976. private static _IndividualBabylonFileParsers;
  34977. /**
  34978. * Adds a parser in the list of available ones
  34979. * @param name Defines the name of the parser
  34980. * @param parser Defines the parser to add
  34981. */
  34982. static AddParser(name: string, parser: BabylonFileParser): void;
  34983. /**
  34984. * Gets a general parser from the list of avaialble ones
  34985. * @param name Defines the name of the parser
  34986. * @returns the requested parser or null
  34987. */
  34988. static GetParser(name: string): Nullable<BabylonFileParser>;
  34989. /**
  34990. * Adds n individual parser in the list of available ones
  34991. * @param name Defines the name of the parser
  34992. * @param parser Defines the parser to add
  34993. */
  34994. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34995. /**
  34996. * Gets an individual parser from the list of avaialble ones
  34997. * @param name Defines the name of the parser
  34998. * @returns the requested parser or null
  34999. */
  35000. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35001. /**
  35002. * Parser json data and populate both a scene and its associated container object
  35003. * @param jsonData Defines the data to parse
  35004. * @param scene Defines the scene to parse the data for
  35005. * @param container Defines the container attached to the parsing sequence
  35006. * @param rootUrl Defines the root url of the data
  35007. */
  35008. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35009. /**
  35010. * Gets the list of root nodes (ie. nodes with no parent)
  35011. */
  35012. rootNodes: Node[];
  35013. /** All of the cameras added to this scene
  35014. * @see http://doc.babylonjs.com/babylon101/cameras
  35015. */
  35016. cameras: Camera[];
  35017. /**
  35018. * All of the lights added to this scene
  35019. * @see http://doc.babylonjs.com/babylon101/lights
  35020. */
  35021. lights: Light[];
  35022. /**
  35023. * All of the (abstract) meshes added to this scene
  35024. */
  35025. meshes: AbstractMesh[];
  35026. /**
  35027. * The list of skeletons added to the scene
  35028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35029. */
  35030. skeletons: Skeleton[];
  35031. /**
  35032. * All of the particle systems added to this scene
  35033. * @see http://doc.babylonjs.com/babylon101/particles
  35034. */
  35035. particleSystems: IParticleSystem[];
  35036. /**
  35037. * Gets a list of Animations associated with the scene
  35038. */
  35039. animations: Animation[];
  35040. /**
  35041. * All of the animation groups added to this scene
  35042. * @see http://doc.babylonjs.com/how_to/group
  35043. */
  35044. animationGroups: AnimationGroup[];
  35045. /**
  35046. * All of the multi-materials added to this scene
  35047. * @see http://doc.babylonjs.com/how_to/multi_materials
  35048. */
  35049. multiMaterials: MultiMaterial[];
  35050. /**
  35051. * All of the materials added to this scene
  35052. * In the context of a Scene, it is not supposed to be modified manually.
  35053. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35054. * Note also that the order of the Material wihin the array is not significant and might change.
  35055. * @see http://doc.babylonjs.com/babylon101/materials
  35056. */
  35057. materials: Material[];
  35058. /**
  35059. * The list of morph target managers added to the scene
  35060. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35061. */
  35062. morphTargetManagers: MorphTargetManager[];
  35063. /**
  35064. * The list of geometries used in the scene.
  35065. */
  35066. geometries: Geometry[];
  35067. /**
  35068. * All of the tranform nodes added to this scene
  35069. * In the context of a Scene, it is not supposed to be modified manually.
  35070. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35071. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35072. * @see http://doc.babylonjs.com/how_to/transformnode
  35073. */
  35074. transformNodes: TransformNode[];
  35075. /**
  35076. * ActionManagers available on the scene.
  35077. */
  35078. actionManagers: AbstractActionManager[];
  35079. /**
  35080. * Textures to keep.
  35081. */
  35082. textures: BaseTexture[];
  35083. /**
  35084. * Environment texture for the scene
  35085. */
  35086. environmentTexture: Nullable<BaseTexture>;
  35087. }
  35088. }
  35089. declare module BABYLON {
  35090. /**
  35091. * Interface used to define options for Sound class
  35092. */
  35093. export interface ISoundOptions {
  35094. /**
  35095. * Does the sound autoplay once loaded.
  35096. */
  35097. autoplay?: boolean;
  35098. /**
  35099. * Does the sound loop after it finishes playing once.
  35100. */
  35101. loop?: boolean;
  35102. /**
  35103. * Sound's volume
  35104. */
  35105. volume?: number;
  35106. /**
  35107. * Is it a spatial sound?
  35108. */
  35109. spatialSound?: boolean;
  35110. /**
  35111. * Maximum distance to hear that sound
  35112. */
  35113. maxDistance?: number;
  35114. /**
  35115. * Uses user defined attenuation function
  35116. */
  35117. useCustomAttenuation?: boolean;
  35118. /**
  35119. * Define the roll off factor of spatial sounds.
  35120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35121. */
  35122. rolloffFactor?: number;
  35123. /**
  35124. * Define the reference distance the sound should be heard perfectly.
  35125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35126. */
  35127. refDistance?: number;
  35128. /**
  35129. * Define the distance attenuation model the sound will follow.
  35130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35131. */
  35132. distanceModel?: string;
  35133. /**
  35134. * Defines the playback speed (1 by default)
  35135. */
  35136. playbackRate?: number;
  35137. /**
  35138. * Defines if the sound is from a streaming source
  35139. */
  35140. streaming?: boolean;
  35141. /**
  35142. * Defines an optional length (in seconds) inside the sound file
  35143. */
  35144. length?: number;
  35145. /**
  35146. * Defines an optional offset (in seconds) inside the sound file
  35147. */
  35148. offset?: number;
  35149. /**
  35150. * If true, URLs will not be required to state the audio file codec to use.
  35151. */
  35152. skipCodecCheck?: boolean;
  35153. }
  35154. /**
  35155. * Defines a sound that can be played in the application.
  35156. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35157. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35158. */
  35159. export class Sound {
  35160. /**
  35161. * The name of the sound in the scene.
  35162. */
  35163. name: string;
  35164. /**
  35165. * Does the sound autoplay once loaded.
  35166. */
  35167. autoplay: boolean;
  35168. /**
  35169. * Does the sound loop after it finishes playing once.
  35170. */
  35171. loop: boolean;
  35172. /**
  35173. * Does the sound use a custom attenuation curve to simulate the falloff
  35174. * happening when the source gets further away from the camera.
  35175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35176. */
  35177. useCustomAttenuation: boolean;
  35178. /**
  35179. * The sound track id this sound belongs to.
  35180. */
  35181. soundTrackId: number;
  35182. /**
  35183. * Is this sound currently played.
  35184. */
  35185. isPlaying: boolean;
  35186. /**
  35187. * Is this sound currently paused.
  35188. */
  35189. isPaused: boolean;
  35190. /**
  35191. * Does this sound enables spatial sound.
  35192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35193. */
  35194. spatialSound: boolean;
  35195. /**
  35196. * Define the reference distance the sound should be heard perfectly.
  35197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35198. */
  35199. refDistance: number;
  35200. /**
  35201. * Define the roll off factor of spatial sounds.
  35202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35203. */
  35204. rolloffFactor: number;
  35205. /**
  35206. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35208. */
  35209. maxDistance: number;
  35210. /**
  35211. * Define the distance attenuation model the sound will follow.
  35212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35213. */
  35214. distanceModel: string;
  35215. /**
  35216. * @hidden
  35217. * Back Compat
  35218. **/
  35219. onended: () => any;
  35220. /**
  35221. * Observable event when the current playing sound finishes.
  35222. */
  35223. onEndedObservable: Observable<Sound>;
  35224. private _panningModel;
  35225. private _playbackRate;
  35226. private _streaming;
  35227. private _startTime;
  35228. private _startOffset;
  35229. private _position;
  35230. /** @hidden */
  35231. _positionInEmitterSpace: boolean;
  35232. private _localDirection;
  35233. private _volume;
  35234. private _isReadyToPlay;
  35235. private _isDirectional;
  35236. private _readyToPlayCallback;
  35237. private _audioBuffer;
  35238. private _soundSource;
  35239. private _streamingSource;
  35240. private _soundPanner;
  35241. private _soundGain;
  35242. private _inputAudioNode;
  35243. private _outputAudioNode;
  35244. private _coneInnerAngle;
  35245. private _coneOuterAngle;
  35246. private _coneOuterGain;
  35247. private _scene;
  35248. private _connectedTransformNode;
  35249. private _customAttenuationFunction;
  35250. private _registerFunc;
  35251. private _isOutputConnected;
  35252. private _htmlAudioElement;
  35253. private _urlType;
  35254. private _length?;
  35255. private _offset?;
  35256. /** @hidden */
  35257. static _SceneComponentInitialization: (scene: Scene) => void;
  35258. /**
  35259. * Create a sound and attach it to a scene
  35260. * @param name Name of your sound
  35261. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35262. * @param scene defines the scene the sound belongs to
  35263. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35264. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35265. */
  35266. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35267. /**
  35268. * Release the sound and its associated resources
  35269. */
  35270. dispose(): void;
  35271. /**
  35272. * Gets if the sounds is ready to be played or not.
  35273. * @returns true if ready, otherwise false
  35274. */
  35275. isReady(): boolean;
  35276. private _soundLoaded;
  35277. /**
  35278. * Sets the data of the sound from an audiobuffer
  35279. * @param audioBuffer The audioBuffer containing the data
  35280. */
  35281. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35282. /**
  35283. * Updates the current sounds options such as maxdistance, loop...
  35284. * @param options A JSON object containing values named as the object properties
  35285. */
  35286. updateOptions(options: ISoundOptions): void;
  35287. private _createSpatialParameters;
  35288. private _updateSpatialParameters;
  35289. /**
  35290. * Switch the panning model to HRTF:
  35291. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35293. */
  35294. switchPanningModelToHRTF(): void;
  35295. /**
  35296. * Switch the panning model to Equal Power:
  35297. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35299. */
  35300. switchPanningModelToEqualPower(): void;
  35301. private _switchPanningModel;
  35302. /**
  35303. * Connect this sound to a sound track audio node like gain...
  35304. * @param soundTrackAudioNode the sound track audio node to connect to
  35305. */
  35306. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35307. /**
  35308. * Transform this sound into a directional source
  35309. * @param coneInnerAngle Size of the inner cone in degree
  35310. * @param coneOuterAngle Size of the outer cone in degree
  35311. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35312. */
  35313. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35314. /**
  35315. * Gets or sets the inner angle for the directional cone.
  35316. */
  35317. /**
  35318. * Gets or sets the inner angle for the directional cone.
  35319. */
  35320. directionalConeInnerAngle: number;
  35321. /**
  35322. * Gets or sets the outer angle for the directional cone.
  35323. */
  35324. /**
  35325. * Gets or sets the outer angle for the directional cone.
  35326. */
  35327. directionalConeOuterAngle: number;
  35328. /**
  35329. * Sets the position of the emitter if spatial sound is enabled
  35330. * @param newPosition Defines the new posisiton
  35331. */
  35332. setPosition(newPosition: Vector3): void;
  35333. /**
  35334. * Sets the local direction of the emitter if spatial sound is enabled
  35335. * @param newLocalDirection Defines the new local direction
  35336. */
  35337. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35338. private _updateDirection;
  35339. /** @hidden */
  35340. updateDistanceFromListener(): void;
  35341. /**
  35342. * Sets a new custom attenuation function for the sound.
  35343. * @param callback Defines the function used for the attenuation
  35344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35345. */
  35346. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35347. /**
  35348. * Play the sound
  35349. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35350. * @param offset (optional) Start the sound at a specific time in seconds
  35351. * @param length (optional) Sound duration (in seconds)
  35352. */
  35353. play(time?: number, offset?: number, length?: number): void;
  35354. private _onended;
  35355. /**
  35356. * Stop the sound
  35357. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35358. */
  35359. stop(time?: number): void;
  35360. /**
  35361. * Put the sound in pause
  35362. */
  35363. pause(): void;
  35364. /**
  35365. * Sets a dedicated volume for this sounds
  35366. * @param newVolume Define the new volume of the sound
  35367. * @param time Define time for gradual change to new volume
  35368. */
  35369. setVolume(newVolume: number, time?: number): void;
  35370. /**
  35371. * Set the sound play back rate
  35372. * @param newPlaybackRate Define the playback rate the sound should be played at
  35373. */
  35374. setPlaybackRate(newPlaybackRate: number): void;
  35375. /**
  35376. * Gets the volume of the sound.
  35377. * @returns the volume of the sound
  35378. */
  35379. getVolume(): number;
  35380. /**
  35381. * Attach the sound to a dedicated mesh
  35382. * @param transformNode The transform node to connect the sound with
  35383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35384. */
  35385. attachToMesh(transformNode: TransformNode): void;
  35386. /**
  35387. * Detach the sound from the previously attached mesh
  35388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35389. */
  35390. detachFromMesh(): void;
  35391. private _onRegisterAfterWorldMatrixUpdate;
  35392. /**
  35393. * Clone the current sound in the scene.
  35394. * @returns the new sound clone
  35395. */
  35396. clone(): Nullable<Sound>;
  35397. /**
  35398. * Gets the current underlying audio buffer containing the data
  35399. * @returns the audio buffer
  35400. */
  35401. getAudioBuffer(): Nullable<AudioBuffer>;
  35402. /**
  35403. * Serializes the Sound in a JSON representation
  35404. * @returns the JSON representation of the sound
  35405. */
  35406. serialize(): any;
  35407. /**
  35408. * Parse a JSON representation of a sound to innstantiate in a given scene
  35409. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35410. * @param scene Define the scene the new parsed sound should be created in
  35411. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35412. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35413. * @returns the newly parsed sound
  35414. */
  35415. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35416. }
  35417. }
  35418. declare module BABYLON {
  35419. /**
  35420. * This defines an action helpful to play a defined sound on a triggered action.
  35421. */
  35422. export class PlaySoundAction extends Action {
  35423. private _sound;
  35424. /**
  35425. * Instantiate the action
  35426. * @param triggerOptions defines the trigger options
  35427. * @param sound defines the sound to play
  35428. * @param condition defines the trigger related conditions
  35429. */
  35430. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35431. /** @hidden */
  35432. _prepare(): void;
  35433. /**
  35434. * Execute the action and play the sound.
  35435. */
  35436. execute(): void;
  35437. /**
  35438. * Serializes the actions and its related information.
  35439. * @param parent defines the object to serialize in
  35440. * @returns the serialized object
  35441. */
  35442. serialize(parent: any): any;
  35443. }
  35444. /**
  35445. * This defines an action helpful to stop a defined sound on a triggered action.
  35446. */
  35447. export class StopSoundAction extends Action {
  35448. private _sound;
  35449. /**
  35450. * Instantiate the action
  35451. * @param triggerOptions defines the trigger options
  35452. * @param sound defines the sound to stop
  35453. * @param condition defines the trigger related conditions
  35454. */
  35455. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35456. /** @hidden */
  35457. _prepare(): void;
  35458. /**
  35459. * Execute the action and stop the sound.
  35460. */
  35461. execute(): void;
  35462. /**
  35463. * Serializes the actions and its related information.
  35464. * @param parent defines the object to serialize in
  35465. * @returns the serialized object
  35466. */
  35467. serialize(parent: any): any;
  35468. }
  35469. }
  35470. declare module BABYLON {
  35471. /**
  35472. * This defines an action responsible to change the value of a property
  35473. * by interpolating between its current value and the newly set one once triggered.
  35474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35475. */
  35476. export class InterpolateValueAction extends Action {
  35477. /**
  35478. * Defines the path of the property where the value should be interpolated
  35479. */
  35480. propertyPath: string;
  35481. /**
  35482. * Defines the target value at the end of the interpolation.
  35483. */
  35484. value: any;
  35485. /**
  35486. * Defines the time it will take for the property to interpolate to the value.
  35487. */
  35488. duration: number;
  35489. /**
  35490. * Defines if the other scene animations should be stopped when the action has been triggered
  35491. */
  35492. stopOtherAnimations?: boolean;
  35493. /**
  35494. * Defines a callback raised once the interpolation animation has been done.
  35495. */
  35496. onInterpolationDone?: () => void;
  35497. /**
  35498. * Observable triggered once the interpolation animation has been done.
  35499. */
  35500. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35501. private _target;
  35502. private _effectiveTarget;
  35503. private _property;
  35504. /**
  35505. * Instantiate the action
  35506. * @param triggerOptions defines the trigger options
  35507. * @param target defines the object containing the value to interpolate
  35508. * @param propertyPath defines the path to the property in the target object
  35509. * @param value defines the target value at the end of the interpolation
  35510. * @param duration deines the time it will take for the property to interpolate to the value.
  35511. * @param condition defines the trigger related conditions
  35512. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35513. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35514. */
  35515. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35516. /** @hidden */
  35517. _prepare(): void;
  35518. /**
  35519. * Execute the action starts the value interpolation.
  35520. */
  35521. execute(): void;
  35522. /**
  35523. * Serializes the actions and its related information.
  35524. * @param parent defines the object to serialize in
  35525. * @returns the serialized object
  35526. */
  35527. serialize(parent: any): any;
  35528. }
  35529. }
  35530. declare module BABYLON {
  35531. /**
  35532. * Options allowed during the creation of a sound track.
  35533. */
  35534. export interface ISoundTrackOptions {
  35535. /**
  35536. * The volume the sound track should take during creation
  35537. */
  35538. volume?: number;
  35539. /**
  35540. * Define if the sound track is the main sound track of the scene
  35541. */
  35542. mainTrack?: boolean;
  35543. }
  35544. /**
  35545. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35546. * It will be also used in a future release to apply effects on a specific track.
  35547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35548. */
  35549. export class SoundTrack {
  35550. /**
  35551. * The unique identifier of the sound track in the scene.
  35552. */
  35553. id: number;
  35554. /**
  35555. * The list of sounds included in the sound track.
  35556. */
  35557. soundCollection: Array<Sound>;
  35558. private _outputAudioNode;
  35559. private _scene;
  35560. private _isMainTrack;
  35561. private _connectedAnalyser;
  35562. private _options;
  35563. private _isInitialized;
  35564. /**
  35565. * Creates a new sound track.
  35566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35567. * @param scene Define the scene the sound track belongs to
  35568. * @param options
  35569. */
  35570. constructor(scene: Scene, options?: ISoundTrackOptions);
  35571. private _initializeSoundTrackAudioGraph;
  35572. /**
  35573. * Release the sound track and its associated resources
  35574. */
  35575. dispose(): void;
  35576. /**
  35577. * Adds a sound to this sound track
  35578. * @param sound define the cound to add
  35579. * @ignoreNaming
  35580. */
  35581. AddSound(sound: Sound): void;
  35582. /**
  35583. * Removes a sound to this sound track
  35584. * @param sound define the cound to remove
  35585. * @ignoreNaming
  35586. */
  35587. RemoveSound(sound: Sound): void;
  35588. /**
  35589. * Set a global volume for the full sound track.
  35590. * @param newVolume Define the new volume of the sound track
  35591. */
  35592. setVolume(newVolume: number): void;
  35593. /**
  35594. * Switch the panning model to HRTF:
  35595. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35597. */
  35598. switchPanningModelToHRTF(): void;
  35599. /**
  35600. * Switch the panning model to Equal Power:
  35601. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35603. */
  35604. switchPanningModelToEqualPower(): void;
  35605. /**
  35606. * Connect the sound track to an audio analyser allowing some amazing
  35607. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35609. * @param analyser The analyser to connect to the engine
  35610. */
  35611. connectToAnalyser(analyser: Analyser): void;
  35612. }
  35613. }
  35614. declare module BABYLON {
  35615. interface AbstractScene {
  35616. /**
  35617. * The list of sounds used in the scene.
  35618. */
  35619. sounds: Nullable<Array<Sound>>;
  35620. }
  35621. interface Scene {
  35622. /**
  35623. * @hidden
  35624. * Backing field
  35625. */
  35626. _mainSoundTrack: SoundTrack;
  35627. /**
  35628. * The main sound track played by the scene.
  35629. * It cotains your primary collection of sounds.
  35630. */
  35631. mainSoundTrack: SoundTrack;
  35632. /**
  35633. * The list of sound tracks added to the scene
  35634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35635. */
  35636. soundTracks: Nullable<Array<SoundTrack>>;
  35637. /**
  35638. * Gets a sound using a given name
  35639. * @param name defines the name to search for
  35640. * @return the found sound or null if not found at all.
  35641. */
  35642. getSoundByName(name: string): Nullable<Sound>;
  35643. /**
  35644. * Gets or sets if audio support is enabled
  35645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35646. */
  35647. audioEnabled: boolean;
  35648. /**
  35649. * Gets or sets if audio will be output to headphones
  35650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35651. */
  35652. headphone: boolean;
  35653. /**
  35654. * Gets or sets custom audio listener position provider
  35655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35656. */
  35657. audioListenerPositionProvider: Nullable<() => Vector3>;
  35658. }
  35659. /**
  35660. * Defines the sound scene component responsible to manage any sounds
  35661. * in a given scene.
  35662. */
  35663. export class AudioSceneComponent implements ISceneSerializableComponent {
  35664. /**
  35665. * The component name helpfull to identify the component in the list of scene components.
  35666. */
  35667. readonly name: string;
  35668. /**
  35669. * The scene the component belongs to.
  35670. */
  35671. scene: Scene;
  35672. private _audioEnabled;
  35673. /**
  35674. * Gets whether audio is enabled or not.
  35675. * Please use related enable/disable method to switch state.
  35676. */
  35677. readonly audioEnabled: boolean;
  35678. private _headphone;
  35679. /**
  35680. * Gets whether audio is outputing to headphone or not.
  35681. * Please use the according Switch methods to change output.
  35682. */
  35683. readonly headphone: boolean;
  35684. private _audioListenerPositionProvider;
  35685. /**
  35686. * Gets the current audio listener position provider
  35687. */
  35688. /**
  35689. * Sets a custom listener position for all sounds in the scene
  35690. * By default, this is the position of the first active camera
  35691. */
  35692. audioListenerPositionProvider: Nullable<() => Vector3>;
  35693. /**
  35694. * Creates a new instance of the component for the given scene
  35695. * @param scene Defines the scene to register the component in
  35696. */
  35697. constructor(scene: Scene);
  35698. /**
  35699. * Registers the component in a given scene
  35700. */
  35701. register(): void;
  35702. /**
  35703. * Rebuilds the elements related to this component in case of
  35704. * context lost for instance.
  35705. */
  35706. rebuild(): void;
  35707. /**
  35708. * Serializes the component data to the specified json object
  35709. * @param serializationObject The object to serialize to
  35710. */
  35711. serialize(serializationObject: any): void;
  35712. /**
  35713. * Adds all the elements from the container to the scene
  35714. * @param container the container holding the elements
  35715. */
  35716. addFromContainer(container: AbstractScene): void;
  35717. /**
  35718. * Removes all the elements in the container from the scene
  35719. * @param container contains the elements to remove
  35720. * @param dispose if the removed element should be disposed (default: false)
  35721. */
  35722. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35723. /**
  35724. * Disposes the component and the associated ressources.
  35725. */
  35726. dispose(): void;
  35727. /**
  35728. * Disables audio in the associated scene.
  35729. */
  35730. disableAudio(): void;
  35731. /**
  35732. * Enables audio in the associated scene.
  35733. */
  35734. enableAudio(): void;
  35735. /**
  35736. * Switch audio to headphone output.
  35737. */
  35738. switchAudioModeForHeadphones(): void;
  35739. /**
  35740. * Switch audio to normal speakers.
  35741. */
  35742. switchAudioModeForNormalSpeakers(): void;
  35743. private _afterRender;
  35744. }
  35745. }
  35746. declare module BABYLON {
  35747. /**
  35748. * Wraps one or more Sound objects and selects one with random weight for playback.
  35749. */
  35750. export class WeightedSound {
  35751. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35752. loop: boolean;
  35753. private _coneInnerAngle;
  35754. private _coneOuterAngle;
  35755. private _volume;
  35756. /** A Sound is currently playing. */
  35757. isPlaying: boolean;
  35758. /** A Sound is currently paused. */
  35759. isPaused: boolean;
  35760. private _sounds;
  35761. private _weights;
  35762. private _currentIndex?;
  35763. /**
  35764. * Creates a new WeightedSound from the list of sounds given.
  35765. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35766. * @param sounds Array of Sounds that will be selected from.
  35767. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35768. */
  35769. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35770. /**
  35771. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35772. */
  35773. /**
  35774. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35775. */
  35776. directionalConeInnerAngle: number;
  35777. /**
  35778. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35779. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35780. */
  35781. /**
  35782. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35783. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35784. */
  35785. directionalConeOuterAngle: number;
  35786. /**
  35787. * Playback volume.
  35788. */
  35789. /**
  35790. * Playback volume.
  35791. */
  35792. volume: number;
  35793. private _onended;
  35794. /**
  35795. * Suspend playback
  35796. */
  35797. pause(): void;
  35798. /**
  35799. * Stop playback
  35800. */
  35801. stop(): void;
  35802. /**
  35803. * Start playback.
  35804. * @param startOffset Position the clip head at a specific time in seconds.
  35805. */
  35806. play(startOffset?: number): void;
  35807. }
  35808. }
  35809. declare module BABYLON {
  35810. /**
  35811. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35812. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35813. */
  35814. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35815. /**
  35816. * Gets the name of the behavior.
  35817. */
  35818. readonly name: string;
  35819. /**
  35820. * The easing function used by animations
  35821. */
  35822. static EasingFunction: BackEase;
  35823. /**
  35824. * The easing mode used by animations
  35825. */
  35826. static EasingMode: number;
  35827. /**
  35828. * The duration of the animation, in milliseconds
  35829. */
  35830. transitionDuration: number;
  35831. /**
  35832. * Length of the distance animated by the transition when lower radius is reached
  35833. */
  35834. lowerRadiusTransitionRange: number;
  35835. /**
  35836. * Length of the distance animated by the transition when upper radius is reached
  35837. */
  35838. upperRadiusTransitionRange: number;
  35839. private _autoTransitionRange;
  35840. /**
  35841. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35842. */
  35843. /**
  35844. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35845. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35846. */
  35847. autoTransitionRange: boolean;
  35848. private _attachedCamera;
  35849. private _onAfterCheckInputsObserver;
  35850. private _onMeshTargetChangedObserver;
  35851. /**
  35852. * Initializes the behavior.
  35853. */
  35854. init(): void;
  35855. /**
  35856. * Attaches the behavior to its arc rotate camera.
  35857. * @param camera Defines the camera to attach the behavior to
  35858. */
  35859. attach(camera: ArcRotateCamera): void;
  35860. /**
  35861. * Detaches the behavior from its current arc rotate camera.
  35862. */
  35863. detach(): void;
  35864. private _radiusIsAnimating;
  35865. private _radiusBounceTransition;
  35866. private _animatables;
  35867. private _cachedWheelPrecision;
  35868. /**
  35869. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35870. * @param radiusLimit The limit to check against.
  35871. * @return Bool to indicate if at limit.
  35872. */
  35873. private _isRadiusAtLimit;
  35874. /**
  35875. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35876. * @param radiusDelta The delta by which to animate to. Can be negative.
  35877. */
  35878. private _applyBoundRadiusAnimation;
  35879. /**
  35880. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35881. */
  35882. protected _clearAnimationLocks(): void;
  35883. /**
  35884. * Stops and removes all animations that have been applied to the camera
  35885. */
  35886. stopAllAnimations(): void;
  35887. }
  35888. }
  35889. declare module BABYLON {
  35890. /**
  35891. * 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.
  35892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35893. */
  35894. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35895. /**
  35896. * Gets the name of the behavior.
  35897. */
  35898. readonly name: string;
  35899. private _mode;
  35900. private _radiusScale;
  35901. private _positionScale;
  35902. private _defaultElevation;
  35903. private _elevationReturnTime;
  35904. private _elevationReturnWaitTime;
  35905. private _zoomStopsAnimation;
  35906. private _framingTime;
  35907. /**
  35908. * The easing function used by animations
  35909. */
  35910. static EasingFunction: ExponentialEase;
  35911. /**
  35912. * The easing mode used by animations
  35913. */
  35914. static EasingMode: number;
  35915. /**
  35916. * Sets the current mode used by the behavior
  35917. */
  35918. /**
  35919. * Gets current mode used by the behavior.
  35920. */
  35921. mode: number;
  35922. /**
  35923. * Sets the scale applied to the radius (1 by default)
  35924. */
  35925. /**
  35926. * Gets the scale applied to the radius
  35927. */
  35928. radiusScale: number;
  35929. /**
  35930. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35931. */
  35932. /**
  35933. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35934. */
  35935. positionScale: number;
  35936. /**
  35937. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35938. * behaviour is triggered, in radians.
  35939. */
  35940. /**
  35941. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35942. * behaviour is triggered, in radians.
  35943. */
  35944. defaultElevation: number;
  35945. /**
  35946. * Sets the time (in milliseconds) taken to return to the default beta position.
  35947. * Negative value indicates camera should not return to default.
  35948. */
  35949. /**
  35950. * Gets the time (in milliseconds) taken to return to the default beta position.
  35951. * Negative value indicates camera should not return to default.
  35952. */
  35953. elevationReturnTime: number;
  35954. /**
  35955. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35956. */
  35957. /**
  35958. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35959. */
  35960. elevationReturnWaitTime: number;
  35961. /**
  35962. * Sets the flag that indicates if user zooming should stop animation.
  35963. */
  35964. /**
  35965. * Gets the flag that indicates if user zooming should stop animation.
  35966. */
  35967. zoomStopsAnimation: boolean;
  35968. /**
  35969. * Sets the transition time when framing the mesh, in milliseconds
  35970. */
  35971. /**
  35972. * Gets the transition time when framing the mesh, in milliseconds
  35973. */
  35974. framingTime: number;
  35975. /**
  35976. * Define if the behavior should automatically change the configured
  35977. * camera limits and sensibilities.
  35978. */
  35979. autoCorrectCameraLimitsAndSensibility: boolean;
  35980. private _onPrePointerObservableObserver;
  35981. private _onAfterCheckInputsObserver;
  35982. private _onMeshTargetChangedObserver;
  35983. private _attachedCamera;
  35984. private _isPointerDown;
  35985. private _lastInteractionTime;
  35986. /**
  35987. * Initializes the behavior.
  35988. */
  35989. init(): void;
  35990. /**
  35991. * Attaches the behavior to its arc rotate camera.
  35992. * @param camera Defines the camera to attach the behavior to
  35993. */
  35994. attach(camera: ArcRotateCamera): void;
  35995. /**
  35996. * Detaches the behavior from its current arc rotate camera.
  35997. */
  35998. detach(): void;
  35999. private _animatables;
  36000. private _betaIsAnimating;
  36001. private _betaTransition;
  36002. private _radiusTransition;
  36003. private _vectorTransition;
  36004. /**
  36005. * Targets the given mesh and updates zoom level accordingly.
  36006. * @param mesh The mesh to target.
  36007. * @param radius Optional. If a cached radius position already exists, overrides default.
  36008. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36009. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36010. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36011. */
  36012. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36013. /**
  36014. * Targets the given mesh with its children and updates zoom level accordingly.
  36015. * @param mesh The mesh to target.
  36016. * @param radius Optional. If a cached radius position already exists, overrides default.
  36017. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36018. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36019. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36020. */
  36021. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36022. /**
  36023. * Targets the given meshes with their children and updates zoom level accordingly.
  36024. * @param meshes The mesh to target.
  36025. * @param radius Optional. If a cached radius position already exists, overrides default.
  36026. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36027. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36028. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36029. */
  36030. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36031. /**
  36032. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36033. * @param minimumWorld Determines the smaller position of the bounding box extend
  36034. * @param maximumWorld Determines the bigger position of the bounding box extend
  36035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36037. */
  36038. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36039. /**
  36040. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36041. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36042. * frustum width.
  36043. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36044. * to fully enclose the mesh in the viewing frustum.
  36045. */
  36046. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36047. /**
  36048. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36049. * is automatically returned to its default position (expected to be above ground plane).
  36050. */
  36051. private _maintainCameraAboveGround;
  36052. /**
  36053. * Returns the frustum slope based on the canvas ratio and camera FOV
  36054. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36055. */
  36056. private _getFrustumSlope;
  36057. /**
  36058. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36059. */
  36060. private _clearAnimationLocks;
  36061. /**
  36062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36063. */
  36064. private _applyUserInteraction;
  36065. /**
  36066. * Stops and removes all animations that have been applied to the camera
  36067. */
  36068. stopAllAnimations(): void;
  36069. /**
  36070. * Gets a value indicating if the user is moving the camera
  36071. */
  36072. readonly isUserIsMoving: boolean;
  36073. /**
  36074. * The camera can move all the way towards the mesh.
  36075. */
  36076. static IgnoreBoundsSizeMode: number;
  36077. /**
  36078. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36079. */
  36080. static FitFrustumSidesMode: number;
  36081. }
  36082. }
  36083. declare module BABYLON {
  36084. /**
  36085. * Base class for Camera Pointer Inputs.
  36086. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36087. * for example usage.
  36088. */
  36089. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36090. /**
  36091. * Defines the camera the input is attached to.
  36092. */
  36093. abstract camera: Camera;
  36094. /**
  36095. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36096. */
  36097. protected _altKey: boolean;
  36098. protected _ctrlKey: boolean;
  36099. protected _metaKey: boolean;
  36100. protected _shiftKey: boolean;
  36101. /**
  36102. * Which mouse buttons were pressed at time of last mouse event.
  36103. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36104. */
  36105. protected _buttonsPressed: number;
  36106. /**
  36107. * Defines the buttons associated with the input to handle camera move.
  36108. */
  36109. buttons: number[];
  36110. /**
  36111. * Attach the input controls to a specific dom element to get the input from.
  36112. * @param element Defines the element the controls should be listened from
  36113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36114. */
  36115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36116. /**
  36117. * Detach the current controls from the specified dom element.
  36118. * @param element Defines the element to stop listening the inputs from
  36119. */
  36120. detachControl(element: Nullable<HTMLElement>): void;
  36121. /**
  36122. * Gets the class name of the current input.
  36123. * @returns the class name
  36124. */
  36125. getClassName(): string;
  36126. /**
  36127. * Get the friendly name associated with the input class.
  36128. * @returns the input friendly name
  36129. */
  36130. getSimpleName(): string;
  36131. /**
  36132. * Called on pointer POINTERDOUBLETAP event.
  36133. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36134. */
  36135. protected onDoubleTap(type: string): void;
  36136. /**
  36137. * Called on pointer POINTERMOVE event if only a single touch is active.
  36138. * Override this method to provide functionality.
  36139. */
  36140. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36141. /**
  36142. * Called on pointer POINTERMOVE event if multiple touches are active.
  36143. * Override this method to provide functionality.
  36144. */
  36145. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36146. /**
  36147. * Called on JS contextmenu event.
  36148. * Override this method to provide functionality.
  36149. */
  36150. protected onContextMenu(evt: PointerEvent): void;
  36151. /**
  36152. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36153. * press.
  36154. * Override this method to provide functionality.
  36155. */
  36156. protected onButtonDown(evt: PointerEvent): void;
  36157. /**
  36158. * Called each time a new POINTERUP event occurs. Ie, for each button
  36159. * release.
  36160. * Override this method to provide functionality.
  36161. */
  36162. protected onButtonUp(evt: PointerEvent): void;
  36163. /**
  36164. * Called when window becomes inactive.
  36165. * Override this method to provide functionality.
  36166. */
  36167. protected onLostFocus(): void;
  36168. private _pointerInput;
  36169. private _observer;
  36170. private _onLostFocus;
  36171. private pointA;
  36172. private pointB;
  36173. }
  36174. }
  36175. declare module BABYLON {
  36176. /**
  36177. * Manage the pointers inputs to control an arc rotate camera.
  36178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36179. */
  36180. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36181. /**
  36182. * Defines the camera the input is attached to.
  36183. */
  36184. camera: ArcRotateCamera;
  36185. /**
  36186. * Gets the class name of the current input.
  36187. * @returns the class name
  36188. */
  36189. getClassName(): string;
  36190. /**
  36191. * Defines the buttons associated with the input to handle camera move.
  36192. */
  36193. buttons: number[];
  36194. /**
  36195. * Defines the pointer angular sensibility along the X axis or how fast is
  36196. * the camera rotating.
  36197. */
  36198. angularSensibilityX: number;
  36199. /**
  36200. * Defines the pointer angular sensibility along the Y axis or how fast is
  36201. * the camera rotating.
  36202. */
  36203. angularSensibilityY: number;
  36204. /**
  36205. * Defines the pointer pinch precision or how fast is the camera zooming.
  36206. */
  36207. pinchPrecision: number;
  36208. /**
  36209. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36210. * from 0.
  36211. * It defines the percentage of current camera.radius to use as delta when
  36212. * pinch zoom is used.
  36213. */
  36214. pinchDeltaPercentage: number;
  36215. /**
  36216. * Defines the pointer panning sensibility or how fast is the camera moving.
  36217. */
  36218. panningSensibility: number;
  36219. /**
  36220. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36221. */
  36222. multiTouchPanning: boolean;
  36223. /**
  36224. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36225. * zoom (pinch) through multitouch.
  36226. */
  36227. multiTouchPanAndZoom: boolean;
  36228. /**
  36229. * Revers pinch action direction.
  36230. */
  36231. pinchInwards: boolean;
  36232. private _isPanClick;
  36233. private _twoFingerActivityCount;
  36234. private _isPinching;
  36235. /**
  36236. * Called on pointer POINTERMOVE event if only a single touch is active.
  36237. */
  36238. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36239. /**
  36240. * Called on pointer POINTERDOUBLETAP event.
  36241. */
  36242. protected onDoubleTap(type: string): void;
  36243. /**
  36244. * Called on pointer POINTERMOVE event if multiple touches are active.
  36245. */
  36246. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36247. /**
  36248. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36249. * press.
  36250. */
  36251. protected onButtonDown(evt: PointerEvent): void;
  36252. /**
  36253. * Called each time a new POINTERUP event occurs. Ie, for each button
  36254. * release.
  36255. */
  36256. protected onButtonUp(evt: PointerEvent): void;
  36257. /**
  36258. * Called when window becomes inactive.
  36259. */
  36260. protected onLostFocus(): void;
  36261. }
  36262. }
  36263. declare module BABYLON {
  36264. /**
  36265. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36267. */
  36268. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36269. /**
  36270. * Defines the camera the input is attached to.
  36271. */
  36272. camera: ArcRotateCamera;
  36273. /**
  36274. * Defines the list of key codes associated with the up action (increase alpha)
  36275. */
  36276. keysUp: number[];
  36277. /**
  36278. * Defines the list of key codes associated with the down action (decrease alpha)
  36279. */
  36280. keysDown: number[];
  36281. /**
  36282. * Defines the list of key codes associated with the left action (increase beta)
  36283. */
  36284. keysLeft: number[];
  36285. /**
  36286. * Defines the list of key codes associated with the right action (decrease beta)
  36287. */
  36288. keysRight: number[];
  36289. /**
  36290. * Defines the list of key codes associated with the reset action.
  36291. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36292. */
  36293. keysReset: number[];
  36294. /**
  36295. * Defines the panning sensibility of the inputs.
  36296. * (How fast is the camera paning)
  36297. */
  36298. panningSensibility: number;
  36299. /**
  36300. * Defines the zooming sensibility of the inputs.
  36301. * (How fast is the camera zooming)
  36302. */
  36303. zoomingSensibility: number;
  36304. /**
  36305. * Defines wether maintaining the alt key down switch the movement mode from
  36306. * orientation to zoom.
  36307. */
  36308. useAltToZoom: boolean;
  36309. /**
  36310. * Rotation speed of the camera
  36311. */
  36312. angularSpeed: number;
  36313. private _keys;
  36314. private _ctrlPressed;
  36315. private _altPressed;
  36316. private _onCanvasBlurObserver;
  36317. private _onKeyboardObserver;
  36318. private _engine;
  36319. private _scene;
  36320. /**
  36321. * Attach the input controls to a specific dom element to get the input from.
  36322. * @param element Defines the element the controls should be listened from
  36323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36324. */
  36325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36326. /**
  36327. * Detach the current controls from the specified dom element.
  36328. * @param element Defines the element to stop listening the inputs from
  36329. */
  36330. detachControl(element: Nullable<HTMLElement>): void;
  36331. /**
  36332. * Update the current camera state depending on the inputs that have been used this frame.
  36333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36334. */
  36335. checkInputs(): void;
  36336. /**
  36337. * Gets the class name of the current intput.
  36338. * @returns the class name
  36339. */
  36340. getClassName(): string;
  36341. /**
  36342. * Get the friendly name associated with the input class.
  36343. * @returns the input friendly name
  36344. */
  36345. getSimpleName(): string;
  36346. }
  36347. }
  36348. declare module BABYLON {
  36349. /**
  36350. * Manage the mouse wheel inputs to control an arc rotate camera.
  36351. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36352. */
  36353. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36354. /**
  36355. * Defines the camera the input is attached to.
  36356. */
  36357. camera: ArcRotateCamera;
  36358. /**
  36359. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36360. */
  36361. wheelPrecision: number;
  36362. /**
  36363. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36364. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36365. */
  36366. wheelDeltaPercentage: number;
  36367. private _wheel;
  36368. private _observer;
  36369. private computeDeltaFromMouseWheelLegacyEvent;
  36370. /**
  36371. * Attach the input controls to a specific dom element to get the input from.
  36372. * @param element Defines the element the controls should be listened from
  36373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36374. */
  36375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36376. /**
  36377. * Detach the current controls from the specified dom element.
  36378. * @param element Defines the element to stop listening the inputs from
  36379. */
  36380. detachControl(element: Nullable<HTMLElement>): void;
  36381. /**
  36382. * Gets the class name of the current intput.
  36383. * @returns the class name
  36384. */
  36385. getClassName(): string;
  36386. /**
  36387. * Get the friendly name associated with the input class.
  36388. * @returns the input friendly name
  36389. */
  36390. getSimpleName(): string;
  36391. }
  36392. }
  36393. declare module BABYLON {
  36394. /**
  36395. * Default Inputs manager for the ArcRotateCamera.
  36396. * It groups all the default supported inputs for ease of use.
  36397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36398. */
  36399. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36400. /**
  36401. * Instantiates a new ArcRotateCameraInputsManager.
  36402. * @param camera Defines the camera the inputs belong to
  36403. */
  36404. constructor(camera: ArcRotateCamera);
  36405. /**
  36406. * Add mouse wheel input support to the input manager.
  36407. * @returns the current input manager
  36408. */
  36409. addMouseWheel(): ArcRotateCameraInputsManager;
  36410. /**
  36411. * Add pointers input support to the input manager.
  36412. * @returns the current input manager
  36413. */
  36414. addPointers(): ArcRotateCameraInputsManager;
  36415. /**
  36416. * Add keyboard input support to the input manager.
  36417. * @returns the current input manager
  36418. */
  36419. addKeyboard(): ArcRotateCameraInputsManager;
  36420. }
  36421. }
  36422. declare module BABYLON {
  36423. /**
  36424. * This represents an orbital type of camera.
  36425. *
  36426. * 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.
  36427. * 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.
  36428. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36429. */
  36430. export class ArcRotateCamera extends TargetCamera {
  36431. /**
  36432. * Defines the rotation angle of the camera along the longitudinal axis.
  36433. */
  36434. alpha: number;
  36435. /**
  36436. * Defines the rotation angle of the camera along the latitudinal axis.
  36437. */
  36438. beta: number;
  36439. /**
  36440. * Defines the radius of the camera from it s target point.
  36441. */
  36442. radius: number;
  36443. protected _target: Vector3;
  36444. protected _targetHost: Nullable<AbstractMesh>;
  36445. /**
  36446. * Defines the target point of the camera.
  36447. * The camera looks towards it form the radius distance.
  36448. */
  36449. target: Vector3;
  36450. /**
  36451. * Define the current local position of the camera in the scene
  36452. */
  36453. position: Vector3;
  36454. protected _upVector: Vector3;
  36455. protected _upToYMatrix: Matrix;
  36456. protected _YToUpMatrix: Matrix;
  36457. /**
  36458. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36459. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36460. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36461. */
  36462. upVector: Vector3;
  36463. /**
  36464. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36465. */
  36466. setMatUp(): void;
  36467. /**
  36468. * Current inertia value on the longitudinal axis.
  36469. * The bigger this number the longer it will take for the camera to stop.
  36470. */
  36471. inertialAlphaOffset: number;
  36472. /**
  36473. * Current inertia value on the latitudinal axis.
  36474. * The bigger this number the longer it will take for the camera to stop.
  36475. */
  36476. inertialBetaOffset: number;
  36477. /**
  36478. * Current inertia value on the radius axis.
  36479. * The bigger this number the longer it will take for the camera to stop.
  36480. */
  36481. inertialRadiusOffset: number;
  36482. /**
  36483. * Minimum allowed angle on the longitudinal axis.
  36484. * This can help limiting how the Camera is able to move in the scene.
  36485. */
  36486. lowerAlphaLimit: Nullable<number>;
  36487. /**
  36488. * Maximum allowed angle on the longitudinal axis.
  36489. * This can help limiting how the Camera is able to move in the scene.
  36490. */
  36491. upperAlphaLimit: Nullable<number>;
  36492. /**
  36493. * Minimum allowed angle on the latitudinal axis.
  36494. * This can help limiting how the Camera is able to move in the scene.
  36495. */
  36496. lowerBetaLimit: number;
  36497. /**
  36498. * Maximum allowed angle on the latitudinal axis.
  36499. * This can help limiting how the Camera is able to move in the scene.
  36500. */
  36501. upperBetaLimit: number;
  36502. /**
  36503. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36504. * This can help limiting how the Camera is able to move in the scene.
  36505. */
  36506. lowerRadiusLimit: Nullable<number>;
  36507. /**
  36508. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36509. * This can help limiting how the Camera is able to move in the scene.
  36510. */
  36511. upperRadiusLimit: Nullable<number>;
  36512. /**
  36513. * Defines the current inertia value used during panning of the camera along the X axis.
  36514. */
  36515. inertialPanningX: number;
  36516. /**
  36517. * Defines the current inertia value used during panning of the camera along the Y axis.
  36518. */
  36519. inertialPanningY: number;
  36520. /**
  36521. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36522. * Basically if your fingers moves away from more than this distance you will be considered
  36523. * in pinch mode.
  36524. */
  36525. pinchToPanMaxDistance: number;
  36526. /**
  36527. * Defines the maximum distance the camera can pan.
  36528. * This could help keeping the cammera always in your scene.
  36529. */
  36530. panningDistanceLimit: Nullable<number>;
  36531. /**
  36532. * Defines the target of the camera before paning.
  36533. */
  36534. panningOriginTarget: Vector3;
  36535. /**
  36536. * Defines the value of the inertia used during panning.
  36537. * 0 would mean stop inertia and one would mean no decelleration at all.
  36538. */
  36539. panningInertia: number;
  36540. /**
  36541. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36542. */
  36543. angularSensibilityX: number;
  36544. /**
  36545. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36546. */
  36547. angularSensibilityY: number;
  36548. /**
  36549. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36550. */
  36551. pinchPrecision: number;
  36552. /**
  36553. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36554. * It will be used instead of pinchDeltaPrecision if different from 0.
  36555. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36556. */
  36557. pinchDeltaPercentage: number;
  36558. /**
  36559. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36560. */
  36561. panningSensibility: number;
  36562. /**
  36563. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36564. */
  36565. keysUp: number[];
  36566. /**
  36567. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36568. */
  36569. keysDown: number[];
  36570. /**
  36571. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36572. */
  36573. keysLeft: number[];
  36574. /**
  36575. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36576. */
  36577. keysRight: number[];
  36578. /**
  36579. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36580. */
  36581. wheelPrecision: number;
  36582. /**
  36583. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36584. * It will be used instead of pinchDeltaPrecision if different from 0.
  36585. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36586. */
  36587. wheelDeltaPercentage: number;
  36588. /**
  36589. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36590. */
  36591. zoomOnFactor: number;
  36592. /**
  36593. * Defines a screen offset for the camera position.
  36594. */
  36595. targetScreenOffset: Vector2;
  36596. /**
  36597. * Allows the camera to be completely reversed.
  36598. * If false the camera can not arrive upside down.
  36599. */
  36600. allowUpsideDown: boolean;
  36601. /**
  36602. * Define if double tap/click is used to restore the previously saved state of the camera.
  36603. */
  36604. useInputToRestoreState: boolean;
  36605. /** @hidden */
  36606. _viewMatrix: Matrix;
  36607. /** @hidden */
  36608. _useCtrlForPanning: boolean;
  36609. /** @hidden */
  36610. _panningMouseButton: number;
  36611. /**
  36612. * Defines the input associated to the camera.
  36613. */
  36614. inputs: ArcRotateCameraInputsManager;
  36615. /** @hidden */
  36616. _reset: () => void;
  36617. /**
  36618. * Defines the allowed panning axis.
  36619. */
  36620. panningAxis: Vector3;
  36621. protected _localDirection: Vector3;
  36622. protected _transformedDirection: Vector3;
  36623. private _bouncingBehavior;
  36624. /**
  36625. * Gets the bouncing behavior of the camera if it has been enabled.
  36626. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36627. */
  36628. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36629. /**
  36630. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36632. */
  36633. useBouncingBehavior: boolean;
  36634. private _framingBehavior;
  36635. /**
  36636. * Gets the framing behavior of the camera if it has been enabled.
  36637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36638. */
  36639. readonly framingBehavior: Nullable<FramingBehavior>;
  36640. /**
  36641. * Defines if the framing behavior of the camera is enabled on the camera.
  36642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36643. */
  36644. useFramingBehavior: boolean;
  36645. private _autoRotationBehavior;
  36646. /**
  36647. * Gets the auto rotation behavior of the camera if it has been enabled.
  36648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36649. */
  36650. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36651. /**
  36652. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36654. */
  36655. useAutoRotationBehavior: boolean;
  36656. /**
  36657. * Observable triggered when the mesh target has been changed on the camera.
  36658. */
  36659. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36660. /**
  36661. * Event raised when the camera is colliding with a mesh.
  36662. */
  36663. onCollide: (collidedMesh: AbstractMesh) => void;
  36664. /**
  36665. * Defines whether the camera should check collision with the objects oh the scene.
  36666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36667. */
  36668. checkCollisions: boolean;
  36669. /**
  36670. * Defines the collision radius of the camera.
  36671. * This simulates a sphere around the camera.
  36672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36673. */
  36674. collisionRadius: Vector3;
  36675. protected _collider: Collider;
  36676. protected _previousPosition: Vector3;
  36677. protected _collisionVelocity: Vector3;
  36678. protected _newPosition: Vector3;
  36679. protected _previousAlpha: number;
  36680. protected _previousBeta: number;
  36681. protected _previousRadius: number;
  36682. protected _collisionTriggered: boolean;
  36683. protected _targetBoundingCenter: Nullable<Vector3>;
  36684. private _computationVector;
  36685. /**
  36686. * Instantiates a new ArcRotateCamera in a given scene
  36687. * @param name Defines the name of the camera
  36688. * @param alpha Defines the camera rotation along the logitudinal axis
  36689. * @param beta Defines the camera rotation along the latitudinal axis
  36690. * @param radius Defines the camera distance from its target
  36691. * @param target Defines the camera target
  36692. * @param scene Defines the scene the camera belongs to
  36693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36694. */
  36695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36696. /** @hidden */
  36697. _initCache(): void;
  36698. /** @hidden */
  36699. _updateCache(ignoreParentClass?: boolean): void;
  36700. protected _getTargetPosition(): Vector3;
  36701. private _storedAlpha;
  36702. private _storedBeta;
  36703. private _storedRadius;
  36704. private _storedTarget;
  36705. private _storedTargetScreenOffset;
  36706. /**
  36707. * Stores the current state of the camera (alpha, beta, radius and target)
  36708. * @returns the camera itself
  36709. */
  36710. storeState(): Camera;
  36711. /**
  36712. * @hidden
  36713. * Restored camera state. You must call storeState() first
  36714. */
  36715. _restoreStateValues(): boolean;
  36716. /** @hidden */
  36717. _isSynchronizedViewMatrix(): boolean;
  36718. /**
  36719. * Attached controls to the current camera.
  36720. * @param element Defines the element the controls should be listened from
  36721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36722. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36723. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36724. */
  36725. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36726. /**
  36727. * Detach the current controls from the camera.
  36728. * The camera will stop reacting to inputs.
  36729. * @param element Defines the element to stop listening the inputs from
  36730. */
  36731. detachControl(element: HTMLElement): void;
  36732. /** @hidden */
  36733. _checkInputs(): void;
  36734. protected _checkLimits(): void;
  36735. /**
  36736. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36737. */
  36738. rebuildAnglesAndRadius(): void;
  36739. /**
  36740. * Use a position to define the current camera related information like alpha, beta and radius
  36741. * @param position Defines the position to set the camera at
  36742. */
  36743. setPosition(position: Vector3): void;
  36744. /**
  36745. * Defines the target the camera should look at.
  36746. * This will automatically adapt alpha beta and radius to fit within the new target.
  36747. * @param target Defines the new target as a Vector or a mesh
  36748. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36749. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36750. */
  36751. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36752. /** @hidden */
  36753. _getViewMatrix(): Matrix;
  36754. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36755. /**
  36756. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36757. * @param meshes Defines the mesh to zoom on
  36758. * @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)
  36759. */
  36760. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36761. /**
  36762. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36763. * The target will be changed but the radius
  36764. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36765. * @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)
  36766. */
  36767. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36768. min: Vector3;
  36769. max: Vector3;
  36770. distance: number;
  36771. }, doNotUpdateMaxZ?: boolean): void;
  36772. /**
  36773. * @override
  36774. * Override Camera.createRigCamera
  36775. */
  36776. createRigCamera(name: string, cameraIndex: number): Camera;
  36777. /**
  36778. * @hidden
  36779. * @override
  36780. * Override Camera._updateRigCameras
  36781. */
  36782. _updateRigCameras(): void;
  36783. /**
  36784. * Destroy the camera and release the current resources hold by it.
  36785. */
  36786. dispose(): void;
  36787. /**
  36788. * Gets the current object class name.
  36789. * @return the class name
  36790. */
  36791. getClassName(): string;
  36792. }
  36793. }
  36794. declare module BABYLON {
  36795. /**
  36796. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36798. */
  36799. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36800. /**
  36801. * Gets the name of the behavior.
  36802. */
  36803. readonly name: string;
  36804. private _zoomStopsAnimation;
  36805. private _idleRotationSpeed;
  36806. private _idleRotationWaitTime;
  36807. private _idleRotationSpinupTime;
  36808. /**
  36809. * Sets the flag that indicates if user zooming should stop animation.
  36810. */
  36811. /**
  36812. * Gets the flag that indicates if user zooming should stop animation.
  36813. */
  36814. zoomStopsAnimation: boolean;
  36815. /**
  36816. * Sets the default speed at which the camera rotates around the model.
  36817. */
  36818. /**
  36819. * Gets the default speed at which the camera rotates around the model.
  36820. */
  36821. idleRotationSpeed: number;
  36822. /**
  36823. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36824. */
  36825. /**
  36826. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36827. */
  36828. idleRotationWaitTime: number;
  36829. /**
  36830. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36831. */
  36832. /**
  36833. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36834. */
  36835. idleRotationSpinupTime: number;
  36836. /**
  36837. * Gets a value indicating if the camera is currently rotating because of this behavior
  36838. */
  36839. readonly rotationInProgress: boolean;
  36840. private _onPrePointerObservableObserver;
  36841. private _onAfterCheckInputsObserver;
  36842. private _attachedCamera;
  36843. private _isPointerDown;
  36844. private _lastFrameTime;
  36845. private _lastInteractionTime;
  36846. private _cameraRotationSpeed;
  36847. /**
  36848. * Initializes the behavior.
  36849. */
  36850. init(): void;
  36851. /**
  36852. * Attaches the behavior to its arc rotate camera.
  36853. * @param camera Defines the camera to attach the behavior to
  36854. */
  36855. attach(camera: ArcRotateCamera): void;
  36856. /**
  36857. * Detaches the behavior from its current arc rotate camera.
  36858. */
  36859. detach(): void;
  36860. /**
  36861. * Returns true if user is scrolling.
  36862. * @return true if user is scrolling.
  36863. */
  36864. private _userIsZooming;
  36865. private _lastFrameRadius;
  36866. private _shouldAnimationStopForInteraction;
  36867. /**
  36868. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36869. */
  36870. private _applyUserInteraction;
  36871. private _userIsMoving;
  36872. }
  36873. }
  36874. declare module BABYLON {
  36875. /**
  36876. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36877. */
  36878. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36879. private ui;
  36880. /**
  36881. * The name of the behavior
  36882. */
  36883. name: string;
  36884. /**
  36885. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36886. */
  36887. distanceAwayFromFace: number;
  36888. /**
  36889. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36890. */
  36891. distanceAwayFromBottomOfFace: number;
  36892. private _faceVectors;
  36893. private _target;
  36894. private _scene;
  36895. private _onRenderObserver;
  36896. private _tmpMatrix;
  36897. private _tmpVector;
  36898. /**
  36899. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36900. * @param ui The transform node that should be attched to the mesh
  36901. */
  36902. constructor(ui: TransformNode);
  36903. /**
  36904. * Initializes the behavior
  36905. */
  36906. init(): void;
  36907. private _closestFace;
  36908. private _zeroVector;
  36909. private _lookAtTmpMatrix;
  36910. private _lookAtToRef;
  36911. /**
  36912. * Attaches the AttachToBoxBehavior to the passed in mesh
  36913. * @param target The mesh that the specified node will be attached to
  36914. */
  36915. attach(target: Mesh): void;
  36916. /**
  36917. * Detaches the behavior from the mesh
  36918. */
  36919. detach(): void;
  36920. }
  36921. }
  36922. declare module BABYLON {
  36923. /**
  36924. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36925. */
  36926. export class FadeInOutBehavior implements Behavior<Mesh> {
  36927. /**
  36928. * Time in milliseconds to delay before fading in (Default: 0)
  36929. */
  36930. delay: number;
  36931. /**
  36932. * Time in milliseconds for the mesh to fade in (Default: 300)
  36933. */
  36934. fadeInTime: number;
  36935. private _millisecondsPerFrame;
  36936. private _hovered;
  36937. private _hoverValue;
  36938. private _ownerNode;
  36939. /**
  36940. * Instatiates the FadeInOutBehavior
  36941. */
  36942. constructor();
  36943. /**
  36944. * The name of the behavior
  36945. */
  36946. readonly name: string;
  36947. /**
  36948. * Initializes the behavior
  36949. */
  36950. init(): void;
  36951. /**
  36952. * Attaches the fade behavior on the passed in mesh
  36953. * @param ownerNode The mesh that will be faded in/out once attached
  36954. */
  36955. attach(ownerNode: Mesh): void;
  36956. /**
  36957. * Detaches the behavior from the mesh
  36958. */
  36959. detach(): void;
  36960. /**
  36961. * Triggers the mesh to begin fading in or out
  36962. * @param value if the object should fade in or out (true to fade in)
  36963. */
  36964. fadeIn(value: boolean): void;
  36965. private _update;
  36966. private _setAllVisibility;
  36967. }
  36968. }
  36969. declare module BABYLON {
  36970. /**
  36971. * Class containing a set of static utilities functions for managing Pivots
  36972. * @hidden
  36973. */
  36974. export class PivotTools {
  36975. private static _PivotCached;
  36976. private static _OldPivotPoint;
  36977. private static _PivotTranslation;
  36978. private static _PivotTmpVector;
  36979. /** @hidden */
  36980. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36981. /** @hidden */
  36982. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36983. }
  36984. }
  36985. declare module BABYLON {
  36986. /**
  36987. * Class containing static functions to help procedurally build meshes
  36988. */
  36989. export class PlaneBuilder {
  36990. /**
  36991. * Creates a plane mesh
  36992. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36993. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36994. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36996. * * 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
  36997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36998. * @param name defines the name of the mesh
  36999. * @param options defines the options used to create the mesh
  37000. * @param scene defines the hosting scene
  37001. * @returns the plane mesh
  37002. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37003. */
  37004. static CreatePlane(name: string, options: {
  37005. size?: number;
  37006. width?: number;
  37007. height?: number;
  37008. sideOrientation?: number;
  37009. frontUVs?: Vector4;
  37010. backUVs?: Vector4;
  37011. updatable?: boolean;
  37012. sourcePlane?: Plane;
  37013. }, scene?: Nullable<Scene>): Mesh;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. /**
  37018. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37019. */
  37020. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37021. private static _AnyMouseID;
  37022. /**
  37023. * Abstract mesh the behavior is set on
  37024. */
  37025. attachedNode: AbstractMesh;
  37026. private _dragPlane;
  37027. private _scene;
  37028. private _pointerObserver;
  37029. private _beforeRenderObserver;
  37030. private static _planeScene;
  37031. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37032. /**
  37033. * 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)
  37034. */
  37035. maxDragAngle: number;
  37036. /**
  37037. * @hidden
  37038. */
  37039. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37040. /**
  37041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37042. */
  37043. currentDraggingPointerID: number;
  37044. /**
  37045. * The last position where the pointer hit the drag plane in world space
  37046. */
  37047. lastDragPosition: Vector3;
  37048. /**
  37049. * If the behavior is currently in a dragging state
  37050. */
  37051. dragging: boolean;
  37052. /**
  37053. * 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)
  37054. */
  37055. dragDeltaRatio: number;
  37056. /**
  37057. * If the drag plane orientation should be updated during the dragging (Default: true)
  37058. */
  37059. updateDragPlane: boolean;
  37060. private _debugMode;
  37061. private _moving;
  37062. /**
  37063. * Fires each time the attached mesh is dragged with the pointer
  37064. * * delta between last drag position and current drag position in world space
  37065. * * dragDistance along the drag axis
  37066. * * dragPlaneNormal normal of the current drag plane used during the drag
  37067. * * dragPlanePoint in world space where the drag intersects the drag plane
  37068. */
  37069. onDragObservable: Observable<{
  37070. delta: Vector3;
  37071. dragPlanePoint: Vector3;
  37072. dragPlaneNormal: Vector3;
  37073. dragDistance: number;
  37074. pointerId: number;
  37075. }>;
  37076. /**
  37077. * Fires each time a drag begins (eg. mouse down on mesh)
  37078. */
  37079. onDragStartObservable: Observable<{
  37080. dragPlanePoint: Vector3;
  37081. pointerId: number;
  37082. }>;
  37083. /**
  37084. * Fires each time a drag ends (eg. mouse release after drag)
  37085. */
  37086. onDragEndObservable: Observable<{
  37087. dragPlanePoint: Vector3;
  37088. pointerId: number;
  37089. }>;
  37090. /**
  37091. * If the attached mesh should be moved when dragged
  37092. */
  37093. moveAttached: boolean;
  37094. /**
  37095. * If the drag behavior will react to drag events (Default: true)
  37096. */
  37097. enabled: boolean;
  37098. /**
  37099. * If pointer events should start and release the drag (Default: true)
  37100. */
  37101. startAndReleaseDragOnPointerEvents: boolean;
  37102. /**
  37103. * If camera controls should be detached during the drag
  37104. */
  37105. detachCameraControls: boolean;
  37106. /**
  37107. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37108. */
  37109. useObjectOrienationForDragging: boolean;
  37110. private _options;
  37111. /**
  37112. * Creates a pointer drag behavior that can be attached to a mesh
  37113. * @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)
  37114. */
  37115. constructor(options?: {
  37116. dragAxis?: Vector3;
  37117. dragPlaneNormal?: Vector3;
  37118. });
  37119. /**
  37120. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37121. */
  37122. validateDrag: (targetPosition: Vector3) => boolean;
  37123. /**
  37124. * The name of the behavior
  37125. */
  37126. readonly name: string;
  37127. /**
  37128. * Initializes the behavior
  37129. */
  37130. init(): void;
  37131. private _tmpVector;
  37132. private _alternatePickedPoint;
  37133. private _worldDragAxis;
  37134. private _targetPosition;
  37135. private _attachedElement;
  37136. /**
  37137. * Attaches the drag behavior the passed in mesh
  37138. * @param ownerNode The mesh that will be dragged around once attached
  37139. * @param predicate Predicate to use for pick filtering
  37140. */
  37141. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37142. /**
  37143. * Force relase the drag action by code.
  37144. */
  37145. releaseDrag(): void;
  37146. private _startDragRay;
  37147. private _lastPointerRay;
  37148. /**
  37149. * Simulates the start of a pointer drag event on the behavior
  37150. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37151. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37152. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37153. */
  37154. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37155. private _startDrag;
  37156. private _dragDelta;
  37157. private _moveDrag;
  37158. private _pickWithRayOnDragPlane;
  37159. private _pointA;
  37160. private _pointB;
  37161. private _pointC;
  37162. private _lineA;
  37163. private _lineB;
  37164. private _localAxis;
  37165. private _lookAt;
  37166. private _updateDragPlanePosition;
  37167. /**
  37168. * Detaches the behavior from the mesh
  37169. */
  37170. detach(): void;
  37171. }
  37172. }
  37173. declare module BABYLON {
  37174. /**
  37175. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37176. */
  37177. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37178. private _dragBehaviorA;
  37179. private _dragBehaviorB;
  37180. private _startDistance;
  37181. private _initialScale;
  37182. private _targetScale;
  37183. private _ownerNode;
  37184. private _sceneRenderObserver;
  37185. /**
  37186. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37187. */
  37188. constructor();
  37189. /**
  37190. * The name of the behavior
  37191. */
  37192. readonly name: string;
  37193. /**
  37194. * Initializes the behavior
  37195. */
  37196. init(): void;
  37197. private _getCurrentDistance;
  37198. /**
  37199. * Attaches the scale behavior the passed in mesh
  37200. * @param ownerNode The mesh that will be scaled around once attached
  37201. */
  37202. attach(ownerNode: Mesh): void;
  37203. /**
  37204. * Detaches the behavior from the mesh
  37205. */
  37206. detach(): void;
  37207. }
  37208. }
  37209. declare module BABYLON {
  37210. /**
  37211. * 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
  37212. */
  37213. export class SixDofDragBehavior implements Behavior<Mesh> {
  37214. private static _virtualScene;
  37215. private _ownerNode;
  37216. private _sceneRenderObserver;
  37217. private _scene;
  37218. private _targetPosition;
  37219. private _virtualOriginMesh;
  37220. private _virtualDragMesh;
  37221. private _pointerObserver;
  37222. private _moving;
  37223. private _startingOrientation;
  37224. /**
  37225. * 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)
  37226. */
  37227. private zDragFactor;
  37228. /**
  37229. * If the object should rotate to face the drag origin
  37230. */
  37231. rotateDraggedObject: boolean;
  37232. /**
  37233. * If the behavior is currently in a dragging state
  37234. */
  37235. dragging: boolean;
  37236. /**
  37237. * 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)
  37238. */
  37239. dragDeltaRatio: number;
  37240. /**
  37241. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37242. */
  37243. currentDraggingPointerID: number;
  37244. /**
  37245. * If camera controls should be detached during the drag
  37246. */
  37247. detachCameraControls: boolean;
  37248. /**
  37249. * Fires each time a drag starts
  37250. */
  37251. onDragStartObservable: Observable<{}>;
  37252. /**
  37253. * Fires each time a drag ends (eg. mouse release after drag)
  37254. */
  37255. onDragEndObservable: Observable<{}>;
  37256. /**
  37257. * 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
  37258. */
  37259. constructor();
  37260. /**
  37261. * The name of the behavior
  37262. */
  37263. readonly name: string;
  37264. /**
  37265. * Initializes the behavior
  37266. */
  37267. init(): void;
  37268. /**
  37269. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37270. */
  37271. private readonly _pointerCamera;
  37272. /**
  37273. * Attaches the scale behavior the passed in mesh
  37274. * @param ownerNode The mesh that will be scaled around once attached
  37275. */
  37276. attach(ownerNode: Mesh): void;
  37277. /**
  37278. * Detaches the behavior from the mesh
  37279. */
  37280. detach(): void;
  37281. }
  37282. }
  37283. declare module BABYLON {
  37284. /**
  37285. * Class used to apply inverse kinematics to bones
  37286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37287. */
  37288. export class BoneIKController {
  37289. private static _tmpVecs;
  37290. private static _tmpQuat;
  37291. private static _tmpMats;
  37292. /**
  37293. * Gets or sets the target mesh
  37294. */
  37295. targetMesh: AbstractMesh;
  37296. /** Gets or sets the mesh used as pole */
  37297. poleTargetMesh: AbstractMesh;
  37298. /**
  37299. * Gets or sets the bone used as pole
  37300. */
  37301. poleTargetBone: Nullable<Bone>;
  37302. /**
  37303. * Gets or sets the target position
  37304. */
  37305. targetPosition: Vector3;
  37306. /**
  37307. * Gets or sets the pole target position
  37308. */
  37309. poleTargetPosition: Vector3;
  37310. /**
  37311. * Gets or sets the pole target local offset
  37312. */
  37313. poleTargetLocalOffset: Vector3;
  37314. /**
  37315. * Gets or sets the pole angle
  37316. */
  37317. poleAngle: number;
  37318. /**
  37319. * Gets or sets the mesh associated with the controller
  37320. */
  37321. mesh: AbstractMesh;
  37322. /**
  37323. * 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)
  37324. */
  37325. slerpAmount: number;
  37326. private _bone1Quat;
  37327. private _bone1Mat;
  37328. private _bone2Ang;
  37329. private _bone1;
  37330. private _bone2;
  37331. private _bone1Length;
  37332. private _bone2Length;
  37333. private _maxAngle;
  37334. private _maxReach;
  37335. private _rightHandedSystem;
  37336. private _bendAxis;
  37337. private _slerping;
  37338. private _adjustRoll;
  37339. /**
  37340. * Gets or sets maximum allowed angle
  37341. */
  37342. maxAngle: number;
  37343. /**
  37344. * Creates a new BoneIKController
  37345. * @param mesh defines the mesh to control
  37346. * @param bone defines the bone to control
  37347. * @param options defines options to set up the controller
  37348. */
  37349. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37350. targetMesh?: AbstractMesh;
  37351. poleTargetMesh?: AbstractMesh;
  37352. poleTargetBone?: Bone;
  37353. poleTargetLocalOffset?: Vector3;
  37354. poleAngle?: number;
  37355. bendAxis?: Vector3;
  37356. maxAngle?: number;
  37357. slerpAmount?: number;
  37358. });
  37359. private _setMaxAngle;
  37360. /**
  37361. * Force the controller to update the bones
  37362. */
  37363. update(): void;
  37364. }
  37365. }
  37366. declare module BABYLON {
  37367. /**
  37368. * Class used to make a bone look toward a point in space
  37369. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37370. */
  37371. export class BoneLookController {
  37372. private static _tmpVecs;
  37373. private static _tmpQuat;
  37374. private static _tmpMats;
  37375. /**
  37376. * The target Vector3 that the bone will look at
  37377. */
  37378. target: Vector3;
  37379. /**
  37380. * The mesh that the bone is attached to
  37381. */
  37382. mesh: AbstractMesh;
  37383. /**
  37384. * The bone that will be looking to the target
  37385. */
  37386. bone: Bone;
  37387. /**
  37388. * The up axis of the coordinate system that is used when the bone is rotated
  37389. */
  37390. upAxis: Vector3;
  37391. /**
  37392. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37393. */
  37394. upAxisSpace: Space;
  37395. /**
  37396. * Used to make an adjustment to the yaw of the bone
  37397. */
  37398. adjustYaw: number;
  37399. /**
  37400. * Used to make an adjustment to the pitch of the bone
  37401. */
  37402. adjustPitch: number;
  37403. /**
  37404. * Used to make an adjustment to the roll of the bone
  37405. */
  37406. adjustRoll: number;
  37407. /**
  37408. * 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)
  37409. */
  37410. slerpAmount: number;
  37411. private _minYaw;
  37412. private _maxYaw;
  37413. private _minPitch;
  37414. private _maxPitch;
  37415. private _minYawSin;
  37416. private _minYawCos;
  37417. private _maxYawSin;
  37418. private _maxYawCos;
  37419. private _midYawConstraint;
  37420. private _minPitchTan;
  37421. private _maxPitchTan;
  37422. private _boneQuat;
  37423. private _slerping;
  37424. private _transformYawPitch;
  37425. private _transformYawPitchInv;
  37426. private _firstFrameSkipped;
  37427. private _yawRange;
  37428. private _fowardAxis;
  37429. /**
  37430. * Gets or sets the minimum yaw angle that the bone can look to
  37431. */
  37432. minYaw: number;
  37433. /**
  37434. * Gets or sets the maximum yaw angle that the bone can look to
  37435. */
  37436. maxYaw: number;
  37437. /**
  37438. * Gets or sets the minimum pitch angle that the bone can look to
  37439. */
  37440. minPitch: number;
  37441. /**
  37442. * Gets or sets the maximum pitch angle that the bone can look to
  37443. */
  37444. maxPitch: number;
  37445. /**
  37446. * Create a BoneLookController
  37447. * @param mesh the mesh that the bone belongs to
  37448. * @param bone the bone that will be looking to the target
  37449. * @param target the target Vector3 to look at
  37450. * @param options optional settings:
  37451. * * maxYaw: the maximum angle the bone will yaw to
  37452. * * minYaw: the minimum angle the bone will yaw to
  37453. * * maxPitch: the maximum angle the bone will pitch to
  37454. * * minPitch: the minimum angle the bone will yaw to
  37455. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37456. * * upAxis: the up axis of the coordinate system
  37457. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37458. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37459. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37460. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37461. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37462. * * adjustRoll: used to make an adjustment to the roll of the bone
  37463. **/
  37464. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37465. maxYaw?: number;
  37466. minYaw?: number;
  37467. maxPitch?: number;
  37468. minPitch?: number;
  37469. slerpAmount?: number;
  37470. upAxis?: Vector3;
  37471. upAxisSpace?: Space;
  37472. yawAxis?: Vector3;
  37473. pitchAxis?: Vector3;
  37474. adjustYaw?: number;
  37475. adjustPitch?: number;
  37476. adjustRoll?: number;
  37477. });
  37478. /**
  37479. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37480. */
  37481. update(): void;
  37482. private _getAngleDiff;
  37483. private _getAngleBetween;
  37484. private _isAngleBetween;
  37485. }
  37486. }
  37487. declare module BABYLON {
  37488. /**
  37489. * Manage the gamepad inputs to control an arc rotate camera.
  37490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37491. */
  37492. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37493. /**
  37494. * Defines the camera the input is attached to.
  37495. */
  37496. camera: ArcRotateCamera;
  37497. /**
  37498. * Defines the gamepad the input is gathering event from.
  37499. */
  37500. gamepad: Nullable<Gamepad>;
  37501. /**
  37502. * Defines the gamepad rotation sensiblity.
  37503. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37504. */
  37505. gamepadRotationSensibility: number;
  37506. /**
  37507. * Defines the gamepad move sensiblity.
  37508. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37509. */
  37510. gamepadMoveSensibility: number;
  37511. private _yAxisScale;
  37512. /**
  37513. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37514. */
  37515. invertYAxis: boolean;
  37516. private _onGamepadConnectedObserver;
  37517. private _onGamepadDisconnectedObserver;
  37518. /**
  37519. * Attach the input controls to a specific dom element to get the input from.
  37520. * @param element Defines the element the controls should be listened from
  37521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37522. */
  37523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37524. /**
  37525. * Detach the current controls from the specified dom element.
  37526. * @param element Defines the element to stop listening the inputs from
  37527. */
  37528. detachControl(element: Nullable<HTMLElement>): void;
  37529. /**
  37530. * Update the current camera state depending on the inputs that have been used this frame.
  37531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37532. */
  37533. checkInputs(): void;
  37534. /**
  37535. * Gets the class name of the current intput.
  37536. * @returns the class name
  37537. */
  37538. getClassName(): string;
  37539. /**
  37540. * Get the friendly name associated with the input class.
  37541. * @returns the input friendly name
  37542. */
  37543. getSimpleName(): string;
  37544. }
  37545. }
  37546. declare module BABYLON {
  37547. interface ArcRotateCameraInputsManager {
  37548. /**
  37549. * Add orientation input support to the input manager.
  37550. * @returns the current input manager
  37551. */
  37552. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37553. }
  37554. /**
  37555. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37557. */
  37558. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37559. /**
  37560. * Defines the camera the input is attached to.
  37561. */
  37562. camera: ArcRotateCamera;
  37563. /**
  37564. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37565. */
  37566. alphaCorrection: number;
  37567. /**
  37568. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37569. */
  37570. gammaCorrection: number;
  37571. private _alpha;
  37572. private _gamma;
  37573. private _dirty;
  37574. private _deviceOrientationHandler;
  37575. /**
  37576. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37577. */
  37578. constructor();
  37579. /**
  37580. * Attach the input controls to a specific dom element to get the input from.
  37581. * @param element Defines the element the controls should be listened from
  37582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37583. */
  37584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37585. /** @hidden */
  37586. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37587. /**
  37588. * Update the current camera state depending on the inputs that have been used this frame.
  37589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37590. */
  37591. checkInputs(): void;
  37592. /**
  37593. * Detach the current controls from the specified dom element.
  37594. * @param element Defines the element to stop listening the inputs from
  37595. */
  37596. detachControl(element: Nullable<HTMLElement>): void;
  37597. /**
  37598. * Gets the class name of the current intput.
  37599. * @returns the class name
  37600. */
  37601. getClassName(): string;
  37602. /**
  37603. * Get the friendly name associated with the input class.
  37604. * @returns the input friendly name
  37605. */
  37606. getSimpleName(): string;
  37607. }
  37608. }
  37609. declare module BABYLON {
  37610. /**
  37611. * Listen to mouse events to control the camera.
  37612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37613. */
  37614. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37615. /**
  37616. * Defines the camera the input is attached to.
  37617. */
  37618. camera: FlyCamera;
  37619. /**
  37620. * Defines if touch is enabled. (Default is true.)
  37621. */
  37622. touchEnabled: boolean;
  37623. /**
  37624. * Defines the buttons associated with the input to handle camera rotation.
  37625. */
  37626. buttons: number[];
  37627. /**
  37628. * Assign buttons for Yaw control.
  37629. */
  37630. buttonsYaw: number[];
  37631. /**
  37632. * Assign buttons for Pitch control.
  37633. */
  37634. buttonsPitch: number[];
  37635. /**
  37636. * Assign buttons for Roll control.
  37637. */
  37638. buttonsRoll: number[];
  37639. /**
  37640. * Detect if any button is being pressed while mouse is moved.
  37641. * -1 = Mouse locked.
  37642. * 0 = Left button.
  37643. * 1 = Middle Button.
  37644. * 2 = Right Button.
  37645. */
  37646. activeButton: number;
  37647. /**
  37648. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37649. * Higher values reduce its sensitivity.
  37650. */
  37651. angularSensibility: number;
  37652. private _mousemoveCallback;
  37653. private _observer;
  37654. private _rollObserver;
  37655. private previousPosition;
  37656. private noPreventDefault;
  37657. private element;
  37658. /**
  37659. * Listen to mouse events to control the camera.
  37660. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37662. */
  37663. constructor(touchEnabled?: boolean);
  37664. /**
  37665. * Attach the mouse control to the HTML DOM element.
  37666. * @param element Defines the element that listens to the input events.
  37667. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37668. */
  37669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37670. /**
  37671. * Detach the current controls from the specified dom element.
  37672. * @param element Defines the element to stop listening the inputs from
  37673. */
  37674. detachControl(element: Nullable<HTMLElement>): void;
  37675. /**
  37676. * Gets the class name of the current input.
  37677. * @returns the class name.
  37678. */
  37679. getClassName(): string;
  37680. /**
  37681. * Get the friendly name associated with the input class.
  37682. * @returns the input's friendly name.
  37683. */
  37684. getSimpleName(): string;
  37685. private _pointerInput;
  37686. private _onMouseMove;
  37687. /**
  37688. * Rotate camera by mouse offset.
  37689. */
  37690. private rotateCamera;
  37691. }
  37692. }
  37693. declare module BABYLON {
  37694. /**
  37695. * Default Inputs manager for the FlyCamera.
  37696. * It groups all the default supported inputs for ease of use.
  37697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37698. */
  37699. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37700. /**
  37701. * Instantiates a new FlyCameraInputsManager.
  37702. * @param camera Defines the camera the inputs belong to.
  37703. */
  37704. constructor(camera: FlyCamera);
  37705. /**
  37706. * Add keyboard input support to the input manager.
  37707. * @returns the new FlyCameraKeyboardMoveInput().
  37708. */
  37709. addKeyboard(): FlyCameraInputsManager;
  37710. /**
  37711. * Add mouse input support to the input manager.
  37712. * @param touchEnabled Enable touch screen support.
  37713. * @returns the new FlyCameraMouseInput().
  37714. */
  37715. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37716. }
  37717. }
  37718. declare module BABYLON {
  37719. /**
  37720. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37721. * such as in a 3D Space Shooter or a Flight Simulator.
  37722. */
  37723. export class FlyCamera extends TargetCamera {
  37724. /**
  37725. * Define the collision ellipsoid of the camera.
  37726. * This is helpful for simulating a camera body, like a player's body.
  37727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37728. */
  37729. ellipsoid: Vector3;
  37730. /**
  37731. * Define an offset for the position of the ellipsoid around the camera.
  37732. * This can be helpful if the camera is attached away from the player's body center,
  37733. * such as at its head.
  37734. */
  37735. ellipsoidOffset: Vector3;
  37736. /**
  37737. * Enable or disable collisions of the camera with the rest of the scene objects.
  37738. */
  37739. checkCollisions: boolean;
  37740. /**
  37741. * Enable or disable gravity on the camera.
  37742. */
  37743. applyGravity: boolean;
  37744. /**
  37745. * Define the current direction the camera is moving to.
  37746. */
  37747. cameraDirection: Vector3;
  37748. /**
  37749. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37750. * This overrides and empties cameraRotation.
  37751. */
  37752. rotationQuaternion: Quaternion;
  37753. /**
  37754. * Track Roll to maintain the wanted Rolling when looking around.
  37755. */
  37756. _trackRoll: number;
  37757. /**
  37758. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37759. */
  37760. rollCorrect: number;
  37761. /**
  37762. * Mimic a banked turn, Rolling the camera when Yawing.
  37763. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37764. */
  37765. bankedTurn: boolean;
  37766. /**
  37767. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37768. */
  37769. bankedTurnLimit: number;
  37770. /**
  37771. * Value of 0 disables the banked Roll.
  37772. * Value of 1 is equal to the Yaw angle in radians.
  37773. */
  37774. bankedTurnMultiplier: number;
  37775. /**
  37776. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37777. */
  37778. inputs: FlyCameraInputsManager;
  37779. /**
  37780. * Gets the input sensibility for mouse input.
  37781. * Higher values reduce sensitivity.
  37782. */
  37783. /**
  37784. * Sets the input sensibility for a mouse input.
  37785. * Higher values reduce sensitivity.
  37786. */
  37787. angularSensibility: number;
  37788. /**
  37789. * Get the keys for camera movement forward.
  37790. */
  37791. /**
  37792. * Set the keys for camera movement forward.
  37793. */
  37794. keysForward: number[];
  37795. /**
  37796. * Get the keys for camera movement backward.
  37797. */
  37798. keysBackward: number[];
  37799. /**
  37800. * Get the keys for camera movement up.
  37801. */
  37802. /**
  37803. * Set the keys for camera movement up.
  37804. */
  37805. keysUp: number[];
  37806. /**
  37807. * Get the keys for camera movement down.
  37808. */
  37809. /**
  37810. * Set the keys for camera movement down.
  37811. */
  37812. keysDown: number[];
  37813. /**
  37814. * Get the keys for camera movement left.
  37815. */
  37816. /**
  37817. * Set the keys for camera movement left.
  37818. */
  37819. keysLeft: number[];
  37820. /**
  37821. * Set the keys for camera movement right.
  37822. */
  37823. /**
  37824. * Set the keys for camera movement right.
  37825. */
  37826. keysRight: number[];
  37827. /**
  37828. * Event raised when the camera collides with a mesh in the scene.
  37829. */
  37830. onCollide: (collidedMesh: AbstractMesh) => void;
  37831. private _collider;
  37832. private _needMoveForGravity;
  37833. private _oldPosition;
  37834. private _diffPosition;
  37835. private _newPosition;
  37836. /** @hidden */
  37837. _localDirection: Vector3;
  37838. /** @hidden */
  37839. _transformedDirection: Vector3;
  37840. /**
  37841. * Instantiates a FlyCamera.
  37842. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37843. * such as in a 3D Space Shooter or a Flight Simulator.
  37844. * @param name Define the name of the camera in the scene.
  37845. * @param position Define the starting position of the camera in the scene.
  37846. * @param scene Define the scene the camera belongs to.
  37847. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37848. */
  37849. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37850. /**
  37851. * Attach a control to the HTML DOM element.
  37852. * @param element Defines the element that listens to the input events.
  37853. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37854. */
  37855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37856. /**
  37857. * Detach a control from the HTML DOM element.
  37858. * The camera will stop reacting to that input.
  37859. * @param element Defines the element that listens to the input events.
  37860. */
  37861. detachControl(element: HTMLElement): void;
  37862. private _collisionMask;
  37863. /**
  37864. * Get the mask that the camera ignores in collision events.
  37865. */
  37866. /**
  37867. * Set the mask that the camera ignores in collision events.
  37868. */
  37869. collisionMask: number;
  37870. /** @hidden */
  37871. _collideWithWorld(displacement: Vector3): void;
  37872. /** @hidden */
  37873. private _onCollisionPositionChange;
  37874. /** @hidden */
  37875. _checkInputs(): void;
  37876. /** @hidden */
  37877. _decideIfNeedsToMove(): boolean;
  37878. /** @hidden */
  37879. _updatePosition(): void;
  37880. /**
  37881. * Restore the Roll to its target value at the rate specified.
  37882. * @param rate - Higher means slower restoring.
  37883. * @hidden
  37884. */
  37885. restoreRoll(rate: number): void;
  37886. /**
  37887. * Destroy the camera and release the current resources held by it.
  37888. */
  37889. dispose(): void;
  37890. /**
  37891. * Get the current object class name.
  37892. * @returns the class name.
  37893. */
  37894. getClassName(): string;
  37895. }
  37896. }
  37897. declare module BABYLON {
  37898. /**
  37899. * Listen to keyboard events to control the camera.
  37900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37901. */
  37902. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37903. /**
  37904. * Defines the camera the input is attached to.
  37905. */
  37906. camera: FlyCamera;
  37907. /**
  37908. * The list of keyboard keys used to control the forward move of the camera.
  37909. */
  37910. keysForward: number[];
  37911. /**
  37912. * The list of keyboard keys used to control the backward move of the camera.
  37913. */
  37914. keysBackward: number[];
  37915. /**
  37916. * The list of keyboard keys used to control the forward move of the camera.
  37917. */
  37918. keysUp: number[];
  37919. /**
  37920. * The list of keyboard keys used to control the backward move of the camera.
  37921. */
  37922. keysDown: number[];
  37923. /**
  37924. * The list of keyboard keys used to control the right strafe move of the camera.
  37925. */
  37926. keysRight: number[];
  37927. /**
  37928. * The list of keyboard keys used to control the left strafe move of the camera.
  37929. */
  37930. keysLeft: number[];
  37931. private _keys;
  37932. private _onCanvasBlurObserver;
  37933. private _onKeyboardObserver;
  37934. private _engine;
  37935. private _scene;
  37936. /**
  37937. * Attach the input controls to a specific dom element to get the input from.
  37938. * @param element Defines the element the controls should be listened from
  37939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37940. */
  37941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37942. /**
  37943. * Detach the current controls from the specified dom element.
  37944. * @param element Defines the element to stop listening the inputs from
  37945. */
  37946. detachControl(element: Nullable<HTMLElement>): void;
  37947. /**
  37948. * Gets the class name of the current intput.
  37949. * @returns the class name
  37950. */
  37951. getClassName(): string;
  37952. /** @hidden */
  37953. _onLostFocus(e: FocusEvent): void;
  37954. /**
  37955. * Get the friendly name associated with the input class.
  37956. * @returns the input friendly name
  37957. */
  37958. getSimpleName(): string;
  37959. /**
  37960. * Update the current camera state depending on the inputs that have been used this frame.
  37961. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37962. */
  37963. checkInputs(): void;
  37964. }
  37965. }
  37966. declare module BABYLON {
  37967. /**
  37968. * Manage the mouse wheel inputs to control a follow camera.
  37969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37970. */
  37971. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37972. /**
  37973. * Defines the camera the input is attached to.
  37974. */
  37975. camera: FollowCamera;
  37976. /**
  37977. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37978. */
  37979. axisControlRadius: boolean;
  37980. /**
  37981. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37982. */
  37983. axisControlHeight: boolean;
  37984. /**
  37985. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37986. */
  37987. axisControlRotation: boolean;
  37988. /**
  37989. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37990. * relation to mouseWheel events.
  37991. */
  37992. wheelPrecision: number;
  37993. /**
  37994. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37995. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37996. */
  37997. wheelDeltaPercentage: number;
  37998. private _wheel;
  37999. private _observer;
  38000. /**
  38001. * Attach the input controls to a specific dom element to get the input from.
  38002. * @param element Defines the element the controls should be listened from
  38003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38004. */
  38005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38006. /**
  38007. * Detach the current controls from the specified dom element.
  38008. * @param element Defines the element to stop listening the inputs from
  38009. */
  38010. detachControl(element: Nullable<HTMLElement>): void;
  38011. /**
  38012. * Gets the class name of the current intput.
  38013. * @returns the class name
  38014. */
  38015. getClassName(): string;
  38016. /**
  38017. * Get the friendly name associated with the input class.
  38018. * @returns the input friendly name
  38019. */
  38020. getSimpleName(): string;
  38021. }
  38022. }
  38023. declare module BABYLON {
  38024. /**
  38025. * Manage the pointers inputs to control an follow camera.
  38026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38027. */
  38028. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38029. /**
  38030. * Defines the camera the input is attached to.
  38031. */
  38032. camera: FollowCamera;
  38033. /**
  38034. * Gets the class name of the current input.
  38035. * @returns the class name
  38036. */
  38037. getClassName(): string;
  38038. /**
  38039. * Defines the pointer angular sensibility along the X axis or how fast is
  38040. * the camera rotating.
  38041. * A negative number will reverse the axis direction.
  38042. */
  38043. angularSensibilityX: number;
  38044. /**
  38045. * Defines the pointer angular sensibility along the Y axis or how fast is
  38046. * the camera rotating.
  38047. * A negative number will reverse the axis direction.
  38048. */
  38049. angularSensibilityY: number;
  38050. /**
  38051. * Defines the pointer pinch precision or how fast is the camera zooming.
  38052. * A negative number will reverse the axis direction.
  38053. */
  38054. pinchPrecision: number;
  38055. /**
  38056. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38057. * from 0.
  38058. * It defines the percentage of current camera.radius to use as delta when
  38059. * pinch zoom is used.
  38060. */
  38061. pinchDeltaPercentage: number;
  38062. /**
  38063. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38064. */
  38065. axisXControlRadius: boolean;
  38066. /**
  38067. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38068. */
  38069. axisXControlHeight: boolean;
  38070. /**
  38071. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38072. */
  38073. axisXControlRotation: boolean;
  38074. /**
  38075. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38076. */
  38077. axisYControlRadius: boolean;
  38078. /**
  38079. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38080. */
  38081. axisYControlHeight: boolean;
  38082. /**
  38083. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38084. */
  38085. axisYControlRotation: boolean;
  38086. /**
  38087. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38088. */
  38089. axisPinchControlRadius: boolean;
  38090. /**
  38091. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38092. */
  38093. axisPinchControlHeight: boolean;
  38094. /**
  38095. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38096. */
  38097. axisPinchControlRotation: boolean;
  38098. /**
  38099. * Log error messages if basic misconfiguration has occurred.
  38100. */
  38101. warningEnable: boolean;
  38102. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38103. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38104. private _warningCounter;
  38105. private _warning;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * Default Inputs manager for the FollowCamera.
  38111. * It groups all the default supported inputs for ease of use.
  38112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38113. */
  38114. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38115. /**
  38116. * Instantiates a new FollowCameraInputsManager.
  38117. * @param camera Defines the camera the inputs belong to
  38118. */
  38119. constructor(camera: FollowCamera);
  38120. /**
  38121. * Add keyboard input support to the input manager.
  38122. * @returns the current input manager
  38123. */
  38124. addKeyboard(): FollowCameraInputsManager;
  38125. /**
  38126. * Add mouse wheel input support to the input manager.
  38127. * @returns the current input manager
  38128. */
  38129. addMouseWheel(): FollowCameraInputsManager;
  38130. /**
  38131. * Add pointers input support to the input manager.
  38132. * @returns the current input manager
  38133. */
  38134. addPointers(): FollowCameraInputsManager;
  38135. /**
  38136. * Add orientation input support to the input manager.
  38137. * @returns the current input manager
  38138. */
  38139. addVRDeviceOrientation(): FollowCameraInputsManager;
  38140. }
  38141. }
  38142. declare module BABYLON {
  38143. /**
  38144. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38145. * an arc rotate version arcFollowCamera are available.
  38146. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38147. */
  38148. export class FollowCamera extends TargetCamera {
  38149. /**
  38150. * Distance the follow camera should follow an object at
  38151. */
  38152. radius: number;
  38153. /**
  38154. * Minimum allowed distance of the camera to the axis of rotation
  38155. * (The camera can not get closer).
  38156. * This can help limiting how the Camera is able to move in the scene.
  38157. */
  38158. lowerRadiusLimit: Nullable<number>;
  38159. /**
  38160. * Maximum allowed distance of the camera to the axis of rotation
  38161. * (The camera can not get further).
  38162. * This can help limiting how the Camera is able to move in the scene.
  38163. */
  38164. upperRadiusLimit: Nullable<number>;
  38165. /**
  38166. * Define a rotation offset between the camera and the object it follows
  38167. */
  38168. rotationOffset: number;
  38169. /**
  38170. * Minimum allowed angle to camera position relative to target object.
  38171. * This can help limiting how the Camera is able to move in the scene.
  38172. */
  38173. lowerRotationOffsetLimit: Nullable<number>;
  38174. /**
  38175. * Maximum allowed angle to camera position relative to target object.
  38176. * This can help limiting how the Camera is able to move in the scene.
  38177. */
  38178. upperRotationOffsetLimit: Nullable<number>;
  38179. /**
  38180. * Define a height offset between the camera and the object it follows.
  38181. * It can help following an object from the top (like a car chaing a plane)
  38182. */
  38183. heightOffset: number;
  38184. /**
  38185. * Minimum allowed height of camera position relative to target object.
  38186. * This can help limiting how the Camera is able to move in the scene.
  38187. */
  38188. lowerHeightOffsetLimit: Nullable<number>;
  38189. /**
  38190. * Maximum allowed height of camera position relative to target object.
  38191. * This can help limiting how the Camera is able to move in the scene.
  38192. */
  38193. upperHeightOffsetLimit: Nullable<number>;
  38194. /**
  38195. * Define how fast the camera can accelerate to follow it s target.
  38196. */
  38197. cameraAcceleration: number;
  38198. /**
  38199. * Define the speed limit of the camera following an object.
  38200. */
  38201. maxCameraSpeed: number;
  38202. /**
  38203. * Define the target of the camera.
  38204. */
  38205. lockedTarget: Nullable<AbstractMesh>;
  38206. /**
  38207. * Defines the input associated with the camera.
  38208. */
  38209. inputs: FollowCameraInputsManager;
  38210. /**
  38211. * Instantiates the follow camera.
  38212. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38213. * @param name Define the name of the camera in the scene
  38214. * @param position Define the position of the camera
  38215. * @param scene Define the scene the camera belong to
  38216. * @param lockedTarget Define the target of the camera
  38217. */
  38218. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38219. private _follow;
  38220. /**
  38221. * Attached controls to the current camera.
  38222. * @param element Defines the element the controls should be listened from
  38223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38224. */
  38225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38226. /**
  38227. * Detach the current controls from the camera.
  38228. * The camera will stop reacting to inputs.
  38229. * @param element Defines the element to stop listening the inputs from
  38230. */
  38231. detachControl(element: HTMLElement): void;
  38232. /** @hidden */
  38233. _checkInputs(): void;
  38234. private _checkLimits;
  38235. /**
  38236. * Gets the camera class name.
  38237. * @returns the class name
  38238. */
  38239. getClassName(): string;
  38240. }
  38241. /**
  38242. * Arc Rotate version of the follow camera.
  38243. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38244. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38245. */
  38246. export class ArcFollowCamera extends TargetCamera {
  38247. /** The longitudinal angle of the camera */
  38248. alpha: number;
  38249. /** The latitudinal angle of the camera */
  38250. beta: number;
  38251. /** The radius of the camera from its target */
  38252. radius: number;
  38253. /** Define the camera target (the messh it should follow) */
  38254. target: Nullable<AbstractMesh>;
  38255. private _cartesianCoordinates;
  38256. /**
  38257. * Instantiates a new ArcFollowCamera
  38258. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38259. * @param name Define the name of the camera
  38260. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38261. * @param beta Define the rotation angle of the camera around the elevation axis
  38262. * @param radius Define the radius of the camera from its target point
  38263. * @param target Define the target of the camera
  38264. * @param scene Define the scene the camera belongs to
  38265. */
  38266. constructor(name: string,
  38267. /** The longitudinal angle of the camera */
  38268. alpha: number,
  38269. /** The latitudinal angle of the camera */
  38270. beta: number,
  38271. /** The radius of the camera from its target */
  38272. radius: number,
  38273. /** Define the camera target (the messh it should follow) */
  38274. target: Nullable<AbstractMesh>, scene: Scene);
  38275. private _follow;
  38276. /** @hidden */
  38277. _checkInputs(): void;
  38278. /**
  38279. * Returns the class name of the object.
  38280. * It is mostly used internally for serialization purposes.
  38281. */
  38282. getClassName(): string;
  38283. }
  38284. }
  38285. declare module BABYLON {
  38286. /**
  38287. * Manage the keyboard inputs to control the movement of a follow camera.
  38288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38289. */
  38290. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38291. /**
  38292. * Defines the camera the input is attached to.
  38293. */
  38294. camera: FollowCamera;
  38295. /**
  38296. * Defines the list of key codes associated with the up action (increase heightOffset)
  38297. */
  38298. keysHeightOffsetIncr: number[];
  38299. /**
  38300. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38301. */
  38302. keysHeightOffsetDecr: number[];
  38303. /**
  38304. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38305. */
  38306. keysHeightOffsetModifierAlt: boolean;
  38307. /**
  38308. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38309. */
  38310. keysHeightOffsetModifierCtrl: boolean;
  38311. /**
  38312. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38313. */
  38314. keysHeightOffsetModifierShift: boolean;
  38315. /**
  38316. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38317. */
  38318. keysRotationOffsetIncr: number[];
  38319. /**
  38320. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38321. */
  38322. keysRotationOffsetDecr: number[];
  38323. /**
  38324. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38325. */
  38326. keysRotationOffsetModifierAlt: boolean;
  38327. /**
  38328. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38329. */
  38330. keysRotationOffsetModifierCtrl: boolean;
  38331. /**
  38332. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38333. */
  38334. keysRotationOffsetModifierShift: boolean;
  38335. /**
  38336. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38337. */
  38338. keysRadiusIncr: number[];
  38339. /**
  38340. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38341. */
  38342. keysRadiusDecr: number[];
  38343. /**
  38344. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38345. */
  38346. keysRadiusModifierAlt: boolean;
  38347. /**
  38348. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38349. */
  38350. keysRadiusModifierCtrl: boolean;
  38351. /**
  38352. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38353. */
  38354. keysRadiusModifierShift: boolean;
  38355. /**
  38356. * Defines the rate of change of heightOffset.
  38357. */
  38358. heightSensibility: number;
  38359. /**
  38360. * Defines the rate of change of rotationOffset.
  38361. */
  38362. rotationSensibility: number;
  38363. /**
  38364. * Defines the rate of change of radius.
  38365. */
  38366. radiusSensibility: number;
  38367. private _keys;
  38368. private _ctrlPressed;
  38369. private _altPressed;
  38370. private _shiftPressed;
  38371. private _onCanvasBlurObserver;
  38372. private _onKeyboardObserver;
  38373. private _engine;
  38374. private _scene;
  38375. /**
  38376. * Attach the input controls to a specific dom element to get the input from.
  38377. * @param element Defines the element the controls should be listened from
  38378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38379. */
  38380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38381. /**
  38382. * Detach the current controls from the specified dom element.
  38383. * @param element Defines the element to stop listening the inputs from
  38384. */
  38385. detachControl(element: Nullable<HTMLElement>): void;
  38386. /**
  38387. * Update the current camera state depending on the inputs that have been used this frame.
  38388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38389. */
  38390. checkInputs(): void;
  38391. /**
  38392. * Gets the class name of the current input.
  38393. * @returns the class name
  38394. */
  38395. getClassName(): string;
  38396. /**
  38397. * Get the friendly name associated with the input class.
  38398. * @returns the input friendly name
  38399. */
  38400. getSimpleName(): string;
  38401. /**
  38402. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38403. * allow modification of the heightOffset value.
  38404. */
  38405. private _modifierHeightOffset;
  38406. /**
  38407. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38408. * allow modification of the rotationOffset value.
  38409. */
  38410. private _modifierRotationOffset;
  38411. /**
  38412. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38413. * allow modification of the radius value.
  38414. */
  38415. private _modifierRadius;
  38416. }
  38417. }
  38418. declare module BABYLON {
  38419. interface FreeCameraInputsManager {
  38420. /**
  38421. * @hidden
  38422. */
  38423. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38424. /**
  38425. * Add orientation input support to the input manager.
  38426. * @returns the current input manager
  38427. */
  38428. addDeviceOrientation(): FreeCameraInputsManager;
  38429. }
  38430. /**
  38431. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38432. * Screen rotation is taken into account.
  38433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38434. */
  38435. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38436. private _camera;
  38437. private _screenOrientationAngle;
  38438. private _constantTranform;
  38439. private _screenQuaternion;
  38440. private _alpha;
  38441. private _beta;
  38442. private _gamma;
  38443. /**
  38444. * Can be used to detect if a device orientation sensor is availible on a device
  38445. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38446. * @returns a promise that will resolve on orientation change
  38447. */
  38448. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38449. /**
  38450. * @hidden
  38451. */
  38452. _onDeviceOrientationChangedObservable: Observable<void>;
  38453. /**
  38454. * Instantiates a new input
  38455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38456. */
  38457. constructor();
  38458. /**
  38459. * Define the camera controlled by the input.
  38460. */
  38461. camera: FreeCamera;
  38462. /**
  38463. * Attach the input controls to a specific dom element to get the input from.
  38464. * @param element Defines the element the controls should be listened from
  38465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38466. */
  38467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38468. private _orientationChanged;
  38469. private _deviceOrientation;
  38470. /**
  38471. * Detach the current controls from the specified dom element.
  38472. * @param element Defines the element to stop listening the inputs from
  38473. */
  38474. detachControl(element: Nullable<HTMLElement>): void;
  38475. /**
  38476. * Update the current camera state depending on the inputs that have been used this frame.
  38477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38478. */
  38479. checkInputs(): void;
  38480. /**
  38481. * Gets the class name of the current intput.
  38482. * @returns the class name
  38483. */
  38484. getClassName(): string;
  38485. /**
  38486. * Get the friendly name associated with the input class.
  38487. * @returns the input friendly name
  38488. */
  38489. getSimpleName(): string;
  38490. }
  38491. }
  38492. declare module BABYLON {
  38493. /**
  38494. * Manage the gamepad inputs to control a free camera.
  38495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38496. */
  38497. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38498. /**
  38499. * Define the camera the input is attached to.
  38500. */
  38501. camera: FreeCamera;
  38502. /**
  38503. * Define the Gamepad controlling the input
  38504. */
  38505. gamepad: Nullable<Gamepad>;
  38506. /**
  38507. * Defines the gamepad rotation sensiblity.
  38508. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38509. */
  38510. gamepadAngularSensibility: number;
  38511. /**
  38512. * Defines the gamepad move sensiblity.
  38513. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38514. */
  38515. gamepadMoveSensibility: number;
  38516. private _yAxisScale;
  38517. /**
  38518. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38519. */
  38520. invertYAxis: boolean;
  38521. private _onGamepadConnectedObserver;
  38522. private _onGamepadDisconnectedObserver;
  38523. private _cameraTransform;
  38524. private _deltaTransform;
  38525. private _vector3;
  38526. private _vector2;
  38527. /**
  38528. * Attach the input controls to a specific dom element to get the input from.
  38529. * @param element Defines the element the controls should be listened from
  38530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38531. */
  38532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38533. /**
  38534. * Detach the current controls from the specified dom element.
  38535. * @param element Defines the element to stop listening the inputs from
  38536. */
  38537. detachControl(element: Nullable<HTMLElement>): void;
  38538. /**
  38539. * Update the current camera state depending on the inputs that have been used this frame.
  38540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38541. */
  38542. checkInputs(): void;
  38543. /**
  38544. * Gets the class name of the current intput.
  38545. * @returns the class name
  38546. */
  38547. getClassName(): string;
  38548. /**
  38549. * Get the friendly name associated with the input class.
  38550. * @returns the input friendly name
  38551. */
  38552. getSimpleName(): string;
  38553. }
  38554. }
  38555. declare module BABYLON {
  38556. /**
  38557. * Defines the potential axis of a Joystick
  38558. */
  38559. export enum JoystickAxis {
  38560. /** X axis */
  38561. X = 0,
  38562. /** Y axis */
  38563. Y = 1,
  38564. /** Z axis */
  38565. Z = 2
  38566. }
  38567. /**
  38568. * Class used to define virtual joystick (used in touch mode)
  38569. */
  38570. export class VirtualJoystick {
  38571. /**
  38572. * Gets or sets a boolean indicating that left and right values must be inverted
  38573. */
  38574. reverseLeftRight: boolean;
  38575. /**
  38576. * Gets or sets a boolean indicating that up and down values must be inverted
  38577. */
  38578. reverseUpDown: boolean;
  38579. /**
  38580. * Gets the offset value for the position (ie. the change of the position value)
  38581. */
  38582. deltaPosition: Vector3;
  38583. /**
  38584. * Gets a boolean indicating if the virtual joystick was pressed
  38585. */
  38586. pressed: boolean;
  38587. /**
  38588. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38589. */
  38590. static Canvas: Nullable<HTMLCanvasElement>;
  38591. private static _globalJoystickIndex;
  38592. private static vjCanvasContext;
  38593. private static vjCanvasWidth;
  38594. private static vjCanvasHeight;
  38595. private static halfWidth;
  38596. private _action;
  38597. private _axisTargetedByLeftAndRight;
  38598. private _axisTargetedByUpAndDown;
  38599. private _joystickSensibility;
  38600. private _inversedSensibility;
  38601. private _joystickPointerID;
  38602. private _joystickColor;
  38603. private _joystickPointerPos;
  38604. private _joystickPreviousPointerPos;
  38605. private _joystickPointerStartPos;
  38606. private _deltaJoystickVector;
  38607. private _leftJoystick;
  38608. private _touches;
  38609. private _onPointerDownHandlerRef;
  38610. private _onPointerMoveHandlerRef;
  38611. private _onPointerUpHandlerRef;
  38612. private _onResize;
  38613. /**
  38614. * Creates a new virtual joystick
  38615. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38616. */
  38617. constructor(leftJoystick?: boolean);
  38618. /**
  38619. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38620. * @param newJoystickSensibility defines the new sensibility
  38621. */
  38622. setJoystickSensibility(newJoystickSensibility: number): void;
  38623. private _onPointerDown;
  38624. private _onPointerMove;
  38625. private _onPointerUp;
  38626. /**
  38627. * Change the color of the virtual joystick
  38628. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38629. */
  38630. setJoystickColor(newColor: string): void;
  38631. /**
  38632. * Defines a callback to call when the joystick is touched
  38633. * @param action defines the callback
  38634. */
  38635. setActionOnTouch(action: () => any): void;
  38636. /**
  38637. * Defines which axis you'd like to control for left & right
  38638. * @param axis defines the axis to use
  38639. */
  38640. setAxisForLeftRight(axis: JoystickAxis): void;
  38641. /**
  38642. * Defines which axis you'd like to control for up & down
  38643. * @param axis defines the axis to use
  38644. */
  38645. setAxisForUpDown(axis: JoystickAxis): void;
  38646. private _drawVirtualJoystick;
  38647. /**
  38648. * Release internal HTML canvas
  38649. */
  38650. releaseCanvas(): void;
  38651. }
  38652. }
  38653. declare module BABYLON {
  38654. interface FreeCameraInputsManager {
  38655. /**
  38656. * Add virtual joystick input support to the input manager.
  38657. * @returns the current input manager
  38658. */
  38659. addVirtualJoystick(): FreeCameraInputsManager;
  38660. }
  38661. /**
  38662. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38664. */
  38665. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38666. /**
  38667. * Defines the camera the input is attached to.
  38668. */
  38669. camera: FreeCamera;
  38670. private _leftjoystick;
  38671. private _rightjoystick;
  38672. /**
  38673. * Gets the left stick of the virtual joystick.
  38674. * @returns The virtual Joystick
  38675. */
  38676. getLeftJoystick(): VirtualJoystick;
  38677. /**
  38678. * Gets the right stick of the virtual joystick.
  38679. * @returns The virtual Joystick
  38680. */
  38681. getRightJoystick(): VirtualJoystick;
  38682. /**
  38683. * Update the current camera state depending on the inputs that have been used this frame.
  38684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38685. */
  38686. checkInputs(): void;
  38687. /**
  38688. * Attach the input controls to a specific dom element to get the input from.
  38689. * @param element Defines the element the controls should be listened from
  38690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38691. */
  38692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38693. /**
  38694. * Detach the current controls from the specified dom element.
  38695. * @param element Defines the element to stop listening the inputs from
  38696. */
  38697. detachControl(element: Nullable<HTMLElement>): void;
  38698. /**
  38699. * Gets the class name of the current intput.
  38700. * @returns the class name
  38701. */
  38702. getClassName(): string;
  38703. /**
  38704. * Get the friendly name associated with the input class.
  38705. * @returns the input friendly name
  38706. */
  38707. getSimpleName(): string;
  38708. }
  38709. }
  38710. declare module BABYLON {
  38711. /**
  38712. * This represents a FPS type of camera controlled by touch.
  38713. * This is like a universal camera minus the Gamepad controls.
  38714. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38715. */
  38716. export class TouchCamera extends FreeCamera {
  38717. /**
  38718. * Defines the touch sensibility for rotation.
  38719. * The higher the faster.
  38720. */
  38721. touchAngularSensibility: number;
  38722. /**
  38723. * Defines the touch sensibility for move.
  38724. * The higher the faster.
  38725. */
  38726. touchMoveSensibility: number;
  38727. /**
  38728. * Instantiates a new touch camera.
  38729. * This represents a FPS type of camera controlled by touch.
  38730. * This is like a universal camera minus the Gamepad controls.
  38731. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38732. * @param name Define the name of the camera in the scene
  38733. * @param position Define the start position of the camera in the scene
  38734. * @param scene Define the scene the camera belongs to
  38735. */
  38736. constructor(name: string, position: Vector3, scene: Scene);
  38737. /**
  38738. * Gets the current object class name.
  38739. * @return the class name
  38740. */
  38741. getClassName(): string;
  38742. /** @hidden */
  38743. _setupInputs(): void;
  38744. }
  38745. }
  38746. declare module BABYLON {
  38747. /**
  38748. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38749. * being tilted forward or back and left or right.
  38750. */
  38751. export class DeviceOrientationCamera extends FreeCamera {
  38752. private _initialQuaternion;
  38753. private _quaternionCache;
  38754. private _tmpDragQuaternion;
  38755. private _disablePointerInputWhenUsingDeviceOrientation;
  38756. /**
  38757. * Creates a new device orientation camera
  38758. * @param name The name of the camera
  38759. * @param position The start position camera
  38760. * @param scene The scene the camera belongs to
  38761. */
  38762. constructor(name: string, position: Vector3, scene: Scene);
  38763. /**
  38764. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38765. */
  38766. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38767. private _dragFactor;
  38768. /**
  38769. * Enabled turning on the y axis when the orientation sensor is active
  38770. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38771. */
  38772. enableHorizontalDragging(dragFactor?: number): void;
  38773. /**
  38774. * Gets the current instance class name ("DeviceOrientationCamera").
  38775. * This helps avoiding instanceof at run time.
  38776. * @returns the class name
  38777. */
  38778. getClassName(): string;
  38779. /**
  38780. * @hidden
  38781. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38782. */
  38783. _checkInputs(): void;
  38784. /**
  38785. * Reset the camera to its default orientation on the specified axis only.
  38786. * @param axis The axis to reset
  38787. */
  38788. resetToCurrentRotation(axis?: Axis): void;
  38789. }
  38790. }
  38791. declare module BABYLON {
  38792. /**
  38793. * Defines supported buttons for XBox360 compatible gamepads
  38794. */
  38795. export enum Xbox360Button {
  38796. /** A */
  38797. A = 0,
  38798. /** B */
  38799. B = 1,
  38800. /** X */
  38801. X = 2,
  38802. /** Y */
  38803. Y = 3,
  38804. /** Start */
  38805. Start = 4,
  38806. /** Back */
  38807. Back = 5,
  38808. /** Left button */
  38809. LB = 6,
  38810. /** Right button */
  38811. RB = 7,
  38812. /** Left stick */
  38813. LeftStick = 8,
  38814. /** Right stick */
  38815. RightStick = 9
  38816. }
  38817. /** Defines values for XBox360 DPad */
  38818. export enum Xbox360Dpad {
  38819. /** Up */
  38820. Up = 0,
  38821. /** Down */
  38822. Down = 1,
  38823. /** Left */
  38824. Left = 2,
  38825. /** Right */
  38826. Right = 3
  38827. }
  38828. /**
  38829. * Defines a XBox360 gamepad
  38830. */
  38831. export class Xbox360Pad extends Gamepad {
  38832. private _leftTrigger;
  38833. private _rightTrigger;
  38834. private _onlefttriggerchanged;
  38835. private _onrighttriggerchanged;
  38836. private _onbuttondown;
  38837. private _onbuttonup;
  38838. private _ondpaddown;
  38839. private _ondpadup;
  38840. /** Observable raised when a button is pressed */
  38841. onButtonDownObservable: Observable<Xbox360Button>;
  38842. /** Observable raised when a button is released */
  38843. onButtonUpObservable: Observable<Xbox360Button>;
  38844. /** Observable raised when a pad is pressed */
  38845. onPadDownObservable: Observable<Xbox360Dpad>;
  38846. /** Observable raised when a pad is released */
  38847. onPadUpObservable: Observable<Xbox360Dpad>;
  38848. private _buttonA;
  38849. private _buttonB;
  38850. private _buttonX;
  38851. private _buttonY;
  38852. private _buttonBack;
  38853. private _buttonStart;
  38854. private _buttonLB;
  38855. private _buttonRB;
  38856. private _buttonLeftStick;
  38857. private _buttonRightStick;
  38858. private _dPadUp;
  38859. private _dPadDown;
  38860. private _dPadLeft;
  38861. private _dPadRight;
  38862. private _isXboxOnePad;
  38863. /**
  38864. * Creates a new XBox360 gamepad object
  38865. * @param id defines the id of this gamepad
  38866. * @param index defines its index
  38867. * @param gamepad defines the internal HTML gamepad object
  38868. * @param xboxOne defines if it is a XBox One gamepad
  38869. */
  38870. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38871. /**
  38872. * Defines the callback to call when left trigger is pressed
  38873. * @param callback defines the callback to use
  38874. */
  38875. onlefttriggerchanged(callback: (value: number) => void): void;
  38876. /**
  38877. * Defines the callback to call when right trigger is pressed
  38878. * @param callback defines the callback to use
  38879. */
  38880. onrighttriggerchanged(callback: (value: number) => void): void;
  38881. /**
  38882. * Gets the left trigger value
  38883. */
  38884. /**
  38885. * Sets the left trigger value
  38886. */
  38887. leftTrigger: number;
  38888. /**
  38889. * Gets the right trigger value
  38890. */
  38891. /**
  38892. * Sets the right trigger value
  38893. */
  38894. rightTrigger: number;
  38895. /**
  38896. * Defines the callback to call when a button is pressed
  38897. * @param callback defines the callback to use
  38898. */
  38899. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38900. /**
  38901. * Defines the callback to call when a button is released
  38902. * @param callback defines the callback to use
  38903. */
  38904. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38905. /**
  38906. * Defines the callback to call when a pad is pressed
  38907. * @param callback defines the callback to use
  38908. */
  38909. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38910. /**
  38911. * Defines the callback to call when a pad is released
  38912. * @param callback defines the callback to use
  38913. */
  38914. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38915. private _setButtonValue;
  38916. private _setDPadValue;
  38917. /**
  38918. * Gets the value of the `A` button
  38919. */
  38920. /**
  38921. * Sets the value of the `A` button
  38922. */
  38923. buttonA: number;
  38924. /**
  38925. * Gets the value of the `B` button
  38926. */
  38927. /**
  38928. * Sets the value of the `B` button
  38929. */
  38930. buttonB: number;
  38931. /**
  38932. * Gets the value of the `X` button
  38933. */
  38934. /**
  38935. * Sets the value of the `X` button
  38936. */
  38937. buttonX: number;
  38938. /**
  38939. * Gets the value of the `Y` button
  38940. */
  38941. /**
  38942. * Sets the value of the `Y` button
  38943. */
  38944. buttonY: number;
  38945. /**
  38946. * Gets the value of the `Start` button
  38947. */
  38948. /**
  38949. * Sets the value of the `Start` button
  38950. */
  38951. buttonStart: number;
  38952. /**
  38953. * Gets the value of the `Back` button
  38954. */
  38955. /**
  38956. * Sets the value of the `Back` button
  38957. */
  38958. buttonBack: number;
  38959. /**
  38960. * Gets the value of the `Left` button
  38961. */
  38962. /**
  38963. * Sets the value of the `Left` button
  38964. */
  38965. buttonLB: number;
  38966. /**
  38967. * Gets the value of the `Right` button
  38968. */
  38969. /**
  38970. * Sets the value of the `Right` button
  38971. */
  38972. buttonRB: number;
  38973. /**
  38974. * Gets the value of the Left joystick
  38975. */
  38976. /**
  38977. * Sets the value of the Left joystick
  38978. */
  38979. buttonLeftStick: number;
  38980. /**
  38981. * Gets the value of the Right joystick
  38982. */
  38983. /**
  38984. * Sets the value of the Right joystick
  38985. */
  38986. buttonRightStick: number;
  38987. /**
  38988. * Gets the value of D-pad up
  38989. */
  38990. /**
  38991. * Sets the value of D-pad up
  38992. */
  38993. dPadUp: number;
  38994. /**
  38995. * Gets the value of D-pad down
  38996. */
  38997. /**
  38998. * Sets the value of D-pad down
  38999. */
  39000. dPadDown: number;
  39001. /**
  39002. * Gets the value of D-pad left
  39003. */
  39004. /**
  39005. * Sets the value of D-pad left
  39006. */
  39007. dPadLeft: number;
  39008. /**
  39009. * Gets the value of D-pad right
  39010. */
  39011. /**
  39012. * Sets the value of D-pad right
  39013. */
  39014. dPadRight: number;
  39015. /**
  39016. * Force the gamepad to synchronize with device values
  39017. */
  39018. update(): void;
  39019. /**
  39020. * Disposes the gamepad
  39021. */
  39022. dispose(): void;
  39023. }
  39024. }
  39025. declare module BABYLON {
  39026. /**
  39027. * Defines supported buttons for DualShock compatible gamepads
  39028. */
  39029. export enum DualShockButton {
  39030. /** Cross */
  39031. Cross = 0,
  39032. /** Circle */
  39033. Circle = 1,
  39034. /** Square */
  39035. Square = 2,
  39036. /** Triangle */
  39037. Triangle = 3,
  39038. /** Options */
  39039. Options = 4,
  39040. /** Share */
  39041. Share = 5,
  39042. /** L1 */
  39043. L1 = 6,
  39044. /** R1 */
  39045. R1 = 7,
  39046. /** Left stick */
  39047. LeftStick = 8,
  39048. /** Right stick */
  39049. RightStick = 9
  39050. }
  39051. /** Defines values for DualShock DPad */
  39052. export enum DualShockDpad {
  39053. /** Up */
  39054. Up = 0,
  39055. /** Down */
  39056. Down = 1,
  39057. /** Left */
  39058. Left = 2,
  39059. /** Right */
  39060. Right = 3
  39061. }
  39062. /**
  39063. * Defines a DualShock gamepad
  39064. */
  39065. export class DualShockPad extends Gamepad {
  39066. private _leftTrigger;
  39067. private _rightTrigger;
  39068. private _onlefttriggerchanged;
  39069. private _onrighttriggerchanged;
  39070. private _onbuttondown;
  39071. private _onbuttonup;
  39072. private _ondpaddown;
  39073. private _ondpadup;
  39074. /** Observable raised when a button is pressed */
  39075. onButtonDownObservable: Observable<DualShockButton>;
  39076. /** Observable raised when a button is released */
  39077. onButtonUpObservable: Observable<DualShockButton>;
  39078. /** Observable raised when a pad is pressed */
  39079. onPadDownObservable: Observable<DualShockDpad>;
  39080. /** Observable raised when a pad is released */
  39081. onPadUpObservable: Observable<DualShockDpad>;
  39082. private _buttonCross;
  39083. private _buttonCircle;
  39084. private _buttonSquare;
  39085. private _buttonTriangle;
  39086. private _buttonShare;
  39087. private _buttonOptions;
  39088. private _buttonL1;
  39089. private _buttonR1;
  39090. private _buttonLeftStick;
  39091. private _buttonRightStick;
  39092. private _dPadUp;
  39093. private _dPadDown;
  39094. private _dPadLeft;
  39095. private _dPadRight;
  39096. /**
  39097. * Creates a new DualShock gamepad object
  39098. * @param id defines the id of this gamepad
  39099. * @param index defines its index
  39100. * @param gamepad defines the internal HTML gamepad object
  39101. */
  39102. constructor(id: string, index: number, gamepad: any);
  39103. /**
  39104. * Defines the callback to call when left trigger is pressed
  39105. * @param callback defines the callback to use
  39106. */
  39107. onlefttriggerchanged(callback: (value: number) => void): void;
  39108. /**
  39109. * Defines the callback to call when right trigger is pressed
  39110. * @param callback defines the callback to use
  39111. */
  39112. onrighttriggerchanged(callback: (value: number) => void): void;
  39113. /**
  39114. * Gets the left trigger value
  39115. */
  39116. /**
  39117. * Sets the left trigger value
  39118. */
  39119. leftTrigger: number;
  39120. /**
  39121. * Gets the right trigger value
  39122. */
  39123. /**
  39124. * Sets the right trigger value
  39125. */
  39126. rightTrigger: number;
  39127. /**
  39128. * Defines the callback to call when a button is pressed
  39129. * @param callback defines the callback to use
  39130. */
  39131. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39132. /**
  39133. * Defines the callback to call when a button is released
  39134. * @param callback defines the callback to use
  39135. */
  39136. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39137. /**
  39138. * Defines the callback to call when a pad is pressed
  39139. * @param callback defines the callback to use
  39140. */
  39141. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39142. /**
  39143. * Defines the callback to call when a pad is released
  39144. * @param callback defines the callback to use
  39145. */
  39146. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39147. private _setButtonValue;
  39148. private _setDPadValue;
  39149. /**
  39150. * Gets the value of the `Cross` button
  39151. */
  39152. /**
  39153. * Sets the value of the `Cross` button
  39154. */
  39155. buttonCross: number;
  39156. /**
  39157. * Gets the value of the `Circle` button
  39158. */
  39159. /**
  39160. * Sets the value of the `Circle` button
  39161. */
  39162. buttonCircle: number;
  39163. /**
  39164. * Gets the value of the `Square` button
  39165. */
  39166. /**
  39167. * Sets the value of the `Square` button
  39168. */
  39169. buttonSquare: number;
  39170. /**
  39171. * Gets the value of the `Triangle` button
  39172. */
  39173. /**
  39174. * Sets the value of the `Triangle` button
  39175. */
  39176. buttonTriangle: number;
  39177. /**
  39178. * Gets the value of the `Options` button
  39179. */
  39180. /**
  39181. * Sets the value of the `Options` button
  39182. */
  39183. buttonOptions: number;
  39184. /**
  39185. * Gets the value of the `Share` button
  39186. */
  39187. /**
  39188. * Sets the value of the `Share` button
  39189. */
  39190. buttonShare: number;
  39191. /**
  39192. * Gets the value of the `L1` button
  39193. */
  39194. /**
  39195. * Sets the value of the `L1` button
  39196. */
  39197. buttonL1: number;
  39198. /**
  39199. * Gets the value of the `R1` button
  39200. */
  39201. /**
  39202. * Sets the value of the `R1` button
  39203. */
  39204. buttonR1: number;
  39205. /**
  39206. * Gets the value of the Left joystick
  39207. */
  39208. /**
  39209. * Sets the value of the Left joystick
  39210. */
  39211. buttonLeftStick: number;
  39212. /**
  39213. * Gets the value of the Right joystick
  39214. */
  39215. /**
  39216. * Sets the value of the Right joystick
  39217. */
  39218. buttonRightStick: number;
  39219. /**
  39220. * Gets the value of D-pad up
  39221. */
  39222. /**
  39223. * Sets the value of D-pad up
  39224. */
  39225. dPadUp: number;
  39226. /**
  39227. * Gets the value of D-pad down
  39228. */
  39229. /**
  39230. * Sets the value of D-pad down
  39231. */
  39232. dPadDown: number;
  39233. /**
  39234. * Gets the value of D-pad left
  39235. */
  39236. /**
  39237. * Sets the value of D-pad left
  39238. */
  39239. dPadLeft: number;
  39240. /**
  39241. * Gets the value of D-pad right
  39242. */
  39243. /**
  39244. * Sets the value of D-pad right
  39245. */
  39246. dPadRight: number;
  39247. /**
  39248. * Force the gamepad to synchronize with device values
  39249. */
  39250. update(): void;
  39251. /**
  39252. * Disposes the gamepad
  39253. */
  39254. dispose(): void;
  39255. }
  39256. }
  39257. declare module BABYLON {
  39258. /**
  39259. * Manager for handling gamepads
  39260. */
  39261. export class GamepadManager {
  39262. private _scene?;
  39263. private _babylonGamepads;
  39264. private _oneGamepadConnected;
  39265. /** @hidden */
  39266. _isMonitoring: boolean;
  39267. private _gamepadEventSupported;
  39268. private _gamepadSupport;
  39269. /**
  39270. * observable to be triggered when the gamepad controller has been connected
  39271. */
  39272. onGamepadConnectedObservable: Observable<Gamepad>;
  39273. /**
  39274. * observable to be triggered when the gamepad controller has been disconnected
  39275. */
  39276. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39277. private _onGamepadConnectedEvent;
  39278. private _onGamepadDisconnectedEvent;
  39279. /**
  39280. * Initializes the gamepad manager
  39281. * @param _scene BabylonJS scene
  39282. */
  39283. constructor(_scene?: Scene | undefined);
  39284. /**
  39285. * The gamepads in the game pad manager
  39286. */
  39287. readonly gamepads: Gamepad[];
  39288. /**
  39289. * Get the gamepad controllers based on type
  39290. * @param type The type of gamepad controller
  39291. * @returns Nullable gamepad
  39292. */
  39293. getGamepadByType(type?: number): Nullable<Gamepad>;
  39294. /**
  39295. * Disposes the gamepad manager
  39296. */
  39297. dispose(): void;
  39298. private _addNewGamepad;
  39299. private _startMonitoringGamepads;
  39300. private _stopMonitoringGamepads;
  39301. /** @hidden */
  39302. _checkGamepadsStatus(): void;
  39303. private _updateGamepadObjects;
  39304. }
  39305. }
  39306. declare module BABYLON {
  39307. interface Scene {
  39308. /** @hidden */
  39309. _gamepadManager: Nullable<GamepadManager>;
  39310. /**
  39311. * Gets the gamepad manager associated with the scene
  39312. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39313. */
  39314. gamepadManager: GamepadManager;
  39315. }
  39316. /**
  39317. * Interface representing a free camera inputs manager
  39318. */
  39319. interface FreeCameraInputsManager {
  39320. /**
  39321. * Adds gamepad input support to the FreeCameraInputsManager.
  39322. * @returns the FreeCameraInputsManager
  39323. */
  39324. addGamepad(): FreeCameraInputsManager;
  39325. }
  39326. /**
  39327. * Interface representing an arc rotate camera inputs manager
  39328. */
  39329. interface ArcRotateCameraInputsManager {
  39330. /**
  39331. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39332. * @returns the camera inputs manager
  39333. */
  39334. addGamepad(): ArcRotateCameraInputsManager;
  39335. }
  39336. /**
  39337. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39338. */
  39339. export class GamepadSystemSceneComponent implements ISceneComponent {
  39340. /**
  39341. * The component name helpfull to identify the component in the list of scene components.
  39342. */
  39343. readonly name: string;
  39344. /**
  39345. * The scene the component belongs to.
  39346. */
  39347. scene: Scene;
  39348. /**
  39349. * Creates a new instance of the component for the given scene
  39350. * @param scene Defines the scene to register the component in
  39351. */
  39352. constructor(scene: Scene);
  39353. /**
  39354. * Registers the component in a given scene
  39355. */
  39356. register(): void;
  39357. /**
  39358. * Rebuilds the elements related to this component in case of
  39359. * context lost for instance.
  39360. */
  39361. rebuild(): void;
  39362. /**
  39363. * Disposes the component and the associated ressources
  39364. */
  39365. dispose(): void;
  39366. private _beforeCameraUpdate;
  39367. }
  39368. }
  39369. declare module BABYLON {
  39370. /**
  39371. * 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,
  39372. * which still works and will still be found in many Playgrounds.
  39373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39374. */
  39375. export class UniversalCamera extends TouchCamera {
  39376. /**
  39377. * Defines the gamepad rotation sensiblity.
  39378. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39379. */
  39380. gamepadAngularSensibility: number;
  39381. /**
  39382. * Defines the gamepad move sensiblity.
  39383. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39384. */
  39385. gamepadMoveSensibility: number;
  39386. /**
  39387. * 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,
  39388. * which still works and will still be found in many Playgrounds.
  39389. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39390. * @param name Define the name of the camera in the scene
  39391. * @param position Define the start position of the camera in the scene
  39392. * @param scene Define the scene the camera belongs to
  39393. */
  39394. constructor(name: string, position: Vector3, scene: Scene);
  39395. /**
  39396. * Gets the current object class name.
  39397. * @return the class name
  39398. */
  39399. getClassName(): string;
  39400. }
  39401. }
  39402. declare module BABYLON {
  39403. /**
  39404. * This represents a FPS type of camera. This is only here for back compat purpose.
  39405. * Please use the UniversalCamera instead as both are identical.
  39406. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39407. */
  39408. export class GamepadCamera extends UniversalCamera {
  39409. /**
  39410. * Instantiates a new Gamepad Camera
  39411. * This represents a FPS type of camera. This is only here for back compat purpose.
  39412. * Please use the UniversalCamera instead as both are identical.
  39413. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39414. * @param name Define the name of the camera in the scene
  39415. * @param position Define the start position of the camera in the scene
  39416. * @param scene Define the scene the camera belongs to
  39417. */
  39418. constructor(name: string, position: Vector3, scene: Scene);
  39419. /**
  39420. * Gets the current object class name.
  39421. * @return the class name
  39422. */
  39423. getClassName(): string;
  39424. }
  39425. }
  39426. declare module BABYLON {
  39427. /** @hidden */
  39428. export var passPixelShader: {
  39429. name: string;
  39430. shader: string;
  39431. };
  39432. }
  39433. declare module BABYLON {
  39434. /** @hidden */
  39435. export var passCubePixelShader: {
  39436. name: string;
  39437. shader: string;
  39438. };
  39439. }
  39440. declare module BABYLON {
  39441. /**
  39442. * PassPostProcess which produces an output the same as it's input
  39443. */
  39444. export class PassPostProcess extends PostProcess {
  39445. /**
  39446. * Creates the PassPostProcess
  39447. * @param name The name of the effect.
  39448. * @param options The required width/height ratio to downsize to before computing the render pass.
  39449. * @param camera The camera to apply the render pass to.
  39450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39451. * @param engine The engine which the post process will be applied. (default: current engine)
  39452. * @param reusable If the post process can be reused on the same frame. (default: false)
  39453. * @param textureType The type of texture to be used when performing the post processing.
  39454. * @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)
  39455. */
  39456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39457. }
  39458. /**
  39459. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39460. */
  39461. export class PassCubePostProcess extends PostProcess {
  39462. private _face;
  39463. /**
  39464. * Gets or sets the cube face to display.
  39465. * * 0 is +X
  39466. * * 1 is -X
  39467. * * 2 is +Y
  39468. * * 3 is -Y
  39469. * * 4 is +Z
  39470. * * 5 is -Z
  39471. */
  39472. face: number;
  39473. /**
  39474. * Creates the PassCubePostProcess
  39475. * @param name The name of the effect.
  39476. * @param options The required width/height ratio to downsize to before computing the render pass.
  39477. * @param camera The camera to apply the render pass to.
  39478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39479. * @param engine The engine which the post process will be applied. (default: current engine)
  39480. * @param reusable If the post process can be reused on the same frame. (default: false)
  39481. * @param textureType The type of texture to be used when performing the post processing.
  39482. * @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)
  39483. */
  39484. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39485. }
  39486. }
  39487. declare module BABYLON {
  39488. /** @hidden */
  39489. export var anaglyphPixelShader: {
  39490. name: string;
  39491. shader: string;
  39492. };
  39493. }
  39494. declare module BABYLON {
  39495. /**
  39496. * Postprocess used to generate anaglyphic rendering
  39497. */
  39498. export class AnaglyphPostProcess extends PostProcess {
  39499. private _passedProcess;
  39500. /**
  39501. * Creates a new AnaglyphPostProcess
  39502. * @param name defines postprocess name
  39503. * @param options defines creation options or target ratio scale
  39504. * @param rigCameras defines cameras using this postprocess
  39505. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39506. * @param engine defines hosting engine
  39507. * @param reusable defines if the postprocess will be reused multiple times per frame
  39508. */
  39509. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39510. }
  39511. }
  39512. declare module BABYLON {
  39513. /**
  39514. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39515. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39516. */
  39517. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39518. /**
  39519. * Creates a new AnaglyphArcRotateCamera
  39520. * @param name defines camera name
  39521. * @param alpha defines alpha angle (in radians)
  39522. * @param beta defines beta angle (in radians)
  39523. * @param radius defines radius
  39524. * @param target defines camera target
  39525. * @param interaxialDistance defines distance between each color axis
  39526. * @param scene defines the hosting scene
  39527. */
  39528. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39529. /**
  39530. * Gets camera class name
  39531. * @returns AnaglyphArcRotateCamera
  39532. */
  39533. getClassName(): string;
  39534. }
  39535. }
  39536. declare module BABYLON {
  39537. /**
  39538. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39539. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39540. */
  39541. export class AnaglyphFreeCamera extends FreeCamera {
  39542. /**
  39543. * Creates a new AnaglyphFreeCamera
  39544. * @param name defines camera name
  39545. * @param position defines initial position
  39546. * @param interaxialDistance defines distance between each color axis
  39547. * @param scene defines the hosting scene
  39548. */
  39549. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39550. /**
  39551. * Gets camera class name
  39552. * @returns AnaglyphFreeCamera
  39553. */
  39554. getClassName(): string;
  39555. }
  39556. }
  39557. declare module BABYLON {
  39558. /**
  39559. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39560. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39561. */
  39562. export class AnaglyphGamepadCamera extends GamepadCamera {
  39563. /**
  39564. * Creates a new AnaglyphGamepadCamera
  39565. * @param name defines camera name
  39566. * @param position defines initial position
  39567. * @param interaxialDistance defines distance between each color axis
  39568. * @param scene defines the hosting scene
  39569. */
  39570. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39571. /**
  39572. * Gets camera class name
  39573. * @returns AnaglyphGamepadCamera
  39574. */
  39575. getClassName(): string;
  39576. }
  39577. }
  39578. declare module BABYLON {
  39579. /**
  39580. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39581. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39582. */
  39583. export class AnaglyphUniversalCamera extends UniversalCamera {
  39584. /**
  39585. * Creates a new AnaglyphUniversalCamera
  39586. * @param name defines camera name
  39587. * @param position defines initial position
  39588. * @param interaxialDistance defines distance between each color axis
  39589. * @param scene defines the hosting scene
  39590. */
  39591. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39592. /**
  39593. * Gets camera class name
  39594. * @returns AnaglyphUniversalCamera
  39595. */
  39596. getClassName(): string;
  39597. }
  39598. }
  39599. declare module BABYLON {
  39600. /** @hidden */
  39601. export var stereoscopicInterlacePixelShader: {
  39602. name: string;
  39603. shader: string;
  39604. };
  39605. }
  39606. declare module BABYLON {
  39607. /**
  39608. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39609. */
  39610. export class StereoscopicInterlacePostProcess extends PostProcess {
  39611. private _stepSize;
  39612. private _passedProcess;
  39613. /**
  39614. * Initializes a StereoscopicInterlacePostProcess
  39615. * @param name The name of the effect.
  39616. * @param rigCameras The rig cameras to be appled to the post process
  39617. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39619. * @param engine The engine which the post process will be applied. (default: current engine)
  39620. * @param reusable If the post process can be reused on the same frame. (default: false)
  39621. */
  39622. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39628. * @see http://doc.babylonjs.com/features/cameras
  39629. */
  39630. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39631. /**
  39632. * Creates a new StereoscopicArcRotateCamera
  39633. * @param name defines camera name
  39634. * @param alpha defines alpha angle (in radians)
  39635. * @param beta defines beta angle (in radians)
  39636. * @param radius defines radius
  39637. * @param target defines camera target
  39638. * @param interaxialDistance defines distance between each color axis
  39639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39640. * @param scene defines the hosting scene
  39641. */
  39642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39643. /**
  39644. * Gets camera class name
  39645. * @returns StereoscopicArcRotateCamera
  39646. */
  39647. getClassName(): string;
  39648. }
  39649. }
  39650. declare module BABYLON {
  39651. /**
  39652. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39653. * @see http://doc.babylonjs.com/features/cameras
  39654. */
  39655. export class StereoscopicFreeCamera extends FreeCamera {
  39656. /**
  39657. * Creates a new StereoscopicFreeCamera
  39658. * @param name defines camera name
  39659. * @param position defines initial position
  39660. * @param interaxialDistance defines distance between each color axis
  39661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39662. * @param scene defines the hosting scene
  39663. */
  39664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39665. /**
  39666. * Gets camera class name
  39667. * @returns StereoscopicFreeCamera
  39668. */
  39669. getClassName(): string;
  39670. }
  39671. }
  39672. declare module BABYLON {
  39673. /**
  39674. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39675. * @see http://doc.babylonjs.com/features/cameras
  39676. */
  39677. export class StereoscopicGamepadCamera extends GamepadCamera {
  39678. /**
  39679. * Creates a new StereoscopicGamepadCamera
  39680. * @param name defines camera name
  39681. * @param position defines initial position
  39682. * @param interaxialDistance defines distance between each color axis
  39683. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39684. * @param scene defines the hosting scene
  39685. */
  39686. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39687. /**
  39688. * Gets camera class name
  39689. * @returns StereoscopicGamepadCamera
  39690. */
  39691. getClassName(): string;
  39692. }
  39693. }
  39694. declare module BABYLON {
  39695. /**
  39696. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39697. * @see http://doc.babylonjs.com/features/cameras
  39698. */
  39699. export class StereoscopicUniversalCamera extends UniversalCamera {
  39700. /**
  39701. * Creates a new StereoscopicUniversalCamera
  39702. * @param name defines camera name
  39703. * @param position defines initial position
  39704. * @param interaxialDistance defines distance between each color axis
  39705. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39706. * @param scene defines the hosting scene
  39707. */
  39708. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39709. /**
  39710. * Gets camera class name
  39711. * @returns StereoscopicUniversalCamera
  39712. */
  39713. getClassName(): string;
  39714. }
  39715. }
  39716. declare module BABYLON {
  39717. /**
  39718. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39719. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39720. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39721. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39722. */
  39723. export class VirtualJoysticksCamera extends FreeCamera {
  39724. /**
  39725. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39726. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39727. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39728. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39729. * @param name Define the name of the camera in the scene
  39730. * @param position Define the start position of the camera in the scene
  39731. * @param scene Define the scene the camera belongs to
  39732. */
  39733. constructor(name: string, position: Vector3, scene: Scene);
  39734. /**
  39735. * Gets the current object class name.
  39736. * @return the class name
  39737. */
  39738. getClassName(): string;
  39739. }
  39740. }
  39741. declare module BABYLON {
  39742. /**
  39743. * This represents all the required metrics to create a VR camera.
  39744. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39745. */
  39746. export class VRCameraMetrics {
  39747. /**
  39748. * Define the horizontal resolution off the screen.
  39749. */
  39750. hResolution: number;
  39751. /**
  39752. * Define the vertical resolution off the screen.
  39753. */
  39754. vResolution: number;
  39755. /**
  39756. * Define the horizontal screen size.
  39757. */
  39758. hScreenSize: number;
  39759. /**
  39760. * Define the vertical screen size.
  39761. */
  39762. vScreenSize: number;
  39763. /**
  39764. * Define the vertical screen center position.
  39765. */
  39766. vScreenCenter: number;
  39767. /**
  39768. * Define the distance of the eyes to the screen.
  39769. */
  39770. eyeToScreenDistance: number;
  39771. /**
  39772. * Define the distance between both lenses
  39773. */
  39774. lensSeparationDistance: number;
  39775. /**
  39776. * Define the distance between both viewer's eyes.
  39777. */
  39778. interpupillaryDistance: number;
  39779. /**
  39780. * Define the distortion factor of the VR postprocess.
  39781. * Please, touch with care.
  39782. */
  39783. distortionK: number[];
  39784. /**
  39785. * Define the chromatic aberration correction factors for the VR post process.
  39786. */
  39787. chromaAbCorrection: number[];
  39788. /**
  39789. * Define the scale factor of the post process.
  39790. * The smaller the better but the slower.
  39791. */
  39792. postProcessScaleFactor: number;
  39793. /**
  39794. * Define an offset for the lens center.
  39795. */
  39796. lensCenterOffset: number;
  39797. /**
  39798. * Define if the current vr camera should compensate the distortion of the lense or not.
  39799. */
  39800. compensateDistortion: boolean;
  39801. /**
  39802. * Defines if multiview should be enabled when rendering (Default: false)
  39803. */
  39804. multiviewEnabled: boolean;
  39805. /**
  39806. * Gets the rendering aspect ratio based on the provided resolutions.
  39807. */
  39808. readonly aspectRatio: number;
  39809. /**
  39810. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39811. */
  39812. readonly aspectRatioFov: number;
  39813. /**
  39814. * @hidden
  39815. */
  39816. readonly leftHMatrix: Matrix;
  39817. /**
  39818. * @hidden
  39819. */
  39820. readonly rightHMatrix: Matrix;
  39821. /**
  39822. * @hidden
  39823. */
  39824. readonly leftPreViewMatrix: Matrix;
  39825. /**
  39826. * @hidden
  39827. */
  39828. readonly rightPreViewMatrix: Matrix;
  39829. /**
  39830. * Get the default VRMetrics based on the most generic setup.
  39831. * @returns the default vr metrics
  39832. */
  39833. static GetDefault(): VRCameraMetrics;
  39834. }
  39835. }
  39836. declare module BABYLON {
  39837. /** @hidden */
  39838. export var vrDistortionCorrectionPixelShader: {
  39839. name: string;
  39840. shader: string;
  39841. };
  39842. }
  39843. declare module BABYLON {
  39844. /**
  39845. * VRDistortionCorrectionPostProcess used for mobile VR
  39846. */
  39847. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39848. private _isRightEye;
  39849. private _distortionFactors;
  39850. private _postProcessScaleFactor;
  39851. private _lensCenterOffset;
  39852. private _scaleIn;
  39853. private _scaleFactor;
  39854. private _lensCenter;
  39855. /**
  39856. * Initializes the VRDistortionCorrectionPostProcess
  39857. * @param name The name of the effect.
  39858. * @param camera The camera to apply the render pass to.
  39859. * @param isRightEye If this is for the right eye distortion
  39860. * @param vrMetrics All the required metrics for the VR camera
  39861. */
  39862. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39863. }
  39864. }
  39865. declare module BABYLON {
  39866. /**
  39867. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39868. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39869. */
  39870. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39871. /**
  39872. * Creates a new VRDeviceOrientationArcRotateCamera
  39873. * @param name defines camera name
  39874. * @param alpha defines the camera rotation along the logitudinal axis
  39875. * @param beta defines the camera rotation along the latitudinal axis
  39876. * @param radius defines the camera distance from its target
  39877. * @param target defines the camera target
  39878. * @param scene defines the scene the camera belongs to
  39879. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39880. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39881. */
  39882. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39883. /**
  39884. * Gets camera class name
  39885. * @returns VRDeviceOrientationArcRotateCamera
  39886. */
  39887. getClassName(): string;
  39888. }
  39889. }
  39890. declare module BABYLON {
  39891. /**
  39892. * Camera used to simulate VR rendering (based on FreeCamera)
  39893. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39894. */
  39895. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39896. /**
  39897. * Creates a new VRDeviceOrientationFreeCamera
  39898. * @param name defines camera name
  39899. * @param position defines the start position of the camera
  39900. * @param scene defines the scene the camera belongs to
  39901. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39902. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39903. */
  39904. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39905. /**
  39906. * Gets camera class name
  39907. * @returns VRDeviceOrientationFreeCamera
  39908. */
  39909. getClassName(): string;
  39910. }
  39911. }
  39912. declare module BABYLON {
  39913. /**
  39914. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39915. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39916. */
  39917. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39918. /**
  39919. * Creates a new VRDeviceOrientationGamepadCamera
  39920. * @param name defines camera name
  39921. * @param position defines the start position of the camera
  39922. * @param scene defines the scene the camera belongs to
  39923. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39924. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39925. */
  39926. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39927. /**
  39928. * Gets camera class name
  39929. * @returns VRDeviceOrientationGamepadCamera
  39930. */
  39931. getClassName(): string;
  39932. }
  39933. }
  39934. declare module BABYLON {
  39935. /**
  39936. * Base class of materials working in push mode in babylon JS
  39937. * @hidden
  39938. */
  39939. export class PushMaterial extends Material {
  39940. protected _activeEffect: Effect;
  39941. protected _normalMatrix: Matrix;
  39942. /**
  39943. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39944. * This means that the material can keep using a previous shader while a new one is being compiled.
  39945. * This is mostly used when shader parallel compilation is supported (true by default)
  39946. */
  39947. allowShaderHotSwapping: boolean;
  39948. constructor(name: string, scene: Scene);
  39949. getEffect(): Effect;
  39950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39951. /**
  39952. * Binds the given world matrix to the active effect
  39953. *
  39954. * @param world the matrix to bind
  39955. */
  39956. bindOnlyWorldMatrix(world: Matrix): void;
  39957. /**
  39958. * Binds the given normal matrix to the active effect
  39959. *
  39960. * @param normalMatrix the matrix to bind
  39961. */
  39962. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39963. bind(world: Matrix, mesh?: Mesh): void;
  39964. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39965. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39966. }
  39967. }
  39968. declare module BABYLON {
  39969. /**
  39970. * This groups all the flags used to control the materials channel.
  39971. */
  39972. export class MaterialFlags {
  39973. private static _DiffuseTextureEnabled;
  39974. /**
  39975. * Are diffuse textures enabled in the application.
  39976. */
  39977. static DiffuseTextureEnabled: boolean;
  39978. private static _AmbientTextureEnabled;
  39979. /**
  39980. * Are ambient textures enabled in the application.
  39981. */
  39982. static AmbientTextureEnabled: boolean;
  39983. private static _OpacityTextureEnabled;
  39984. /**
  39985. * Are opacity textures enabled in the application.
  39986. */
  39987. static OpacityTextureEnabled: boolean;
  39988. private static _ReflectionTextureEnabled;
  39989. /**
  39990. * Are reflection textures enabled in the application.
  39991. */
  39992. static ReflectionTextureEnabled: boolean;
  39993. private static _EmissiveTextureEnabled;
  39994. /**
  39995. * Are emissive textures enabled in the application.
  39996. */
  39997. static EmissiveTextureEnabled: boolean;
  39998. private static _SpecularTextureEnabled;
  39999. /**
  40000. * Are specular textures enabled in the application.
  40001. */
  40002. static SpecularTextureEnabled: boolean;
  40003. private static _BumpTextureEnabled;
  40004. /**
  40005. * Are bump textures enabled in the application.
  40006. */
  40007. static BumpTextureEnabled: boolean;
  40008. private static _LightmapTextureEnabled;
  40009. /**
  40010. * Are lightmap textures enabled in the application.
  40011. */
  40012. static LightmapTextureEnabled: boolean;
  40013. private static _RefractionTextureEnabled;
  40014. /**
  40015. * Are refraction textures enabled in the application.
  40016. */
  40017. static RefractionTextureEnabled: boolean;
  40018. private static _ColorGradingTextureEnabled;
  40019. /**
  40020. * Are color grading textures enabled in the application.
  40021. */
  40022. static ColorGradingTextureEnabled: boolean;
  40023. private static _FresnelEnabled;
  40024. /**
  40025. * Are fresnels enabled in the application.
  40026. */
  40027. static FresnelEnabled: boolean;
  40028. private static _ClearCoatTextureEnabled;
  40029. /**
  40030. * Are clear coat textures enabled in the application.
  40031. */
  40032. static ClearCoatTextureEnabled: boolean;
  40033. private static _ClearCoatBumpTextureEnabled;
  40034. /**
  40035. * Are clear coat bump textures enabled in the application.
  40036. */
  40037. static ClearCoatBumpTextureEnabled: boolean;
  40038. private static _ClearCoatTintTextureEnabled;
  40039. /**
  40040. * Are clear coat tint textures enabled in the application.
  40041. */
  40042. static ClearCoatTintTextureEnabled: boolean;
  40043. private static _SheenTextureEnabled;
  40044. /**
  40045. * Are sheen textures enabled in the application.
  40046. */
  40047. static SheenTextureEnabled: boolean;
  40048. private static _AnisotropicTextureEnabled;
  40049. /**
  40050. * Are anisotropic textures enabled in the application.
  40051. */
  40052. static AnisotropicTextureEnabled: boolean;
  40053. private static _ThicknessTextureEnabled;
  40054. /**
  40055. * Are thickness textures enabled in the application.
  40056. */
  40057. static ThicknessTextureEnabled: boolean;
  40058. }
  40059. }
  40060. declare module BABYLON {
  40061. /** @hidden */
  40062. export var defaultFragmentDeclaration: {
  40063. name: string;
  40064. shader: string;
  40065. };
  40066. }
  40067. declare module BABYLON {
  40068. /** @hidden */
  40069. export var defaultUboDeclaration: {
  40070. name: string;
  40071. shader: string;
  40072. };
  40073. }
  40074. declare module BABYLON {
  40075. /** @hidden */
  40076. export var lightFragmentDeclaration: {
  40077. name: string;
  40078. shader: string;
  40079. };
  40080. }
  40081. declare module BABYLON {
  40082. /** @hidden */
  40083. export var lightUboDeclaration: {
  40084. name: string;
  40085. shader: string;
  40086. };
  40087. }
  40088. declare module BABYLON {
  40089. /** @hidden */
  40090. export var lightsFragmentFunctions: {
  40091. name: string;
  40092. shader: string;
  40093. };
  40094. }
  40095. declare module BABYLON {
  40096. /** @hidden */
  40097. export var shadowsFragmentFunctions: {
  40098. name: string;
  40099. shader: string;
  40100. };
  40101. }
  40102. declare module BABYLON {
  40103. /** @hidden */
  40104. export var fresnelFunction: {
  40105. name: string;
  40106. shader: string;
  40107. };
  40108. }
  40109. declare module BABYLON {
  40110. /** @hidden */
  40111. export var reflectionFunction: {
  40112. name: string;
  40113. shader: string;
  40114. };
  40115. }
  40116. declare module BABYLON {
  40117. /** @hidden */
  40118. export var bumpFragmentFunctions: {
  40119. name: string;
  40120. shader: string;
  40121. };
  40122. }
  40123. declare module BABYLON {
  40124. /** @hidden */
  40125. export var logDepthDeclaration: {
  40126. name: string;
  40127. shader: string;
  40128. };
  40129. }
  40130. declare module BABYLON {
  40131. /** @hidden */
  40132. export var bumpFragment: {
  40133. name: string;
  40134. shader: string;
  40135. };
  40136. }
  40137. declare module BABYLON {
  40138. /** @hidden */
  40139. export var depthPrePass: {
  40140. name: string;
  40141. shader: string;
  40142. };
  40143. }
  40144. declare module BABYLON {
  40145. /** @hidden */
  40146. export var lightFragment: {
  40147. name: string;
  40148. shader: string;
  40149. };
  40150. }
  40151. declare module BABYLON {
  40152. /** @hidden */
  40153. export var logDepthFragment: {
  40154. name: string;
  40155. shader: string;
  40156. };
  40157. }
  40158. declare module BABYLON {
  40159. /** @hidden */
  40160. export var defaultPixelShader: {
  40161. name: string;
  40162. shader: string;
  40163. };
  40164. }
  40165. declare module BABYLON {
  40166. /** @hidden */
  40167. export var defaultVertexDeclaration: {
  40168. name: string;
  40169. shader: string;
  40170. };
  40171. }
  40172. declare module BABYLON {
  40173. /** @hidden */
  40174. export var bumpVertexDeclaration: {
  40175. name: string;
  40176. shader: string;
  40177. };
  40178. }
  40179. declare module BABYLON {
  40180. /** @hidden */
  40181. export var bumpVertex: {
  40182. name: string;
  40183. shader: string;
  40184. };
  40185. }
  40186. declare module BABYLON {
  40187. /** @hidden */
  40188. export var fogVertex: {
  40189. name: string;
  40190. shader: string;
  40191. };
  40192. }
  40193. declare module BABYLON {
  40194. /** @hidden */
  40195. export var shadowsVertex: {
  40196. name: string;
  40197. shader: string;
  40198. };
  40199. }
  40200. declare module BABYLON {
  40201. /** @hidden */
  40202. export var pointCloudVertex: {
  40203. name: string;
  40204. shader: string;
  40205. };
  40206. }
  40207. declare module BABYLON {
  40208. /** @hidden */
  40209. export var logDepthVertex: {
  40210. name: string;
  40211. shader: string;
  40212. };
  40213. }
  40214. declare module BABYLON {
  40215. /** @hidden */
  40216. export var defaultVertexShader: {
  40217. name: string;
  40218. shader: string;
  40219. };
  40220. }
  40221. declare module BABYLON {
  40222. /** @hidden */
  40223. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40224. MAINUV1: boolean;
  40225. MAINUV2: boolean;
  40226. DIFFUSE: boolean;
  40227. DIFFUSEDIRECTUV: number;
  40228. AMBIENT: boolean;
  40229. AMBIENTDIRECTUV: number;
  40230. OPACITY: boolean;
  40231. OPACITYDIRECTUV: number;
  40232. OPACITYRGB: boolean;
  40233. REFLECTION: boolean;
  40234. EMISSIVE: boolean;
  40235. EMISSIVEDIRECTUV: number;
  40236. SPECULAR: boolean;
  40237. SPECULARDIRECTUV: number;
  40238. BUMP: boolean;
  40239. BUMPDIRECTUV: number;
  40240. PARALLAX: boolean;
  40241. PARALLAXOCCLUSION: boolean;
  40242. SPECULAROVERALPHA: boolean;
  40243. CLIPPLANE: boolean;
  40244. CLIPPLANE2: boolean;
  40245. CLIPPLANE3: boolean;
  40246. CLIPPLANE4: boolean;
  40247. ALPHATEST: boolean;
  40248. DEPTHPREPASS: boolean;
  40249. ALPHAFROMDIFFUSE: boolean;
  40250. POINTSIZE: boolean;
  40251. FOG: boolean;
  40252. SPECULARTERM: boolean;
  40253. DIFFUSEFRESNEL: boolean;
  40254. OPACITYFRESNEL: boolean;
  40255. REFLECTIONFRESNEL: boolean;
  40256. REFRACTIONFRESNEL: boolean;
  40257. EMISSIVEFRESNEL: boolean;
  40258. FRESNEL: boolean;
  40259. NORMAL: boolean;
  40260. UV1: boolean;
  40261. UV2: boolean;
  40262. VERTEXCOLOR: boolean;
  40263. VERTEXALPHA: boolean;
  40264. NUM_BONE_INFLUENCERS: number;
  40265. BonesPerMesh: number;
  40266. BONETEXTURE: boolean;
  40267. INSTANCES: boolean;
  40268. GLOSSINESS: boolean;
  40269. ROUGHNESS: boolean;
  40270. EMISSIVEASILLUMINATION: boolean;
  40271. LINKEMISSIVEWITHDIFFUSE: boolean;
  40272. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40273. LIGHTMAP: boolean;
  40274. LIGHTMAPDIRECTUV: number;
  40275. OBJECTSPACE_NORMALMAP: boolean;
  40276. USELIGHTMAPASSHADOWMAP: boolean;
  40277. REFLECTIONMAP_3D: boolean;
  40278. REFLECTIONMAP_SPHERICAL: boolean;
  40279. REFLECTIONMAP_PLANAR: boolean;
  40280. REFLECTIONMAP_CUBIC: boolean;
  40281. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40282. REFLECTIONMAP_PROJECTION: boolean;
  40283. REFLECTIONMAP_SKYBOX: boolean;
  40284. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40285. REFLECTIONMAP_EXPLICIT: boolean;
  40286. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40287. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40288. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40289. INVERTCUBICMAP: boolean;
  40290. LOGARITHMICDEPTH: boolean;
  40291. REFRACTION: boolean;
  40292. REFRACTIONMAP_3D: boolean;
  40293. REFLECTIONOVERALPHA: boolean;
  40294. TWOSIDEDLIGHTING: boolean;
  40295. SHADOWFLOAT: boolean;
  40296. MORPHTARGETS: boolean;
  40297. MORPHTARGETS_NORMAL: boolean;
  40298. MORPHTARGETS_TANGENT: boolean;
  40299. MORPHTARGETS_UV: boolean;
  40300. NUM_MORPH_INFLUENCERS: number;
  40301. NONUNIFORMSCALING: boolean;
  40302. PREMULTIPLYALPHA: boolean;
  40303. IMAGEPROCESSING: boolean;
  40304. VIGNETTE: boolean;
  40305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40306. VIGNETTEBLENDMODEOPAQUE: boolean;
  40307. TONEMAPPING: boolean;
  40308. TONEMAPPING_ACES: boolean;
  40309. CONTRAST: boolean;
  40310. COLORCURVES: boolean;
  40311. COLORGRADING: boolean;
  40312. COLORGRADING3D: boolean;
  40313. SAMPLER3DGREENDEPTH: boolean;
  40314. SAMPLER3DBGRMAP: boolean;
  40315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40316. MULTIVIEW: boolean;
  40317. /**
  40318. * If the reflection texture on this material is in linear color space
  40319. * @hidden
  40320. */
  40321. IS_REFLECTION_LINEAR: boolean;
  40322. /**
  40323. * If the refraction texture on this material is in linear color space
  40324. * @hidden
  40325. */
  40326. IS_REFRACTION_LINEAR: boolean;
  40327. EXPOSURE: boolean;
  40328. constructor();
  40329. setReflectionMode(modeToEnable: string): void;
  40330. }
  40331. /**
  40332. * This is the default material used in Babylon. It is the best trade off between quality
  40333. * and performances.
  40334. * @see http://doc.babylonjs.com/babylon101/materials
  40335. */
  40336. export class StandardMaterial extends PushMaterial {
  40337. private _diffuseTexture;
  40338. /**
  40339. * The basic texture of the material as viewed under a light.
  40340. */
  40341. diffuseTexture: Nullable<BaseTexture>;
  40342. private _ambientTexture;
  40343. /**
  40344. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40345. */
  40346. ambientTexture: Nullable<BaseTexture>;
  40347. private _opacityTexture;
  40348. /**
  40349. * Define the transparency of the material from a texture.
  40350. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40351. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40352. */
  40353. opacityTexture: Nullable<BaseTexture>;
  40354. private _reflectionTexture;
  40355. /**
  40356. * Define the texture used to display the reflection.
  40357. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40358. */
  40359. reflectionTexture: Nullable<BaseTexture>;
  40360. private _emissiveTexture;
  40361. /**
  40362. * Define texture of the material as if self lit.
  40363. * This will be mixed in the final result even in the absence of light.
  40364. */
  40365. emissiveTexture: Nullable<BaseTexture>;
  40366. private _specularTexture;
  40367. /**
  40368. * Define how the color and intensity of the highlight given by the light in the material.
  40369. */
  40370. specularTexture: Nullable<BaseTexture>;
  40371. private _bumpTexture;
  40372. /**
  40373. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40374. * 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.
  40375. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40376. */
  40377. bumpTexture: Nullable<BaseTexture>;
  40378. private _lightmapTexture;
  40379. /**
  40380. * Complex lighting can be computationally expensive to compute at runtime.
  40381. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40382. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40383. */
  40384. lightmapTexture: Nullable<BaseTexture>;
  40385. private _refractionTexture;
  40386. /**
  40387. * Define the texture used to display the refraction.
  40388. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40389. */
  40390. refractionTexture: Nullable<BaseTexture>;
  40391. /**
  40392. * The color of the material lit by the environmental background lighting.
  40393. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40394. */
  40395. ambientColor: Color3;
  40396. /**
  40397. * The basic color of the material as viewed under a light.
  40398. */
  40399. diffuseColor: Color3;
  40400. /**
  40401. * Define how the color and intensity of the highlight given by the light in the material.
  40402. */
  40403. specularColor: Color3;
  40404. /**
  40405. * Define the color of the material as if self lit.
  40406. * This will be mixed in the final result even in the absence of light.
  40407. */
  40408. emissiveColor: Color3;
  40409. /**
  40410. * Defines how sharp are the highlights in the material.
  40411. * The bigger the value the sharper giving a more glossy feeling to the result.
  40412. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40413. */
  40414. specularPower: number;
  40415. private _useAlphaFromDiffuseTexture;
  40416. /**
  40417. * Does the transparency come from the diffuse texture alpha channel.
  40418. */
  40419. useAlphaFromDiffuseTexture: boolean;
  40420. private _useEmissiveAsIllumination;
  40421. /**
  40422. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40423. */
  40424. useEmissiveAsIllumination: boolean;
  40425. private _linkEmissiveWithDiffuse;
  40426. /**
  40427. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40428. * the emissive level when the final color is close to one.
  40429. */
  40430. linkEmissiveWithDiffuse: boolean;
  40431. private _useSpecularOverAlpha;
  40432. /**
  40433. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40434. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40435. */
  40436. useSpecularOverAlpha: boolean;
  40437. private _useReflectionOverAlpha;
  40438. /**
  40439. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40440. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40441. */
  40442. useReflectionOverAlpha: boolean;
  40443. private _disableLighting;
  40444. /**
  40445. * Does lights from the scene impacts this material.
  40446. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40447. */
  40448. disableLighting: boolean;
  40449. private _useObjectSpaceNormalMap;
  40450. /**
  40451. * Allows using an object space normal map (instead of tangent space).
  40452. */
  40453. useObjectSpaceNormalMap: boolean;
  40454. private _useParallax;
  40455. /**
  40456. * Is parallax enabled or not.
  40457. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40458. */
  40459. useParallax: boolean;
  40460. private _useParallaxOcclusion;
  40461. /**
  40462. * Is parallax occlusion enabled or not.
  40463. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40464. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40465. */
  40466. useParallaxOcclusion: boolean;
  40467. /**
  40468. * 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.
  40469. */
  40470. parallaxScaleBias: number;
  40471. private _roughness;
  40472. /**
  40473. * Helps to define how blurry the reflections should appears in the material.
  40474. */
  40475. roughness: number;
  40476. /**
  40477. * In case of refraction, define the value of the index of refraction.
  40478. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40479. */
  40480. indexOfRefraction: number;
  40481. /**
  40482. * Invert the refraction texture alongside the y axis.
  40483. * It can be useful with procedural textures or probe for instance.
  40484. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40485. */
  40486. invertRefractionY: boolean;
  40487. /**
  40488. * Defines the alpha limits in alpha test mode.
  40489. */
  40490. alphaCutOff: number;
  40491. private _useLightmapAsShadowmap;
  40492. /**
  40493. * In case of light mapping, define whether the map contains light or shadow informations.
  40494. */
  40495. useLightmapAsShadowmap: boolean;
  40496. private _diffuseFresnelParameters;
  40497. /**
  40498. * Define the diffuse fresnel parameters of the material.
  40499. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40500. */
  40501. diffuseFresnelParameters: FresnelParameters;
  40502. private _opacityFresnelParameters;
  40503. /**
  40504. * Define the opacity fresnel parameters of the material.
  40505. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40506. */
  40507. opacityFresnelParameters: FresnelParameters;
  40508. private _reflectionFresnelParameters;
  40509. /**
  40510. * Define the reflection fresnel parameters of the material.
  40511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40512. */
  40513. reflectionFresnelParameters: FresnelParameters;
  40514. private _refractionFresnelParameters;
  40515. /**
  40516. * Define the refraction fresnel parameters of the material.
  40517. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40518. */
  40519. refractionFresnelParameters: FresnelParameters;
  40520. private _emissiveFresnelParameters;
  40521. /**
  40522. * Define the emissive fresnel parameters of the material.
  40523. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40524. */
  40525. emissiveFresnelParameters: FresnelParameters;
  40526. private _useReflectionFresnelFromSpecular;
  40527. /**
  40528. * If true automatically deducts the fresnels values from the material specularity.
  40529. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40530. */
  40531. useReflectionFresnelFromSpecular: boolean;
  40532. private _useGlossinessFromSpecularMapAlpha;
  40533. /**
  40534. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40535. */
  40536. useGlossinessFromSpecularMapAlpha: boolean;
  40537. private _maxSimultaneousLights;
  40538. /**
  40539. * Defines the maximum number of lights that can be used in the material
  40540. */
  40541. maxSimultaneousLights: number;
  40542. private _invertNormalMapX;
  40543. /**
  40544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40545. */
  40546. invertNormalMapX: boolean;
  40547. private _invertNormalMapY;
  40548. /**
  40549. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40550. */
  40551. invertNormalMapY: boolean;
  40552. private _twoSidedLighting;
  40553. /**
  40554. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40555. */
  40556. twoSidedLighting: boolean;
  40557. /**
  40558. * Default configuration related to image processing available in the standard Material.
  40559. */
  40560. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40561. /**
  40562. * Gets the image processing configuration used either in this material.
  40563. */
  40564. /**
  40565. * Sets the Default image processing configuration used either in the this material.
  40566. *
  40567. * If sets to null, the scene one is in use.
  40568. */
  40569. imageProcessingConfiguration: ImageProcessingConfiguration;
  40570. /**
  40571. * Keep track of the image processing observer to allow dispose and replace.
  40572. */
  40573. private _imageProcessingObserver;
  40574. /**
  40575. * Attaches a new image processing configuration to the Standard Material.
  40576. * @param configuration
  40577. */
  40578. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40579. /**
  40580. * Gets wether the color curves effect is enabled.
  40581. */
  40582. /**
  40583. * Sets wether the color curves effect is enabled.
  40584. */
  40585. cameraColorCurvesEnabled: boolean;
  40586. /**
  40587. * Gets wether the color grading effect is enabled.
  40588. */
  40589. /**
  40590. * Gets wether the color grading effect is enabled.
  40591. */
  40592. cameraColorGradingEnabled: boolean;
  40593. /**
  40594. * Gets wether tonemapping is enabled or not.
  40595. */
  40596. /**
  40597. * Sets wether tonemapping is enabled or not
  40598. */
  40599. cameraToneMappingEnabled: boolean;
  40600. /**
  40601. * The camera exposure used on this material.
  40602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40603. * This corresponds to a photographic exposure.
  40604. */
  40605. /**
  40606. * The camera exposure used on this material.
  40607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40608. * This corresponds to a photographic exposure.
  40609. */
  40610. cameraExposure: number;
  40611. /**
  40612. * Gets The camera contrast used on this material.
  40613. */
  40614. /**
  40615. * Sets The camera contrast used on this material.
  40616. */
  40617. cameraContrast: number;
  40618. /**
  40619. * Gets the Color Grading 2D Lookup Texture.
  40620. */
  40621. /**
  40622. * Sets the Color Grading 2D Lookup Texture.
  40623. */
  40624. cameraColorGradingTexture: Nullable<BaseTexture>;
  40625. /**
  40626. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40627. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40628. * 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;
  40629. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40630. */
  40631. /**
  40632. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40633. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40634. * 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;
  40635. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40636. */
  40637. cameraColorCurves: Nullable<ColorCurves>;
  40638. /**
  40639. * Custom callback helping to override the default shader used in the material.
  40640. */
  40641. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40642. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40643. protected _worldViewProjectionMatrix: Matrix;
  40644. protected _globalAmbientColor: Color3;
  40645. protected _useLogarithmicDepth: boolean;
  40646. protected _rebuildInParallel: boolean;
  40647. /**
  40648. * Instantiates a new standard material.
  40649. * This is the default material used in Babylon. It is the best trade off between quality
  40650. * and performances.
  40651. * @see http://doc.babylonjs.com/babylon101/materials
  40652. * @param name Define the name of the material in the scene
  40653. * @param scene Define the scene the material belong to
  40654. */
  40655. constructor(name: string, scene: Scene);
  40656. /**
  40657. * Gets a boolean indicating that current material needs to register RTT
  40658. */
  40659. readonly hasRenderTargetTextures: boolean;
  40660. /**
  40661. * Gets the current class name of the material e.g. "StandardMaterial"
  40662. * Mainly use in serialization.
  40663. * @returns the class name
  40664. */
  40665. getClassName(): string;
  40666. /**
  40667. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40668. * You can try switching to logarithmic depth.
  40669. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40670. */
  40671. useLogarithmicDepth: boolean;
  40672. /**
  40673. * Specifies if the material will require alpha blending
  40674. * @returns a boolean specifying if alpha blending is needed
  40675. */
  40676. needAlphaBlending(): boolean;
  40677. /**
  40678. * Specifies if this material should be rendered in alpha test mode
  40679. * @returns a boolean specifying if an alpha test is needed.
  40680. */
  40681. needAlphaTesting(): boolean;
  40682. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40683. /**
  40684. * Get the texture used for alpha test purpose.
  40685. * @returns the diffuse texture in case of the standard material.
  40686. */
  40687. getAlphaTestTexture(): Nullable<BaseTexture>;
  40688. /**
  40689. * Get if the submesh is ready to be used and all its information available.
  40690. * Child classes can use it to update shaders
  40691. * @param mesh defines the mesh to check
  40692. * @param subMesh defines which submesh to check
  40693. * @param useInstances specifies that instances should be used
  40694. * @returns a boolean indicating that the submesh is ready or not
  40695. */
  40696. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40697. /**
  40698. * Builds the material UBO layouts.
  40699. * Used internally during the effect preparation.
  40700. */
  40701. buildUniformLayout(): void;
  40702. /**
  40703. * Unbinds the material from the mesh
  40704. */
  40705. unbind(): void;
  40706. /**
  40707. * Binds the submesh to this material by preparing the effect and shader to draw
  40708. * @param world defines the world transformation matrix
  40709. * @param mesh defines the mesh containing the submesh
  40710. * @param subMesh defines the submesh to bind the material to
  40711. */
  40712. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40713. /**
  40714. * Get the list of animatables in the material.
  40715. * @returns the list of animatables object used in the material
  40716. */
  40717. getAnimatables(): IAnimatable[];
  40718. /**
  40719. * Gets the active textures from the material
  40720. * @returns an array of textures
  40721. */
  40722. getActiveTextures(): BaseTexture[];
  40723. /**
  40724. * Specifies if the material uses a texture
  40725. * @param texture defines the texture to check against the material
  40726. * @returns a boolean specifying if the material uses the texture
  40727. */
  40728. hasTexture(texture: BaseTexture): boolean;
  40729. /**
  40730. * Disposes the material
  40731. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40732. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40733. */
  40734. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40735. /**
  40736. * Makes a duplicate of the material, and gives it a new name
  40737. * @param name defines the new name for the duplicated material
  40738. * @returns the cloned material
  40739. */
  40740. clone(name: string): StandardMaterial;
  40741. /**
  40742. * Serializes this material in a JSON representation
  40743. * @returns the serialized material object
  40744. */
  40745. serialize(): any;
  40746. /**
  40747. * Creates a standard material from parsed material data
  40748. * @param source defines the JSON representation of the material
  40749. * @param scene defines the hosting scene
  40750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40751. * @returns a new standard material
  40752. */
  40753. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40754. /**
  40755. * Are diffuse textures enabled in the application.
  40756. */
  40757. static DiffuseTextureEnabled: boolean;
  40758. /**
  40759. * Are ambient textures enabled in the application.
  40760. */
  40761. static AmbientTextureEnabled: boolean;
  40762. /**
  40763. * Are opacity textures enabled in the application.
  40764. */
  40765. static OpacityTextureEnabled: boolean;
  40766. /**
  40767. * Are reflection textures enabled in the application.
  40768. */
  40769. static ReflectionTextureEnabled: boolean;
  40770. /**
  40771. * Are emissive textures enabled in the application.
  40772. */
  40773. static EmissiveTextureEnabled: boolean;
  40774. /**
  40775. * Are specular textures enabled in the application.
  40776. */
  40777. static SpecularTextureEnabled: boolean;
  40778. /**
  40779. * Are bump textures enabled in the application.
  40780. */
  40781. static BumpTextureEnabled: boolean;
  40782. /**
  40783. * Are lightmap textures enabled in the application.
  40784. */
  40785. static LightmapTextureEnabled: boolean;
  40786. /**
  40787. * Are refraction textures enabled in the application.
  40788. */
  40789. static RefractionTextureEnabled: boolean;
  40790. /**
  40791. * Are color grading textures enabled in the application.
  40792. */
  40793. static ColorGradingTextureEnabled: boolean;
  40794. /**
  40795. * Are fresnels enabled in the application.
  40796. */
  40797. static FresnelEnabled: boolean;
  40798. }
  40799. }
  40800. declare module BABYLON {
  40801. /** @hidden */
  40802. export var imageProcessingPixelShader: {
  40803. name: string;
  40804. shader: string;
  40805. };
  40806. }
  40807. declare module BABYLON {
  40808. /**
  40809. * ImageProcessingPostProcess
  40810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40811. */
  40812. export class ImageProcessingPostProcess extends PostProcess {
  40813. /**
  40814. * Default configuration related to image processing available in the PBR Material.
  40815. */
  40816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40817. /**
  40818. * Gets the image processing configuration used either in this material.
  40819. */
  40820. /**
  40821. * Sets the Default image processing configuration used either in the this material.
  40822. *
  40823. * If sets to null, the scene one is in use.
  40824. */
  40825. imageProcessingConfiguration: ImageProcessingConfiguration;
  40826. /**
  40827. * Keep track of the image processing observer to allow dispose and replace.
  40828. */
  40829. private _imageProcessingObserver;
  40830. /**
  40831. * Attaches a new image processing configuration to the PBR Material.
  40832. * @param configuration
  40833. */
  40834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40835. /**
  40836. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40837. */
  40838. /**
  40839. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40840. */
  40841. colorCurves: Nullable<ColorCurves>;
  40842. /**
  40843. * Gets wether the color curves effect is enabled.
  40844. */
  40845. /**
  40846. * Sets wether the color curves effect is enabled.
  40847. */
  40848. colorCurvesEnabled: boolean;
  40849. /**
  40850. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40851. */
  40852. /**
  40853. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40854. */
  40855. colorGradingTexture: Nullable<BaseTexture>;
  40856. /**
  40857. * Gets wether the color grading effect is enabled.
  40858. */
  40859. /**
  40860. * Gets wether the color grading effect is enabled.
  40861. */
  40862. colorGradingEnabled: boolean;
  40863. /**
  40864. * Gets exposure used in the effect.
  40865. */
  40866. /**
  40867. * Sets exposure used in the effect.
  40868. */
  40869. exposure: number;
  40870. /**
  40871. * Gets wether tonemapping is enabled or not.
  40872. */
  40873. /**
  40874. * Sets wether tonemapping is enabled or not
  40875. */
  40876. toneMappingEnabled: boolean;
  40877. /**
  40878. * Gets the type of tone mapping effect.
  40879. */
  40880. /**
  40881. * Sets the type of tone mapping effect.
  40882. */
  40883. toneMappingType: number;
  40884. /**
  40885. * Gets contrast used in the effect.
  40886. */
  40887. /**
  40888. * Sets contrast used in the effect.
  40889. */
  40890. contrast: number;
  40891. /**
  40892. * Gets Vignette stretch size.
  40893. */
  40894. /**
  40895. * Sets Vignette stretch size.
  40896. */
  40897. vignetteStretch: number;
  40898. /**
  40899. * Gets Vignette centre X Offset.
  40900. */
  40901. /**
  40902. * Sets Vignette centre X Offset.
  40903. */
  40904. vignetteCentreX: number;
  40905. /**
  40906. * Gets Vignette centre Y Offset.
  40907. */
  40908. /**
  40909. * Sets Vignette centre Y Offset.
  40910. */
  40911. vignetteCentreY: number;
  40912. /**
  40913. * Gets Vignette weight or intensity of the vignette effect.
  40914. */
  40915. /**
  40916. * Sets Vignette weight or intensity of the vignette effect.
  40917. */
  40918. vignetteWeight: number;
  40919. /**
  40920. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40921. * if vignetteEnabled is set to true.
  40922. */
  40923. /**
  40924. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40925. * if vignetteEnabled is set to true.
  40926. */
  40927. vignetteColor: Color4;
  40928. /**
  40929. * Gets Camera field of view used by the Vignette effect.
  40930. */
  40931. /**
  40932. * Sets Camera field of view used by the Vignette effect.
  40933. */
  40934. vignetteCameraFov: number;
  40935. /**
  40936. * Gets the vignette blend mode allowing different kind of effect.
  40937. */
  40938. /**
  40939. * Sets the vignette blend mode allowing different kind of effect.
  40940. */
  40941. vignetteBlendMode: number;
  40942. /**
  40943. * Gets wether the vignette effect is enabled.
  40944. */
  40945. /**
  40946. * Sets wether the vignette effect is enabled.
  40947. */
  40948. vignetteEnabled: boolean;
  40949. private _fromLinearSpace;
  40950. /**
  40951. * Gets wether the input of the processing is in Gamma or Linear Space.
  40952. */
  40953. /**
  40954. * Sets wether the input of the processing is in Gamma or Linear Space.
  40955. */
  40956. fromLinearSpace: boolean;
  40957. /**
  40958. * Defines cache preventing GC.
  40959. */
  40960. private _defines;
  40961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40962. /**
  40963. * "ImageProcessingPostProcess"
  40964. * @returns "ImageProcessingPostProcess"
  40965. */
  40966. getClassName(): string;
  40967. protected _updateParameters(): void;
  40968. dispose(camera?: Camera): void;
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /**
  40973. * Class containing static functions to help procedurally build meshes
  40974. */
  40975. export class GroundBuilder {
  40976. /**
  40977. * Creates a ground mesh
  40978. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40979. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40981. * @param name defines the name of the mesh
  40982. * @param options defines the options used to create the mesh
  40983. * @param scene defines the hosting scene
  40984. * @returns the ground mesh
  40985. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40986. */
  40987. static CreateGround(name: string, options: {
  40988. width?: number;
  40989. height?: number;
  40990. subdivisions?: number;
  40991. subdivisionsX?: number;
  40992. subdivisionsY?: number;
  40993. updatable?: boolean;
  40994. }, scene: any): Mesh;
  40995. /**
  40996. * Creates a tiled ground mesh
  40997. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40998. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40999. * * 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
  41000. * * 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
  41001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41002. * @param name defines the name of the mesh
  41003. * @param options defines the options used to create the mesh
  41004. * @param scene defines the hosting scene
  41005. * @returns the tiled ground mesh
  41006. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41007. */
  41008. static CreateTiledGround(name: string, options: {
  41009. xmin: number;
  41010. zmin: number;
  41011. xmax: number;
  41012. zmax: number;
  41013. subdivisions?: {
  41014. w: number;
  41015. h: number;
  41016. };
  41017. precision?: {
  41018. w: number;
  41019. h: number;
  41020. };
  41021. updatable?: boolean;
  41022. }, scene?: Nullable<Scene>): Mesh;
  41023. /**
  41024. * Creates a ground mesh from a height map
  41025. * * The parameter `url` sets the URL of the height map image resource.
  41026. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41027. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41028. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41029. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41030. * * 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.
  41031. * * 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).
  41032. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41034. * @param name defines the name of the mesh
  41035. * @param url defines the url to the height map
  41036. * @param options defines the options used to create the mesh
  41037. * @param scene defines the hosting scene
  41038. * @returns the ground mesh
  41039. * @see https://doc.babylonjs.com/babylon101/height_map
  41040. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41041. */
  41042. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41043. width?: number;
  41044. height?: number;
  41045. subdivisions?: number;
  41046. minHeight?: number;
  41047. maxHeight?: number;
  41048. colorFilter?: Color3;
  41049. alphaFilter?: number;
  41050. updatable?: boolean;
  41051. onReady?: (mesh: GroundMesh) => void;
  41052. }, scene?: Nullable<Scene>): GroundMesh;
  41053. }
  41054. }
  41055. declare module BABYLON {
  41056. /**
  41057. * Class containing static functions to help procedurally build meshes
  41058. */
  41059. export class TorusBuilder {
  41060. /**
  41061. * Creates a torus mesh
  41062. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41063. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41064. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41066. * * 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
  41067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41068. * @param name defines the name of the mesh
  41069. * @param options defines the options used to create the mesh
  41070. * @param scene defines the hosting scene
  41071. * @returns the torus mesh
  41072. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41073. */
  41074. static CreateTorus(name: string, options: {
  41075. diameter?: number;
  41076. thickness?: number;
  41077. tessellation?: number;
  41078. updatable?: boolean;
  41079. sideOrientation?: number;
  41080. frontUVs?: Vector4;
  41081. backUVs?: Vector4;
  41082. }, scene: any): Mesh;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * Class containing static functions to help procedurally build meshes
  41088. */
  41089. export class CylinderBuilder {
  41090. /**
  41091. * Creates a cylinder or a cone mesh
  41092. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41093. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41094. * * 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.
  41095. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41096. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41097. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41098. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41099. * * 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).
  41100. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41101. * * 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).
  41102. * * 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
  41103. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41104. * * 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
  41105. * * 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.
  41106. * * If `enclose` is false, a ring surface is one element.
  41107. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41108. * * 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
  41109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41110. * * 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
  41111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41112. * @param name defines the name of the mesh
  41113. * @param options defines the options used to create the mesh
  41114. * @param scene defines the hosting scene
  41115. * @returns the cylinder mesh
  41116. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41117. */
  41118. static CreateCylinder(name: string, options: {
  41119. height?: number;
  41120. diameterTop?: number;
  41121. diameterBottom?: number;
  41122. diameter?: number;
  41123. tessellation?: number;
  41124. subdivisions?: number;
  41125. arc?: number;
  41126. faceColors?: Color4[];
  41127. faceUV?: Vector4[];
  41128. updatable?: boolean;
  41129. hasRings?: boolean;
  41130. enclose?: boolean;
  41131. cap?: number;
  41132. sideOrientation?: number;
  41133. frontUVs?: Vector4;
  41134. backUVs?: Vector4;
  41135. }, scene: any): Mesh;
  41136. }
  41137. }
  41138. declare module BABYLON {
  41139. /**
  41140. * Options to modify the vr teleportation behavior.
  41141. */
  41142. export interface VRTeleportationOptions {
  41143. /**
  41144. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41145. */
  41146. floorMeshName?: string;
  41147. /**
  41148. * A list of meshes to be used as the teleportation floor. (default: empty)
  41149. */
  41150. floorMeshes?: Mesh[];
  41151. }
  41152. /**
  41153. * Options to modify the vr experience helper's behavior.
  41154. */
  41155. export interface VRExperienceHelperOptions extends WebVROptions {
  41156. /**
  41157. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41158. */
  41159. createDeviceOrientationCamera?: boolean;
  41160. /**
  41161. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41162. */
  41163. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41164. /**
  41165. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41166. */
  41167. laserToggle?: boolean;
  41168. /**
  41169. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41170. */
  41171. floorMeshes?: Mesh[];
  41172. /**
  41173. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41174. */
  41175. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41176. }
  41177. /**
  41178. * Event containing information after VR has been entered
  41179. */
  41180. export class OnAfterEnteringVRObservableEvent {
  41181. /**
  41182. * If entering vr was successful
  41183. */
  41184. success: boolean;
  41185. }
  41186. /**
  41187. * Helps to quickly add VR support to an existing scene.
  41188. * See http://doc.babylonjs.com/how_to/webvr_helper
  41189. */
  41190. export class VRExperienceHelper {
  41191. /** Options to modify the vr experience helper's behavior. */
  41192. webVROptions: VRExperienceHelperOptions;
  41193. private _scene;
  41194. private _position;
  41195. private _btnVR;
  41196. private _btnVRDisplayed;
  41197. private _webVRsupported;
  41198. private _webVRready;
  41199. private _webVRrequesting;
  41200. private _webVRpresenting;
  41201. private _hasEnteredVR;
  41202. private _fullscreenVRpresenting;
  41203. private _canvas;
  41204. private _webVRCamera;
  41205. private _vrDeviceOrientationCamera;
  41206. private _deviceOrientationCamera;
  41207. private _existingCamera;
  41208. private _onKeyDown;
  41209. private _onVrDisplayPresentChange;
  41210. private _onVRDisplayChanged;
  41211. private _onVRRequestPresentStart;
  41212. private _onVRRequestPresentComplete;
  41213. /**
  41214. * 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)
  41215. */
  41216. enableGazeEvenWhenNoPointerLock: boolean;
  41217. /**
  41218. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41219. */
  41220. exitVROnDoubleTap: boolean;
  41221. /**
  41222. * Observable raised right before entering VR.
  41223. */
  41224. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41225. /**
  41226. * Observable raised when entering VR has completed.
  41227. */
  41228. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41229. /**
  41230. * Observable raised when exiting VR.
  41231. */
  41232. onExitingVRObservable: Observable<VRExperienceHelper>;
  41233. /**
  41234. * Observable raised when controller mesh is loaded.
  41235. */
  41236. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41237. /** Return this.onEnteringVRObservable
  41238. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41239. */
  41240. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41241. /** Return this.onExitingVRObservable
  41242. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41243. */
  41244. readonly onExitingVR: Observable<VRExperienceHelper>;
  41245. /** Return this.onControllerMeshLoadedObservable
  41246. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41247. */
  41248. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41249. private _rayLength;
  41250. private _useCustomVRButton;
  41251. private _teleportationRequested;
  41252. private _teleportActive;
  41253. private _floorMeshName;
  41254. private _floorMeshesCollection;
  41255. private _rotationAllowed;
  41256. private _teleportBackwardsVector;
  41257. private _teleportationTarget;
  41258. private _isDefaultTeleportationTarget;
  41259. private _postProcessMove;
  41260. private _teleportationFillColor;
  41261. private _teleportationBorderColor;
  41262. private _rotationAngle;
  41263. private _haloCenter;
  41264. private _cameraGazer;
  41265. private _padSensibilityUp;
  41266. private _padSensibilityDown;
  41267. private _leftController;
  41268. private _rightController;
  41269. /**
  41270. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41271. */
  41272. onNewMeshSelected: Observable<AbstractMesh>;
  41273. /**
  41274. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41275. * This observable will provide the mesh and the controller used to select the mesh
  41276. */
  41277. onMeshSelectedWithController: Observable<{
  41278. mesh: AbstractMesh;
  41279. controller: WebVRController;
  41280. }>;
  41281. /**
  41282. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41283. */
  41284. onNewMeshPicked: Observable<PickingInfo>;
  41285. private _circleEase;
  41286. /**
  41287. * Observable raised before camera teleportation
  41288. */
  41289. onBeforeCameraTeleport: Observable<Vector3>;
  41290. /**
  41291. * Observable raised after camera teleportation
  41292. */
  41293. onAfterCameraTeleport: Observable<Vector3>;
  41294. /**
  41295. * Observable raised when current selected mesh gets unselected
  41296. */
  41297. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41298. private _raySelectionPredicate;
  41299. /**
  41300. * To be optionaly changed by user to define custom ray selection
  41301. */
  41302. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41303. /**
  41304. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41305. */
  41306. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41307. /**
  41308. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41309. */
  41310. teleportationEnabled: boolean;
  41311. private _defaultHeight;
  41312. private _teleportationInitialized;
  41313. private _interactionsEnabled;
  41314. private _interactionsRequested;
  41315. private _displayGaze;
  41316. private _displayLaserPointer;
  41317. /**
  41318. * The mesh used to display where the user is going to teleport.
  41319. */
  41320. /**
  41321. * Sets the mesh to be used to display where the user is going to teleport.
  41322. */
  41323. teleportationTarget: Mesh;
  41324. /**
  41325. * 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
  41326. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41327. * See http://doc.babylonjs.com/resources/baking_transformations
  41328. */
  41329. gazeTrackerMesh: Mesh;
  41330. /**
  41331. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41332. */
  41333. updateGazeTrackerScale: boolean;
  41334. /**
  41335. * If the gaze trackers color should be updated when selecting meshes
  41336. */
  41337. updateGazeTrackerColor: boolean;
  41338. /**
  41339. * If the controller laser color should be updated when selecting meshes
  41340. */
  41341. updateControllerLaserColor: boolean;
  41342. /**
  41343. * The gaze tracking mesh corresponding to the left controller
  41344. */
  41345. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41346. /**
  41347. * The gaze tracking mesh corresponding to the right controller
  41348. */
  41349. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41350. /**
  41351. * If the ray of the gaze should be displayed.
  41352. */
  41353. /**
  41354. * Sets if the ray of the gaze should be displayed.
  41355. */
  41356. displayGaze: boolean;
  41357. /**
  41358. * If the ray of the LaserPointer should be displayed.
  41359. */
  41360. /**
  41361. * Sets if the ray of the LaserPointer should be displayed.
  41362. */
  41363. displayLaserPointer: boolean;
  41364. /**
  41365. * The deviceOrientationCamera used as the camera when not in VR.
  41366. */
  41367. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41368. /**
  41369. * Based on the current WebVR support, returns the current VR camera used.
  41370. */
  41371. readonly currentVRCamera: Nullable<Camera>;
  41372. /**
  41373. * The webVRCamera which is used when in VR.
  41374. */
  41375. readonly webVRCamera: WebVRFreeCamera;
  41376. /**
  41377. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41378. */
  41379. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41380. /**
  41381. * The html button that is used to trigger entering into VR.
  41382. */
  41383. readonly vrButton: Nullable<HTMLButtonElement>;
  41384. private readonly _teleportationRequestInitiated;
  41385. /**
  41386. * Defines wether or not Pointer lock should be requested when switching to
  41387. * full screen.
  41388. */
  41389. requestPointerLockOnFullScreen: boolean;
  41390. /**
  41391. * Instantiates a VRExperienceHelper.
  41392. * Helps to quickly add VR support to an existing scene.
  41393. * @param scene The scene the VRExperienceHelper belongs to.
  41394. * @param webVROptions Options to modify the vr experience helper's behavior.
  41395. */
  41396. constructor(scene: Scene,
  41397. /** Options to modify the vr experience helper's behavior. */
  41398. webVROptions?: VRExperienceHelperOptions);
  41399. private _onDefaultMeshLoaded;
  41400. private _onResize;
  41401. private _onFullscreenChange;
  41402. /**
  41403. * Gets a value indicating if we are currently in VR mode.
  41404. */
  41405. readonly isInVRMode: boolean;
  41406. private onVrDisplayPresentChange;
  41407. private onVRDisplayChanged;
  41408. private moveButtonToBottomRight;
  41409. private displayVRButton;
  41410. private updateButtonVisibility;
  41411. private _cachedAngularSensibility;
  41412. /**
  41413. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41414. * Otherwise, will use the fullscreen API.
  41415. */
  41416. enterVR(): void;
  41417. /**
  41418. * Attempt to exit VR, or fullscreen.
  41419. */
  41420. exitVR(): void;
  41421. /**
  41422. * The position of the vr experience helper.
  41423. */
  41424. /**
  41425. * Sets the position of the vr experience helper.
  41426. */
  41427. position: Vector3;
  41428. /**
  41429. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41430. */
  41431. enableInteractions(): void;
  41432. private readonly _noControllerIsActive;
  41433. private beforeRender;
  41434. private _isTeleportationFloor;
  41435. /**
  41436. * Adds a floor mesh to be used for teleportation.
  41437. * @param floorMesh the mesh to be used for teleportation.
  41438. */
  41439. addFloorMesh(floorMesh: Mesh): void;
  41440. /**
  41441. * Removes a floor mesh from being used for teleportation.
  41442. * @param floorMesh the mesh to be removed.
  41443. */
  41444. removeFloorMesh(floorMesh: Mesh): void;
  41445. /**
  41446. * Enables interactions and teleportation using the VR controllers and gaze.
  41447. * @param vrTeleportationOptions options to modify teleportation behavior.
  41448. */
  41449. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41450. private _onNewGamepadConnected;
  41451. private _tryEnableInteractionOnController;
  41452. private _onNewGamepadDisconnected;
  41453. private _enableInteractionOnController;
  41454. private _checkTeleportWithRay;
  41455. private _checkRotate;
  41456. private _checkTeleportBackwards;
  41457. private _enableTeleportationOnController;
  41458. private _createTeleportationCircles;
  41459. private _displayTeleportationTarget;
  41460. private _hideTeleportationTarget;
  41461. private _rotateCamera;
  41462. private _moveTeleportationSelectorTo;
  41463. private _workingVector;
  41464. private _workingQuaternion;
  41465. private _workingMatrix;
  41466. /**
  41467. * Teleports the users feet to the desired location
  41468. * @param location The location where the user's feet should be placed
  41469. */
  41470. teleportCamera(location: Vector3): void;
  41471. private _convertNormalToDirectionOfRay;
  41472. private _castRayAndSelectObject;
  41473. private _notifySelectedMeshUnselected;
  41474. /**
  41475. * Sets the color of the laser ray from the vr controllers.
  41476. * @param color new color for the ray.
  41477. */
  41478. changeLaserColor(color: Color3): void;
  41479. /**
  41480. * Sets the color of the ray from the vr headsets gaze.
  41481. * @param color new color for the ray.
  41482. */
  41483. changeGazeColor(color: Color3): void;
  41484. /**
  41485. * Exits VR and disposes of the vr experience helper
  41486. */
  41487. dispose(): void;
  41488. /**
  41489. * Gets the name of the VRExperienceHelper class
  41490. * @returns "VRExperienceHelper"
  41491. */
  41492. getClassName(): string;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. /**
  41497. * Manages an XRSession to work with Babylon's engine
  41498. * @see https://doc.babylonjs.com/how_to/webxr
  41499. */
  41500. export class WebXRSessionManager implements IDisposable {
  41501. private scene;
  41502. /**
  41503. * Fires every time a new xrFrame arrives which can be used to update the camera
  41504. */
  41505. onXRFrameObservable: Observable<any>;
  41506. /**
  41507. * Fires when the xr session is ended either by the device or manually done
  41508. */
  41509. onXRSessionEnded: Observable<any>;
  41510. /**
  41511. * Underlying xr session
  41512. */
  41513. session: XRSession;
  41514. /**
  41515. * Type of reference space used when creating the session
  41516. */
  41517. referenceSpace: XRReferenceSpace;
  41518. /** @hidden */
  41519. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41520. /**
  41521. * Current XR frame
  41522. */
  41523. currentFrame: Nullable<XRFrame>;
  41524. private _xrNavigator;
  41525. private baseLayer;
  41526. /**
  41527. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41528. * @param scene The scene which the session should be created for
  41529. */
  41530. constructor(scene: Scene);
  41531. /**
  41532. * Initializes the manager
  41533. * After initialization enterXR can be called to start an XR session
  41534. * @returns Promise which resolves after it is initialized
  41535. */
  41536. initializeAsync(): Promise<void>;
  41537. /**
  41538. * Initializes an xr session
  41539. * @param xrSessionMode mode to initialize
  41540. * @returns a promise which will resolve once the session has been initialized
  41541. */
  41542. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41543. /**
  41544. * Sets the reference space on the xr session
  41545. * @param referenceSpace space to set
  41546. * @returns a promise that will resolve once the reference space has been set
  41547. */
  41548. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41549. /**
  41550. * Updates the render state of the session
  41551. * @param state state to set
  41552. * @returns a promise that resolves once the render state has been updated
  41553. */
  41554. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41555. /**
  41556. * Starts rendering to the xr layer
  41557. * @returns a promise that will resolve once rendering has started
  41558. */
  41559. startRenderingToXRAsync(): Promise<void>;
  41560. /**
  41561. * Stops the xrSession and restores the renderloop
  41562. * @returns Promise which resolves after it exits XR
  41563. */
  41564. exitXRAsync(): Promise<unknown>;
  41565. /**
  41566. * Checks if a session would be supported for the creation options specified
  41567. * @param sessionMode session mode to check if supported eg. immersive-vr
  41568. * @returns true if supported
  41569. */
  41570. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41571. /**
  41572. * @hidden
  41573. * Converts the render layer of xrSession to a render target
  41574. * @param session session to create render target for
  41575. * @param scene scene the new render target should be created for
  41576. */
  41577. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41578. /**
  41579. * Disposes of the session manager
  41580. */
  41581. dispose(): void;
  41582. }
  41583. }
  41584. declare module BABYLON {
  41585. /**
  41586. * WebXR Camera which holds the views for the xrSession
  41587. * @see https://doc.babylonjs.com/how_to/webxr
  41588. */
  41589. export class WebXRCamera extends FreeCamera {
  41590. private static _TmpMatrix;
  41591. /**
  41592. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41593. * @param name the name of the camera
  41594. * @param scene the scene to add the camera to
  41595. */
  41596. constructor(name: string, scene: Scene);
  41597. private _updateNumberOfRigCameras;
  41598. /** @hidden */
  41599. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41600. /**
  41601. * Updates the cameras position from the current pose information of the XR session
  41602. * @param xrSessionManager the session containing pose information
  41603. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41604. */
  41605. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41606. }
  41607. }
  41608. declare module BABYLON {
  41609. /**
  41610. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41611. */
  41612. export class WebXRManagedOutputCanvas implements IDisposable {
  41613. private helper;
  41614. private _canvas;
  41615. /**
  41616. * xrpresent context of the canvas which can be used to display/mirror xr content
  41617. */
  41618. canvasContext: WebGLRenderingContext;
  41619. /**
  41620. * xr layer for the canvas
  41621. */
  41622. xrLayer: Nullable<XRWebGLLayer>;
  41623. /**
  41624. * Initializes the xr layer for the session
  41625. * @param xrSession xr session
  41626. * @returns a promise that will resolve once the XR Layer has been created
  41627. */
  41628. initializeXRLayerAsync(xrSession: any): any;
  41629. /**
  41630. * Initializes the canvas to be added/removed upon entering/exiting xr
  41631. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41632. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41633. */
  41634. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41635. /**
  41636. * Disposes of the object
  41637. */
  41638. dispose(): void;
  41639. private _setManagedOutputCanvas;
  41640. private _addCanvas;
  41641. private _removeCanvas;
  41642. }
  41643. }
  41644. declare module BABYLON {
  41645. /**
  41646. * States of the webXR experience
  41647. */
  41648. export enum WebXRState {
  41649. /**
  41650. * Transitioning to being in XR mode
  41651. */
  41652. ENTERING_XR = 0,
  41653. /**
  41654. * Transitioning to non XR mode
  41655. */
  41656. EXITING_XR = 1,
  41657. /**
  41658. * In XR mode and presenting
  41659. */
  41660. IN_XR = 2,
  41661. /**
  41662. * Not entered XR mode
  41663. */
  41664. NOT_IN_XR = 3
  41665. }
  41666. /**
  41667. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41668. * @see https://doc.babylonjs.com/how_to/webxr
  41669. */
  41670. export class WebXRExperienceHelper implements IDisposable {
  41671. private scene;
  41672. /**
  41673. * 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
  41674. */
  41675. container: AbstractMesh;
  41676. /**
  41677. * Camera used to render xr content
  41678. */
  41679. camera: WebXRCamera;
  41680. /**
  41681. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41682. */
  41683. state: WebXRState;
  41684. private _setState;
  41685. private static _TmpVector;
  41686. /**
  41687. * Fires when the state of the experience helper has changed
  41688. */
  41689. onStateChangedObservable: Observable<WebXRState>;
  41690. /** Session manager used to keep track of xr session */
  41691. sessionManager: WebXRSessionManager;
  41692. private _nonVRCamera;
  41693. private _originalSceneAutoClear;
  41694. private _supported;
  41695. /**
  41696. * Creates the experience helper
  41697. * @param scene the scene to attach the experience helper to
  41698. * @returns a promise for the experience helper
  41699. */
  41700. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41701. /**
  41702. * Creates a WebXRExperienceHelper
  41703. * @param scene The scene the helper should be created in
  41704. */
  41705. private constructor();
  41706. /**
  41707. * Exits XR mode and returns the scene to its original state
  41708. * @returns promise that resolves after xr mode has exited
  41709. */
  41710. exitXRAsync(): Promise<unknown>;
  41711. /**
  41712. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41713. * @param sessionCreationOptions options for the XR session
  41714. * @param referenceSpaceType frame of reference of the XR session
  41715. * @param outputCanvas the output canvas that will be used to enter XR mode
  41716. * @returns promise that resolves after xr mode has entered
  41717. */
  41718. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41719. /**
  41720. * Updates the global position of the camera by moving the camera's container
  41721. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41722. * @param position The desired global position of the camera
  41723. */
  41724. setPositionOfCameraUsingContainer(position: Vector3): void;
  41725. /**
  41726. * Rotates the xr camera by rotating the camera's container around the camera's position
  41727. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41728. * @param rotation the desired quaternion rotation to apply to the camera
  41729. */
  41730. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41731. /**
  41732. * Disposes of the experience helper
  41733. */
  41734. dispose(): void;
  41735. }
  41736. }
  41737. declare module BABYLON {
  41738. /**
  41739. * Button which can be used to enter a different mode of XR
  41740. */
  41741. export class WebXREnterExitUIButton {
  41742. /** button element */
  41743. element: HTMLElement;
  41744. /** XR initialization options for the button */
  41745. sessionMode: XRSessionMode;
  41746. /** Reference space type */
  41747. referenceSpaceType: XRReferenceSpaceType;
  41748. /**
  41749. * Creates a WebXREnterExitUIButton
  41750. * @param element button element
  41751. * @param sessionMode XR initialization session mode
  41752. * @param referenceSpaceType the type of reference space to be used
  41753. */
  41754. constructor(
  41755. /** button element */
  41756. element: HTMLElement,
  41757. /** XR initialization options for the button */
  41758. sessionMode: XRSessionMode,
  41759. /** Reference space type */
  41760. referenceSpaceType: XRReferenceSpaceType);
  41761. /**
  41762. * Overwritable function which can be used to update the button's visuals when the state changes
  41763. * @param activeButton the current active button in the UI
  41764. */
  41765. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41766. }
  41767. /**
  41768. * Options to create the webXR UI
  41769. */
  41770. export class WebXREnterExitUIOptions {
  41771. /**
  41772. * Context to enter xr with
  41773. */
  41774. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41775. /**
  41776. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41777. */
  41778. customButtons?: Array<WebXREnterExitUIButton>;
  41779. }
  41780. /**
  41781. * UI to allow the user to enter/exit XR mode
  41782. */
  41783. export class WebXREnterExitUI implements IDisposable {
  41784. private scene;
  41785. private _overlay;
  41786. private _buttons;
  41787. private _activeButton;
  41788. /**
  41789. * Fired every time the active button is changed.
  41790. *
  41791. * When xr is entered via a button that launches xr that button will be the callback parameter
  41792. *
  41793. * When exiting xr the callback parameter will be null)
  41794. */
  41795. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41796. /**
  41797. * Creates UI to allow the user to enter/exit XR mode
  41798. * @param scene the scene to add the ui to
  41799. * @param helper the xr experience helper to enter/exit xr with
  41800. * @param options options to configure the UI
  41801. * @returns the created ui
  41802. */
  41803. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41804. private constructor();
  41805. private _updateButtons;
  41806. /**
  41807. * Disposes of the object
  41808. */
  41809. dispose(): void;
  41810. }
  41811. }
  41812. declare module BABYLON {
  41813. /**
  41814. * Represents an XR input
  41815. */
  41816. export class WebXRController {
  41817. private scene;
  41818. /** The underlying input source for the controller */
  41819. inputSource: XRInputSource;
  41820. private parentContainer;
  41821. /**
  41822. * 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
  41823. */
  41824. grip?: AbstractMesh;
  41825. /**
  41826. * Pointer which can be used to select objects or attach a visible laser to
  41827. */
  41828. pointer: AbstractMesh;
  41829. /**
  41830. * Event that fires when the controller is removed/disposed
  41831. */
  41832. onDisposeObservable: Observable<{}>;
  41833. private _tmpMatrix;
  41834. private _tmpQuaternion;
  41835. private _tmpVector;
  41836. /**
  41837. * Creates the controller
  41838. * @see https://doc.babylonjs.com/how_to/webxr
  41839. * @param scene the scene which the controller should be associated to
  41840. * @param inputSource the underlying input source for the controller
  41841. * @param parentContainer parent that the controller meshes should be children of
  41842. */
  41843. constructor(scene: Scene,
  41844. /** The underlying input source for the controller */
  41845. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41846. /**
  41847. * Updates the controller pose based on the given XRFrame
  41848. * @param xrFrame xr frame to update the pose with
  41849. * @param referenceSpace reference space to use
  41850. */
  41851. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41852. /**
  41853. * Gets a world space ray coming from the controller
  41854. * @param result the resulting ray
  41855. */
  41856. getWorldPointerRayToRef(result: Ray): void;
  41857. /**
  41858. * Disposes of the object
  41859. */
  41860. dispose(): void;
  41861. }
  41862. }
  41863. declare module BABYLON {
  41864. /**
  41865. * XR input used to track XR inputs such as controllers/rays
  41866. */
  41867. export class WebXRInput implements IDisposable {
  41868. /**
  41869. * Base experience the input listens to
  41870. */
  41871. baseExperience: WebXRExperienceHelper;
  41872. /**
  41873. * XR controllers being tracked
  41874. */
  41875. controllers: Array<WebXRController>;
  41876. private _frameObserver;
  41877. private _stateObserver;
  41878. /**
  41879. * Event when a controller has been connected/added
  41880. */
  41881. onControllerAddedObservable: Observable<WebXRController>;
  41882. /**
  41883. * Event when a controller has been removed/disconnected
  41884. */
  41885. onControllerRemovedObservable: Observable<WebXRController>;
  41886. /**
  41887. * Initializes the WebXRInput
  41888. * @param baseExperience experience helper which the input should be created for
  41889. */
  41890. constructor(
  41891. /**
  41892. * Base experience the input listens to
  41893. */
  41894. baseExperience: WebXRExperienceHelper);
  41895. private _onInputSourcesChange;
  41896. private _addAndRemoveControllers;
  41897. /**
  41898. * Disposes of the object
  41899. */
  41900. dispose(): void;
  41901. }
  41902. }
  41903. declare module BABYLON {
  41904. /**
  41905. * Enables teleportation
  41906. */
  41907. export class WebXRControllerTeleportation {
  41908. private _teleportationFillColor;
  41909. private _teleportationBorderColor;
  41910. private _tmpRay;
  41911. private _tmpVector;
  41912. /**
  41913. * Creates a WebXRControllerTeleportation
  41914. * @param input input manager to add teleportation to
  41915. * @param floorMeshes floormeshes which can be teleported to
  41916. */
  41917. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * Handles pointer input automatically for the pointer of XR controllers
  41923. */
  41924. export class WebXRControllerPointerSelection {
  41925. private static _idCounter;
  41926. private _tmpRay;
  41927. /**
  41928. * Creates a WebXRControllerPointerSelection
  41929. * @param input input manager to setup pointer selection
  41930. */
  41931. constructor(input: WebXRInput);
  41932. private _convertNormalToDirectionOfRay;
  41933. private _updatePointerDistance;
  41934. }
  41935. }
  41936. declare module BABYLON {
  41937. /**
  41938. * Class used to represent data loading progression
  41939. */
  41940. export class SceneLoaderProgressEvent {
  41941. /** defines if data length to load can be evaluated */
  41942. readonly lengthComputable: boolean;
  41943. /** defines the loaded data length */
  41944. readonly loaded: number;
  41945. /** defines the data length to load */
  41946. readonly total: number;
  41947. /**
  41948. * Create a new progress event
  41949. * @param lengthComputable defines if data length to load can be evaluated
  41950. * @param loaded defines the loaded data length
  41951. * @param total defines the data length to load
  41952. */
  41953. constructor(
  41954. /** defines if data length to load can be evaluated */
  41955. lengthComputable: boolean,
  41956. /** defines the loaded data length */
  41957. loaded: number,
  41958. /** defines the data length to load */
  41959. total: number);
  41960. /**
  41961. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41962. * @param event defines the source event
  41963. * @returns a new SceneLoaderProgressEvent
  41964. */
  41965. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41966. }
  41967. /**
  41968. * Interface used by SceneLoader plugins to define supported file extensions
  41969. */
  41970. export interface ISceneLoaderPluginExtensions {
  41971. /**
  41972. * Defines the list of supported extensions
  41973. */
  41974. [extension: string]: {
  41975. isBinary: boolean;
  41976. };
  41977. }
  41978. /**
  41979. * Interface used by SceneLoader plugin factory
  41980. */
  41981. export interface ISceneLoaderPluginFactory {
  41982. /**
  41983. * Defines the name of the factory
  41984. */
  41985. name: string;
  41986. /**
  41987. * Function called to create a new plugin
  41988. * @return the new plugin
  41989. */
  41990. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41991. /**
  41992. * The callback that returns true if the data can be directly loaded.
  41993. * @param data string containing the file data
  41994. * @returns if the data can be loaded directly
  41995. */
  41996. canDirectLoad?(data: string): boolean;
  41997. }
  41998. /**
  41999. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  42000. */
  42001. export interface ISceneLoaderPluginBase {
  42002. /**
  42003. * The friendly name of this plugin.
  42004. */
  42005. name: string;
  42006. /**
  42007. * The file extensions supported by this plugin.
  42008. */
  42009. extensions: string | ISceneLoaderPluginExtensions;
  42010. /**
  42011. * The callback called when loading from a url.
  42012. * @param scene scene loading this url
  42013. * @param url url to load
  42014. * @param onSuccess callback called when the file successfully loads
  42015. * @param onProgress callback called while file is loading (if the server supports this mode)
  42016. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42017. * @param onError callback called when the file fails to load
  42018. * @returns a file request object
  42019. */
  42020. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42021. /**
  42022. * The callback called when loading from a file object.
  42023. * @param scene scene loading this file
  42024. * @param file defines the file to load
  42025. * @param onSuccess defines the callback to call when data is loaded
  42026. * @param onProgress defines the callback to call during loading process
  42027. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42028. * @param onError defines the callback to call when an error occurs
  42029. * @returns a file request object
  42030. */
  42031. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  42032. /**
  42033. * The callback that returns true if the data can be directly loaded.
  42034. * @param data string containing the file data
  42035. * @returns if the data can be loaded directly
  42036. */
  42037. canDirectLoad?(data: string): boolean;
  42038. /**
  42039. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  42040. * @param scene scene loading this data
  42041. * @param data string containing the data
  42042. * @returns data to pass to the plugin
  42043. */
  42044. directLoad?(scene: Scene, data: string): any;
  42045. /**
  42046. * The callback that allows custom handling of the root url based on the response url.
  42047. * @param rootUrl the original root url
  42048. * @param responseURL the response url if available
  42049. * @returns the new root url
  42050. */
  42051. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  42052. }
  42053. /**
  42054. * Interface used to define a SceneLoader plugin
  42055. */
  42056. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  42057. /**
  42058. * Import meshes into a scene.
  42059. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42060. * @param scene The scene to import into
  42061. * @param data The data to import
  42062. * @param rootUrl The root url for scene and resources
  42063. * @param meshes The meshes array to import into
  42064. * @param particleSystems The particle systems array to import into
  42065. * @param skeletons The skeletons array to import into
  42066. * @param onError The callback when import fails
  42067. * @returns True if successful or false otherwise
  42068. */
  42069. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42070. /**
  42071. * Load into a scene.
  42072. * @param scene The scene to load into
  42073. * @param data The data to import
  42074. * @param rootUrl The root url for scene and resources
  42075. * @param onError The callback when import fails
  42076. * @returns True if successful or false otherwise
  42077. */
  42078. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42079. /**
  42080. * Load into an asset container.
  42081. * @param scene The scene to load into
  42082. * @param data The data to import
  42083. * @param rootUrl The root url for scene and resources
  42084. * @param onError The callback when import fails
  42085. * @returns The loaded asset container
  42086. */
  42087. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42088. }
  42089. /**
  42090. * Interface used to define an async SceneLoader plugin
  42091. */
  42092. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  42093. /**
  42094. * Import meshes into a scene.
  42095. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42096. * @param scene The scene to import into
  42097. * @param data The data to import
  42098. * @param rootUrl The root url for scene and resources
  42099. * @param onProgress The callback when the load progresses
  42100. * @param fileName Defines the name of the file to load
  42101. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42102. */
  42103. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42104. meshes: AbstractMesh[];
  42105. particleSystems: IParticleSystem[];
  42106. skeletons: Skeleton[];
  42107. animationGroups: AnimationGroup[];
  42108. }>;
  42109. /**
  42110. * Load into a scene.
  42111. * @param scene The scene to load into
  42112. * @param data The data to import
  42113. * @param rootUrl The root url for scene and resources
  42114. * @param onProgress The callback when the load progresses
  42115. * @param fileName Defines the name of the file to load
  42116. * @returns Nothing
  42117. */
  42118. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42119. /**
  42120. * Load into an asset container.
  42121. * @param scene The scene to load into
  42122. * @param data The data to import
  42123. * @param rootUrl The root url for scene and resources
  42124. * @param onProgress The callback when the load progresses
  42125. * @param fileName Defines the name of the file to load
  42126. * @returns The loaded asset container
  42127. */
  42128. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42129. }
  42130. /**
  42131. * Class used to load scene from various file formats using registered plugins
  42132. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42133. */
  42134. export class SceneLoader {
  42135. /**
  42136. * No logging while loading
  42137. */
  42138. static readonly NO_LOGGING: number;
  42139. /**
  42140. * Minimal logging while loading
  42141. */
  42142. static readonly MINIMAL_LOGGING: number;
  42143. /**
  42144. * Summary logging while loading
  42145. */
  42146. static readonly SUMMARY_LOGGING: number;
  42147. /**
  42148. * Detailled logging while loading
  42149. */
  42150. static readonly DETAILED_LOGGING: number;
  42151. /**
  42152. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42153. */
  42154. static ForceFullSceneLoadingForIncremental: boolean;
  42155. /**
  42156. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42157. */
  42158. static ShowLoadingScreen: boolean;
  42159. /**
  42160. * Defines the current logging level (while loading the scene)
  42161. * @ignorenaming
  42162. */
  42163. static loggingLevel: number;
  42164. /**
  42165. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42166. */
  42167. static CleanBoneMatrixWeights: boolean;
  42168. /**
  42169. * Event raised when a plugin is used to load a scene
  42170. */
  42171. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42172. private static _registeredPlugins;
  42173. private static _getDefaultPlugin;
  42174. private static _getPluginForExtension;
  42175. private static _getPluginForDirectLoad;
  42176. private static _getPluginForFilename;
  42177. private static _getDirectLoad;
  42178. private static _loadData;
  42179. private static _getFileInfo;
  42180. /**
  42181. * Gets a plugin that can load the given extension
  42182. * @param extension defines the extension to load
  42183. * @returns a plugin or null if none works
  42184. */
  42185. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42186. /**
  42187. * Gets a boolean indicating that the given extension can be loaded
  42188. * @param extension defines the extension to load
  42189. * @returns true if the extension is supported
  42190. */
  42191. static IsPluginForExtensionAvailable(extension: string): boolean;
  42192. /**
  42193. * Adds a new plugin to the list of registered plugins
  42194. * @param plugin defines the plugin to add
  42195. */
  42196. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42197. /**
  42198. * Import meshes into a scene
  42199. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42200. * @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)
  42201. * @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)
  42202. * @param scene the instance of BABYLON.Scene to append to
  42203. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42204. * @param onProgress a callback with a progress event for each file being loaded
  42205. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42206. * @param pluginExtension the extension used to determine the plugin
  42207. * @returns The loaded plugin
  42208. */
  42209. 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>;
  42210. /**
  42211. * Import meshes into a scene
  42212. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42213. * @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)
  42214. * @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)
  42215. * @param scene the instance of BABYLON.Scene to append to
  42216. * @param onProgress a callback with a progress event for each file being loaded
  42217. * @param pluginExtension the extension used to determine the plugin
  42218. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42219. */
  42220. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42221. meshes: AbstractMesh[];
  42222. particleSystems: IParticleSystem[];
  42223. skeletons: Skeleton[];
  42224. animationGroups: AnimationGroup[];
  42225. }>;
  42226. /**
  42227. * Load a scene
  42228. * @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)
  42229. * @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)
  42230. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42231. * @param onSuccess a callback with the scene when import succeeds
  42232. * @param onProgress a callback with a progress event for each file being loaded
  42233. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42234. * @param pluginExtension the extension used to determine the plugin
  42235. * @returns The loaded plugin
  42236. */
  42237. 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>;
  42238. /**
  42239. * Load a scene
  42240. * @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)
  42241. * @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)
  42242. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42243. * @param onProgress a callback with a progress event for each file being loaded
  42244. * @param pluginExtension the extension used to determine the plugin
  42245. * @returns The loaded scene
  42246. */
  42247. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42248. /**
  42249. * Append a scene
  42250. * @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)
  42251. * @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)
  42252. * @param scene is the instance of BABYLON.Scene to append to
  42253. * @param onSuccess a callback with the scene when import succeeds
  42254. * @param onProgress a callback with a progress event for each file being loaded
  42255. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42256. * @param pluginExtension the extension used to determine the plugin
  42257. * @returns The loaded plugin
  42258. */
  42259. 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>;
  42260. /**
  42261. * Append a scene
  42262. * @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)
  42263. * @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)
  42264. * @param scene is the instance of BABYLON.Scene to append to
  42265. * @param onProgress a callback with a progress event for each file being loaded
  42266. * @param pluginExtension the extension used to determine the plugin
  42267. * @returns The given scene
  42268. */
  42269. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42270. /**
  42271. * Load a scene into an asset container
  42272. * @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)
  42273. * @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)
  42274. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42275. * @param onSuccess a callback with the scene when import succeeds
  42276. * @param onProgress a callback with a progress event for each file being loaded
  42277. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42278. * @param pluginExtension the extension used to determine the plugin
  42279. * @returns The loaded plugin
  42280. */
  42281. 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>;
  42282. /**
  42283. * Load a scene into an asset container
  42284. * @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)
  42285. * @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)
  42286. * @param scene is the instance of Scene to append to
  42287. * @param onProgress a callback with a progress event for each file being loaded
  42288. * @param pluginExtension the extension used to determine the plugin
  42289. * @returns The loaded asset container
  42290. */
  42291. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42292. }
  42293. }
  42294. declare module BABYLON {
  42295. /**
  42296. * Generic Controller
  42297. */
  42298. export class GenericController extends WebVRController {
  42299. /**
  42300. * Base Url for the controller model.
  42301. */
  42302. static readonly MODEL_BASE_URL: string;
  42303. /**
  42304. * File name for the controller model.
  42305. */
  42306. static readonly MODEL_FILENAME: string;
  42307. /**
  42308. * Creates a new GenericController from a gamepad
  42309. * @param vrGamepad the gamepad that the controller should be created from
  42310. */
  42311. constructor(vrGamepad: any);
  42312. /**
  42313. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42314. * @param scene scene in which to add meshes
  42315. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42316. */
  42317. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42318. /**
  42319. * Called once for each button that changed state since the last frame
  42320. * @param buttonIdx Which button index changed
  42321. * @param state New state of the button
  42322. * @param changes Which properties on the state changed since last frame
  42323. */
  42324. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42325. }
  42326. }
  42327. declare module BABYLON {
  42328. /**
  42329. * Defines the WindowsMotionController object that the state of the windows motion controller
  42330. */
  42331. export class WindowsMotionController extends WebVRController {
  42332. /**
  42333. * The base url used to load the left and right controller models
  42334. */
  42335. static MODEL_BASE_URL: string;
  42336. /**
  42337. * The name of the left controller model file
  42338. */
  42339. static MODEL_LEFT_FILENAME: string;
  42340. /**
  42341. * The name of the right controller model file
  42342. */
  42343. static MODEL_RIGHT_FILENAME: string;
  42344. /**
  42345. * The controller name prefix for this controller type
  42346. */
  42347. static readonly GAMEPAD_ID_PREFIX: string;
  42348. /**
  42349. * The controller id pattern for this controller type
  42350. */
  42351. private static readonly GAMEPAD_ID_PATTERN;
  42352. private _loadedMeshInfo;
  42353. private readonly _mapping;
  42354. /**
  42355. * Fired when the trackpad on this controller is clicked
  42356. */
  42357. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42358. /**
  42359. * Fired when the trackpad on this controller is modified
  42360. */
  42361. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42362. /**
  42363. * The current x and y values of this controller's trackpad
  42364. */
  42365. trackpad: StickValues;
  42366. /**
  42367. * Creates a new WindowsMotionController from a gamepad
  42368. * @param vrGamepad the gamepad that the controller should be created from
  42369. */
  42370. constructor(vrGamepad: any);
  42371. /**
  42372. * Fired when the trigger on this controller is modified
  42373. */
  42374. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42375. /**
  42376. * Fired when the menu button on this controller is modified
  42377. */
  42378. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42379. /**
  42380. * Fired when the grip button on this controller is modified
  42381. */
  42382. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42383. /**
  42384. * Fired when the thumbstick button on this controller is modified
  42385. */
  42386. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42387. /**
  42388. * Fired when the touchpad button on this controller is modified
  42389. */
  42390. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42391. /**
  42392. * Fired when the touchpad values on this controller are modified
  42393. */
  42394. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42395. private _updateTrackpad;
  42396. /**
  42397. * Called once per frame by the engine.
  42398. */
  42399. update(): void;
  42400. /**
  42401. * Called once for each button that changed state since the last frame
  42402. * @param buttonIdx Which button index changed
  42403. * @param state New state of the button
  42404. * @param changes Which properties on the state changed since last frame
  42405. */
  42406. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42407. /**
  42408. * Moves the buttons on the controller mesh based on their current state
  42409. * @param buttonName the name of the button to move
  42410. * @param buttonValue the value of the button which determines the buttons new position
  42411. */
  42412. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42413. /**
  42414. * Moves the axis on the controller mesh based on its current state
  42415. * @param axis the index of the axis
  42416. * @param axisValue the value of the axis which determines the meshes new position
  42417. * @hidden
  42418. */
  42419. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42420. /**
  42421. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42422. * @param scene scene in which to add meshes
  42423. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42424. */
  42425. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42426. /**
  42427. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42428. * can be transformed by button presses and axes values, based on this._mapping.
  42429. *
  42430. * @param scene scene in which the meshes exist
  42431. * @param meshes list of meshes that make up the controller model to process
  42432. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42433. */
  42434. private processModel;
  42435. private createMeshInfo;
  42436. /**
  42437. * Gets the ray of the controller in the direction the controller is pointing
  42438. * @param length the length the resulting ray should be
  42439. * @returns a ray in the direction the controller is pointing
  42440. */
  42441. getForwardRay(length?: number): Ray;
  42442. /**
  42443. * Disposes of the controller
  42444. */
  42445. dispose(): void;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /**
  42450. * Oculus Touch Controller
  42451. */
  42452. export class OculusTouchController extends WebVRController {
  42453. /**
  42454. * Base Url for the controller model.
  42455. */
  42456. static MODEL_BASE_URL: string;
  42457. /**
  42458. * File name for the left controller model.
  42459. */
  42460. static MODEL_LEFT_FILENAME: string;
  42461. /**
  42462. * File name for the right controller model.
  42463. */
  42464. static MODEL_RIGHT_FILENAME: string;
  42465. /**
  42466. * Base Url for the Quest controller model.
  42467. */
  42468. static QUEST_MODEL_BASE_URL: string;
  42469. /**
  42470. * @hidden
  42471. * If the controllers are running on a device that needs the updated Quest controller models
  42472. */
  42473. static _IsQuest: boolean;
  42474. /**
  42475. * Fired when the secondary trigger on this controller is modified
  42476. */
  42477. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42478. /**
  42479. * Fired when the thumb rest on this controller is modified
  42480. */
  42481. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42482. /**
  42483. * Creates a new OculusTouchController from a gamepad
  42484. * @param vrGamepad the gamepad that the controller should be created from
  42485. */
  42486. constructor(vrGamepad: any);
  42487. /**
  42488. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42489. * @param scene scene in which to add meshes
  42490. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42491. */
  42492. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42493. /**
  42494. * Fired when the A button on this controller is modified
  42495. */
  42496. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42497. /**
  42498. * Fired when the B button on this controller is modified
  42499. */
  42500. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42501. /**
  42502. * Fired when the X button on this controller is modified
  42503. */
  42504. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42505. /**
  42506. * Fired when the Y button on this controller is modified
  42507. */
  42508. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42509. /**
  42510. * Called once for each button that changed state since the last frame
  42511. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42512. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42513. * 2) secondary trigger (same)
  42514. * 3) A (right) X (left), touch, pressed = value
  42515. * 4) B / Y
  42516. * 5) thumb rest
  42517. * @param buttonIdx Which button index changed
  42518. * @param state New state of the button
  42519. * @param changes Which properties on the state changed since last frame
  42520. */
  42521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * Vive Controller
  42527. */
  42528. export class ViveController extends WebVRController {
  42529. /**
  42530. * Base Url for the controller model.
  42531. */
  42532. static MODEL_BASE_URL: string;
  42533. /**
  42534. * File name for the controller model.
  42535. */
  42536. static MODEL_FILENAME: string;
  42537. /**
  42538. * Creates a new ViveController from a gamepad
  42539. * @param vrGamepad the gamepad that the controller should be created from
  42540. */
  42541. constructor(vrGamepad: any);
  42542. /**
  42543. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42544. * @param scene scene in which to add meshes
  42545. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42546. */
  42547. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42548. /**
  42549. * Fired when the left button on this controller is modified
  42550. */
  42551. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42552. /**
  42553. * Fired when the right button on this controller is modified
  42554. */
  42555. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42556. /**
  42557. * Fired when the menu button on this controller is modified
  42558. */
  42559. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42560. /**
  42561. * Called once for each button that changed state since the last frame
  42562. * Vive mapping:
  42563. * 0: touchpad
  42564. * 1: trigger
  42565. * 2: left AND right buttons
  42566. * 3: menu button
  42567. * @param buttonIdx Which button index changed
  42568. * @param state New state of the button
  42569. * @param changes Which properties on the state changed since last frame
  42570. */
  42571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42572. }
  42573. }
  42574. declare module BABYLON {
  42575. /**
  42576. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42577. */
  42578. export class WebXRControllerModelLoader {
  42579. /**
  42580. * Creates the WebXRControllerModelLoader
  42581. * @param input xr input that creates the controllers
  42582. */
  42583. constructor(input: WebXRInput);
  42584. }
  42585. }
  42586. declare module BABYLON {
  42587. /**
  42588. * Contains an array of blocks representing the octree
  42589. */
  42590. export interface IOctreeContainer<T> {
  42591. /**
  42592. * Blocks within the octree
  42593. */
  42594. blocks: Array<OctreeBlock<T>>;
  42595. }
  42596. /**
  42597. * Class used to store a cell in an octree
  42598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42599. */
  42600. export class OctreeBlock<T> {
  42601. /**
  42602. * Gets the content of the current block
  42603. */
  42604. entries: T[];
  42605. /**
  42606. * Gets the list of block children
  42607. */
  42608. blocks: Array<OctreeBlock<T>>;
  42609. private _depth;
  42610. private _maxDepth;
  42611. private _capacity;
  42612. private _minPoint;
  42613. private _maxPoint;
  42614. private _boundingVectors;
  42615. private _creationFunc;
  42616. /**
  42617. * Creates a new block
  42618. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42619. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42620. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42621. * @param depth defines the current depth of this block in the octree
  42622. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42623. * @param creationFunc defines a callback to call when an element is added to the block
  42624. */
  42625. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42626. /**
  42627. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42628. */
  42629. readonly capacity: number;
  42630. /**
  42631. * Gets the minimum vector (in world space) of the block's bounding box
  42632. */
  42633. readonly minPoint: Vector3;
  42634. /**
  42635. * Gets the maximum vector (in world space) of the block's bounding box
  42636. */
  42637. readonly maxPoint: Vector3;
  42638. /**
  42639. * Add a new element to this block
  42640. * @param entry defines the element to add
  42641. */
  42642. addEntry(entry: T): void;
  42643. /**
  42644. * Remove an element from this block
  42645. * @param entry defines the element to remove
  42646. */
  42647. removeEntry(entry: T): void;
  42648. /**
  42649. * Add an array of elements to this block
  42650. * @param entries defines the array of elements to add
  42651. */
  42652. addEntries(entries: T[]): void;
  42653. /**
  42654. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42655. * @param frustumPlanes defines the frustum planes to test
  42656. * @param selection defines the array to store current content if selection is positive
  42657. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42658. */
  42659. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42660. /**
  42661. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42662. * @param sphereCenter defines the bounding sphere center
  42663. * @param sphereRadius defines the bounding sphere radius
  42664. * @param selection defines the array to store current content if selection is positive
  42665. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42666. */
  42667. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42668. /**
  42669. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42670. * @param ray defines the ray to test with
  42671. * @param selection defines the array to store current content if selection is positive
  42672. */
  42673. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42674. /**
  42675. * Subdivide the content into child blocks (this block will then be empty)
  42676. */
  42677. createInnerBlocks(): void;
  42678. /**
  42679. * @hidden
  42680. */
  42681. 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;
  42682. }
  42683. }
  42684. declare module BABYLON {
  42685. /**
  42686. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42687. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42688. */
  42689. export class Octree<T> {
  42690. /** 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.) */
  42691. maxDepth: number;
  42692. /**
  42693. * Blocks within the octree containing objects
  42694. */
  42695. blocks: Array<OctreeBlock<T>>;
  42696. /**
  42697. * Content stored in the octree
  42698. */
  42699. dynamicContent: T[];
  42700. private _maxBlockCapacity;
  42701. private _selectionContent;
  42702. private _creationFunc;
  42703. /**
  42704. * Creates a octree
  42705. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42706. * @param creationFunc function to be used to instatiate the octree
  42707. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42708. * @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.)
  42709. */
  42710. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42711. /** 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.) */
  42712. maxDepth?: number);
  42713. /**
  42714. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42715. * @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);
  42716. * @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);
  42717. * @param entries meshes to be added to the octree blocks
  42718. */
  42719. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42720. /**
  42721. * Adds a mesh to the octree
  42722. * @param entry Mesh to add to the octree
  42723. */
  42724. addMesh(entry: T): void;
  42725. /**
  42726. * Remove an element from the octree
  42727. * @param entry defines the element to remove
  42728. */
  42729. removeMesh(entry: T): void;
  42730. /**
  42731. * Selects an array of meshes within the frustum
  42732. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42733. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42734. * @returns array of meshes within the frustum
  42735. */
  42736. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42737. /**
  42738. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42739. * @param sphereCenter defines the bounding sphere center
  42740. * @param sphereRadius defines the bounding sphere radius
  42741. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42742. * @returns an array of objects that intersect the sphere
  42743. */
  42744. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42745. /**
  42746. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42747. * @param ray defines the ray to test with
  42748. * @returns array of intersected objects
  42749. */
  42750. intersectsRay(ray: Ray): SmartArray<T>;
  42751. /**
  42752. * Adds a mesh into the octree block if it intersects the block
  42753. */
  42754. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42755. /**
  42756. * Adds a submesh into the octree block if it intersects the block
  42757. */
  42758. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42759. }
  42760. }
  42761. declare module BABYLON {
  42762. interface Scene {
  42763. /**
  42764. * @hidden
  42765. * Backing Filed
  42766. */
  42767. _selectionOctree: Octree<AbstractMesh>;
  42768. /**
  42769. * Gets the octree used to boost mesh selection (picking)
  42770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42771. */
  42772. selectionOctree: Octree<AbstractMesh>;
  42773. /**
  42774. * Creates or updates the octree used to boost selection (picking)
  42775. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42776. * @param maxCapacity defines the maximum capacity per leaf
  42777. * @param maxDepth defines the maximum depth of the octree
  42778. * @returns an octree of AbstractMesh
  42779. */
  42780. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42781. }
  42782. interface AbstractMesh {
  42783. /**
  42784. * @hidden
  42785. * Backing Field
  42786. */
  42787. _submeshesOctree: Octree<SubMesh>;
  42788. /**
  42789. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42790. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42791. * @param maxCapacity defines the maximum size of each block (64 by default)
  42792. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42793. * @returns the new octree
  42794. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42795. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42796. */
  42797. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42798. }
  42799. /**
  42800. * Defines the octree scene component responsible to manage any octrees
  42801. * in a given scene.
  42802. */
  42803. export class OctreeSceneComponent {
  42804. /**
  42805. * The component name help to identify the component in the list of scene components.
  42806. */
  42807. readonly name: string;
  42808. /**
  42809. * The scene the component belongs to.
  42810. */
  42811. scene: Scene;
  42812. /**
  42813. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42814. */
  42815. readonly checksIsEnabled: boolean;
  42816. /**
  42817. * Creates a new instance of the component for the given scene
  42818. * @param scene Defines the scene to register the component in
  42819. */
  42820. constructor(scene: Scene);
  42821. /**
  42822. * Registers the component in a given scene
  42823. */
  42824. register(): void;
  42825. /**
  42826. * Return the list of active meshes
  42827. * @returns the list of active meshes
  42828. */
  42829. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42830. /**
  42831. * Return the list of active sub meshes
  42832. * @param mesh The mesh to get the candidates sub meshes from
  42833. * @returns the list of active sub meshes
  42834. */
  42835. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42836. private _tempRay;
  42837. /**
  42838. * Return the list of sub meshes intersecting with a given local ray
  42839. * @param mesh defines the mesh to find the submesh for
  42840. * @param localRay defines the ray in local space
  42841. * @returns the list of intersecting sub meshes
  42842. */
  42843. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42844. /**
  42845. * Return the list of sub meshes colliding with a collider
  42846. * @param mesh defines the mesh to find the submesh for
  42847. * @param collider defines the collider to evaluate the collision against
  42848. * @returns the list of colliding sub meshes
  42849. */
  42850. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42851. /**
  42852. * Rebuilds the elements related to this component in case of
  42853. * context lost for instance.
  42854. */
  42855. rebuild(): void;
  42856. /**
  42857. * Disposes the component and the associated ressources.
  42858. */
  42859. dispose(): void;
  42860. }
  42861. }
  42862. declare module BABYLON {
  42863. /**
  42864. * Renders a layer on top of an existing scene
  42865. */
  42866. export class UtilityLayerRenderer implements IDisposable {
  42867. /** the original scene that will be rendered on top of */
  42868. originalScene: Scene;
  42869. private _pointerCaptures;
  42870. private _lastPointerEvents;
  42871. private static _DefaultUtilityLayer;
  42872. private static _DefaultKeepDepthUtilityLayer;
  42873. private _sharedGizmoLight;
  42874. private _renderCamera;
  42875. /**
  42876. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42877. * @returns the camera that is used when rendering the utility layer
  42878. */
  42879. getRenderCamera(): Nullable<Camera>;
  42880. /**
  42881. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42882. * @param cam the camera that should be used when rendering the utility layer
  42883. */
  42884. setRenderCamera(cam: Nullable<Camera>): void;
  42885. /**
  42886. * @hidden
  42887. * Light which used by gizmos to get light shading
  42888. */
  42889. _getSharedGizmoLight(): HemisphericLight;
  42890. /**
  42891. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42892. */
  42893. pickUtilitySceneFirst: boolean;
  42894. /**
  42895. * 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)
  42896. */
  42897. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42898. /**
  42899. * 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)
  42900. */
  42901. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42902. /**
  42903. * The scene that is rendered on top of the original scene
  42904. */
  42905. utilityLayerScene: Scene;
  42906. /**
  42907. * If the utility layer should automatically be rendered on top of existing scene
  42908. */
  42909. shouldRender: boolean;
  42910. /**
  42911. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42912. */
  42913. onlyCheckPointerDownEvents: boolean;
  42914. /**
  42915. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42916. */
  42917. processAllEvents: boolean;
  42918. /**
  42919. * Observable raised when the pointer move from the utility layer scene to the main scene
  42920. */
  42921. onPointerOutObservable: Observable<number>;
  42922. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42923. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42924. private _afterRenderObserver;
  42925. private _sceneDisposeObserver;
  42926. private _originalPointerObserver;
  42927. /**
  42928. * Instantiates a UtilityLayerRenderer
  42929. * @param originalScene the original scene that will be rendered on top of
  42930. * @param handleEvents boolean indicating if the utility layer should handle events
  42931. */
  42932. constructor(
  42933. /** the original scene that will be rendered on top of */
  42934. originalScene: Scene, handleEvents?: boolean);
  42935. private _notifyObservers;
  42936. /**
  42937. * Renders the utility layers scene on top of the original scene
  42938. */
  42939. render(): void;
  42940. /**
  42941. * Disposes of the renderer
  42942. */
  42943. dispose(): void;
  42944. private _updateCamera;
  42945. }
  42946. }
  42947. declare module BABYLON {
  42948. /**
  42949. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42950. */
  42951. export class Gizmo implements IDisposable {
  42952. /** The utility layer the gizmo will be added to */
  42953. gizmoLayer: UtilityLayerRenderer;
  42954. /**
  42955. * The root mesh of the gizmo
  42956. */
  42957. _rootMesh: Mesh;
  42958. private _attachedMesh;
  42959. /**
  42960. * Ratio for the scale of the gizmo (Default: 1)
  42961. */
  42962. scaleRatio: number;
  42963. /**
  42964. * If a custom mesh has been set (Default: false)
  42965. */
  42966. protected _customMeshSet: boolean;
  42967. /**
  42968. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42969. * * When set, interactions will be enabled
  42970. */
  42971. attachedMesh: Nullable<AbstractMesh>;
  42972. /**
  42973. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42974. * @param mesh The mesh to replace the default mesh of the gizmo
  42975. */
  42976. setCustomMesh(mesh: Mesh): void;
  42977. /**
  42978. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42979. */
  42980. updateGizmoRotationToMatchAttachedMesh: boolean;
  42981. /**
  42982. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42983. */
  42984. updateGizmoPositionToMatchAttachedMesh: boolean;
  42985. /**
  42986. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42987. */
  42988. updateScale: boolean;
  42989. protected _interactionsEnabled: boolean;
  42990. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42991. private _beforeRenderObserver;
  42992. private _tempVector;
  42993. /**
  42994. * Creates a gizmo
  42995. * @param gizmoLayer The utility layer the gizmo will be added to
  42996. */
  42997. constructor(
  42998. /** The utility layer the gizmo will be added to */
  42999. gizmoLayer?: UtilityLayerRenderer);
  43000. /**
  43001. * Updates the gizmo to match the attached mesh's position/rotation
  43002. */
  43003. protected _update(): void;
  43004. /**
  43005. * Disposes of the gizmo
  43006. */
  43007. dispose(): void;
  43008. }
  43009. }
  43010. declare module BABYLON {
  43011. /**
  43012. * Single plane drag gizmo
  43013. */
  43014. export class PlaneDragGizmo extends Gizmo {
  43015. /**
  43016. * Drag behavior responsible for the gizmos dragging interactions
  43017. */
  43018. dragBehavior: PointerDragBehavior;
  43019. private _pointerObserver;
  43020. /**
  43021. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43022. */
  43023. snapDistance: number;
  43024. /**
  43025. * Event that fires each time the gizmo snaps to a new location.
  43026. * * snapDistance is the the change in distance
  43027. */
  43028. onSnapObservable: Observable<{
  43029. snapDistance: number;
  43030. }>;
  43031. private _plane;
  43032. private _coloredMaterial;
  43033. private _hoverMaterial;
  43034. private _isEnabled;
  43035. private _parent;
  43036. /** @hidden */
  43037. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43038. /** @hidden */
  43039. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43040. /**
  43041. * Creates a PlaneDragGizmo
  43042. * @param gizmoLayer The utility layer the gizmo will be added to
  43043. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43044. * @param color The color of the gizmo
  43045. */
  43046. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43047. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43048. /**
  43049. * If the gizmo is enabled
  43050. */
  43051. isEnabled: boolean;
  43052. /**
  43053. * Disposes of the gizmo
  43054. */
  43055. dispose(): void;
  43056. }
  43057. }
  43058. declare module BABYLON {
  43059. /**
  43060. * Gizmo that enables dragging a mesh along 3 axis
  43061. */
  43062. export class PositionGizmo extends Gizmo {
  43063. /**
  43064. * Internal gizmo used for interactions on the x axis
  43065. */
  43066. xGizmo: AxisDragGizmo;
  43067. /**
  43068. * Internal gizmo used for interactions on the y axis
  43069. */
  43070. yGizmo: AxisDragGizmo;
  43071. /**
  43072. * Internal gizmo used for interactions on the z axis
  43073. */
  43074. zGizmo: AxisDragGizmo;
  43075. /**
  43076. * Internal gizmo used for interactions on the yz plane
  43077. */
  43078. xPlaneGizmo: PlaneDragGizmo;
  43079. /**
  43080. * Internal gizmo used for interactions on the xz plane
  43081. */
  43082. yPlaneGizmo: PlaneDragGizmo;
  43083. /**
  43084. * Internal gizmo used for interactions on the xy plane
  43085. */
  43086. zPlaneGizmo: PlaneDragGizmo;
  43087. /**
  43088. * private variables
  43089. */
  43090. private _meshAttached;
  43091. private _updateGizmoRotationToMatchAttachedMesh;
  43092. private _snapDistance;
  43093. private _scaleRatio;
  43094. /** Fires an event when any of it's sub gizmos are dragged */
  43095. onDragStartObservable: Observable<unknown>;
  43096. /** Fires an event when any of it's sub gizmos are released from dragging */
  43097. onDragEndObservable: Observable<unknown>;
  43098. /**
  43099. * If set to true, planar drag is enabled
  43100. */
  43101. private _planarGizmoEnabled;
  43102. attachedMesh: Nullable<AbstractMesh>;
  43103. /**
  43104. * Creates a PositionGizmo
  43105. * @param gizmoLayer The utility layer the gizmo will be added to
  43106. */
  43107. constructor(gizmoLayer?: UtilityLayerRenderer);
  43108. /**
  43109. * If the planar drag gizmo is enabled
  43110. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43111. */
  43112. planarGizmoEnabled: boolean;
  43113. updateGizmoRotationToMatchAttachedMesh: boolean;
  43114. /**
  43115. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43116. */
  43117. snapDistance: number;
  43118. /**
  43119. * Ratio for the scale of the gizmo (Default: 1)
  43120. */
  43121. scaleRatio: number;
  43122. /**
  43123. * Disposes of the gizmo
  43124. */
  43125. dispose(): void;
  43126. /**
  43127. * CustomMeshes are not supported by this gizmo
  43128. * @param mesh The mesh to replace the default mesh of the gizmo
  43129. */
  43130. setCustomMesh(mesh: Mesh): void;
  43131. }
  43132. }
  43133. declare module BABYLON {
  43134. /**
  43135. * Single axis drag gizmo
  43136. */
  43137. export class AxisDragGizmo extends Gizmo {
  43138. /**
  43139. * Drag behavior responsible for the gizmos dragging interactions
  43140. */
  43141. dragBehavior: PointerDragBehavior;
  43142. private _pointerObserver;
  43143. /**
  43144. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43145. */
  43146. snapDistance: number;
  43147. /**
  43148. * Event that fires each time the gizmo snaps to a new location.
  43149. * * snapDistance is the the change in distance
  43150. */
  43151. onSnapObservable: Observable<{
  43152. snapDistance: number;
  43153. }>;
  43154. private _isEnabled;
  43155. private _parent;
  43156. private _arrow;
  43157. private _coloredMaterial;
  43158. private _hoverMaterial;
  43159. /** @hidden */
  43160. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43161. /** @hidden */
  43162. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43163. /**
  43164. * Creates an AxisDragGizmo
  43165. * @param gizmoLayer The utility layer the gizmo will be added to
  43166. * @param dragAxis The axis which the gizmo will be able to drag on
  43167. * @param color The color of the gizmo
  43168. */
  43169. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43171. /**
  43172. * If the gizmo is enabled
  43173. */
  43174. isEnabled: boolean;
  43175. /**
  43176. * Disposes of the gizmo
  43177. */
  43178. dispose(): void;
  43179. }
  43180. }
  43181. declare module BABYLON.Debug {
  43182. /**
  43183. * The Axes viewer will show 3 axes in a specific point in space
  43184. */
  43185. export class AxesViewer {
  43186. private _xAxis;
  43187. private _yAxis;
  43188. private _zAxis;
  43189. private _scaleLinesFactor;
  43190. private _instanced;
  43191. /**
  43192. * Gets the hosting scene
  43193. */
  43194. scene: Scene;
  43195. /**
  43196. * Gets or sets a number used to scale line length
  43197. */
  43198. scaleLines: number;
  43199. /** Gets the node hierarchy used to render x-axis */
  43200. readonly xAxis: TransformNode;
  43201. /** Gets the node hierarchy used to render y-axis */
  43202. readonly yAxis: TransformNode;
  43203. /** Gets the node hierarchy used to render z-axis */
  43204. readonly zAxis: TransformNode;
  43205. /**
  43206. * Creates a new AxesViewer
  43207. * @param scene defines the hosting scene
  43208. * @param scaleLines defines a number used to scale line length (1 by default)
  43209. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43210. * @param xAxis defines the node hierarchy used to render the x-axis
  43211. * @param yAxis defines the node hierarchy used to render the y-axis
  43212. * @param zAxis defines the node hierarchy used to render the z-axis
  43213. */
  43214. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43215. /**
  43216. * Force the viewer to update
  43217. * @param position defines the position of the viewer
  43218. * @param xaxis defines the x axis of the viewer
  43219. * @param yaxis defines the y axis of the viewer
  43220. * @param zaxis defines the z axis of the viewer
  43221. */
  43222. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43223. /**
  43224. * Creates an instance of this axes viewer.
  43225. * @returns a new axes viewer with instanced meshes
  43226. */
  43227. createInstance(): AxesViewer;
  43228. /** Releases resources */
  43229. dispose(): void;
  43230. private static _SetRenderingGroupId;
  43231. }
  43232. }
  43233. declare module BABYLON.Debug {
  43234. /**
  43235. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43236. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43237. */
  43238. export class BoneAxesViewer extends AxesViewer {
  43239. /**
  43240. * Gets or sets the target mesh where to display the axes viewer
  43241. */
  43242. mesh: Nullable<Mesh>;
  43243. /**
  43244. * Gets or sets the target bone where to display the axes viewer
  43245. */
  43246. bone: Nullable<Bone>;
  43247. /** Gets current position */
  43248. pos: Vector3;
  43249. /** Gets direction of X axis */
  43250. xaxis: Vector3;
  43251. /** Gets direction of Y axis */
  43252. yaxis: Vector3;
  43253. /** Gets direction of Z axis */
  43254. zaxis: Vector3;
  43255. /**
  43256. * Creates a new BoneAxesViewer
  43257. * @param scene defines the hosting scene
  43258. * @param bone defines the target bone
  43259. * @param mesh defines the target mesh
  43260. * @param scaleLines defines a scaling factor for line length (1 by default)
  43261. */
  43262. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43263. /**
  43264. * Force the viewer to update
  43265. */
  43266. update(): void;
  43267. /** Releases resources */
  43268. dispose(): void;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /**
  43273. * Interface used to define scene explorer extensibility option
  43274. */
  43275. export interface IExplorerExtensibilityOption {
  43276. /**
  43277. * Define the option label
  43278. */
  43279. label: string;
  43280. /**
  43281. * Defines the action to execute on click
  43282. */
  43283. action: (entity: any) => void;
  43284. }
  43285. /**
  43286. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43287. */
  43288. export interface IExplorerExtensibilityGroup {
  43289. /**
  43290. * Defines a predicate to test if a given type mut be extended
  43291. */
  43292. predicate: (entity: any) => boolean;
  43293. /**
  43294. * Gets the list of options added to a type
  43295. */
  43296. entries: IExplorerExtensibilityOption[];
  43297. }
  43298. /**
  43299. * Interface used to define the options to use to create the Inspector
  43300. */
  43301. export interface IInspectorOptions {
  43302. /**
  43303. * Display in overlay mode (default: false)
  43304. */
  43305. overlay?: boolean;
  43306. /**
  43307. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43308. */
  43309. globalRoot?: HTMLElement;
  43310. /**
  43311. * Display the Scene explorer
  43312. */
  43313. showExplorer?: boolean;
  43314. /**
  43315. * Display the property inspector
  43316. */
  43317. showInspector?: boolean;
  43318. /**
  43319. * Display in embed mode (both panes on the right)
  43320. */
  43321. embedMode?: boolean;
  43322. /**
  43323. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43324. */
  43325. handleResize?: boolean;
  43326. /**
  43327. * Allow the panes to popup (default: true)
  43328. */
  43329. enablePopup?: boolean;
  43330. /**
  43331. * Allow the panes to be closed by users (default: true)
  43332. */
  43333. enableClose?: boolean;
  43334. /**
  43335. * Optional list of extensibility entries
  43336. */
  43337. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43338. /**
  43339. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43340. */
  43341. inspectorURL?: string;
  43342. }
  43343. interface Scene {
  43344. /**
  43345. * @hidden
  43346. * Backing field
  43347. */
  43348. _debugLayer: DebugLayer;
  43349. /**
  43350. * Gets the debug layer (aka Inspector) associated with the scene
  43351. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43352. */
  43353. debugLayer: DebugLayer;
  43354. }
  43355. /**
  43356. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43357. * what is happening in your scene
  43358. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43359. */
  43360. export class DebugLayer {
  43361. /**
  43362. * Define the url to get the inspector script from.
  43363. * By default it uses the babylonjs CDN.
  43364. * @ignoreNaming
  43365. */
  43366. static InspectorURL: string;
  43367. private _scene;
  43368. private BJSINSPECTOR;
  43369. private _onPropertyChangedObservable?;
  43370. /**
  43371. * Observable triggered when a property is changed through the inspector.
  43372. */
  43373. readonly onPropertyChangedObservable: any;
  43374. /**
  43375. * Instantiates a new debug layer.
  43376. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43377. * what is happening in your scene
  43378. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43379. * @param scene Defines the scene to inspect
  43380. */
  43381. constructor(scene: Scene);
  43382. /** Creates the inspector window. */
  43383. private _createInspector;
  43384. /**
  43385. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43386. * @param entity defines the entity to select
  43387. * @param lineContainerTitle defines the specific block to highlight
  43388. */
  43389. select(entity: any, lineContainerTitle?: string): void;
  43390. /** Get the inspector from bundle or global */
  43391. private _getGlobalInspector;
  43392. /**
  43393. * Get if the inspector is visible or not.
  43394. * @returns true if visible otherwise, false
  43395. */
  43396. isVisible(): boolean;
  43397. /**
  43398. * Hide the inspector and close its window.
  43399. */
  43400. hide(): void;
  43401. /**
  43402. * Launch the debugLayer.
  43403. * @param config Define the configuration of the inspector
  43404. * @return a promise fulfilled when the debug layer is visible
  43405. */
  43406. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43407. }
  43408. }
  43409. declare module BABYLON {
  43410. /**
  43411. * Class containing static functions to help procedurally build meshes
  43412. */
  43413. export class BoxBuilder {
  43414. /**
  43415. * Creates a box mesh
  43416. * * The parameter `size` sets the size (float) of each box side (default 1)
  43417. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43418. * * 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)
  43419. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43421. * * 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
  43422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43423. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43424. * @param name defines the name of the mesh
  43425. * @param options defines the options used to create the mesh
  43426. * @param scene defines the hosting scene
  43427. * @returns the box mesh
  43428. */
  43429. static CreateBox(name: string, options: {
  43430. size?: number;
  43431. width?: number;
  43432. height?: number;
  43433. depth?: number;
  43434. faceUV?: Vector4[];
  43435. faceColors?: Color4[];
  43436. sideOrientation?: number;
  43437. frontUVs?: Vector4;
  43438. backUVs?: Vector4;
  43439. wrap?: boolean;
  43440. topBaseAt?: number;
  43441. bottomBaseAt?: number;
  43442. updatable?: boolean;
  43443. }, scene?: Nullable<Scene>): Mesh;
  43444. }
  43445. }
  43446. declare module BABYLON {
  43447. /**
  43448. * Class containing static functions to help procedurally build meshes
  43449. */
  43450. export class SphereBuilder {
  43451. /**
  43452. * Creates a sphere mesh
  43453. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43454. * * 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`)
  43455. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43456. * * 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
  43457. * * 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)
  43458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43459. * * 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
  43460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43461. * @param name defines the name of the mesh
  43462. * @param options defines the options used to create the mesh
  43463. * @param scene defines the hosting scene
  43464. * @returns the sphere mesh
  43465. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43466. */
  43467. static CreateSphere(name: string, options: {
  43468. segments?: number;
  43469. diameter?: number;
  43470. diameterX?: number;
  43471. diameterY?: number;
  43472. diameterZ?: number;
  43473. arc?: number;
  43474. slice?: number;
  43475. sideOrientation?: number;
  43476. frontUVs?: Vector4;
  43477. backUVs?: Vector4;
  43478. updatable?: boolean;
  43479. }, scene?: Nullable<Scene>): Mesh;
  43480. }
  43481. }
  43482. declare module BABYLON.Debug {
  43483. /**
  43484. * Used to show the physics impostor around the specific mesh
  43485. */
  43486. export class PhysicsViewer {
  43487. /** @hidden */
  43488. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43489. /** @hidden */
  43490. protected _meshes: Array<Nullable<AbstractMesh>>;
  43491. /** @hidden */
  43492. protected _scene: Nullable<Scene>;
  43493. /** @hidden */
  43494. protected _numMeshes: number;
  43495. /** @hidden */
  43496. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43497. private _renderFunction;
  43498. private _utilityLayer;
  43499. private _debugBoxMesh;
  43500. private _debugSphereMesh;
  43501. private _debugCylinderMesh;
  43502. private _debugMaterial;
  43503. private _debugMeshMeshes;
  43504. /**
  43505. * Creates a new PhysicsViewer
  43506. * @param scene defines the hosting scene
  43507. */
  43508. constructor(scene: Scene);
  43509. /** @hidden */
  43510. protected _updateDebugMeshes(): void;
  43511. /**
  43512. * Renders a specified physic impostor
  43513. * @param impostor defines the impostor to render
  43514. * @param targetMesh defines the mesh represented by the impostor
  43515. * @returns the new debug mesh used to render the impostor
  43516. */
  43517. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43518. /**
  43519. * Hides a specified physic impostor
  43520. * @param impostor defines the impostor to hide
  43521. */
  43522. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43523. private _getDebugMaterial;
  43524. private _getDebugBoxMesh;
  43525. private _getDebugSphereMesh;
  43526. private _getDebugCylinderMesh;
  43527. private _getDebugMeshMesh;
  43528. private _getDebugMesh;
  43529. /** Releases all resources */
  43530. dispose(): void;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Class containing static functions to help procedurally build meshes
  43536. */
  43537. export class LinesBuilder {
  43538. /**
  43539. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43540. * * 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
  43541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43542. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43543. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43544. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43545. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43546. * * 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
  43547. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43550. * @param name defines the name of the new line system
  43551. * @param options defines the options used to create the line system
  43552. * @param scene defines the hosting scene
  43553. * @returns a new line system mesh
  43554. */
  43555. static CreateLineSystem(name: string, options: {
  43556. lines: Vector3[][];
  43557. updatable?: boolean;
  43558. instance?: Nullable<LinesMesh>;
  43559. colors?: Nullable<Color4[][]>;
  43560. useVertexAlpha?: boolean;
  43561. }, scene: Nullable<Scene>): LinesMesh;
  43562. /**
  43563. * Creates a line mesh
  43564. * 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
  43565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43566. * * The parameter `points` is an array successive Vector3
  43567. * * 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
  43568. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43570. * * When updating an instance, remember that only point positions can change, not the number of points
  43571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43573. * @param name defines the name of the new line system
  43574. * @param options defines the options used to create the line system
  43575. * @param scene defines the hosting scene
  43576. * @returns a new line mesh
  43577. */
  43578. static CreateLines(name: string, options: {
  43579. points: Vector3[];
  43580. updatable?: boolean;
  43581. instance?: Nullable<LinesMesh>;
  43582. colors?: Color4[];
  43583. useVertexAlpha?: boolean;
  43584. }, scene?: Nullable<Scene>): LinesMesh;
  43585. /**
  43586. * Creates a dashed line mesh
  43587. * * 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
  43588. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43589. * * The parameter `points` is an array successive Vector3
  43590. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43591. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43592. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43593. * * 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
  43594. * * When updating an instance, remember that only point positions can change, not the number of points
  43595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43596. * @param name defines the name of the mesh
  43597. * @param options defines the options used to create the mesh
  43598. * @param scene defines the hosting scene
  43599. * @returns the dashed line mesh
  43600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43601. */
  43602. static CreateDashedLines(name: string, options: {
  43603. points: Vector3[];
  43604. dashSize?: number;
  43605. gapSize?: number;
  43606. dashNb?: number;
  43607. updatable?: boolean;
  43608. instance?: LinesMesh;
  43609. }, scene?: Nullable<Scene>): LinesMesh;
  43610. }
  43611. }
  43612. declare module BABYLON {
  43613. /**
  43614. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43615. * in order to better appreciate the issue one might have.
  43616. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43617. */
  43618. export class RayHelper {
  43619. /**
  43620. * Defines the ray we are currently tryin to visualize.
  43621. */
  43622. ray: Nullable<Ray>;
  43623. private _renderPoints;
  43624. private _renderLine;
  43625. private _renderFunction;
  43626. private _scene;
  43627. private _updateToMeshFunction;
  43628. private _attachedToMesh;
  43629. private _meshSpaceDirection;
  43630. private _meshSpaceOrigin;
  43631. /**
  43632. * Helper function to create a colored helper in a scene in one line.
  43633. * @param ray Defines the ray we are currently tryin to visualize
  43634. * @param scene Defines the scene the ray is used in
  43635. * @param color Defines the color we want to see the ray in
  43636. * @returns The newly created ray helper.
  43637. */
  43638. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43639. /**
  43640. * Instantiate a new ray helper.
  43641. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43642. * in order to better appreciate the issue one might have.
  43643. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43644. * @param ray Defines the ray we are currently tryin to visualize
  43645. */
  43646. constructor(ray: Ray);
  43647. /**
  43648. * Shows the ray we are willing to debug.
  43649. * @param scene Defines the scene the ray needs to be rendered in
  43650. * @param color Defines the color the ray needs to be rendered in
  43651. */
  43652. show(scene: Scene, color?: Color3): void;
  43653. /**
  43654. * Hides the ray we are debugging.
  43655. */
  43656. hide(): void;
  43657. private _render;
  43658. /**
  43659. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43660. * @param mesh Defines the mesh we want the helper attached to
  43661. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43662. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43663. * @param length Defines the length of the ray
  43664. */
  43665. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43666. /**
  43667. * Detach the ray helper from the mesh it has previously been attached to.
  43668. */
  43669. detachFromMesh(): void;
  43670. private _updateToMesh;
  43671. /**
  43672. * Dispose the helper and release its associated resources.
  43673. */
  43674. dispose(): void;
  43675. }
  43676. }
  43677. declare module BABYLON.Debug {
  43678. /**
  43679. * Class used to render a debug view of a given skeleton
  43680. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43681. */
  43682. export class SkeletonViewer {
  43683. /** defines the skeleton to render */
  43684. skeleton: Skeleton;
  43685. /** defines the mesh attached to the skeleton */
  43686. mesh: AbstractMesh;
  43687. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43688. autoUpdateBonesMatrices: boolean;
  43689. /** defines the rendering group id to use with the viewer */
  43690. renderingGroupId: number;
  43691. /** Gets or sets the color used to render the skeleton */
  43692. color: Color3;
  43693. private _scene;
  43694. private _debugLines;
  43695. private _debugMesh;
  43696. private _isEnabled;
  43697. private _renderFunction;
  43698. private _utilityLayer;
  43699. /**
  43700. * Returns the mesh used to render the bones
  43701. */
  43702. readonly debugMesh: Nullable<LinesMesh>;
  43703. /**
  43704. * Creates a new SkeletonViewer
  43705. * @param skeleton defines the skeleton to render
  43706. * @param mesh defines the mesh attached to the skeleton
  43707. * @param scene defines the hosting scene
  43708. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43709. * @param renderingGroupId defines the rendering group id to use with the viewer
  43710. */
  43711. constructor(
  43712. /** defines the skeleton to render */
  43713. skeleton: Skeleton,
  43714. /** defines the mesh attached to the skeleton */
  43715. mesh: AbstractMesh, scene: Scene,
  43716. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43717. autoUpdateBonesMatrices?: boolean,
  43718. /** defines the rendering group id to use with the viewer */
  43719. renderingGroupId?: number);
  43720. /** Gets or sets a boolean indicating if the viewer is enabled */
  43721. isEnabled: boolean;
  43722. private _getBonePosition;
  43723. private _getLinesForBonesWithLength;
  43724. private _getLinesForBonesNoLength;
  43725. /** Update the viewer to sync with current skeleton state */
  43726. update(): void;
  43727. /** Release associated resources */
  43728. dispose(): void;
  43729. }
  43730. }
  43731. declare module BABYLON {
  43732. /**
  43733. * Options to create the null engine
  43734. */
  43735. export class NullEngineOptions {
  43736. /**
  43737. * Render width (Default: 512)
  43738. */
  43739. renderWidth: number;
  43740. /**
  43741. * Render height (Default: 256)
  43742. */
  43743. renderHeight: number;
  43744. /**
  43745. * Texture size (Default: 512)
  43746. */
  43747. textureSize: number;
  43748. /**
  43749. * If delta time between frames should be constant
  43750. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43751. */
  43752. deterministicLockstep: boolean;
  43753. /**
  43754. * Maximum about of steps between frames (Default: 4)
  43755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43756. */
  43757. lockstepMaxSteps: number;
  43758. }
  43759. /**
  43760. * The null engine class provides support for headless version of babylon.js.
  43761. * This can be used in server side scenario or for testing purposes
  43762. */
  43763. export class NullEngine extends Engine {
  43764. private _options;
  43765. /**
  43766. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43768. * @returns true if engine is in deterministic lock step mode
  43769. */
  43770. isDeterministicLockStep(): boolean;
  43771. /**
  43772. * Gets the max steps when engine is running in deterministic lock step
  43773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43774. * @returns the max steps
  43775. */
  43776. getLockstepMaxSteps(): number;
  43777. /**
  43778. * Gets the current hardware scaling level.
  43779. * By default the hardware scaling level is computed from the window device ratio.
  43780. * 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.
  43781. * @returns a number indicating the current hardware scaling level
  43782. */
  43783. getHardwareScalingLevel(): number;
  43784. constructor(options?: NullEngineOptions);
  43785. /**
  43786. * Creates a vertex buffer
  43787. * @param vertices the data for the vertex buffer
  43788. * @returns the new WebGL static buffer
  43789. */
  43790. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43791. /**
  43792. * Creates a new index buffer
  43793. * @param indices defines the content of the index buffer
  43794. * @param updatable defines if the index buffer must be updatable
  43795. * @returns a new webGL buffer
  43796. */
  43797. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43798. /**
  43799. * Clear the current render buffer or the current render target (if any is set up)
  43800. * @param color defines the color to use
  43801. * @param backBuffer defines if the back buffer must be cleared
  43802. * @param depth defines if the depth buffer must be cleared
  43803. * @param stencil defines if the stencil buffer must be cleared
  43804. */
  43805. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43806. /**
  43807. * Gets the current render width
  43808. * @param useScreen defines if screen size must be used (or the current render target if any)
  43809. * @returns a number defining the current render width
  43810. */
  43811. getRenderWidth(useScreen?: boolean): number;
  43812. /**
  43813. * Gets the current render height
  43814. * @param useScreen defines if screen size must be used (or the current render target if any)
  43815. * @returns a number defining the current render height
  43816. */
  43817. getRenderHeight(useScreen?: boolean): number;
  43818. /**
  43819. * Set the WebGL's viewport
  43820. * @param viewport defines the viewport element to be used
  43821. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43822. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43823. */
  43824. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43825. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43826. /**
  43827. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43828. * @param pipelineContext defines the pipeline context to use
  43829. * @param uniformsNames defines the list of uniform names
  43830. * @returns an array of webGL uniform locations
  43831. */
  43832. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43833. /**
  43834. * Gets the lsit of active attributes for a given webGL program
  43835. * @param pipelineContext defines the pipeline context to use
  43836. * @param attributesNames defines the list of attribute names to get
  43837. * @returns an array of indices indicating the offset of each attribute
  43838. */
  43839. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43840. /**
  43841. * Binds an effect to the webGL context
  43842. * @param effect defines the effect to bind
  43843. */
  43844. bindSamplers(effect: Effect): void;
  43845. /**
  43846. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43847. * @param effect defines the effect to activate
  43848. */
  43849. enableEffect(effect: Effect): void;
  43850. /**
  43851. * Set various states to the webGL context
  43852. * @param culling defines backface culling state
  43853. * @param zOffset defines the value to apply to zOffset (0 by default)
  43854. * @param force defines if states must be applied even if cache is up to date
  43855. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43856. */
  43857. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43858. /**
  43859. * Set the value of an uniform to an array of int32
  43860. * @param uniform defines the webGL uniform location where to store the value
  43861. * @param array defines the array of int32 to store
  43862. */
  43863. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43864. /**
  43865. * Set the value of an uniform to an array of int32 (stored as vec2)
  43866. * @param uniform defines the webGL uniform location where to store the value
  43867. * @param array defines the array of int32 to store
  43868. */
  43869. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43870. /**
  43871. * Set the value of an uniform to an array of int32 (stored as vec3)
  43872. * @param uniform defines the webGL uniform location where to store the value
  43873. * @param array defines the array of int32 to store
  43874. */
  43875. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43876. /**
  43877. * Set the value of an uniform to an array of int32 (stored as vec4)
  43878. * @param uniform defines the webGL uniform location where to store the value
  43879. * @param array defines the array of int32 to store
  43880. */
  43881. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43882. /**
  43883. * Set the value of an uniform to an array of float32
  43884. * @param uniform defines the webGL uniform location where to store the value
  43885. * @param array defines the array of float32 to store
  43886. */
  43887. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43888. /**
  43889. * Set the value of an uniform to an array of float32 (stored as vec2)
  43890. * @param uniform defines the webGL uniform location where to store the value
  43891. * @param array defines the array of float32 to store
  43892. */
  43893. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43894. /**
  43895. * Set the value of an uniform to an array of float32 (stored as vec3)
  43896. * @param uniform defines the webGL uniform location where to store the value
  43897. * @param array defines the array of float32 to store
  43898. */
  43899. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43900. /**
  43901. * Set the value of an uniform to an array of float32 (stored as vec4)
  43902. * @param uniform defines the webGL uniform location where to store the value
  43903. * @param array defines the array of float32 to store
  43904. */
  43905. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43906. /**
  43907. * Set the value of an uniform to an array of number
  43908. * @param uniform defines the webGL uniform location where to store the value
  43909. * @param array defines the array of number to store
  43910. */
  43911. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43912. /**
  43913. * Set the value of an uniform to an array of number (stored as vec2)
  43914. * @param uniform defines the webGL uniform location where to store the value
  43915. * @param array defines the array of number to store
  43916. */
  43917. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43918. /**
  43919. * Set the value of an uniform to an array of number (stored as vec3)
  43920. * @param uniform defines the webGL uniform location where to store the value
  43921. * @param array defines the array of number to store
  43922. */
  43923. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43924. /**
  43925. * Set the value of an uniform to an array of number (stored as vec4)
  43926. * @param uniform defines the webGL uniform location where to store the value
  43927. * @param array defines the array of number to store
  43928. */
  43929. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43930. /**
  43931. * Set the value of an uniform to an array of float32 (stored as matrices)
  43932. * @param uniform defines the webGL uniform location where to store the value
  43933. * @param matrices defines the array of float32 to store
  43934. */
  43935. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43936. /**
  43937. * Set the value of an uniform to a matrix (3x3)
  43938. * @param uniform defines the webGL uniform location where to store the value
  43939. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43940. */
  43941. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43942. /**
  43943. * Set the value of an uniform to a matrix (2x2)
  43944. * @param uniform defines the webGL uniform location where to store the value
  43945. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43946. */
  43947. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43948. /**
  43949. * Set the value of an uniform to a number (float)
  43950. * @param uniform defines the webGL uniform location where to store the value
  43951. * @param value defines the float number to store
  43952. */
  43953. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43954. /**
  43955. * Set the value of an uniform to a vec2
  43956. * @param uniform defines the webGL uniform location where to store the value
  43957. * @param x defines the 1st component of the value
  43958. * @param y defines the 2nd component of the value
  43959. */
  43960. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43961. /**
  43962. * Set the value of an uniform to a vec3
  43963. * @param uniform defines the webGL uniform location where to store the value
  43964. * @param x defines the 1st component of the value
  43965. * @param y defines the 2nd component of the value
  43966. * @param z defines the 3rd component of the value
  43967. */
  43968. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43969. /**
  43970. * Set the value of an uniform to a boolean
  43971. * @param uniform defines the webGL uniform location where to store the value
  43972. * @param bool defines the boolean to store
  43973. */
  43974. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43975. /**
  43976. * Set the value of an uniform to a vec4
  43977. * @param uniform defines the webGL uniform location where to store the value
  43978. * @param x defines the 1st component of the value
  43979. * @param y defines the 2nd component of the value
  43980. * @param z defines the 3rd component of the value
  43981. * @param w defines the 4th component of the value
  43982. */
  43983. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43984. /**
  43985. * Sets the current alpha mode
  43986. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43987. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43988. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43989. */
  43990. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43991. /**
  43992. * Bind webGl buffers directly to the webGL context
  43993. * @param vertexBuffers defines the vertex buffer to bind
  43994. * @param indexBuffer defines the index buffer to bind
  43995. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43996. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43997. * @param effect defines the effect associated with the vertex buffer
  43998. */
  43999. bindBuffers(vertexBuffers: {
  44000. [key: string]: VertexBuffer;
  44001. }, indexBuffer: DataBuffer, effect: Effect): void;
  44002. /**
  44003. * Force the entire cache to be cleared
  44004. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  44005. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44006. */
  44007. wipeCaches(bruteForce?: boolean): void;
  44008. /**
  44009. * Send a draw order
  44010. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  44011. * @param indexStart defines the starting index
  44012. * @param indexCount defines the number of index to draw
  44013. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44014. */
  44015. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44016. /**
  44017. * Draw a list of indexed primitives
  44018. * @param fillMode defines the primitive to use
  44019. * @param indexStart defines the starting index
  44020. * @param indexCount defines the number of index to draw
  44021. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44022. */
  44023. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44024. /**
  44025. * Draw a list of unindexed primitives
  44026. * @param fillMode defines the primitive to use
  44027. * @param verticesStart defines the index of first vertex to draw
  44028. * @param verticesCount defines the count of vertices to draw
  44029. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44030. */
  44031. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44032. /** @hidden */
  44033. _createTexture(): WebGLTexture;
  44034. /** @hidden */
  44035. _releaseTexture(texture: InternalTexture): void;
  44036. /**
  44037. * Usually called from Texture.ts.
  44038. * Passed information to create a WebGLTexture
  44039. * @param urlArg defines a value which contains one of the following:
  44040. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44041. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44042. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44043. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44044. * @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)
  44045. * @param scene needed for loading to the correct scene
  44046. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  44047. * @param onLoad optional callback to be called upon successful completion
  44048. * @param onError optional callback to be called upon failure
  44049. * @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
  44050. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44051. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44052. * @param forcedExtension defines the extension to use to pick the right loader
  44053. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  44054. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44055. */
  44056. 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;
  44057. /**
  44058. * Creates a new render target texture
  44059. * @param size defines the size of the texture
  44060. * @param options defines the options used to create the texture
  44061. * @returns a new render target texture stored in an InternalTexture
  44062. */
  44063. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44064. /**
  44065. * Update the sampling mode of a given texture
  44066. * @param samplingMode defines the required sampling mode
  44067. * @param texture defines the texture to update
  44068. */
  44069. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44070. /**
  44071. * Binds the frame buffer to the specified texture.
  44072. * @param texture The texture to render to or null for the default canvas
  44073. * @param faceIndex The face of the texture to render to in case of cube texture
  44074. * @param requiredWidth The width of the target to render to
  44075. * @param requiredHeight The height of the target to render to
  44076. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  44077. * @param depthStencilTexture The depth stencil texture to use to render
  44078. * @param lodLevel defines le lod level to bind to the frame buffer
  44079. */
  44080. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44081. /**
  44082. * Unbind the current render target texture from the webGL context
  44083. * @param texture defines the render target texture to unbind
  44084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44086. */
  44087. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44088. /**
  44089. * Creates a dynamic vertex buffer
  44090. * @param vertices the data for the dynamic vertex buffer
  44091. * @returns the new WebGL dynamic buffer
  44092. */
  44093. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44094. /**
  44095. * Update the content of a dynamic texture
  44096. * @param texture defines the texture to update
  44097. * @param canvas defines the canvas containing the source
  44098. * @param invertY defines if data must be stored with Y axis inverted
  44099. * @param premulAlpha defines if alpha is stored as premultiplied
  44100. * @param format defines the format of the data
  44101. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  44102. */
  44103. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44104. /**
  44105. * Gets a boolean indicating if all created effects are ready
  44106. * @returns true if all effects are ready
  44107. */
  44108. areAllEffectsReady(): boolean;
  44109. /**
  44110. * @hidden
  44111. * Get the current error code of the webGL context
  44112. * @returns the error code
  44113. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44114. */
  44115. getError(): number;
  44116. /** @hidden */
  44117. _getUnpackAlignement(): number;
  44118. /** @hidden */
  44119. _unpackFlipY(value: boolean): void;
  44120. /**
  44121. * Update a dynamic index buffer
  44122. * @param indexBuffer defines the target index buffer
  44123. * @param indices defines the data to update
  44124. * @param offset defines the offset in the target index buffer where update should start
  44125. */
  44126. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44127. /**
  44128. * Updates a dynamic vertex buffer.
  44129. * @param vertexBuffer the vertex buffer to update
  44130. * @param vertices the data used to update the vertex buffer
  44131. * @param byteOffset the byte offset of the data (optional)
  44132. * @param byteLength the byte length of the data (optional)
  44133. */
  44134. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44135. /** @hidden */
  44136. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44137. /** @hidden */
  44138. _bindTexture(channel: number, texture: InternalTexture): void;
  44139. protected _deleteBuffer(buffer: WebGLBuffer): void;
  44140. /**
  44141. * 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
  44142. */
  44143. releaseEffects(): void;
  44144. displayLoadingUI(): void;
  44145. hideLoadingUI(): void;
  44146. /** @hidden */
  44147. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44148. /** @hidden */
  44149. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44150. /** @hidden */
  44151. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44152. /** @hidden */
  44153. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44154. }
  44155. }
  44156. declare module BABYLON {
  44157. /** @hidden */
  44158. export class _OcclusionDataStorage {
  44159. /** @hidden */
  44160. occlusionInternalRetryCounter: number;
  44161. /** @hidden */
  44162. isOcclusionQueryInProgress: boolean;
  44163. /** @hidden */
  44164. isOccluded: boolean;
  44165. /** @hidden */
  44166. occlusionRetryCount: number;
  44167. /** @hidden */
  44168. occlusionType: number;
  44169. /** @hidden */
  44170. occlusionQueryAlgorithmType: number;
  44171. }
  44172. interface Engine {
  44173. /**
  44174. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44175. * @return the new query
  44176. */
  44177. createQuery(): WebGLQuery;
  44178. /**
  44179. * Delete and release a webGL query
  44180. * @param query defines the query to delete
  44181. * @return the current engine
  44182. */
  44183. deleteQuery(query: WebGLQuery): Engine;
  44184. /**
  44185. * Check if a given query has resolved and got its value
  44186. * @param query defines the query to check
  44187. * @returns true if the query got its value
  44188. */
  44189. isQueryResultAvailable(query: WebGLQuery): boolean;
  44190. /**
  44191. * Gets the value of a given query
  44192. * @param query defines the query to check
  44193. * @returns the value of the query
  44194. */
  44195. getQueryResult(query: WebGLQuery): number;
  44196. /**
  44197. * Initiates an occlusion query
  44198. * @param algorithmType defines the algorithm to use
  44199. * @param query defines the query to use
  44200. * @returns the current engine
  44201. * @see http://doc.babylonjs.com/features/occlusionquery
  44202. */
  44203. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44204. /**
  44205. * Ends an occlusion query
  44206. * @see http://doc.babylonjs.com/features/occlusionquery
  44207. * @param algorithmType defines the algorithm to use
  44208. * @returns the current engine
  44209. */
  44210. endOcclusionQuery(algorithmType: number): Engine;
  44211. /**
  44212. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44213. * Please note that only one query can be issued at a time
  44214. * @returns a time token used to track the time span
  44215. */
  44216. startTimeQuery(): Nullable<_TimeToken>;
  44217. /**
  44218. * Ends a time query
  44219. * @param token defines the token used to measure the time span
  44220. * @returns the time spent (in ns)
  44221. */
  44222. endTimeQuery(token: _TimeToken): int;
  44223. /** @hidden */
  44224. _currentNonTimestampToken: Nullable<_TimeToken>;
  44225. /** @hidden */
  44226. _createTimeQuery(): WebGLQuery;
  44227. /** @hidden */
  44228. _deleteTimeQuery(query: WebGLQuery): void;
  44229. /** @hidden */
  44230. _getGlAlgorithmType(algorithmType: number): number;
  44231. /** @hidden */
  44232. _getTimeQueryResult(query: WebGLQuery): any;
  44233. /** @hidden */
  44234. _getTimeQueryAvailability(query: WebGLQuery): any;
  44235. }
  44236. interface AbstractMesh {
  44237. /**
  44238. * Backing filed
  44239. * @hidden
  44240. */
  44241. __occlusionDataStorage: _OcclusionDataStorage;
  44242. /**
  44243. * Access property
  44244. * @hidden
  44245. */
  44246. _occlusionDataStorage: _OcclusionDataStorage;
  44247. /**
  44248. * 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.
  44249. * The default value is -1 which means don't break the query and wait till the result
  44250. * @see http://doc.babylonjs.com/features/occlusionquery
  44251. */
  44252. occlusionRetryCount: number;
  44253. /**
  44254. * 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:
  44255. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44256. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44257. * * 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.
  44258. * @see http://doc.babylonjs.com/features/occlusionquery
  44259. */
  44260. occlusionType: number;
  44261. /**
  44262. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44263. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44264. * * 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.
  44265. * @see http://doc.babylonjs.com/features/occlusionquery
  44266. */
  44267. occlusionQueryAlgorithmType: number;
  44268. /**
  44269. * 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
  44270. * @see http://doc.babylonjs.com/features/occlusionquery
  44271. */
  44272. isOccluded: boolean;
  44273. /**
  44274. * Flag to check the progress status of the query
  44275. * @see http://doc.babylonjs.com/features/occlusionquery
  44276. */
  44277. isOcclusionQueryInProgress: boolean;
  44278. }
  44279. }
  44280. declare module BABYLON {
  44281. /** @hidden */
  44282. export var _forceTransformFeedbackToBundle: boolean;
  44283. interface Engine {
  44284. /**
  44285. * Creates a webGL transform feedback object
  44286. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44287. * @returns the webGL transform feedback object
  44288. */
  44289. createTransformFeedback(): WebGLTransformFeedback;
  44290. /**
  44291. * Delete a webGL transform feedback object
  44292. * @param value defines the webGL transform feedback object to delete
  44293. */
  44294. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44295. /**
  44296. * Bind a webGL transform feedback object to the webgl context
  44297. * @param value defines the webGL transform feedback object to bind
  44298. */
  44299. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44300. /**
  44301. * Begins a transform feedback operation
  44302. * @param usePoints defines if points or triangles must be used
  44303. */
  44304. beginTransformFeedback(usePoints: boolean): void;
  44305. /**
  44306. * Ends a transform feedback operation
  44307. */
  44308. endTransformFeedback(): void;
  44309. /**
  44310. * Specify the varyings to use with transform feedback
  44311. * @param program defines the associated webGL program
  44312. * @param value defines the list of strings representing the varying names
  44313. */
  44314. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44315. /**
  44316. * Bind a webGL buffer for a transform feedback operation
  44317. * @param value defines the webGL buffer to bind
  44318. */
  44319. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44320. }
  44321. }
  44322. declare module BABYLON {
  44323. /**
  44324. * Creation options of the multi render target texture.
  44325. */
  44326. export interface IMultiRenderTargetOptions {
  44327. /**
  44328. * Define if the texture needs to create mip maps after render.
  44329. */
  44330. generateMipMaps?: boolean;
  44331. /**
  44332. * Define the types of all the draw buffers we want to create
  44333. */
  44334. types?: number[];
  44335. /**
  44336. * Define the sampling modes of all the draw buffers we want to create
  44337. */
  44338. samplingModes?: number[];
  44339. /**
  44340. * Define if a depth buffer is required
  44341. */
  44342. generateDepthBuffer?: boolean;
  44343. /**
  44344. * Define if a stencil buffer is required
  44345. */
  44346. generateStencilBuffer?: boolean;
  44347. /**
  44348. * Define if a depth texture is required instead of a depth buffer
  44349. */
  44350. generateDepthTexture?: boolean;
  44351. /**
  44352. * Define the number of desired draw buffers
  44353. */
  44354. textureCount?: number;
  44355. /**
  44356. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44357. */
  44358. doNotChangeAspectRatio?: boolean;
  44359. /**
  44360. * Define the default type of the buffers we are creating
  44361. */
  44362. defaultType?: number;
  44363. }
  44364. /**
  44365. * A multi render target, like a render target provides the ability to render to a texture.
  44366. * Unlike the render target, it can render to several draw buffers in one draw.
  44367. * This is specially interesting in deferred rendering or for any effects requiring more than
  44368. * just one color from a single pass.
  44369. */
  44370. export class MultiRenderTarget extends RenderTargetTexture {
  44371. private _internalTextures;
  44372. private _textures;
  44373. private _multiRenderTargetOptions;
  44374. /**
  44375. * Get if draw buffers are currently supported by the used hardware and browser.
  44376. */
  44377. readonly isSupported: boolean;
  44378. /**
  44379. * Get the list of textures generated by the multi render target.
  44380. */
  44381. readonly textures: Texture[];
  44382. /**
  44383. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44384. */
  44385. readonly depthTexture: Texture;
  44386. /**
  44387. * Set the wrapping mode on U of all the textures we are rendering to.
  44388. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44389. */
  44390. wrapU: number;
  44391. /**
  44392. * Set the wrapping mode on V of all the textures we are rendering to.
  44393. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44394. */
  44395. wrapV: number;
  44396. /**
  44397. * Instantiate a new multi render target texture.
  44398. * A multi render target, like a render target provides the ability to render to a texture.
  44399. * Unlike the render target, it can render to several draw buffers in one draw.
  44400. * This is specially interesting in deferred rendering or for any effects requiring more than
  44401. * just one color from a single pass.
  44402. * @param name Define the name of the texture
  44403. * @param size Define the size of the buffers to render to
  44404. * @param count Define the number of target we are rendering into
  44405. * @param scene Define the scene the texture belongs to
  44406. * @param options Define the options used to create the multi render target
  44407. */
  44408. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44409. /** @hidden */
  44410. _rebuild(): void;
  44411. private _createInternalTextures;
  44412. private _createTextures;
  44413. /**
  44414. * Define the number of samples used if MSAA is enabled.
  44415. */
  44416. samples: number;
  44417. /**
  44418. * Resize all the textures in the multi render target.
  44419. * Be carrefull as it will recreate all the data in the new texture.
  44420. * @param size Define the new size
  44421. */
  44422. resize(size: any): void;
  44423. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44424. /**
  44425. * Dispose the render targets and their associated resources
  44426. */
  44427. dispose(): void;
  44428. /**
  44429. * Release all the underlying texture used as draw buffers.
  44430. */
  44431. releaseInternalTextures(): void;
  44432. }
  44433. }
  44434. declare module BABYLON {
  44435. interface ThinEngine {
  44436. /**
  44437. * Unbind a list of render target textures from the webGL context
  44438. * This is used only when drawBuffer extension or webGL2 are active
  44439. * @param textures defines the render target textures to unbind
  44440. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44441. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44442. */
  44443. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44444. /**
  44445. * Create a multi render target texture
  44446. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44447. * @param size defines the size of the texture
  44448. * @param options defines the creation options
  44449. * @returns the cube texture as an InternalTexture
  44450. */
  44451. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44452. /**
  44453. * Update the sample count for a given multiple render target texture
  44454. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44455. * @param textures defines the textures to update
  44456. * @param samples defines the sample count to set
  44457. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44458. */
  44459. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44460. }
  44461. }
  44462. declare module BABYLON {
  44463. /**
  44464. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  44465. */
  44466. export interface CubeMapInfo {
  44467. /**
  44468. * The pixel array for the front face.
  44469. * This is stored in format, left to right, up to down format.
  44470. */
  44471. front: Nullable<ArrayBufferView>;
  44472. /**
  44473. * The pixel array for the back face.
  44474. * This is stored in format, left to right, up to down format.
  44475. */
  44476. back: Nullable<ArrayBufferView>;
  44477. /**
  44478. * The pixel array for the left face.
  44479. * This is stored in format, left to right, up to down format.
  44480. */
  44481. left: Nullable<ArrayBufferView>;
  44482. /**
  44483. * The pixel array for the right face.
  44484. * This is stored in format, left to right, up to down format.
  44485. */
  44486. right: Nullable<ArrayBufferView>;
  44487. /**
  44488. * The pixel array for the up face.
  44489. * This is stored in format, left to right, up to down format.
  44490. */
  44491. up: Nullable<ArrayBufferView>;
  44492. /**
  44493. * The pixel array for the down face.
  44494. * This is stored in format, left to right, up to down format.
  44495. */
  44496. down: Nullable<ArrayBufferView>;
  44497. /**
  44498. * The size of the cubemap stored.
  44499. *
  44500. * Each faces will be size * size pixels.
  44501. */
  44502. size: number;
  44503. /**
  44504. * The format of the texture.
  44505. *
  44506. * RGBA, RGB.
  44507. */
  44508. format: number;
  44509. /**
  44510. * The type of the texture data.
  44511. *
  44512. * UNSIGNED_INT, FLOAT.
  44513. */
  44514. type: number;
  44515. /**
  44516. * Specifies whether the texture is in gamma space.
  44517. */
  44518. gammaSpace: boolean;
  44519. }
  44520. /**
  44521. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  44522. */
  44523. export class PanoramaToCubeMapTools {
  44524. private static FACE_FRONT;
  44525. private static FACE_BACK;
  44526. private static FACE_RIGHT;
  44527. private static FACE_LEFT;
  44528. private static FACE_DOWN;
  44529. private static FACE_UP;
  44530. /**
  44531. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  44532. *
  44533. * @param float32Array The source data.
  44534. * @param inputWidth The width of the input panorama.
  44535. * @param inputHeight The height of the input panorama.
  44536. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  44537. * @return The cubemap data
  44538. */
  44539. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  44540. private static CreateCubemapTexture;
  44541. private static CalcProjectionSpherical;
  44542. }
  44543. }
  44544. declare module BABYLON {
  44545. /**
  44546. * Helper class dealing with the extraction of spherical polynomial dataArray
  44547. * from a cube map.
  44548. */
  44549. export class CubeMapToSphericalPolynomialTools {
  44550. private static FileFaces;
  44551. /**
  44552. * Converts a texture to the according Spherical Polynomial data.
  44553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44554. *
  44555. * @param texture The texture to extract the information from.
  44556. * @return The Spherical Polynomial data.
  44557. */
  44558. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  44559. /**
  44560. * Converts a cubemap to the according Spherical Polynomial data.
  44561. * This extracts the first 3 orders only as they are the only one used in the lighting.
  44562. *
  44563. * @param cubeInfo The Cube map to extract the information from.
  44564. * @return The Spherical Polynomial data.
  44565. */
  44566. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  44567. }
  44568. }
  44569. declare module BABYLON {
  44570. interface BaseTexture {
  44571. /**
  44572. * Get the polynomial representation of the texture data.
  44573. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  44574. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  44575. */
  44576. sphericalPolynomial: Nullable<SphericalPolynomial>;
  44577. }
  44578. }
  44579. declare module BABYLON {
  44580. /** @hidden */
  44581. export var rgbdEncodePixelShader: {
  44582. name: string;
  44583. shader: string;
  44584. };
  44585. }
  44586. declare module BABYLON {
  44587. /** @hidden */
  44588. export var rgbdDecodePixelShader: {
  44589. name: string;
  44590. shader: string;
  44591. };
  44592. }
  44593. declare module BABYLON {
  44594. /**
  44595. * Raw texture data and descriptor sufficient for WebGL texture upload
  44596. */
  44597. export interface EnvironmentTextureInfo {
  44598. /**
  44599. * Version of the environment map
  44600. */
  44601. version: number;
  44602. /**
  44603. * Width of image
  44604. */
  44605. width: number;
  44606. /**
  44607. * Irradiance information stored in the file.
  44608. */
  44609. irradiance: any;
  44610. /**
  44611. * Specular information stored in the file.
  44612. */
  44613. specular: any;
  44614. }
  44615. /**
  44616. * Defines One Image in the file. It requires only the position in the file
  44617. * as well as the length.
  44618. */
  44619. interface BufferImageData {
  44620. /**
  44621. * Length of the image data.
  44622. */
  44623. length: number;
  44624. /**
  44625. * Position of the data from the null terminator delimiting the end of the JSON.
  44626. */
  44627. position: number;
  44628. }
  44629. /**
  44630. * Defines the specular data enclosed in the file.
  44631. * This corresponds to the version 1 of the data.
  44632. */
  44633. export interface EnvironmentTextureSpecularInfoV1 {
  44634. /**
  44635. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44636. */
  44637. specularDataPosition?: number;
  44638. /**
  44639. * This contains all the images data needed to reconstruct the cubemap.
  44640. */
  44641. mipmaps: Array<BufferImageData>;
  44642. /**
  44643. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44644. */
  44645. lodGenerationScale: number;
  44646. }
  44647. /**
  44648. * Sets of helpers addressing the serialization and deserialization of environment texture
  44649. * stored in a BabylonJS env file.
  44650. * Those files are usually stored as .env files.
  44651. */
  44652. export class EnvironmentTextureTools {
  44653. /**
  44654. * Magic number identifying the env file.
  44655. */
  44656. private static _MagicBytes;
  44657. /**
  44658. * Gets the environment info from an env file.
  44659. * @param data The array buffer containing the .env bytes.
  44660. * @returns the environment file info (the json header) if successfully parsed.
  44661. */
  44662. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44663. /**
  44664. * Creates an environment texture from a loaded cube texture.
  44665. * @param texture defines the cube texture to convert in env file
  44666. * @return a promise containing the environment data if succesfull.
  44667. */
  44668. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44669. /**
  44670. * Creates a JSON representation of the spherical data.
  44671. * @param texture defines the texture containing the polynomials
  44672. * @return the JSON representation of the spherical info
  44673. */
  44674. private static _CreateEnvTextureIrradiance;
  44675. /**
  44676. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44677. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44678. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44679. * @return the views described by info providing access to the underlying buffer
  44680. */
  44681. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44682. /**
  44683. * Uploads the texture info contained in the env file to the GPU.
  44684. * @param texture defines the internal texture to upload to
  44685. * @param arrayBuffer defines the buffer cotaining the data to load
  44686. * @param info defines the texture info retrieved through the GetEnvInfo method
  44687. * @returns a promise
  44688. */
  44689. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44690. private static _OnImageReadyAsync;
  44691. /**
  44692. * Uploads the levels of image data to the GPU.
  44693. * @param texture defines the internal texture to upload to
  44694. * @param imageData defines the array buffer views of image data [mipmap][face]
  44695. * @returns a promise
  44696. */
  44697. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44698. /**
  44699. * Uploads spherical polynomials information to the texture.
  44700. * @param texture defines the texture we are trying to upload the information to
  44701. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44702. */
  44703. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44704. /** @hidden */
  44705. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44706. }
  44707. }
  44708. declare module BABYLON {
  44709. /**
  44710. * Contains position and normal vectors for a vertex
  44711. */
  44712. export class PositionNormalVertex {
  44713. /** the position of the vertex (defaut: 0,0,0) */
  44714. position: Vector3;
  44715. /** the normal of the vertex (defaut: 0,1,0) */
  44716. normal: Vector3;
  44717. /**
  44718. * Creates a PositionNormalVertex
  44719. * @param position the position of the vertex (defaut: 0,0,0)
  44720. * @param normal the normal of the vertex (defaut: 0,1,0)
  44721. */
  44722. constructor(
  44723. /** the position of the vertex (defaut: 0,0,0) */
  44724. position?: Vector3,
  44725. /** the normal of the vertex (defaut: 0,1,0) */
  44726. normal?: Vector3);
  44727. /**
  44728. * Clones the PositionNormalVertex
  44729. * @returns the cloned PositionNormalVertex
  44730. */
  44731. clone(): PositionNormalVertex;
  44732. }
  44733. /**
  44734. * Contains position, normal and uv vectors for a vertex
  44735. */
  44736. export class PositionNormalTextureVertex {
  44737. /** the position of the vertex (defaut: 0,0,0) */
  44738. position: Vector3;
  44739. /** the normal of the vertex (defaut: 0,1,0) */
  44740. normal: Vector3;
  44741. /** the uv of the vertex (default: 0,0) */
  44742. uv: Vector2;
  44743. /**
  44744. * Creates a PositionNormalTextureVertex
  44745. * @param position the position of the vertex (defaut: 0,0,0)
  44746. * @param normal the normal of the vertex (defaut: 0,1,0)
  44747. * @param uv the uv of the vertex (default: 0,0)
  44748. */
  44749. constructor(
  44750. /** the position of the vertex (defaut: 0,0,0) */
  44751. position?: Vector3,
  44752. /** the normal of the vertex (defaut: 0,1,0) */
  44753. normal?: Vector3,
  44754. /** the uv of the vertex (default: 0,0) */
  44755. uv?: Vector2);
  44756. /**
  44757. * Clones the PositionNormalTextureVertex
  44758. * @returns the cloned PositionNormalTextureVertex
  44759. */
  44760. clone(): PositionNormalTextureVertex;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. /** @hidden */
  44765. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44766. private _genericAttributeLocation;
  44767. private _varyingLocationCount;
  44768. private _varyingLocationMap;
  44769. private _replacements;
  44770. private _textureCount;
  44771. private _uniforms;
  44772. lineProcessor(line: string): string;
  44773. attributeProcessor(attribute: string): string;
  44774. varyingProcessor(varying: string, isFragment: boolean): string;
  44775. uniformProcessor(uniform: string): string;
  44776. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44777. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44778. }
  44779. }
  44780. declare module BABYLON {
  44781. /**
  44782. * Container for accessors for natively-stored mesh data buffers.
  44783. */
  44784. class NativeDataBuffer extends DataBuffer {
  44785. /**
  44786. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44787. */
  44788. nativeIndexBuffer?: any;
  44789. /**
  44790. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44791. */
  44792. nativeVertexBuffer?: any;
  44793. }
  44794. /** @hidden */
  44795. export class NativeEngine extends Engine {
  44796. private readonly _native;
  44797. getHardwareScalingLevel(): number;
  44798. constructor();
  44799. /**
  44800. * Can be used to override the current requestAnimationFrame requester.
  44801. * @hidden
  44802. */
  44803. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44804. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44805. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44806. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44807. recordVertexArrayObject(vertexBuffers: {
  44808. [key: string]: VertexBuffer;
  44809. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44810. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44811. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44812. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44813. /**
  44814. * Draw a list of indexed primitives
  44815. * @param fillMode defines the primitive to use
  44816. * @param indexStart defines the starting index
  44817. * @param indexCount defines the number of index to draw
  44818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44819. */
  44820. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44821. /**
  44822. * Draw a list of unindexed primitives
  44823. * @param fillMode defines the primitive to use
  44824. * @param verticesStart defines the index of first vertex to draw
  44825. * @param verticesCount defines the count of vertices to draw
  44826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44827. */
  44828. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44829. createPipelineContext(): IPipelineContext;
  44830. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44831. /** @hidden */
  44832. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44833. /** @hidden */
  44834. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44835. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44836. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44837. protected _setProgram(program: WebGLProgram): void;
  44838. _releaseEffect(effect: Effect): void;
  44839. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44840. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44841. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44842. bindSamplers(effect: Effect): void;
  44843. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44844. getRenderWidth(useScreen?: boolean): number;
  44845. getRenderHeight(useScreen?: boolean): number;
  44846. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44847. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44848. /**
  44849. * Set the z offset to apply to current rendering
  44850. * @param value defines the offset to apply
  44851. */
  44852. setZOffset(value: number): void;
  44853. /**
  44854. * Gets the current value of the zOffset
  44855. * @returns the current zOffset state
  44856. */
  44857. getZOffset(): number;
  44858. /**
  44859. * Enable or disable depth buffering
  44860. * @param enable defines the state to set
  44861. */
  44862. setDepthBuffer(enable: boolean): void;
  44863. /**
  44864. * Gets a boolean indicating if depth writing is enabled
  44865. * @returns the current depth writing state
  44866. */
  44867. getDepthWrite(): boolean;
  44868. /**
  44869. * Enable or disable depth writing
  44870. * @param enable defines the state to set
  44871. */
  44872. setDepthWrite(enable: boolean): void;
  44873. /**
  44874. * Enable or disable color writing
  44875. * @param enable defines the state to set
  44876. */
  44877. setColorWrite(enable: boolean): void;
  44878. /**
  44879. * Gets a boolean indicating if color writing is enabled
  44880. * @returns the current color writing state
  44881. */
  44882. getColorWrite(): boolean;
  44883. /**
  44884. * Sets alpha constants used by some alpha blending modes
  44885. * @param r defines the red component
  44886. * @param g defines the green component
  44887. * @param b defines the blue component
  44888. * @param a defines the alpha component
  44889. */
  44890. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44891. /**
  44892. * Sets the current alpha mode
  44893. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44894. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44895. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44896. */
  44897. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44898. /**
  44899. * Gets the current alpha mode
  44900. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44901. * @returns the current alpha mode
  44902. */
  44903. getAlphaMode(): number;
  44904. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44905. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44906. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44907. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44908. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44909. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44910. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44911. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44912. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44913. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44914. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44915. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44916. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44917. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44918. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44919. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44920. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44921. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44922. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44923. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44924. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44925. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44926. wipeCaches(bruteForce?: boolean): void;
  44927. _createTexture(): WebGLTexture;
  44928. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44929. /**
  44930. * Usually called from BABYLON.Texture.ts.
  44931. * Passed information to create a WebGLTexture
  44932. * @param urlArg defines a value which contains one of the following:
  44933. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44934. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44935. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44937. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44938. * @param scene needed for loading to the correct scene
  44939. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44940. * @param onLoad optional callback to be called upon successful completion
  44941. * @param onError optional callback to be called upon failure
  44942. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44943. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44944. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44945. * @param forcedExtension defines the extension to use to pick the right loader
  44946. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44947. */
  44948. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44949. /**
  44950. * Creates a cube texture
  44951. * @param rootUrl defines the url where the files to load is located
  44952. * @param scene defines the current scene
  44953. * @param files defines the list of files to load (1 per face)
  44954. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44955. * @param onLoad defines an optional callback raised when the texture is loaded
  44956. * @param onError defines an optional callback raised if there is an issue to load the texture
  44957. * @param format defines the format of the data
  44958. * @param forcedExtension defines the extension to use to pick the right loader
  44959. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44960. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44961. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44962. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44963. * @returns the cube texture as an InternalTexture
  44964. */
  44965. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44966. private _getSamplingFilter;
  44967. private static _GetNativeTextureFormat;
  44968. createRenderTargetTexture(size: number | {
  44969. width: number;
  44970. height: number;
  44971. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44972. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44973. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44974. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44975. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44976. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44977. /**
  44978. * Updates a dynamic vertex buffer.
  44979. * @param vertexBuffer the vertex buffer to update
  44980. * @param data the data used to update the vertex buffer
  44981. * @param byteOffset the byte offset of the data (optional)
  44982. * @param byteLength the byte length of the data (optional)
  44983. */
  44984. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44985. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44986. private _updateAnisotropicLevel;
  44987. private _getAddressMode;
  44988. /** @hidden */
  44989. _bindTexture(channel: number, texture: InternalTexture): void;
  44990. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44991. releaseEffects(): void;
  44992. /** @hidden */
  44993. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44994. /** @hidden */
  44995. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44996. /** @hidden */
  44997. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44998. /** @hidden */
  44999. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45000. }
  45001. }
  45002. declare module BABYLON {
  45003. /**
  45004. * Gather the list of clipboard event types as constants.
  45005. */
  45006. export class ClipboardEventTypes {
  45007. /**
  45008. * The clipboard event is fired when a copy command is active (pressed).
  45009. */
  45010. static readonly COPY: number;
  45011. /**
  45012. * The clipboard event is fired when a cut command is active (pressed).
  45013. */
  45014. static readonly CUT: number;
  45015. /**
  45016. * The clipboard event is fired when a paste command is active (pressed).
  45017. */
  45018. static readonly PASTE: number;
  45019. }
  45020. /**
  45021. * This class is used to store clipboard related info for the onClipboardObservable event.
  45022. */
  45023. export class ClipboardInfo {
  45024. /**
  45025. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45026. */
  45027. type: number;
  45028. /**
  45029. * Defines the related dom event
  45030. */
  45031. event: ClipboardEvent;
  45032. /**
  45033. *Creates an instance of ClipboardInfo.
  45034. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45035. * @param event Defines the related dom event
  45036. */
  45037. constructor(
  45038. /**
  45039. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45040. */
  45041. type: number,
  45042. /**
  45043. * Defines the related dom event
  45044. */
  45045. event: ClipboardEvent);
  45046. /**
  45047. * Get the clipboard event's type from the keycode.
  45048. * @param keyCode Defines the keyCode for the current keyboard event.
  45049. * @return {number}
  45050. */
  45051. static GetTypeFromCharacter(keyCode: number): number;
  45052. }
  45053. }
  45054. declare module BABYLON {
  45055. /**
  45056. * Google Daydream controller
  45057. */
  45058. export class DaydreamController extends WebVRController {
  45059. /**
  45060. * Base Url for the controller model.
  45061. */
  45062. static MODEL_BASE_URL: string;
  45063. /**
  45064. * File name for the controller model.
  45065. */
  45066. static MODEL_FILENAME: string;
  45067. /**
  45068. * Gamepad Id prefix used to identify Daydream Controller.
  45069. */
  45070. static readonly GAMEPAD_ID_PREFIX: string;
  45071. /**
  45072. * Creates a new DaydreamController from a gamepad
  45073. * @param vrGamepad the gamepad that the controller should be created from
  45074. */
  45075. constructor(vrGamepad: any);
  45076. /**
  45077. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45078. * @param scene scene in which to add meshes
  45079. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45080. */
  45081. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45082. /**
  45083. * Called once for each button that changed state since the last frame
  45084. * @param buttonIdx Which button index changed
  45085. * @param state New state of the button
  45086. * @param changes Which properties on the state changed since last frame
  45087. */
  45088. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45089. }
  45090. }
  45091. declare module BABYLON {
  45092. /**
  45093. * Gear VR Controller
  45094. */
  45095. export class GearVRController extends WebVRController {
  45096. /**
  45097. * Base Url for the controller model.
  45098. */
  45099. static MODEL_BASE_URL: string;
  45100. /**
  45101. * File name for the controller model.
  45102. */
  45103. static MODEL_FILENAME: string;
  45104. /**
  45105. * Gamepad Id prefix used to identify this controller.
  45106. */
  45107. static readonly GAMEPAD_ID_PREFIX: string;
  45108. private readonly _buttonIndexToObservableNameMap;
  45109. /**
  45110. * Creates a new GearVRController from a gamepad
  45111. * @param vrGamepad the gamepad that the controller should be created from
  45112. */
  45113. constructor(vrGamepad: any);
  45114. /**
  45115. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45116. * @param scene scene in which to add meshes
  45117. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45118. */
  45119. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45120. /**
  45121. * Called once for each button that changed state since the last frame
  45122. * @param buttonIdx Which button index changed
  45123. * @param state New state of the button
  45124. * @param changes Which properties on the state changed since last frame
  45125. */
  45126. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45127. }
  45128. }
  45129. declare module BABYLON {
  45130. /**
  45131. * Class containing static functions to help procedurally build meshes
  45132. */
  45133. export class PolyhedronBuilder {
  45134. /**
  45135. * Creates a polyhedron mesh
  45136. * * 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
  45137. * * The parameter `size` (positive float, default 1) sets the polygon size
  45138. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45139. * * 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`
  45140. * * 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
  45141. * * 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)`)
  45142. * * 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
  45143. * * 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
  45144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45145. * * 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
  45146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45147. * @param name defines the name of the mesh
  45148. * @param options defines the options used to create the mesh
  45149. * @param scene defines the hosting scene
  45150. * @returns the polyhedron mesh
  45151. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45152. */
  45153. static CreatePolyhedron(name: string, options: {
  45154. type?: number;
  45155. size?: number;
  45156. sizeX?: number;
  45157. sizeY?: number;
  45158. sizeZ?: number;
  45159. custom?: any;
  45160. faceUV?: Vector4[];
  45161. faceColors?: Color4[];
  45162. flat?: boolean;
  45163. updatable?: boolean;
  45164. sideOrientation?: number;
  45165. frontUVs?: Vector4;
  45166. backUVs?: Vector4;
  45167. }, scene?: Nullable<Scene>): Mesh;
  45168. }
  45169. }
  45170. declare module BABYLON {
  45171. /**
  45172. * Gizmo that enables scaling a mesh along 3 axis
  45173. */
  45174. export class ScaleGizmo extends Gizmo {
  45175. /**
  45176. * Internal gizmo used for interactions on the x axis
  45177. */
  45178. xGizmo: AxisScaleGizmo;
  45179. /**
  45180. * Internal gizmo used for interactions on the y axis
  45181. */
  45182. yGizmo: AxisScaleGizmo;
  45183. /**
  45184. * Internal gizmo used for interactions on the z axis
  45185. */
  45186. zGizmo: AxisScaleGizmo;
  45187. /**
  45188. * Internal gizmo used to scale all axis equally
  45189. */
  45190. uniformScaleGizmo: AxisScaleGizmo;
  45191. private _meshAttached;
  45192. private _updateGizmoRotationToMatchAttachedMesh;
  45193. private _snapDistance;
  45194. private _scaleRatio;
  45195. private _uniformScalingMesh;
  45196. private _octahedron;
  45197. /** Fires an event when any of it's sub gizmos are dragged */
  45198. onDragStartObservable: Observable<unknown>;
  45199. /** Fires an event when any of it's sub gizmos are released from dragging */
  45200. onDragEndObservable: Observable<unknown>;
  45201. attachedMesh: Nullable<AbstractMesh>;
  45202. /**
  45203. * Creates a ScaleGizmo
  45204. * @param gizmoLayer The utility layer the gizmo will be added to
  45205. */
  45206. constructor(gizmoLayer?: UtilityLayerRenderer);
  45207. updateGizmoRotationToMatchAttachedMesh: boolean;
  45208. /**
  45209. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45210. */
  45211. snapDistance: number;
  45212. /**
  45213. * Ratio for the scale of the gizmo (Default: 1)
  45214. */
  45215. scaleRatio: number;
  45216. /**
  45217. * Disposes of the gizmo
  45218. */
  45219. dispose(): void;
  45220. }
  45221. }
  45222. declare module BABYLON {
  45223. /**
  45224. * Single axis scale gizmo
  45225. */
  45226. export class AxisScaleGizmo extends Gizmo {
  45227. /**
  45228. * Drag behavior responsible for the gizmos dragging interactions
  45229. */
  45230. dragBehavior: PointerDragBehavior;
  45231. private _pointerObserver;
  45232. /**
  45233. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45234. */
  45235. snapDistance: number;
  45236. /**
  45237. * Event that fires each time the gizmo snaps to a new location.
  45238. * * snapDistance is the the change in distance
  45239. */
  45240. onSnapObservable: Observable<{
  45241. snapDistance: number;
  45242. }>;
  45243. /**
  45244. * If the scaling operation should be done on all axis (default: false)
  45245. */
  45246. uniformScaling: boolean;
  45247. private _isEnabled;
  45248. private _parent;
  45249. private _arrow;
  45250. private _coloredMaterial;
  45251. private _hoverMaterial;
  45252. /**
  45253. * Creates an AxisScaleGizmo
  45254. * @param gizmoLayer The utility layer the gizmo will be added to
  45255. * @param dragAxis The axis which the gizmo will be able to scale on
  45256. * @param color The color of the gizmo
  45257. */
  45258. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45259. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45260. /**
  45261. * If the gizmo is enabled
  45262. */
  45263. isEnabled: boolean;
  45264. /**
  45265. * Disposes of the gizmo
  45266. */
  45267. dispose(): void;
  45268. /**
  45269. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45270. * @param mesh The mesh to replace the default mesh of the gizmo
  45271. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45272. */
  45273. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * Bounding box gizmo
  45279. */
  45280. export class BoundingBoxGizmo extends Gizmo {
  45281. private _lineBoundingBox;
  45282. private _rotateSpheresParent;
  45283. private _scaleBoxesParent;
  45284. private _boundingDimensions;
  45285. private _renderObserver;
  45286. private _pointerObserver;
  45287. private _scaleDragSpeed;
  45288. private _tmpQuaternion;
  45289. private _tmpVector;
  45290. private _tmpRotationMatrix;
  45291. /**
  45292. * 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)
  45293. */
  45294. ignoreChildren: boolean;
  45295. /**
  45296. * 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)
  45297. */
  45298. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45299. /**
  45300. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45301. */
  45302. rotationSphereSize: number;
  45303. /**
  45304. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45305. */
  45306. scaleBoxSize: number;
  45307. /**
  45308. * 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)
  45309. */
  45310. fixedDragMeshScreenSize: boolean;
  45311. /**
  45312. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45313. */
  45314. fixedDragMeshScreenSizeDistanceFactor: number;
  45315. /**
  45316. * Fired when a rotation sphere or scale box is dragged
  45317. */
  45318. onDragStartObservable: Observable<{}>;
  45319. /**
  45320. * Fired when a scale box is dragged
  45321. */
  45322. onScaleBoxDragObservable: Observable<{}>;
  45323. /**
  45324. * Fired when a scale box drag is ended
  45325. */
  45326. onScaleBoxDragEndObservable: Observable<{}>;
  45327. /**
  45328. * Fired when a rotation sphere is dragged
  45329. */
  45330. onRotationSphereDragObservable: Observable<{}>;
  45331. /**
  45332. * Fired when a rotation sphere drag is ended
  45333. */
  45334. onRotationSphereDragEndObservable: Observable<{}>;
  45335. /**
  45336. * 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)
  45337. */
  45338. scalePivot: Nullable<Vector3>;
  45339. /**
  45340. * Mesh used as a pivot to rotate the attached mesh
  45341. */
  45342. private _anchorMesh;
  45343. private _existingMeshScale;
  45344. private _dragMesh;
  45345. private pointerDragBehavior;
  45346. private coloredMaterial;
  45347. private hoverColoredMaterial;
  45348. /**
  45349. * Sets the color of the bounding box gizmo
  45350. * @param color the color to set
  45351. */
  45352. setColor(color: Color3): void;
  45353. /**
  45354. * Creates an BoundingBoxGizmo
  45355. * @param gizmoLayer The utility layer the gizmo will be added to
  45356. * @param color The color of the gizmo
  45357. */
  45358. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45359. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45360. private _selectNode;
  45361. /**
  45362. * Updates the bounding box information for the Gizmo
  45363. */
  45364. updateBoundingBox(): void;
  45365. private _updateRotationSpheres;
  45366. private _updateScaleBoxes;
  45367. /**
  45368. * Enables rotation on the specified axis and disables rotation on the others
  45369. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45370. */
  45371. setEnabledRotationAxis(axis: string): void;
  45372. /**
  45373. * Enables/disables scaling
  45374. * @param enable if scaling should be enabled
  45375. */
  45376. setEnabledScaling(enable: boolean): void;
  45377. private _updateDummy;
  45378. /**
  45379. * Enables a pointer drag behavior on the bounding box of the gizmo
  45380. */
  45381. enableDragBehavior(): void;
  45382. /**
  45383. * Disposes of the gizmo
  45384. */
  45385. dispose(): void;
  45386. /**
  45387. * 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)
  45388. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45389. * @returns the bounding box mesh with the passed in mesh as a child
  45390. */
  45391. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45392. /**
  45393. * CustomMeshes are not supported by this gizmo
  45394. * @param mesh The mesh to replace the default mesh of the gizmo
  45395. */
  45396. setCustomMesh(mesh: Mesh): void;
  45397. }
  45398. }
  45399. declare module BABYLON {
  45400. /**
  45401. * Single plane rotation gizmo
  45402. */
  45403. export class PlaneRotationGizmo extends Gizmo {
  45404. /**
  45405. * Drag behavior responsible for the gizmos dragging interactions
  45406. */
  45407. dragBehavior: PointerDragBehavior;
  45408. private _pointerObserver;
  45409. /**
  45410. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45411. */
  45412. snapDistance: number;
  45413. /**
  45414. * Event that fires each time the gizmo snaps to a new location.
  45415. * * snapDistance is the the change in distance
  45416. */
  45417. onSnapObservable: Observable<{
  45418. snapDistance: number;
  45419. }>;
  45420. private _isEnabled;
  45421. private _parent;
  45422. /**
  45423. * Creates a PlaneRotationGizmo
  45424. * @param gizmoLayer The utility layer the gizmo will be added to
  45425. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45426. * @param color The color of the gizmo
  45427. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45428. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45429. */
  45430. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45431. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45432. /**
  45433. * If the gizmo is enabled
  45434. */
  45435. isEnabled: boolean;
  45436. /**
  45437. * Disposes of the gizmo
  45438. */
  45439. dispose(): void;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * Gizmo that enables rotating a mesh along 3 axis
  45445. */
  45446. export class RotationGizmo extends Gizmo {
  45447. /**
  45448. * Internal gizmo used for interactions on the x axis
  45449. */
  45450. xGizmo: PlaneRotationGizmo;
  45451. /**
  45452. * Internal gizmo used for interactions on the y axis
  45453. */
  45454. yGizmo: PlaneRotationGizmo;
  45455. /**
  45456. * Internal gizmo used for interactions on the z axis
  45457. */
  45458. zGizmo: PlaneRotationGizmo;
  45459. /** Fires an event when any of it's sub gizmos are dragged */
  45460. onDragStartObservable: Observable<unknown>;
  45461. /** Fires an event when any of it's sub gizmos are released from dragging */
  45462. onDragEndObservable: Observable<unknown>;
  45463. private _meshAttached;
  45464. attachedMesh: Nullable<AbstractMesh>;
  45465. /**
  45466. * Creates a RotationGizmo
  45467. * @param gizmoLayer The utility layer the gizmo will be added to
  45468. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45469. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45470. */
  45471. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45472. updateGizmoRotationToMatchAttachedMesh: boolean;
  45473. /**
  45474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45475. */
  45476. snapDistance: number;
  45477. /**
  45478. * Ratio for the scale of the gizmo (Default: 1)
  45479. */
  45480. scaleRatio: number;
  45481. /**
  45482. * Disposes of the gizmo
  45483. */
  45484. dispose(): void;
  45485. /**
  45486. * CustomMeshes are not supported by this gizmo
  45487. * @param mesh The mesh to replace the default mesh of the gizmo
  45488. */
  45489. setCustomMesh(mesh: Mesh): void;
  45490. }
  45491. }
  45492. declare module BABYLON {
  45493. /**
  45494. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45495. */
  45496. export class GizmoManager implements IDisposable {
  45497. private scene;
  45498. /**
  45499. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45500. */
  45501. gizmos: {
  45502. positionGizmo: Nullable<PositionGizmo>;
  45503. rotationGizmo: Nullable<RotationGizmo>;
  45504. scaleGizmo: Nullable<ScaleGizmo>;
  45505. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45506. };
  45507. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45508. clearGizmoOnEmptyPointerEvent: boolean;
  45509. /** Fires an event when the manager is attached to a mesh */
  45510. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45511. private _gizmosEnabled;
  45512. private _pointerObserver;
  45513. private _attachedMesh;
  45514. private _boundingBoxColor;
  45515. private _defaultUtilityLayer;
  45516. private _defaultKeepDepthUtilityLayer;
  45517. /**
  45518. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45519. */
  45520. boundingBoxDragBehavior: SixDofDragBehavior;
  45521. /**
  45522. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45523. */
  45524. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45525. /**
  45526. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45527. */
  45528. usePointerToAttachGizmos: boolean;
  45529. /**
  45530. * Utility layer that the bounding box gizmo belongs to
  45531. */
  45532. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45533. /**
  45534. * Utility layer that all gizmos besides bounding box belong to
  45535. */
  45536. readonly utilityLayer: UtilityLayerRenderer;
  45537. /**
  45538. * Instatiates a gizmo manager
  45539. * @param scene the scene to overlay the gizmos on top of
  45540. */
  45541. constructor(scene: Scene);
  45542. /**
  45543. * Attaches a set of gizmos to the specified mesh
  45544. * @param mesh The mesh the gizmo's should be attached to
  45545. */
  45546. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45547. /**
  45548. * If the position gizmo is enabled
  45549. */
  45550. positionGizmoEnabled: boolean;
  45551. /**
  45552. * If the rotation gizmo is enabled
  45553. */
  45554. rotationGizmoEnabled: boolean;
  45555. /**
  45556. * If the scale gizmo is enabled
  45557. */
  45558. scaleGizmoEnabled: boolean;
  45559. /**
  45560. * If the boundingBox gizmo is enabled
  45561. */
  45562. boundingBoxGizmoEnabled: boolean;
  45563. /**
  45564. * Disposes of the gizmo manager
  45565. */
  45566. dispose(): void;
  45567. }
  45568. }
  45569. declare module BABYLON {
  45570. /**
  45571. * A directional light is defined by a direction (what a surprise!).
  45572. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45573. * 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.
  45574. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45575. */
  45576. export class DirectionalLight extends ShadowLight {
  45577. private _shadowFrustumSize;
  45578. /**
  45579. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45580. */
  45581. /**
  45582. * Specifies a fix frustum size for the shadow generation.
  45583. */
  45584. shadowFrustumSize: number;
  45585. private _shadowOrthoScale;
  45586. /**
  45587. * Gets the shadow projection scale against the optimal computed one.
  45588. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45589. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45590. */
  45591. /**
  45592. * Sets the shadow projection scale against the optimal computed one.
  45593. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45594. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45595. */
  45596. shadowOrthoScale: number;
  45597. /**
  45598. * Automatically compute the projection matrix to best fit (including all the casters)
  45599. * on each frame.
  45600. */
  45601. autoUpdateExtends: boolean;
  45602. private _orthoLeft;
  45603. private _orthoRight;
  45604. private _orthoTop;
  45605. private _orthoBottom;
  45606. /**
  45607. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45608. * The directional light is emitted from everywhere in the given direction.
  45609. * It can cast shadows.
  45610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45611. * @param name The friendly name of the light
  45612. * @param direction The direction of the light
  45613. * @param scene The scene the light belongs to
  45614. */
  45615. constructor(name: string, direction: Vector3, scene: Scene);
  45616. /**
  45617. * Returns the string "DirectionalLight".
  45618. * @return The class name
  45619. */
  45620. getClassName(): string;
  45621. /**
  45622. * Returns the integer 1.
  45623. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45624. */
  45625. getTypeID(): number;
  45626. /**
  45627. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45628. * Returns the DirectionalLight Shadow projection matrix.
  45629. */
  45630. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45631. /**
  45632. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45633. * Returns the DirectionalLight Shadow projection matrix.
  45634. */
  45635. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45636. /**
  45637. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45638. * Returns the DirectionalLight Shadow projection matrix.
  45639. */
  45640. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45641. protected _buildUniformLayout(): void;
  45642. /**
  45643. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45644. * @param effect The effect to update
  45645. * @param lightIndex The index of the light in the effect to update
  45646. * @returns The directional light
  45647. */
  45648. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45649. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45650. /**
  45651. * Gets the minZ used for shadow according to both the scene and the light.
  45652. *
  45653. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45654. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45655. * @param activeCamera The camera we are returning the min for
  45656. * @returns the depth min z
  45657. */
  45658. getDepthMinZ(activeCamera: Camera): number;
  45659. /**
  45660. * Gets the maxZ used for shadow according to both the scene and the light.
  45661. *
  45662. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45663. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45664. * @param activeCamera The camera we are returning the max for
  45665. * @returns the depth max z
  45666. */
  45667. getDepthMaxZ(activeCamera: Camera): number;
  45668. /**
  45669. * Prepares the list of defines specific to the light type.
  45670. * @param defines the list of defines
  45671. * @param lightIndex defines the index of the light for the effect
  45672. */
  45673. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45674. }
  45675. }
  45676. declare module BABYLON {
  45677. /**
  45678. * Class containing static functions to help procedurally build meshes
  45679. */
  45680. export class HemisphereBuilder {
  45681. /**
  45682. * Creates a hemisphere mesh
  45683. * @param name defines the name of the mesh
  45684. * @param options defines the options used to create the mesh
  45685. * @param scene defines the hosting scene
  45686. * @returns the hemisphere mesh
  45687. */
  45688. static CreateHemisphere(name: string, options: {
  45689. segments?: number;
  45690. diameter?: number;
  45691. sideOrientation?: number;
  45692. }, scene: any): Mesh;
  45693. }
  45694. }
  45695. declare module BABYLON {
  45696. /**
  45697. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45698. * These values define a cone of light starting from the position, emitting toward the direction.
  45699. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45700. * and the exponent defines the speed of the decay of the light with distance (reach).
  45701. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45702. */
  45703. export class SpotLight extends ShadowLight {
  45704. private _angle;
  45705. private _innerAngle;
  45706. private _cosHalfAngle;
  45707. private _lightAngleScale;
  45708. private _lightAngleOffset;
  45709. /**
  45710. * Gets the cone angle of the spot light in Radians.
  45711. */
  45712. /**
  45713. * Sets the cone angle of the spot light in Radians.
  45714. */
  45715. angle: number;
  45716. /**
  45717. * Only used in gltf falloff mode, this defines the angle where
  45718. * the directional falloff will start before cutting at angle which could be seen
  45719. * as outer angle.
  45720. */
  45721. /**
  45722. * Only used in gltf falloff mode, this defines the angle where
  45723. * the directional falloff will start before cutting at angle which could be seen
  45724. * as outer angle.
  45725. */
  45726. innerAngle: number;
  45727. private _shadowAngleScale;
  45728. /**
  45729. * Allows scaling the angle of the light for shadow generation only.
  45730. */
  45731. /**
  45732. * Allows scaling the angle of the light for shadow generation only.
  45733. */
  45734. shadowAngleScale: number;
  45735. /**
  45736. * The light decay speed with the distance from the emission spot.
  45737. */
  45738. exponent: number;
  45739. private _projectionTextureMatrix;
  45740. /**
  45741. * Allows reading the projecton texture
  45742. */
  45743. readonly projectionTextureMatrix: Matrix;
  45744. protected _projectionTextureLightNear: number;
  45745. /**
  45746. * Gets the near clip of the Spotlight for texture projection.
  45747. */
  45748. /**
  45749. * Sets the near clip of the Spotlight for texture projection.
  45750. */
  45751. projectionTextureLightNear: number;
  45752. protected _projectionTextureLightFar: number;
  45753. /**
  45754. * Gets the far clip of the Spotlight for texture projection.
  45755. */
  45756. /**
  45757. * Sets the far clip of the Spotlight for texture projection.
  45758. */
  45759. projectionTextureLightFar: number;
  45760. protected _projectionTextureUpDirection: Vector3;
  45761. /**
  45762. * Gets the Up vector of the Spotlight for texture projection.
  45763. */
  45764. /**
  45765. * Sets the Up vector of the Spotlight for texture projection.
  45766. */
  45767. projectionTextureUpDirection: Vector3;
  45768. private _projectionTexture;
  45769. /**
  45770. * Gets the projection texture of the light.
  45771. */
  45772. /**
  45773. * Sets the projection texture of the light.
  45774. */
  45775. projectionTexture: Nullable<BaseTexture>;
  45776. private _projectionTextureViewLightDirty;
  45777. private _projectionTextureProjectionLightDirty;
  45778. private _projectionTextureDirty;
  45779. private _projectionTextureViewTargetVector;
  45780. private _projectionTextureViewLightMatrix;
  45781. private _projectionTextureProjectionLightMatrix;
  45782. private _projectionTextureScalingMatrix;
  45783. /**
  45784. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45785. * It can cast shadows.
  45786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45787. * @param name The light friendly name
  45788. * @param position The position of the spot light in the scene
  45789. * @param direction The direction of the light in the scene
  45790. * @param angle The cone angle of the light in Radians
  45791. * @param exponent The light decay speed with the distance from the emission spot
  45792. * @param scene The scene the lights belongs to
  45793. */
  45794. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45795. /**
  45796. * Returns the string "SpotLight".
  45797. * @returns the class name
  45798. */
  45799. getClassName(): string;
  45800. /**
  45801. * Returns the integer 2.
  45802. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45803. */
  45804. getTypeID(): number;
  45805. /**
  45806. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45807. */
  45808. protected _setDirection(value: Vector3): void;
  45809. /**
  45810. * Overrides the position setter to recompute the projection texture view light Matrix.
  45811. */
  45812. protected _setPosition(value: Vector3): void;
  45813. /**
  45814. * 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.
  45815. * Returns the SpotLight.
  45816. */
  45817. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45818. protected _computeProjectionTextureViewLightMatrix(): void;
  45819. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45820. /**
  45821. * Main function for light texture projection matrix computing.
  45822. */
  45823. protected _computeProjectionTextureMatrix(): void;
  45824. protected _buildUniformLayout(): void;
  45825. private _computeAngleValues;
  45826. /**
  45827. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45828. * @param effect The effect to update
  45829. * @param lightIndex The index of the light in the effect to update
  45830. * @returns The spot light
  45831. */
  45832. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45833. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45834. /**
  45835. * Disposes the light and the associated resources.
  45836. */
  45837. dispose(): void;
  45838. /**
  45839. * Prepares the list of defines specific to the light type.
  45840. * @param defines the list of defines
  45841. * @param lightIndex defines the index of the light for the effect
  45842. */
  45843. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45844. }
  45845. }
  45846. declare module BABYLON {
  45847. /**
  45848. * Gizmo that enables viewing a light
  45849. */
  45850. export class LightGizmo extends Gizmo {
  45851. private _lightMesh;
  45852. private _material;
  45853. private cachedPosition;
  45854. private cachedForward;
  45855. /**
  45856. * Creates a LightGizmo
  45857. * @param gizmoLayer The utility layer the gizmo will be added to
  45858. */
  45859. constructor(gizmoLayer?: UtilityLayerRenderer);
  45860. private _light;
  45861. /**
  45862. * The light that the gizmo is attached to
  45863. */
  45864. light: Nullable<Light>;
  45865. /**
  45866. * Gets the material used to render the light gizmo
  45867. */
  45868. readonly material: StandardMaterial;
  45869. /**
  45870. * @hidden
  45871. * Updates the gizmo to match the attached mesh's position/rotation
  45872. */
  45873. protected _update(): void;
  45874. private static _Scale;
  45875. /**
  45876. * Creates the lines for a light mesh
  45877. */
  45878. private static _createLightLines;
  45879. /**
  45880. * Disposes of the light gizmo
  45881. */
  45882. dispose(): void;
  45883. private static _CreateHemisphericLightMesh;
  45884. private static _CreatePointLightMesh;
  45885. private static _CreateSpotLightMesh;
  45886. private static _CreateDirectionalLightMesh;
  45887. }
  45888. }
  45889. declare module BABYLON {
  45890. /** @hidden */
  45891. export var backgroundFragmentDeclaration: {
  45892. name: string;
  45893. shader: string;
  45894. };
  45895. }
  45896. declare module BABYLON {
  45897. /** @hidden */
  45898. export var backgroundUboDeclaration: {
  45899. name: string;
  45900. shader: string;
  45901. };
  45902. }
  45903. declare module BABYLON {
  45904. /** @hidden */
  45905. export var backgroundPixelShader: {
  45906. name: string;
  45907. shader: string;
  45908. };
  45909. }
  45910. declare module BABYLON {
  45911. /** @hidden */
  45912. export var backgroundVertexDeclaration: {
  45913. name: string;
  45914. shader: string;
  45915. };
  45916. }
  45917. declare module BABYLON {
  45918. /** @hidden */
  45919. export var backgroundVertexShader: {
  45920. name: string;
  45921. shader: string;
  45922. };
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Background material used to create an efficient environement around your scene.
  45927. */
  45928. export class BackgroundMaterial extends PushMaterial {
  45929. /**
  45930. * Standard reflectance value at parallel view angle.
  45931. */
  45932. static StandardReflectance0: number;
  45933. /**
  45934. * Standard reflectance value at grazing angle.
  45935. */
  45936. static StandardReflectance90: number;
  45937. protected _primaryColor: Color3;
  45938. /**
  45939. * Key light Color (multiply against the environement texture)
  45940. */
  45941. primaryColor: Color3;
  45942. protected __perceptualColor: Nullable<Color3>;
  45943. /**
  45944. * Experimental Internal Use Only.
  45945. *
  45946. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45947. * This acts as a helper to set the primary color to a more "human friendly" value.
  45948. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45949. * output color as close as possible from the chosen value.
  45950. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45951. * part of lighting setup.)
  45952. */
  45953. _perceptualColor: Nullable<Color3>;
  45954. protected _primaryColorShadowLevel: float;
  45955. /**
  45956. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45957. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45958. */
  45959. primaryColorShadowLevel: float;
  45960. protected _primaryColorHighlightLevel: float;
  45961. /**
  45962. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45963. * The primary color is used at the level chosen to define what the white area would look.
  45964. */
  45965. primaryColorHighlightLevel: float;
  45966. protected _reflectionTexture: Nullable<BaseTexture>;
  45967. /**
  45968. * Reflection Texture used in the material.
  45969. * Should be author in a specific way for the best result (refer to the documentation).
  45970. */
  45971. reflectionTexture: Nullable<BaseTexture>;
  45972. protected _reflectionBlur: float;
  45973. /**
  45974. * Reflection Texture level of blur.
  45975. *
  45976. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45977. * texture twice.
  45978. */
  45979. reflectionBlur: float;
  45980. protected _diffuseTexture: Nullable<BaseTexture>;
  45981. /**
  45982. * Diffuse Texture used in the material.
  45983. * Should be author in a specific way for the best result (refer to the documentation).
  45984. */
  45985. diffuseTexture: Nullable<BaseTexture>;
  45986. protected _shadowLights: Nullable<IShadowLight[]>;
  45987. /**
  45988. * Specify the list of lights casting shadow on the material.
  45989. * All scene shadow lights will be included if null.
  45990. */
  45991. shadowLights: Nullable<IShadowLight[]>;
  45992. protected _shadowLevel: float;
  45993. /**
  45994. * Helps adjusting the shadow to a softer level if required.
  45995. * 0 means black shadows and 1 means no shadows.
  45996. */
  45997. shadowLevel: float;
  45998. protected _sceneCenter: Vector3;
  45999. /**
  46000. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46001. * It is usually zero but might be interesting to modify according to your setup.
  46002. */
  46003. sceneCenter: Vector3;
  46004. protected _opacityFresnel: boolean;
  46005. /**
  46006. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46007. * This helps ensuring a nice transition when the camera goes under the ground.
  46008. */
  46009. opacityFresnel: boolean;
  46010. protected _reflectionFresnel: boolean;
  46011. /**
  46012. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46013. * This helps adding a mirror texture on the ground.
  46014. */
  46015. reflectionFresnel: boolean;
  46016. protected _reflectionFalloffDistance: number;
  46017. /**
  46018. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46019. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46020. */
  46021. reflectionFalloffDistance: number;
  46022. protected _reflectionAmount: number;
  46023. /**
  46024. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46025. */
  46026. reflectionAmount: number;
  46027. protected _reflectionReflectance0: number;
  46028. /**
  46029. * This specifies the weight of the reflection at grazing angle.
  46030. */
  46031. reflectionReflectance0: number;
  46032. protected _reflectionReflectance90: number;
  46033. /**
  46034. * This specifies the weight of the reflection at a perpendicular point of view.
  46035. */
  46036. reflectionReflectance90: number;
  46037. /**
  46038. * Sets the reflection reflectance fresnel values according to the default standard
  46039. * empirically know to work well :-)
  46040. */
  46041. reflectionStandardFresnelWeight: number;
  46042. protected _useRGBColor: boolean;
  46043. /**
  46044. * Helps to directly use the maps channels instead of their level.
  46045. */
  46046. useRGBColor: boolean;
  46047. protected _enableNoise: boolean;
  46048. /**
  46049. * This helps reducing the banding effect that could occur on the background.
  46050. */
  46051. enableNoise: boolean;
  46052. /**
  46053. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46054. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46055. * Recommended to be keep at 1.0 except for special cases.
  46056. */
  46057. fovMultiplier: number;
  46058. private _fovMultiplier;
  46059. /**
  46060. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46061. */
  46062. useEquirectangularFOV: boolean;
  46063. private _maxSimultaneousLights;
  46064. /**
  46065. * Number of Simultaneous lights allowed on the material.
  46066. */
  46067. maxSimultaneousLights: int;
  46068. /**
  46069. * Default configuration related to image processing available in the Background Material.
  46070. */
  46071. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46072. /**
  46073. * Keep track of the image processing observer to allow dispose and replace.
  46074. */
  46075. private _imageProcessingObserver;
  46076. /**
  46077. * Attaches a new image processing configuration to the PBR Material.
  46078. * @param configuration (if null the scene configuration will be use)
  46079. */
  46080. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46081. /**
  46082. * Gets the image processing configuration used either in this material.
  46083. */
  46084. /**
  46085. * Sets the Default image processing configuration used either in the this material.
  46086. *
  46087. * If sets to null, the scene one is in use.
  46088. */
  46089. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46090. /**
  46091. * Gets wether the color curves effect is enabled.
  46092. */
  46093. /**
  46094. * Sets wether the color curves effect is enabled.
  46095. */
  46096. cameraColorCurvesEnabled: boolean;
  46097. /**
  46098. * Gets wether the color grading effect is enabled.
  46099. */
  46100. /**
  46101. * Gets wether the color grading effect is enabled.
  46102. */
  46103. cameraColorGradingEnabled: boolean;
  46104. /**
  46105. * Gets wether tonemapping is enabled or not.
  46106. */
  46107. /**
  46108. * Sets wether tonemapping is enabled or not
  46109. */
  46110. cameraToneMappingEnabled: boolean;
  46111. /**
  46112. * The camera exposure used on this material.
  46113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46114. * This corresponds to a photographic exposure.
  46115. */
  46116. /**
  46117. * The camera exposure used on this material.
  46118. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46119. * This corresponds to a photographic exposure.
  46120. */
  46121. cameraExposure: float;
  46122. /**
  46123. * Gets The camera contrast used on this material.
  46124. */
  46125. /**
  46126. * Sets The camera contrast used on this material.
  46127. */
  46128. cameraContrast: float;
  46129. /**
  46130. * Gets the Color Grading 2D Lookup Texture.
  46131. */
  46132. /**
  46133. * Sets the Color Grading 2D Lookup Texture.
  46134. */
  46135. cameraColorGradingTexture: Nullable<BaseTexture>;
  46136. /**
  46137. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46138. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46139. * 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;
  46140. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46141. */
  46142. /**
  46143. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46144. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46145. * 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;
  46146. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46147. */
  46148. cameraColorCurves: Nullable<ColorCurves>;
  46149. /**
  46150. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46151. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46152. */
  46153. switchToBGR: boolean;
  46154. private _renderTargets;
  46155. private _reflectionControls;
  46156. private _white;
  46157. private _primaryShadowColor;
  46158. private _primaryHighlightColor;
  46159. /**
  46160. * Instantiates a Background Material in the given scene
  46161. * @param name The friendly name of the material
  46162. * @param scene The scene to add the material to
  46163. */
  46164. constructor(name: string, scene: Scene);
  46165. /**
  46166. * Gets a boolean indicating that current material needs to register RTT
  46167. */
  46168. readonly hasRenderTargetTextures: boolean;
  46169. /**
  46170. * The entire material has been created in order to prevent overdraw.
  46171. * @returns false
  46172. */
  46173. needAlphaTesting(): boolean;
  46174. /**
  46175. * The entire material has been created in order to prevent overdraw.
  46176. * @returns true if blending is enable
  46177. */
  46178. needAlphaBlending(): boolean;
  46179. /**
  46180. * Checks wether the material is ready to be rendered for a given mesh.
  46181. * @param mesh The mesh to render
  46182. * @param subMesh The submesh to check against
  46183. * @param useInstances Specify wether or not the material is used with instances
  46184. * @returns true if all the dependencies are ready (Textures, Effects...)
  46185. */
  46186. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46187. /**
  46188. * Compute the primary color according to the chosen perceptual color.
  46189. */
  46190. private _computePrimaryColorFromPerceptualColor;
  46191. /**
  46192. * Compute the highlights and shadow colors according to their chosen levels.
  46193. */
  46194. private _computePrimaryColors;
  46195. /**
  46196. * Build the uniform buffer used in the material.
  46197. */
  46198. buildUniformLayout(): void;
  46199. /**
  46200. * Unbind the material.
  46201. */
  46202. unbind(): void;
  46203. /**
  46204. * Bind only the world matrix to the material.
  46205. * @param world The world matrix to bind.
  46206. */
  46207. bindOnlyWorldMatrix(world: Matrix): void;
  46208. /**
  46209. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46210. * @param world The world matrix to bind.
  46211. * @param subMesh The submesh to bind for.
  46212. */
  46213. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46214. /**
  46215. * Checks to see if a texture is used in the material.
  46216. * @param texture - Base texture to use.
  46217. * @returns - Boolean specifying if a texture is used in the material.
  46218. */
  46219. hasTexture(texture: BaseTexture): boolean;
  46220. /**
  46221. * Dispose the material.
  46222. * @param forceDisposeEffect Force disposal of the associated effect.
  46223. * @param forceDisposeTextures Force disposal of the associated textures.
  46224. */
  46225. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46226. /**
  46227. * Clones the material.
  46228. * @param name The cloned name.
  46229. * @returns The cloned material.
  46230. */
  46231. clone(name: string): BackgroundMaterial;
  46232. /**
  46233. * Serializes the current material to its JSON representation.
  46234. * @returns The JSON representation.
  46235. */
  46236. serialize(): any;
  46237. /**
  46238. * Gets the class name of the material
  46239. * @returns "BackgroundMaterial"
  46240. */
  46241. getClassName(): string;
  46242. /**
  46243. * Parse a JSON input to create back a background material.
  46244. * @param source The JSON data to parse
  46245. * @param scene The scene to create the parsed material in
  46246. * @param rootUrl The root url of the assets the material depends upon
  46247. * @returns the instantiated BackgroundMaterial.
  46248. */
  46249. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46250. }
  46251. }
  46252. declare module BABYLON {
  46253. /**
  46254. * Represents the different options available during the creation of
  46255. * a Environment helper.
  46256. *
  46257. * This can control the default ground, skybox and image processing setup of your scene.
  46258. */
  46259. export interface IEnvironmentHelperOptions {
  46260. /**
  46261. * Specifies wether or not to create a ground.
  46262. * True by default.
  46263. */
  46264. createGround: boolean;
  46265. /**
  46266. * Specifies the ground size.
  46267. * 15 by default.
  46268. */
  46269. groundSize: number;
  46270. /**
  46271. * The texture used on the ground for the main color.
  46272. * Comes from the BabylonJS CDN by default.
  46273. *
  46274. * Remarks: Can be either a texture or a url.
  46275. */
  46276. groundTexture: string | BaseTexture;
  46277. /**
  46278. * The color mixed in the ground texture by default.
  46279. * BabylonJS clearColor by default.
  46280. */
  46281. groundColor: Color3;
  46282. /**
  46283. * Specifies the ground opacity.
  46284. * 1 by default.
  46285. */
  46286. groundOpacity: number;
  46287. /**
  46288. * Enables the ground to receive shadows.
  46289. * True by default.
  46290. */
  46291. enableGroundShadow: boolean;
  46292. /**
  46293. * Helps preventing the shadow to be fully black on the ground.
  46294. * 0.5 by default.
  46295. */
  46296. groundShadowLevel: number;
  46297. /**
  46298. * Creates a mirror texture attach to the ground.
  46299. * false by default.
  46300. */
  46301. enableGroundMirror: boolean;
  46302. /**
  46303. * Specifies the ground mirror size ratio.
  46304. * 0.3 by default as the default kernel is 64.
  46305. */
  46306. groundMirrorSizeRatio: number;
  46307. /**
  46308. * Specifies the ground mirror blur kernel size.
  46309. * 64 by default.
  46310. */
  46311. groundMirrorBlurKernel: number;
  46312. /**
  46313. * Specifies the ground mirror visibility amount.
  46314. * 1 by default
  46315. */
  46316. groundMirrorAmount: number;
  46317. /**
  46318. * Specifies the ground mirror reflectance weight.
  46319. * This uses the standard weight of the background material to setup the fresnel effect
  46320. * of the mirror.
  46321. * 1 by default.
  46322. */
  46323. groundMirrorFresnelWeight: number;
  46324. /**
  46325. * Specifies the ground mirror Falloff distance.
  46326. * This can helps reducing the size of the reflection.
  46327. * 0 by Default.
  46328. */
  46329. groundMirrorFallOffDistance: number;
  46330. /**
  46331. * Specifies the ground mirror texture type.
  46332. * Unsigned Int by Default.
  46333. */
  46334. groundMirrorTextureType: number;
  46335. /**
  46336. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46337. * the shown objects.
  46338. */
  46339. groundYBias: number;
  46340. /**
  46341. * Specifies wether or not to create a skybox.
  46342. * True by default.
  46343. */
  46344. createSkybox: boolean;
  46345. /**
  46346. * Specifies the skybox size.
  46347. * 20 by default.
  46348. */
  46349. skyboxSize: number;
  46350. /**
  46351. * The texture used on the skybox for the main color.
  46352. * Comes from the BabylonJS CDN by default.
  46353. *
  46354. * Remarks: Can be either a texture or a url.
  46355. */
  46356. skyboxTexture: string | BaseTexture;
  46357. /**
  46358. * The color mixed in the skybox texture by default.
  46359. * BabylonJS clearColor by default.
  46360. */
  46361. skyboxColor: Color3;
  46362. /**
  46363. * The background rotation around the Y axis of the scene.
  46364. * This helps aligning the key lights of your scene with the background.
  46365. * 0 by default.
  46366. */
  46367. backgroundYRotation: number;
  46368. /**
  46369. * Compute automatically the size of the elements to best fit with the scene.
  46370. */
  46371. sizeAuto: boolean;
  46372. /**
  46373. * Default position of the rootMesh if autoSize is not true.
  46374. */
  46375. rootPosition: Vector3;
  46376. /**
  46377. * Sets up the image processing in the scene.
  46378. * true by default.
  46379. */
  46380. setupImageProcessing: boolean;
  46381. /**
  46382. * The texture used as your environment texture in the scene.
  46383. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46384. *
  46385. * Remarks: Can be either a texture or a url.
  46386. */
  46387. environmentTexture: string | BaseTexture;
  46388. /**
  46389. * The value of the exposure to apply to the scene.
  46390. * 0.6 by default if setupImageProcessing is true.
  46391. */
  46392. cameraExposure: number;
  46393. /**
  46394. * The value of the contrast to apply to the scene.
  46395. * 1.6 by default if setupImageProcessing is true.
  46396. */
  46397. cameraContrast: number;
  46398. /**
  46399. * Specifies wether or not tonemapping should be enabled in the scene.
  46400. * true by default if setupImageProcessing is true.
  46401. */
  46402. toneMappingEnabled: boolean;
  46403. }
  46404. /**
  46405. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46406. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46407. * It also helps with the default setup of your imageProcessing configuration.
  46408. */
  46409. export class EnvironmentHelper {
  46410. /**
  46411. * Default ground texture URL.
  46412. */
  46413. private static _groundTextureCDNUrl;
  46414. /**
  46415. * Default skybox texture URL.
  46416. */
  46417. private static _skyboxTextureCDNUrl;
  46418. /**
  46419. * Default environment texture URL.
  46420. */
  46421. private static _environmentTextureCDNUrl;
  46422. /**
  46423. * Creates the default options for the helper.
  46424. */
  46425. private static _getDefaultOptions;
  46426. private _rootMesh;
  46427. /**
  46428. * Gets the root mesh created by the helper.
  46429. */
  46430. readonly rootMesh: Mesh;
  46431. private _skybox;
  46432. /**
  46433. * Gets the skybox created by the helper.
  46434. */
  46435. readonly skybox: Nullable<Mesh>;
  46436. private _skyboxTexture;
  46437. /**
  46438. * Gets the skybox texture created by the helper.
  46439. */
  46440. readonly skyboxTexture: Nullable<BaseTexture>;
  46441. private _skyboxMaterial;
  46442. /**
  46443. * Gets the skybox material created by the helper.
  46444. */
  46445. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46446. private _ground;
  46447. /**
  46448. * Gets the ground mesh created by the helper.
  46449. */
  46450. readonly ground: Nullable<Mesh>;
  46451. private _groundTexture;
  46452. /**
  46453. * Gets the ground texture created by the helper.
  46454. */
  46455. readonly groundTexture: Nullable<BaseTexture>;
  46456. private _groundMirror;
  46457. /**
  46458. * Gets the ground mirror created by the helper.
  46459. */
  46460. readonly groundMirror: Nullable<MirrorTexture>;
  46461. /**
  46462. * Gets the ground mirror render list to helps pushing the meshes
  46463. * you wish in the ground reflection.
  46464. */
  46465. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46466. private _groundMaterial;
  46467. /**
  46468. * Gets the ground material created by the helper.
  46469. */
  46470. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46471. /**
  46472. * Stores the creation options.
  46473. */
  46474. private readonly _scene;
  46475. private _options;
  46476. /**
  46477. * This observable will be notified with any error during the creation of the environment,
  46478. * mainly texture creation errors.
  46479. */
  46480. onErrorObservable: Observable<{
  46481. message?: string;
  46482. exception?: any;
  46483. }>;
  46484. /**
  46485. * constructor
  46486. * @param options Defines the options we want to customize the helper
  46487. * @param scene The scene to add the material to
  46488. */
  46489. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46490. /**
  46491. * Updates the background according to the new options
  46492. * @param options
  46493. */
  46494. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46495. /**
  46496. * Sets the primary color of all the available elements.
  46497. * @param color the main color to affect to the ground and the background
  46498. */
  46499. setMainColor(color: Color3): void;
  46500. /**
  46501. * Setup the image processing according to the specified options.
  46502. */
  46503. private _setupImageProcessing;
  46504. /**
  46505. * Setup the environment texture according to the specified options.
  46506. */
  46507. private _setupEnvironmentTexture;
  46508. /**
  46509. * Setup the background according to the specified options.
  46510. */
  46511. private _setupBackground;
  46512. /**
  46513. * Get the scene sizes according to the setup.
  46514. */
  46515. private _getSceneSize;
  46516. /**
  46517. * Setup the ground according to the specified options.
  46518. */
  46519. private _setupGround;
  46520. /**
  46521. * Setup the ground material according to the specified options.
  46522. */
  46523. private _setupGroundMaterial;
  46524. /**
  46525. * Setup the ground diffuse texture according to the specified options.
  46526. */
  46527. private _setupGroundDiffuseTexture;
  46528. /**
  46529. * Setup the ground mirror texture according to the specified options.
  46530. */
  46531. private _setupGroundMirrorTexture;
  46532. /**
  46533. * Setup the ground to receive the mirror texture.
  46534. */
  46535. private _setupMirrorInGroundMaterial;
  46536. /**
  46537. * Setup the skybox according to the specified options.
  46538. */
  46539. private _setupSkybox;
  46540. /**
  46541. * Setup the skybox material according to the specified options.
  46542. */
  46543. private _setupSkyboxMaterial;
  46544. /**
  46545. * Setup the skybox reflection texture according to the specified options.
  46546. */
  46547. private _setupSkyboxReflectionTexture;
  46548. private _errorHandler;
  46549. /**
  46550. * Dispose all the elements created by the Helper.
  46551. */
  46552. dispose(): void;
  46553. }
  46554. }
  46555. declare module BABYLON {
  46556. /**
  46557. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46558. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46559. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46561. */
  46562. export class PhotoDome extends TransformNode {
  46563. /**
  46564. * Define the image as a Monoscopic panoramic 360 image.
  46565. */
  46566. static readonly MODE_MONOSCOPIC: number;
  46567. /**
  46568. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46569. */
  46570. static readonly MODE_TOPBOTTOM: number;
  46571. /**
  46572. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46573. */
  46574. static readonly MODE_SIDEBYSIDE: number;
  46575. private _useDirectMapping;
  46576. /**
  46577. * The texture being displayed on the sphere
  46578. */
  46579. protected _photoTexture: Texture;
  46580. /**
  46581. * Gets or sets the texture being displayed on the sphere
  46582. */
  46583. photoTexture: Texture;
  46584. /**
  46585. * Observable raised when an error occured while loading the 360 image
  46586. */
  46587. onLoadErrorObservable: Observable<string>;
  46588. /**
  46589. * The skybox material
  46590. */
  46591. protected _material: BackgroundMaterial;
  46592. /**
  46593. * The surface used for the skybox
  46594. */
  46595. protected _mesh: Mesh;
  46596. /**
  46597. * Gets the mesh used for the skybox.
  46598. */
  46599. readonly mesh: Mesh;
  46600. /**
  46601. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46602. * Also see the options.resolution property.
  46603. */
  46604. fovMultiplier: number;
  46605. private _imageMode;
  46606. /**
  46607. * Gets or set the current video mode for the video. It can be:
  46608. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46609. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46610. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46611. */
  46612. imageMode: number;
  46613. /**
  46614. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46615. * @param name Element's name, child elements will append suffixes for their own names.
  46616. * @param urlsOfPhoto defines the url of the photo to display
  46617. * @param options defines an object containing optional or exposed sub element properties
  46618. * @param onError defines a callback called when an error occured while loading the texture
  46619. */
  46620. constructor(name: string, urlOfPhoto: string, options: {
  46621. resolution?: number;
  46622. size?: number;
  46623. useDirectMapping?: boolean;
  46624. faceForward?: boolean;
  46625. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46626. private _onBeforeCameraRenderObserver;
  46627. private _changeImageMode;
  46628. /**
  46629. * Releases resources associated with this node.
  46630. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46631. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46632. */
  46633. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46634. }
  46635. }
  46636. declare module BABYLON {
  46637. /**
  46638. * Class used to host RGBD texture specific utilities
  46639. */
  46640. export class RGBDTextureTools {
  46641. /**
  46642. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46643. * @param texture the texture to expand.
  46644. */
  46645. static ExpandRGBDTexture(texture: Texture): void;
  46646. }
  46647. }
  46648. declare module BABYLON {
  46649. /**
  46650. * Class used to host texture specific utilities
  46651. */
  46652. export class BRDFTextureTools {
  46653. /**
  46654. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46655. * @param scene defines the hosting scene
  46656. * @returns the environment BRDF texture
  46657. */
  46658. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46659. private static _environmentBRDFBase64Texture;
  46660. }
  46661. }
  46662. declare module BABYLON {
  46663. /**
  46664. * @hidden
  46665. */
  46666. export interface IMaterialClearCoatDefines {
  46667. CLEARCOAT: boolean;
  46668. CLEARCOAT_DEFAULTIOR: boolean;
  46669. CLEARCOAT_TEXTURE: boolean;
  46670. CLEARCOAT_TEXTUREDIRECTUV: number;
  46671. CLEARCOAT_BUMP: boolean;
  46672. CLEARCOAT_BUMPDIRECTUV: number;
  46673. CLEARCOAT_TINT: boolean;
  46674. CLEARCOAT_TINT_TEXTURE: boolean;
  46675. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46676. /** @hidden */
  46677. _areTexturesDirty: boolean;
  46678. }
  46679. /**
  46680. * Define the code related to the clear coat parameters of the pbr material.
  46681. */
  46682. export class PBRClearCoatConfiguration {
  46683. /**
  46684. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46685. * The default fits with a polyurethane material.
  46686. */
  46687. private static readonly _DefaultIndexOfRefraction;
  46688. private _isEnabled;
  46689. /**
  46690. * Defines if the clear coat is enabled in the material.
  46691. */
  46692. isEnabled: boolean;
  46693. /**
  46694. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46695. */
  46696. intensity: number;
  46697. /**
  46698. * Defines the clear coat layer roughness.
  46699. */
  46700. roughness: number;
  46701. private _indexOfRefraction;
  46702. /**
  46703. * Defines the index of refraction of the clear coat.
  46704. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46705. * The default fits with a polyurethane material.
  46706. * Changing the default value is more performance intensive.
  46707. */
  46708. indexOfRefraction: number;
  46709. private _texture;
  46710. /**
  46711. * Stores the clear coat values in a texture.
  46712. */
  46713. texture: Nullable<BaseTexture>;
  46714. private _bumpTexture;
  46715. /**
  46716. * Define the clear coat specific bump texture.
  46717. */
  46718. bumpTexture: Nullable<BaseTexture>;
  46719. private _isTintEnabled;
  46720. /**
  46721. * Defines if the clear coat tint is enabled in the material.
  46722. */
  46723. isTintEnabled: boolean;
  46724. /**
  46725. * Defines the clear coat tint of the material.
  46726. * This is only use if tint is enabled
  46727. */
  46728. tintColor: Color3;
  46729. /**
  46730. * Defines the distance at which the tint color should be found in the
  46731. * clear coat media.
  46732. * This is only use if tint is enabled
  46733. */
  46734. tintColorAtDistance: number;
  46735. /**
  46736. * Defines the clear coat layer thickness.
  46737. * This is only use if tint is enabled
  46738. */
  46739. tintThickness: number;
  46740. private _tintTexture;
  46741. /**
  46742. * Stores the clear tint values in a texture.
  46743. * rgb is tint
  46744. * a is a thickness factor
  46745. */
  46746. tintTexture: Nullable<BaseTexture>;
  46747. /** @hidden */
  46748. private _internalMarkAllSubMeshesAsTexturesDirty;
  46749. /** @hidden */
  46750. _markAllSubMeshesAsTexturesDirty(): void;
  46751. /**
  46752. * Instantiate a new istance of clear coat configuration.
  46753. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46754. */
  46755. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46756. /**
  46757. * Gets wehter the submesh is ready to be used or not.
  46758. * @param defines the list of "defines" to update.
  46759. * @param scene defines the scene the material belongs to.
  46760. * @param engine defines the engine the material belongs to.
  46761. * @param disableBumpMap defines wether the material disables bump or not.
  46762. * @returns - boolean indicating that the submesh is ready or not.
  46763. */
  46764. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46765. /**
  46766. * Checks to see if a texture is used in the material.
  46767. * @param defines the list of "defines" to update.
  46768. * @param scene defines the scene to the material belongs to.
  46769. */
  46770. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46771. /**
  46772. * Binds the material data.
  46773. * @param uniformBuffer defines the Uniform buffer to fill in.
  46774. * @param scene defines the scene the material belongs to.
  46775. * @param engine defines the engine the material belongs to.
  46776. * @param disableBumpMap defines wether the material disables bump or not.
  46777. * @param isFrozen defines wether the material is frozen or not.
  46778. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46779. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46780. */
  46781. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46782. /**
  46783. * Checks to see if a texture is used in the material.
  46784. * @param texture - Base texture to use.
  46785. * @returns - Boolean specifying if a texture is used in the material.
  46786. */
  46787. hasTexture(texture: BaseTexture): boolean;
  46788. /**
  46789. * Returns an array of the actively used textures.
  46790. * @param activeTextures Array of BaseTextures
  46791. */
  46792. getActiveTextures(activeTextures: BaseTexture[]): void;
  46793. /**
  46794. * Returns the animatable textures.
  46795. * @param animatables Array of animatable textures.
  46796. */
  46797. getAnimatables(animatables: IAnimatable[]): void;
  46798. /**
  46799. * Disposes the resources of the material.
  46800. * @param forceDisposeTextures - Forces the disposal of all textures.
  46801. */
  46802. dispose(forceDisposeTextures?: boolean): void;
  46803. /**
  46804. * Get the current class name of the texture useful for serialization or dynamic coding.
  46805. * @returns "PBRClearCoatConfiguration"
  46806. */
  46807. getClassName(): string;
  46808. /**
  46809. * Add fallbacks to the effect fallbacks list.
  46810. * @param defines defines the Base texture to use.
  46811. * @param fallbacks defines the current fallback list.
  46812. * @param currentRank defines the current fallback rank.
  46813. * @returns the new fallback rank.
  46814. */
  46815. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46816. /**
  46817. * Add the required uniforms to the current list.
  46818. * @param uniforms defines the current uniform list.
  46819. */
  46820. static AddUniforms(uniforms: string[]): void;
  46821. /**
  46822. * Add the required samplers to the current list.
  46823. * @param samplers defines the current sampler list.
  46824. */
  46825. static AddSamplers(samplers: string[]): void;
  46826. /**
  46827. * Add the required uniforms to the current buffer.
  46828. * @param uniformBuffer defines the current uniform buffer.
  46829. */
  46830. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46831. /**
  46832. * Makes a duplicate of the current configuration into another one.
  46833. * @param clearCoatConfiguration define the config where to copy the info
  46834. */
  46835. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46836. /**
  46837. * Serializes this clear coat configuration.
  46838. * @returns - An object with the serialized config.
  46839. */
  46840. serialize(): any;
  46841. /**
  46842. * Parses a anisotropy Configuration from a serialized object.
  46843. * @param source - Serialized object.
  46844. * @param scene Defines the scene we are parsing for
  46845. * @param rootUrl Defines the rootUrl to load from
  46846. */
  46847. parse(source: any, scene: Scene, rootUrl: string): void;
  46848. }
  46849. }
  46850. declare module BABYLON {
  46851. /**
  46852. * @hidden
  46853. */
  46854. export interface IMaterialAnisotropicDefines {
  46855. ANISOTROPIC: boolean;
  46856. ANISOTROPIC_TEXTURE: boolean;
  46857. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46858. MAINUV1: boolean;
  46859. _areTexturesDirty: boolean;
  46860. _needUVs: boolean;
  46861. }
  46862. /**
  46863. * Define the code related to the anisotropic parameters of the pbr material.
  46864. */
  46865. export class PBRAnisotropicConfiguration {
  46866. private _isEnabled;
  46867. /**
  46868. * Defines if the anisotropy is enabled in the material.
  46869. */
  46870. isEnabled: boolean;
  46871. /**
  46872. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46873. */
  46874. intensity: number;
  46875. /**
  46876. * Defines if the effect is along the tangents, bitangents or in between.
  46877. * By default, the effect is "strectching" the highlights along the tangents.
  46878. */
  46879. direction: Vector2;
  46880. private _texture;
  46881. /**
  46882. * Stores the anisotropy values in a texture.
  46883. * rg is direction (like normal from -1 to 1)
  46884. * b is a intensity
  46885. */
  46886. texture: Nullable<BaseTexture>;
  46887. /** @hidden */
  46888. private _internalMarkAllSubMeshesAsTexturesDirty;
  46889. /** @hidden */
  46890. _markAllSubMeshesAsTexturesDirty(): void;
  46891. /**
  46892. * Instantiate a new istance of anisotropy configuration.
  46893. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46894. */
  46895. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46896. /**
  46897. * Specifies that the submesh is ready to be used.
  46898. * @param defines the list of "defines" to update.
  46899. * @param scene defines the scene the material belongs to.
  46900. * @returns - boolean indicating that the submesh is ready or not.
  46901. */
  46902. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46903. /**
  46904. * Checks to see if a texture is used in the material.
  46905. * @param defines the list of "defines" to update.
  46906. * @param mesh the mesh we are preparing the defines for.
  46907. * @param scene defines the scene the material belongs to.
  46908. */
  46909. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46910. /**
  46911. * Binds the material data.
  46912. * @param uniformBuffer defines the Uniform buffer to fill in.
  46913. * @param scene defines the scene the material belongs to.
  46914. * @param isFrozen defines wether the material is frozen or not.
  46915. */
  46916. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46917. /**
  46918. * Checks to see if a texture is used in the material.
  46919. * @param texture - Base texture to use.
  46920. * @returns - Boolean specifying if a texture is used in the material.
  46921. */
  46922. hasTexture(texture: BaseTexture): boolean;
  46923. /**
  46924. * Returns an array of the actively used textures.
  46925. * @param activeTextures Array of BaseTextures
  46926. */
  46927. getActiveTextures(activeTextures: BaseTexture[]): void;
  46928. /**
  46929. * Returns the animatable textures.
  46930. * @param animatables Array of animatable textures.
  46931. */
  46932. getAnimatables(animatables: IAnimatable[]): void;
  46933. /**
  46934. * Disposes the resources of the material.
  46935. * @param forceDisposeTextures - Forces the disposal of all textures.
  46936. */
  46937. dispose(forceDisposeTextures?: boolean): void;
  46938. /**
  46939. * Get the current class name of the texture useful for serialization or dynamic coding.
  46940. * @returns "PBRAnisotropicConfiguration"
  46941. */
  46942. getClassName(): string;
  46943. /**
  46944. * Add fallbacks to the effect fallbacks list.
  46945. * @param defines defines the Base texture to use.
  46946. * @param fallbacks defines the current fallback list.
  46947. * @param currentRank defines the current fallback rank.
  46948. * @returns the new fallback rank.
  46949. */
  46950. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46951. /**
  46952. * Add the required uniforms to the current list.
  46953. * @param uniforms defines the current uniform list.
  46954. */
  46955. static AddUniforms(uniforms: string[]): void;
  46956. /**
  46957. * Add the required uniforms to the current buffer.
  46958. * @param uniformBuffer defines the current uniform buffer.
  46959. */
  46960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46961. /**
  46962. * Add the required samplers to the current list.
  46963. * @param samplers defines the current sampler list.
  46964. */
  46965. static AddSamplers(samplers: string[]): void;
  46966. /**
  46967. * Makes a duplicate of the current configuration into another one.
  46968. * @param anisotropicConfiguration define the config where to copy the info
  46969. */
  46970. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46971. /**
  46972. * Serializes this anisotropy configuration.
  46973. * @returns - An object with the serialized config.
  46974. */
  46975. serialize(): any;
  46976. /**
  46977. * Parses a anisotropy Configuration from a serialized object.
  46978. * @param source - Serialized object.
  46979. * @param scene Defines the scene we are parsing for
  46980. * @param rootUrl Defines the rootUrl to load from
  46981. */
  46982. parse(source: any, scene: Scene, rootUrl: string): void;
  46983. }
  46984. }
  46985. declare module BABYLON {
  46986. /**
  46987. * @hidden
  46988. */
  46989. export interface IMaterialBRDFDefines {
  46990. BRDF_V_HEIGHT_CORRELATED: boolean;
  46991. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46992. SPHERICAL_HARMONICS: boolean;
  46993. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46994. /** @hidden */
  46995. _areMiscDirty: boolean;
  46996. }
  46997. /**
  46998. * Define the code related to the BRDF parameters of the pbr material.
  46999. */
  47000. export class PBRBRDFConfiguration {
  47001. /**
  47002. * Default value used for the energy conservation.
  47003. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47004. */
  47005. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47006. /**
  47007. * Default value used for the Smith Visibility Height Correlated mode.
  47008. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47009. */
  47010. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47011. /**
  47012. * Default value used for the IBL diffuse part.
  47013. * This can help switching back to the polynomials mode globally which is a tiny bit
  47014. * less GPU intensive at the drawback of a lower quality.
  47015. */
  47016. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47017. /**
  47018. * Default value used for activating energy conservation for the specular workflow.
  47019. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47020. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47021. */
  47022. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  47023. private _useEnergyConservation;
  47024. /**
  47025. * Defines if the material uses energy conservation.
  47026. */
  47027. useEnergyConservation: boolean;
  47028. private _useSmithVisibilityHeightCorrelated;
  47029. /**
  47030. * LEGACY Mode set to false
  47031. * Defines if the material uses height smith correlated visibility term.
  47032. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47033. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47034. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47035. * Not relying on height correlated will also disable energy conservation.
  47036. */
  47037. useSmithVisibilityHeightCorrelated: boolean;
  47038. private _useSphericalHarmonics;
  47039. /**
  47040. * LEGACY Mode set to false
  47041. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47042. * diffuse part of the IBL.
  47043. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47044. * to the ground truth.
  47045. */
  47046. useSphericalHarmonics: boolean;
  47047. private _useSpecularGlossinessInputEnergyConservation;
  47048. /**
  47049. * Defines if the material uses energy conservation, when the specular workflow is active.
  47050. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  47051. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  47052. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  47053. */
  47054. useSpecularGlossinessInputEnergyConservation: boolean;
  47055. /** @hidden */
  47056. private _internalMarkAllSubMeshesAsMiscDirty;
  47057. /** @hidden */
  47058. _markAllSubMeshesAsMiscDirty(): void;
  47059. /**
  47060. * Instantiate a new istance of clear coat configuration.
  47061. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47062. */
  47063. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47064. /**
  47065. * Checks to see if a texture is used in the material.
  47066. * @param defines the list of "defines" to update.
  47067. */
  47068. prepareDefines(defines: IMaterialBRDFDefines): void;
  47069. /**
  47070. * Get the current class name of the texture useful for serialization or dynamic coding.
  47071. * @returns "PBRClearCoatConfiguration"
  47072. */
  47073. getClassName(): string;
  47074. /**
  47075. * Makes a duplicate of the current configuration into another one.
  47076. * @param brdfConfiguration define the config where to copy the info
  47077. */
  47078. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47079. /**
  47080. * Serializes this BRDF configuration.
  47081. * @returns - An object with the serialized config.
  47082. */
  47083. serialize(): any;
  47084. /**
  47085. * Parses a anisotropy Configuration from a serialized object.
  47086. * @param source - Serialized object.
  47087. * @param scene Defines the scene we are parsing for
  47088. * @param rootUrl Defines the rootUrl to load from
  47089. */
  47090. parse(source: any, scene: Scene, rootUrl: string): void;
  47091. }
  47092. }
  47093. declare module BABYLON {
  47094. /**
  47095. * @hidden
  47096. */
  47097. export interface IMaterialSheenDefines {
  47098. SHEEN: boolean;
  47099. SHEEN_TEXTURE: boolean;
  47100. SHEEN_TEXTUREDIRECTUV: number;
  47101. SHEEN_LINKWITHALBEDO: boolean;
  47102. /** @hidden */
  47103. _areTexturesDirty: boolean;
  47104. }
  47105. /**
  47106. * Define the code related to the Sheen parameters of the pbr material.
  47107. */
  47108. export class PBRSheenConfiguration {
  47109. private _isEnabled;
  47110. /**
  47111. * Defines if the material uses sheen.
  47112. */
  47113. isEnabled: boolean;
  47114. private _linkSheenWithAlbedo;
  47115. /**
  47116. * Defines if the sheen is linked to the sheen color.
  47117. */
  47118. linkSheenWithAlbedo: boolean;
  47119. /**
  47120. * Defines the sheen intensity.
  47121. */
  47122. intensity: number;
  47123. /**
  47124. * Defines the sheen color.
  47125. */
  47126. color: Color3;
  47127. private _texture;
  47128. /**
  47129. * Stores the sheen tint values in a texture.
  47130. * rgb is tint
  47131. * a is a intensity
  47132. */
  47133. texture: Nullable<BaseTexture>;
  47134. /** @hidden */
  47135. private _internalMarkAllSubMeshesAsTexturesDirty;
  47136. /** @hidden */
  47137. _markAllSubMeshesAsTexturesDirty(): void;
  47138. /**
  47139. * Instantiate a new istance of clear coat configuration.
  47140. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47141. */
  47142. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47143. /**
  47144. * Specifies that the submesh is ready to be used.
  47145. * @param defines the list of "defines" to update.
  47146. * @param scene defines the scene the material belongs to.
  47147. * @returns - boolean indicating that the submesh is ready or not.
  47148. */
  47149. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47150. /**
  47151. * Checks to see if a texture is used in the material.
  47152. * @param defines the list of "defines" to update.
  47153. * @param scene defines the scene the material belongs to.
  47154. */
  47155. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47156. /**
  47157. * Binds the material data.
  47158. * @param uniformBuffer defines the Uniform buffer to fill in.
  47159. * @param scene defines the scene the material belongs to.
  47160. * @param isFrozen defines wether the material is frozen or not.
  47161. */
  47162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47163. /**
  47164. * Checks to see if a texture is used in the material.
  47165. * @param texture - Base texture to use.
  47166. * @returns - Boolean specifying if a texture is used in the material.
  47167. */
  47168. hasTexture(texture: BaseTexture): boolean;
  47169. /**
  47170. * Returns an array of the actively used textures.
  47171. * @param activeTextures Array of BaseTextures
  47172. */
  47173. getActiveTextures(activeTextures: BaseTexture[]): void;
  47174. /**
  47175. * Returns the animatable textures.
  47176. * @param animatables Array of animatable textures.
  47177. */
  47178. getAnimatables(animatables: IAnimatable[]): void;
  47179. /**
  47180. * Disposes the resources of the material.
  47181. * @param forceDisposeTextures - Forces the disposal of all textures.
  47182. */
  47183. dispose(forceDisposeTextures?: boolean): void;
  47184. /**
  47185. * Get the current class name of the texture useful for serialization or dynamic coding.
  47186. * @returns "PBRSheenConfiguration"
  47187. */
  47188. getClassName(): string;
  47189. /**
  47190. * Add fallbacks to the effect fallbacks list.
  47191. * @param defines defines the Base texture to use.
  47192. * @param fallbacks defines the current fallback list.
  47193. * @param currentRank defines the current fallback rank.
  47194. * @returns the new fallback rank.
  47195. */
  47196. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47197. /**
  47198. * Add the required uniforms to the current list.
  47199. * @param uniforms defines the current uniform list.
  47200. */
  47201. static AddUniforms(uniforms: string[]): void;
  47202. /**
  47203. * Add the required uniforms to the current buffer.
  47204. * @param uniformBuffer defines the current uniform buffer.
  47205. */
  47206. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47207. /**
  47208. * Add the required samplers to the current list.
  47209. * @param samplers defines the current sampler list.
  47210. */
  47211. static AddSamplers(samplers: string[]): void;
  47212. /**
  47213. * Makes a duplicate of the current configuration into another one.
  47214. * @param sheenConfiguration define the config where to copy the info
  47215. */
  47216. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47217. /**
  47218. * Serializes this BRDF configuration.
  47219. * @returns - An object with the serialized config.
  47220. */
  47221. serialize(): any;
  47222. /**
  47223. * Parses a anisotropy Configuration from a serialized object.
  47224. * @param source - Serialized object.
  47225. * @param scene Defines the scene we are parsing for
  47226. * @param rootUrl Defines the rootUrl to load from
  47227. */
  47228. parse(source: any, scene: Scene, rootUrl: string): void;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. /**
  47233. * @hidden
  47234. */
  47235. export interface IMaterialSubSurfaceDefines {
  47236. SUBSURFACE: boolean;
  47237. SS_REFRACTION: boolean;
  47238. SS_TRANSLUCENCY: boolean;
  47239. SS_SCATERRING: boolean;
  47240. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47241. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47242. SS_REFRACTIONMAP_3D: boolean;
  47243. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47244. SS_LODINREFRACTIONALPHA: boolean;
  47245. SS_GAMMAREFRACTION: boolean;
  47246. SS_RGBDREFRACTION: boolean;
  47247. SS_LINEARSPECULARREFRACTION: boolean;
  47248. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47249. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47250. /** @hidden */
  47251. _areTexturesDirty: boolean;
  47252. }
  47253. /**
  47254. * Define the code related to the sub surface parameters of the pbr material.
  47255. */
  47256. export class PBRSubSurfaceConfiguration {
  47257. private _isRefractionEnabled;
  47258. /**
  47259. * Defines if the refraction is enabled in the material.
  47260. */
  47261. isRefractionEnabled: boolean;
  47262. private _isTranslucencyEnabled;
  47263. /**
  47264. * Defines if the translucency is enabled in the material.
  47265. */
  47266. isTranslucencyEnabled: boolean;
  47267. private _isScatteringEnabled;
  47268. /**
  47269. * Defines the refraction intensity of the material.
  47270. * The refraction when enabled replaces the Diffuse part of the material.
  47271. * The intensity helps transitionning between diffuse and refraction.
  47272. */
  47273. refractionIntensity: number;
  47274. /**
  47275. * Defines the translucency intensity of the material.
  47276. * When translucency has been enabled, this defines how much of the "translucency"
  47277. * is addded to the diffuse part of the material.
  47278. */
  47279. translucencyIntensity: number;
  47280. /**
  47281. * Defines the scattering intensity of the material.
  47282. * When scattering has been enabled, this defines how much of the "scattered light"
  47283. * is addded to the diffuse part of the material.
  47284. */
  47285. scatteringIntensity: number;
  47286. private _thicknessTexture;
  47287. /**
  47288. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47289. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47290. * 0 would mean minimumThickness
  47291. * 1 would mean maximumThickness
  47292. * The other channels might be use as a mask to vary the different effects intensity.
  47293. */
  47294. thicknessTexture: Nullable<BaseTexture>;
  47295. private _refractionTexture;
  47296. /**
  47297. * Defines the texture to use for refraction.
  47298. */
  47299. refractionTexture: Nullable<BaseTexture>;
  47300. private _indexOfRefraction;
  47301. /**
  47302. * Defines the index of refraction used in the material.
  47303. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47304. */
  47305. indexOfRefraction: number;
  47306. private _invertRefractionY;
  47307. /**
  47308. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47309. */
  47310. invertRefractionY: boolean;
  47311. private _linkRefractionWithTransparency;
  47312. /**
  47313. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47314. * Materials half opaque for instance using refraction could benefit from this control.
  47315. */
  47316. linkRefractionWithTransparency: boolean;
  47317. /**
  47318. * Defines the minimum thickness stored in the thickness map.
  47319. * If no thickness map is defined, this value will be used to simulate thickness.
  47320. */
  47321. minimumThickness: number;
  47322. /**
  47323. * Defines the maximum thickness stored in the thickness map.
  47324. */
  47325. maximumThickness: number;
  47326. /**
  47327. * Defines the volume tint of the material.
  47328. * This is used for both translucency and scattering.
  47329. */
  47330. tintColor: Color3;
  47331. /**
  47332. * Defines the distance at which the tint color should be found in the media.
  47333. * This is used for refraction only.
  47334. */
  47335. tintColorAtDistance: number;
  47336. /**
  47337. * Defines how far each channel transmit through the media.
  47338. * It is defined as a color to simplify it selection.
  47339. */
  47340. diffusionDistance: Color3;
  47341. private _useMaskFromThicknessTexture;
  47342. /**
  47343. * Stores the intensity of the different subsurface effects in the thickness texture.
  47344. * * the green channel is the translucency intensity.
  47345. * * the blue channel is the scattering intensity.
  47346. * * the alpha channel is the refraction intensity.
  47347. */
  47348. useMaskFromThicknessTexture: boolean;
  47349. /** @hidden */
  47350. private _internalMarkAllSubMeshesAsTexturesDirty;
  47351. /** @hidden */
  47352. _markAllSubMeshesAsTexturesDirty(): void;
  47353. /**
  47354. * Instantiate a new istance of sub surface configuration.
  47355. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47356. */
  47357. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47358. /**
  47359. * Gets wehter the submesh is ready to be used or not.
  47360. * @param defines the list of "defines" to update.
  47361. * @param scene defines the scene the material belongs to.
  47362. * @returns - boolean indicating that the submesh is ready or not.
  47363. */
  47364. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47365. /**
  47366. * Checks to see if a texture is used in the material.
  47367. * @param defines the list of "defines" to update.
  47368. * @param scene defines the scene to the material belongs to.
  47369. */
  47370. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47371. /**
  47372. * Binds the material data.
  47373. * @param uniformBuffer defines the Uniform buffer to fill in.
  47374. * @param scene defines the scene the material belongs to.
  47375. * @param engine defines the engine the material belongs to.
  47376. * @param isFrozen defines wether the material is frozen or not.
  47377. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47378. */
  47379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47380. /**
  47381. * Unbinds the material from the mesh.
  47382. * @param activeEffect defines the effect that should be unbound from.
  47383. * @returns true if unbound, otherwise false
  47384. */
  47385. unbind(activeEffect: Effect): boolean;
  47386. /**
  47387. * Returns the texture used for refraction or null if none is used.
  47388. * @param scene defines the scene the material belongs to.
  47389. * @returns - Refraction texture if present. If no refraction texture and refraction
  47390. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47391. */
  47392. private _getRefractionTexture;
  47393. /**
  47394. * Returns true if alpha blending should be disabled.
  47395. */
  47396. readonly disableAlphaBlending: boolean;
  47397. /**
  47398. * Fills the list of render target textures.
  47399. * @param renderTargets the list of render targets to update
  47400. */
  47401. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47402. /**
  47403. * Checks to see if a texture is used in the material.
  47404. * @param texture - Base texture to use.
  47405. * @returns - Boolean specifying if a texture is used in the material.
  47406. */
  47407. hasTexture(texture: BaseTexture): boolean;
  47408. /**
  47409. * Gets a boolean indicating that current material needs to register RTT
  47410. * @returns true if this uses a render target otherwise false.
  47411. */
  47412. hasRenderTargetTextures(): boolean;
  47413. /**
  47414. * Returns an array of the actively used textures.
  47415. * @param activeTextures Array of BaseTextures
  47416. */
  47417. getActiveTextures(activeTextures: BaseTexture[]): void;
  47418. /**
  47419. * Returns the animatable textures.
  47420. * @param animatables Array of animatable textures.
  47421. */
  47422. getAnimatables(animatables: IAnimatable[]): void;
  47423. /**
  47424. * Disposes the resources of the material.
  47425. * @param forceDisposeTextures - Forces the disposal of all textures.
  47426. */
  47427. dispose(forceDisposeTextures?: boolean): void;
  47428. /**
  47429. * Get the current class name of the texture useful for serialization or dynamic coding.
  47430. * @returns "PBRSubSurfaceConfiguration"
  47431. */
  47432. getClassName(): string;
  47433. /**
  47434. * Add fallbacks to the effect fallbacks list.
  47435. * @param defines defines the Base texture to use.
  47436. * @param fallbacks defines the current fallback list.
  47437. * @param currentRank defines the current fallback rank.
  47438. * @returns the new fallback rank.
  47439. */
  47440. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47441. /**
  47442. * Add the required uniforms to the current list.
  47443. * @param uniforms defines the current uniform list.
  47444. */
  47445. static AddUniforms(uniforms: string[]): void;
  47446. /**
  47447. * Add the required samplers to the current list.
  47448. * @param samplers defines the current sampler list.
  47449. */
  47450. static AddSamplers(samplers: string[]): void;
  47451. /**
  47452. * Add the required uniforms to the current buffer.
  47453. * @param uniformBuffer defines the current uniform buffer.
  47454. */
  47455. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47456. /**
  47457. * Makes a duplicate of the current configuration into another one.
  47458. * @param configuration define the config where to copy the info
  47459. */
  47460. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47461. /**
  47462. * Serializes this Sub Surface configuration.
  47463. * @returns - An object with the serialized config.
  47464. */
  47465. serialize(): any;
  47466. /**
  47467. * Parses a anisotropy Configuration from a serialized object.
  47468. * @param source - Serialized object.
  47469. * @param scene Defines the scene we are parsing for
  47470. * @param rootUrl Defines the rootUrl to load from
  47471. */
  47472. parse(source: any, scene: Scene, rootUrl: string): void;
  47473. }
  47474. }
  47475. declare module BABYLON {
  47476. /** @hidden */
  47477. export var pbrFragmentDeclaration: {
  47478. name: string;
  47479. shader: string;
  47480. };
  47481. }
  47482. declare module BABYLON {
  47483. /** @hidden */
  47484. export var pbrUboDeclaration: {
  47485. name: string;
  47486. shader: string;
  47487. };
  47488. }
  47489. declare module BABYLON {
  47490. /** @hidden */
  47491. export var pbrFragmentExtraDeclaration: {
  47492. name: string;
  47493. shader: string;
  47494. };
  47495. }
  47496. declare module BABYLON {
  47497. /** @hidden */
  47498. export var pbrFragmentSamplersDeclaration: {
  47499. name: string;
  47500. shader: string;
  47501. };
  47502. }
  47503. declare module BABYLON {
  47504. /** @hidden */
  47505. export var pbrHelperFunctions: {
  47506. name: string;
  47507. shader: string;
  47508. };
  47509. }
  47510. declare module BABYLON {
  47511. /** @hidden */
  47512. export var harmonicsFunctions: {
  47513. name: string;
  47514. shader: string;
  47515. };
  47516. }
  47517. declare module BABYLON {
  47518. /** @hidden */
  47519. export var pbrDirectLightingSetupFunctions: {
  47520. name: string;
  47521. shader: string;
  47522. };
  47523. }
  47524. declare module BABYLON {
  47525. /** @hidden */
  47526. export var pbrDirectLightingFalloffFunctions: {
  47527. name: string;
  47528. shader: string;
  47529. };
  47530. }
  47531. declare module BABYLON {
  47532. /** @hidden */
  47533. export var pbrBRDFFunctions: {
  47534. name: string;
  47535. shader: string;
  47536. };
  47537. }
  47538. declare module BABYLON {
  47539. /** @hidden */
  47540. export var pbrDirectLightingFunctions: {
  47541. name: string;
  47542. shader: string;
  47543. };
  47544. }
  47545. declare module BABYLON {
  47546. /** @hidden */
  47547. export var pbrIBLFunctions: {
  47548. name: string;
  47549. shader: string;
  47550. };
  47551. }
  47552. declare module BABYLON {
  47553. /** @hidden */
  47554. export var pbrDebug: {
  47555. name: string;
  47556. shader: string;
  47557. };
  47558. }
  47559. declare module BABYLON {
  47560. /** @hidden */
  47561. export var pbrPixelShader: {
  47562. name: string;
  47563. shader: string;
  47564. };
  47565. }
  47566. declare module BABYLON {
  47567. /** @hidden */
  47568. export var pbrVertexDeclaration: {
  47569. name: string;
  47570. shader: string;
  47571. };
  47572. }
  47573. declare module BABYLON {
  47574. /** @hidden */
  47575. export var pbrVertexShader: {
  47576. name: string;
  47577. shader: string;
  47578. };
  47579. }
  47580. declare module BABYLON {
  47581. /**
  47582. * Manages the defines for the PBR Material.
  47583. * @hidden
  47584. */
  47585. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47586. PBR: boolean;
  47587. MAINUV1: boolean;
  47588. MAINUV2: boolean;
  47589. UV1: boolean;
  47590. UV2: boolean;
  47591. ALBEDO: boolean;
  47592. ALBEDODIRECTUV: number;
  47593. VERTEXCOLOR: boolean;
  47594. AMBIENT: boolean;
  47595. AMBIENTDIRECTUV: number;
  47596. AMBIENTINGRAYSCALE: boolean;
  47597. OPACITY: boolean;
  47598. VERTEXALPHA: boolean;
  47599. OPACITYDIRECTUV: number;
  47600. OPACITYRGB: boolean;
  47601. ALPHATEST: boolean;
  47602. DEPTHPREPASS: boolean;
  47603. ALPHABLEND: boolean;
  47604. ALPHAFROMALBEDO: boolean;
  47605. ALPHATESTVALUE: string;
  47606. SPECULAROVERALPHA: boolean;
  47607. RADIANCEOVERALPHA: boolean;
  47608. ALPHAFRESNEL: boolean;
  47609. LINEARALPHAFRESNEL: boolean;
  47610. PREMULTIPLYALPHA: boolean;
  47611. EMISSIVE: boolean;
  47612. EMISSIVEDIRECTUV: number;
  47613. REFLECTIVITY: boolean;
  47614. REFLECTIVITYDIRECTUV: number;
  47615. SPECULARTERM: boolean;
  47616. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47617. MICROSURFACEAUTOMATIC: boolean;
  47618. LODBASEDMICROSFURACE: boolean;
  47619. MICROSURFACEMAP: boolean;
  47620. MICROSURFACEMAPDIRECTUV: number;
  47621. METALLICWORKFLOW: boolean;
  47622. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47623. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47624. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47625. AOSTOREINMETALMAPRED: boolean;
  47626. ENVIRONMENTBRDF: boolean;
  47627. ENVIRONMENTBRDF_RGBD: boolean;
  47628. NORMAL: boolean;
  47629. TANGENT: boolean;
  47630. BUMP: boolean;
  47631. BUMPDIRECTUV: number;
  47632. OBJECTSPACE_NORMALMAP: boolean;
  47633. PARALLAX: boolean;
  47634. PARALLAXOCCLUSION: boolean;
  47635. NORMALXYSCALE: boolean;
  47636. LIGHTMAP: boolean;
  47637. LIGHTMAPDIRECTUV: number;
  47638. USELIGHTMAPASSHADOWMAP: boolean;
  47639. GAMMALIGHTMAP: boolean;
  47640. RGBDLIGHTMAP: boolean;
  47641. REFLECTION: boolean;
  47642. REFLECTIONMAP_3D: boolean;
  47643. REFLECTIONMAP_SPHERICAL: boolean;
  47644. REFLECTIONMAP_PLANAR: boolean;
  47645. REFLECTIONMAP_CUBIC: boolean;
  47646. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47647. REFLECTIONMAP_PROJECTION: boolean;
  47648. REFLECTIONMAP_SKYBOX: boolean;
  47649. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47650. REFLECTIONMAP_EXPLICIT: boolean;
  47651. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47652. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47653. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47654. INVERTCUBICMAP: boolean;
  47655. USESPHERICALFROMREFLECTIONMAP: boolean;
  47656. USEIRRADIANCEMAP: boolean;
  47657. SPHERICAL_HARMONICS: boolean;
  47658. USESPHERICALINVERTEX: boolean;
  47659. REFLECTIONMAP_OPPOSITEZ: boolean;
  47660. LODINREFLECTIONALPHA: boolean;
  47661. GAMMAREFLECTION: boolean;
  47662. RGBDREFLECTION: boolean;
  47663. LINEARSPECULARREFLECTION: boolean;
  47664. RADIANCEOCCLUSION: boolean;
  47665. HORIZONOCCLUSION: boolean;
  47666. INSTANCES: boolean;
  47667. NUM_BONE_INFLUENCERS: number;
  47668. BonesPerMesh: number;
  47669. BONETEXTURE: boolean;
  47670. NONUNIFORMSCALING: boolean;
  47671. MORPHTARGETS: boolean;
  47672. MORPHTARGETS_NORMAL: boolean;
  47673. MORPHTARGETS_TANGENT: boolean;
  47674. MORPHTARGETS_UV: boolean;
  47675. NUM_MORPH_INFLUENCERS: number;
  47676. IMAGEPROCESSING: boolean;
  47677. VIGNETTE: boolean;
  47678. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47679. VIGNETTEBLENDMODEOPAQUE: boolean;
  47680. TONEMAPPING: boolean;
  47681. TONEMAPPING_ACES: boolean;
  47682. CONTRAST: boolean;
  47683. COLORCURVES: boolean;
  47684. COLORGRADING: boolean;
  47685. COLORGRADING3D: boolean;
  47686. SAMPLER3DGREENDEPTH: boolean;
  47687. SAMPLER3DBGRMAP: boolean;
  47688. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47689. EXPOSURE: boolean;
  47690. MULTIVIEW: boolean;
  47691. USEPHYSICALLIGHTFALLOFF: boolean;
  47692. USEGLTFLIGHTFALLOFF: boolean;
  47693. TWOSIDEDLIGHTING: boolean;
  47694. SHADOWFLOAT: boolean;
  47695. CLIPPLANE: boolean;
  47696. CLIPPLANE2: boolean;
  47697. CLIPPLANE3: boolean;
  47698. CLIPPLANE4: boolean;
  47699. POINTSIZE: boolean;
  47700. FOG: boolean;
  47701. LOGARITHMICDEPTH: boolean;
  47702. FORCENORMALFORWARD: boolean;
  47703. SPECULARAA: boolean;
  47704. CLEARCOAT: boolean;
  47705. CLEARCOAT_DEFAULTIOR: boolean;
  47706. CLEARCOAT_TEXTURE: boolean;
  47707. CLEARCOAT_TEXTUREDIRECTUV: number;
  47708. CLEARCOAT_BUMP: boolean;
  47709. CLEARCOAT_BUMPDIRECTUV: number;
  47710. CLEARCOAT_TINT: boolean;
  47711. CLEARCOAT_TINT_TEXTURE: boolean;
  47712. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47713. ANISOTROPIC: boolean;
  47714. ANISOTROPIC_TEXTURE: boolean;
  47715. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47716. BRDF_V_HEIGHT_CORRELATED: boolean;
  47717. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47718. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47719. SHEEN: boolean;
  47720. SHEEN_TEXTURE: boolean;
  47721. SHEEN_TEXTUREDIRECTUV: number;
  47722. SHEEN_LINKWITHALBEDO: boolean;
  47723. SUBSURFACE: boolean;
  47724. SS_REFRACTION: boolean;
  47725. SS_TRANSLUCENCY: boolean;
  47726. SS_SCATERRING: boolean;
  47727. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47728. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47729. SS_REFRACTIONMAP_3D: boolean;
  47730. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47731. SS_LODINREFRACTIONALPHA: boolean;
  47732. SS_GAMMAREFRACTION: boolean;
  47733. SS_RGBDREFRACTION: boolean;
  47734. SS_LINEARSPECULARREFRACTION: boolean;
  47735. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47736. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47737. UNLIT: boolean;
  47738. DEBUGMODE: number;
  47739. /**
  47740. * Initializes the PBR Material defines.
  47741. */
  47742. constructor();
  47743. /**
  47744. * Resets the PBR Material defines.
  47745. */
  47746. reset(): void;
  47747. }
  47748. /**
  47749. * The Physically based material base class of BJS.
  47750. *
  47751. * This offers the main features of a standard PBR material.
  47752. * For more information, please refer to the documentation :
  47753. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47754. */
  47755. export abstract class PBRBaseMaterial extends PushMaterial {
  47756. /**
  47757. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47758. */
  47759. static readonly PBRMATERIAL_OPAQUE: number;
  47760. /**
  47761. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47762. */
  47763. static readonly PBRMATERIAL_ALPHATEST: number;
  47764. /**
  47765. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47766. */
  47767. static readonly PBRMATERIAL_ALPHABLEND: number;
  47768. /**
  47769. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47770. * They are also discarded below the alpha cutoff threshold to improve performances.
  47771. */
  47772. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47773. /**
  47774. * Defines the default value of how much AO map is occluding the analytical lights
  47775. * (point spot...).
  47776. */
  47777. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47778. /**
  47779. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47780. */
  47781. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47782. /**
  47783. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47784. * to enhance interoperability with other engines.
  47785. */
  47786. static readonly LIGHTFALLOFF_GLTF: number;
  47787. /**
  47788. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47789. * to enhance interoperability with other materials.
  47790. */
  47791. static readonly LIGHTFALLOFF_STANDARD: number;
  47792. /**
  47793. * Intensity of the direct lights e.g. the four lights available in your scene.
  47794. * This impacts both the direct diffuse and specular highlights.
  47795. */
  47796. protected _directIntensity: number;
  47797. /**
  47798. * Intensity of the emissive part of the material.
  47799. * This helps controlling the emissive effect without modifying the emissive color.
  47800. */
  47801. protected _emissiveIntensity: number;
  47802. /**
  47803. * Intensity of the environment e.g. how much the environment will light the object
  47804. * either through harmonics for rough material or through the refelction for shiny ones.
  47805. */
  47806. protected _environmentIntensity: number;
  47807. /**
  47808. * This is a special control allowing the reduction of the specular highlights coming from the
  47809. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47810. */
  47811. protected _specularIntensity: number;
  47812. /**
  47813. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47814. */
  47815. private _lightingInfos;
  47816. /**
  47817. * Debug Control allowing disabling the bump map on this material.
  47818. */
  47819. protected _disableBumpMap: boolean;
  47820. /**
  47821. * AKA Diffuse Texture in standard nomenclature.
  47822. */
  47823. protected _albedoTexture: Nullable<BaseTexture>;
  47824. /**
  47825. * AKA Occlusion Texture in other nomenclature.
  47826. */
  47827. protected _ambientTexture: Nullable<BaseTexture>;
  47828. /**
  47829. * AKA Occlusion Texture Intensity in other nomenclature.
  47830. */
  47831. protected _ambientTextureStrength: number;
  47832. /**
  47833. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47834. * 1 means it completely occludes it
  47835. * 0 mean it has no impact
  47836. */
  47837. protected _ambientTextureImpactOnAnalyticalLights: number;
  47838. /**
  47839. * Stores the alpha values in a texture.
  47840. */
  47841. protected _opacityTexture: Nullable<BaseTexture>;
  47842. /**
  47843. * Stores the reflection values in a texture.
  47844. */
  47845. protected _reflectionTexture: Nullable<BaseTexture>;
  47846. /**
  47847. * Stores the emissive values in a texture.
  47848. */
  47849. protected _emissiveTexture: Nullable<BaseTexture>;
  47850. /**
  47851. * AKA Specular texture in other nomenclature.
  47852. */
  47853. protected _reflectivityTexture: Nullable<BaseTexture>;
  47854. /**
  47855. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47856. */
  47857. protected _metallicTexture: Nullable<BaseTexture>;
  47858. /**
  47859. * Specifies the metallic scalar of the metallic/roughness workflow.
  47860. * Can also be used to scale the metalness values of the metallic texture.
  47861. */
  47862. protected _metallic: Nullable<number>;
  47863. /**
  47864. * Specifies the roughness scalar of the metallic/roughness workflow.
  47865. * Can also be used to scale the roughness values of the metallic texture.
  47866. */
  47867. protected _roughness: Nullable<number>;
  47868. /**
  47869. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47870. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47871. */
  47872. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47873. /**
  47874. * Stores surface normal data used to displace a mesh in a texture.
  47875. */
  47876. protected _bumpTexture: Nullable<BaseTexture>;
  47877. /**
  47878. * Stores the pre-calculated light information of a mesh in a texture.
  47879. */
  47880. protected _lightmapTexture: Nullable<BaseTexture>;
  47881. /**
  47882. * The color of a material in ambient lighting.
  47883. */
  47884. protected _ambientColor: Color3;
  47885. /**
  47886. * AKA Diffuse Color in other nomenclature.
  47887. */
  47888. protected _albedoColor: Color3;
  47889. /**
  47890. * AKA Specular Color in other nomenclature.
  47891. */
  47892. protected _reflectivityColor: Color3;
  47893. /**
  47894. * The color applied when light is reflected from a material.
  47895. */
  47896. protected _reflectionColor: Color3;
  47897. /**
  47898. * The color applied when light is emitted from a material.
  47899. */
  47900. protected _emissiveColor: Color3;
  47901. /**
  47902. * AKA Glossiness in other nomenclature.
  47903. */
  47904. protected _microSurface: number;
  47905. /**
  47906. * Specifies that the material will use the light map as a show map.
  47907. */
  47908. protected _useLightmapAsShadowmap: boolean;
  47909. /**
  47910. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47911. * makes the reflect vector face the model (under horizon).
  47912. */
  47913. protected _useHorizonOcclusion: boolean;
  47914. /**
  47915. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47916. * too much the area relying on ambient texture to define their ambient occlusion.
  47917. */
  47918. protected _useRadianceOcclusion: boolean;
  47919. /**
  47920. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47921. */
  47922. protected _useAlphaFromAlbedoTexture: boolean;
  47923. /**
  47924. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47926. */
  47927. protected _useSpecularOverAlpha: boolean;
  47928. /**
  47929. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47930. */
  47931. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47932. /**
  47933. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47934. */
  47935. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47936. /**
  47937. * Specifies if the metallic texture contains the roughness information in its green channel.
  47938. */
  47939. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47940. /**
  47941. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47942. */
  47943. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47944. /**
  47945. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47946. */
  47947. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47948. /**
  47949. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47950. */
  47951. protected _useAmbientInGrayScale: boolean;
  47952. /**
  47953. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47954. * The material will try to infer what glossiness each pixel should be.
  47955. */
  47956. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47957. /**
  47958. * Defines the falloff type used in this material.
  47959. * It by default is Physical.
  47960. */
  47961. protected _lightFalloff: number;
  47962. /**
  47963. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47964. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47965. */
  47966. protected _useRadianceOverAlpha: boolean;
  47967. /**
  47968. * Allows using an object space normal map (instead of tangent space).
  47969. */
  47970. protected _useObjectSpaceNormalMap: boolean;
  47971. /**
  47972. * Allows using the bump map in parallax mode.
  47973. */
  47974. protected _useParallax: boolean;
  47975. /**
  47976. * Allows using the bump map in parallax occlusion mode.
  47977. */
  47978. protected _useParallaxOcclusion: boolean;
  47979. /**
  47980. * Controls the scale bias of the parallax mode.
  47981. */
  47982. protected _parallaxScaleBias: number;
  47983. /**
  47984. * If sets to true, disables all the lights affecting the material.
  47985. */
  47986. protected _disableLighting: boolean;
  47987. /**
  47988. * Number of Simultaneous lights allowed on the material.
  47989. */
  47990. protected _maxSimultaneousLights: number;
  47991. /**
  47992. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47993. */
  47994. protected _invertNormalMapX: boolean;
  47995. /**
  47996. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47997. */
  47998. protected _invertNormalMapY: boolean;
  47999. /**
  48000. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48001. */
  48002. protected _twoSidedLighting: boolean;
  48003. /**
  48004. * Defines the alpha limits in alpha test mode.
  48005. */
  48006. protected _alphaCutOff: number;
  48007. /**
  48008. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48009. */
  48010. protected _forceAlphaTest: boolean;
  48011. /**
  48012. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48013. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48014. */
  48015. protected _useAlphaFresnel: boolean;
  48016. /**
  48017. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48018. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48019. */
  48020. protected _useLinearAlphaFresnel: boolean;
  48021. /**
  48022. * The transparency mode of the material.
  48023. */
  48024. protected _transparencyMode: Nullable<number>;
  48025. /**
  48026. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48027. * from cos thetav and roughness:
  48028. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48029. */
  48030. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48031. /**
  48032. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48033. */
  48034. protected _forceIrradianceInFragment: boolean;
  48035. /**
  48036. * Force normal to face away from face.
  48037. */
  48038. protected _forceNormalForward: boolean;
  48039. /**
  48040. * Enables specular anti aliasing in the PBR shader.
  48041. * It will both interacts on the Geometry for analytical and IBL lighting.
  48042. * It also prefilter the roughness map based on the bump values.
  48043. */
  48044. protected _enableSpecularAntiAliasing: boolean;
  48045. /**
  48046. * Default configuration related to image processing available in the PBR Material.
  48047. */
  48048. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48049. /**
  48050. * Keep track of the image processing observer to allow dispose and replace.
  48051. */
  48052. private _imageProcessingObserver;
  48053. /**
  48054. * Attaches a new image processing configuration to the PBR Material.
  48055. * @param configuration
  48056. */
  48057. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48058. /**
  48059. * Stores the available render targets.
  48060. */
  48061. private _renderTargets;
  48062. /**
  48063. * Sets the global ambient color for the material used in lighting calculations.
  48064. */
  48065. private _globalAmbientColor;
  48066. /**
  48067. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48068. */
  48069. private _useLogarithmicDepth;
  48070. /**
  48071. * If set to true, no lighting calculations will be applied.
  48072. */
  48073. private _unlit;
  48074. private _debugMode;
  48075. /**
  48076. * @hidden
  48077. * This is reserved for the inspector.
  48078. * Defines the material debug mode.
  48079. * It helps seeing only some components of the material while troubleshooting.
  48080. */
  48081. debugMode: number;
  48082. /**
  48083. * @hidden
  48084. * This is reserved for the inspector.
  48085. * Specify from where on screen the debug mode should start.
  48086. * The value goes from -1 (full screen) to 1 (not visible)
  48087. * It helps with side by side comparison against the final render
  48088. * This defaults to -1
  48089. */
  48090. private debugLimit;
  48091. /**
  48092. * @hidden
  48093. * This is reserved for the inspector.
  48094. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48095. * You can use the factor to better multiply the final value.
  48096. */
  48097. private debugFactor;
  48098. /**
  48099. * Defines the clear coat layer parameters for the material.
  48100. */
  48101. readonly clearCoat: PBRClearCoatConfiguration;
  48102. /**
  48103. * Defines the anisotropic parameters for the material.
  48104. */
  48105. readonly anisotropy: PBRAnisotropicConfiguration;
  48106. /**
  48107. * Defines the BRDF parameters for the material.
  48108. */
  48109. readonly brdf: PBRBRDFConfiguration;
  48110. /**
  48111. * Defines the Sheen parameters for the material.
  48112. */
  48113. readonly sheen: PBRSheenConfiguration;
  48114. /**
  48115. * Defines the SubSurface parameters for the material.
  48116. */
  48117. readonly subSurface: PBRSubSurfaceConfiguration;
  48118. /**
  48119. * Custom callback helping to override the default shader used in the material.
  48120. */
  48121. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48122. protected _rebuildInParallel: boolean;
  48123. /**
  48124. * Instantiates a new PBRMaterial instance.
  48125. *
  48126. * @param name The material name
  48127. * @param scene The scene the material will be use in.
  48128. */
  48129. constructor(name: string, scene: Scene);
  48130. /**
  48131. * Gets a boolean indicating that current material needs to register RTT
  48132. */
  48133. readonly hasRenderTargetTextures: boolean;
  48134. /**
  48135. * Gets the name of the material class.
  48136. */
  48137. getClassName(): string;
  48138. /**
  48139. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48140. */
  48141. /**
  48142. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48143. */
  48144. useLogarithmicDepth: boolean;
  48145. /**
  48146. * Gets the current transparency mode.
  48147. */
  48148. /**
  48149. * Sets the transparency mode of the material.
  48150. *
  48151. * | Value | Type | Description |
  48152. * | ----- | ----------------------------------- | ----------- |
  48153. * | 0 | OPAQUE | |
  48154. * | 1 | ALPHATEST | |
  48155. * | 2 | ALPHABLEND | |
  48156. * | 3 | ALPHATESTANDBLEND | |
  48157. *
  48158. */
  48159. transparencyMode: Nullable<number>;
  48160. /**
  48161. * Returns true if alpha blending should be disabled.
  48162. */
  48163. private readonly _disableAlphaBlending;
  48164. /**
  48165. * Specifies whether or not this material should be rendered in alpha blend mode.
  48166. */
  48167. needAlphaBlending(): boolean;
  48168. /**
  48169. * Specifies if the mesh will require alpha blending.
  48170. * @param mesh - BJS mesh.
  48171. */
  48172. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48173. /**
  48174. * Specifies whether or not this material should be rendered in alpha test mode.
  48175. */
  48176. needAlphaTesting(): boolean;
  48177. /**
  48178. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48179. */
  48180. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48181. /**
  48182. * Gets the texture used for the alpha test.
  48183. */
  48184. getAlphaTestTexture(): Nullable<BaseTexture>;
  48185. /**
  48186. * Specifies that the submesh is ready to be used.
  48187. * @param mesh - BJS mesh.
  48188. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48189. * @param useInstances - Specifies that instances should be used.
  48190. * @returns - boolean indicating that the submesh is ready or not.
  48191. */
  48192. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48193. /**
  48194. * Specifies if the material uses metallic roughness workflow.
  48195. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48196. */
  48197. isMetallicWorkflow(): boolean;
  48198. private _prepareEffect;
  48199. private _prepareDefines;
  48200. /**
  48201. * Force shader compilation
  48202. */
  48203. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48204. clipPlane: boolean;
  48205. }>): void;
  48206. /**
  48207. * Initializes the uniform buffer layout for the shader.
  48208. */
  48209. buildUniformLayout(): void;
  48210. /**
  48211. * Unbinds the material from the mesh
  48212. */
  48213. unbind(): void;
  48214. /**
  48215. * Binds the submesh data.
  48216. * @param world - The world matrix.
  48217. * @param mesh - The BJS mesh.
  48218. * @param subMesh - A submesh of the BJS mesh.
  48219. */
  48220. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48221. /**
  48222. * Returns the animatable textures.
  48223. * @returns - Array of animatable textures.
  48224. */
  48225. getAnimatables(): IAnimatable[];
  48226. /**
  48227. * Returns the texture used for reflections.
  48228. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48229. */
  48230. private _getReflectionTexture;
  48231. /**
  48232. * Returns an array of the actively used textures.
  48233. * @returns - Array of BaseTextures
  48234. */
  48235. getActiveTextures(): BaseTexture[];
  48236. /**
  48237. * Checks to see if a texture is used in the material.
  48238. * @param texture - Base texture to use.
  48239. * @returns - Boolean specifying if a texture is used in the material.
  48240. */
  48241. hasTexture(texture: BaseTexture): boolean;
  48242. /**
  48243. * Disposes the resources of the material.
  48244. * @param forceDisposeEffect - Forces the disposal of effects.
  48245. * @param forceDisposeTextures - Forces the disposal of all textures.
  48246. */
  48247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * The Physically based material of BJS.
  48253. *
  48254. * This offers the main features of a standard PBR material.
  48255. * For more information, please refer to the documentation :
  48256. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48257. */
  48258. export class PBRMaterial extends PBRBaseMaterial {
  48259. /**
  48260. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48261. */
  48262. static readonly PBRMATERIAL_OPAQUE: number;
  48263. /**
  48264. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48265. */
  48266. static readonly PBRMATERIAL_ALPHATEST: number;
  48267. /**
  48268. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48269. */
  48270. static readonly PBRMATERIAL_ALPHABLEND: number;
  48271. /**
  48272. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48273. * They are also discarded below the alpha cutoff threshold to improve performances.
  48274. */
  48275. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48276. /**
  48277. * Defines the default value of how much AO map is occluding the analytical lights
  48278. * (point spot...).
  48279. */
  48280. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48281. /**
  48282. * Intensity of the direct lights e.g. the four lights available in your scene.
  48283. * This impacts both the direct diffuse and specular highlights.
  48284. */
  48285. directIntensity: number;
  48286. /**
  48287. * Intensity of the emissive part of the material.
  48288. * This helps controlling the emissive effect without modifying the emissive color.
  48289. */
  48290. emissiveIntensity: number;
  48291. /**
  48292. * Intensity of the environment e.g. how much the environment will light the object
  48293. * either through harmonics for rough material or through the refelction for shiny ones.
  48294. */
  48295. environmentIntensity: number;
  48296. /**
  48297. * This is a special control allowing the reduction of the specular highlights coming from the
  48298. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48299. */
  48300. specularIntensity: number;
  48301. /**
  48302. * Debug Control allowing disabling the bump map on this material.
  48303. */
  48304. disableBumpMap: boolean;
  48305. /**
  48306. * AKA Diffuse Texture in standard nomenclature.
  48307. */
  48308. albedoTexture: BaseTexture;
  48309. /**
  48310. * AKA Occlusion Texture in other nomenclature.
  48311. */
  48312. ambientTexture: BaseTexture;
  48313. /**
  48314. * AKA Occlusion Texture Intensity in other nomenclature.
  48315. */
  48316. ambientTextureStrength: number;
  48317. /**
  48318. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48319. * 1 means it completely occludes it
  48320. * 0 mean it has no impact
  48321. */
  48322. ambientTextureImpactOnAnalyticalLights: number;
  48323. /**
  48324. * Stores the alpha values in a texture.
  48325. */
  48326. opacityTexture: BaseTexture;
  48327. /**
  48328. * Stores the reflection values in a texture.
  48329. */
  48330. reflectionTexture: Nullable<BaseTexture>;
  48331. /**
  48332. * Stores the emissive values in a texture.
  48333. */
  48334. emissiveTexture: BaseTexture;
  48335. /**
  48336. * AKA Specular texture in other nomenclature.
  48337. */
  48338. reflectivityTexture: BaseTexture;
  48339. /**
  48340. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48341. */
  48342. metallicTexture: BaseTexture;
  48343. /**
  48344. * Specifies the metallic scalar of the metallic/roughness workflow.
  48345. * Can also be used to scale the metalness values of the metallic texture.
  48346. */
  48347. metallic: Nullable<number>;
  48348. /**
  48349. * Specifies the roughness scalar of the metallic/roughness workflow.
  48350. * Can also be used to scale the roughness values of the metallic texture.
  48351. */
  48352. roughness: Nullable<number>;
  48353. /**
  48354. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48355. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48356. */
  48357. microSurfaceTexture: BaseTexture;
  48358. /**
  48359. * Stores surface normal data used to displace a mesh in a texture.
  48360. */
  48361. bumpTexture: BaseTexture;
  48362. /**
  48363. * Stores the pre-calculated light information of a mesh in a texture.
  48364. */
  48365. lightmapTexture: BaseTexture;
  48366. /**
  48367. * Stores the refracted light information in a texture.
  48368. */
  48369. refractionTexture: Nullable<BaseTexture>;
  48370. /**
  48371. * The color of a material in ambient lighting.
  48372. */
  48373. ambientColor: Color3;
  48374. /**
  48375. * AKA Diffuse Color in other nomenclature.
  48376. */
  48377. albedoColor: Color3;
  48378. /**
  48379. * AKA Specular Color in other nomenclature.
  48380. */
  48381. reflectivityColor: Color3;
  48382. /**
  48383. * The color reflected from the material.
  48384. */
  48385. reflectionColor: Color3;
  48386. /**
  48387. * The color emitted from the material.
  48388. */
  48389. emissiveColor: Color3;
  48390. /**
  48391. * AKA Glossiness in other nomenclature.
  48392. */
  48393. microSurface: number;
  48394. /**
  48395. * source material index of refraction (IOR)' / 'destination material IOR.
  48396. */
  48397. indexOfRefraction: number;
  48398. /**
  48399. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48400. */
  48401. invertRefractionY: boolean;
  48402. /**
  48403. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48404. * Materials half opaque for instance using refraction could benefit from this control.
  48405. */
  48406. linkRefractionWithTransparency: boolean;
  48407. /**
  48408. * If true, the light map contains occlusion information instead of lighting info.
  48409. */
  48410. useLightmapAsShadowmap: boolean;
  48411. /**
  48412. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48413. */
  48414. useAlphaFromAlbedoTexture: boolean;
  48415. /**
  48416. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48417. */
  48418. forceAlphaTest: boolean;
  48419. /**
  48420. * Defines the alpha limits in alpha test mode.
  48421. */
  48422. alphaCutOff: number;
  48423. /**
  48424. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48425. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48426. */
  48427. useSpecularOverAlpha: boolean;
  48428. /**
  48429. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48430. */
  48431. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48432. /**
  48433. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48434. */
  48435. useRoughnessFromMetallicTextureAlpha: boolean;
  48436. /**
  48437. * Specifies if the metallic texture contains the roughness information in its green channel.
  48438. */
  48439. useRoughnessFromMetallicTextureGreen: boolean;
  48440. /**
  48441. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48442. */
  48443. useMetallnessFromMetallicTextureBlue: boolean;
  48444. /**
  48445. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48446. */
  48447. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48448. /**
  48449. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48450. */
  48451. useAmbientInGrayScale: boolean;
  48452. /**
  48453. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48454. * The material will try to infer what glossiness each pixel should be.
  48455. */
  48456. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48457. /**
  48458. * BJS is using an harcoded light falloff based on a manually sets up range.
  48459. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48460. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48461. */
  48462. /**
  48463. * BJS is using an harcoded light falloff based on a manually sets up range.
  48464. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48465. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48466. */
  48467. usePhysicalLightFalloff: boolean;
  48468. /**
  48469. * In order to support the falloff compatibility with gltf, a special mode has been added
  48470. * to reproduce the gltf light falloff.
  48471. */
  48472. /**
  48473. * In order to support the falloff compatibility with gltf, a special mode has been added
  48474. * to reproduce the gltf light falloff.
  48475. */
  48476. useGLTFLightFalloff: boolean;
  48477. /**
  48478. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48479. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48480. */
  48481. useRadianceOverAlpha: boolean;
  48482. /**
  48483. * Allows using an object space normal map (instead of tangent space).
  48484. */
  48485. useObjectSpaceNormalMap: boolean;
  48486. /**
  48487. * Allows using the bump map in parallax mode.
  48488. */
  48489. useParallax: boolean;
  48490. /**
  48491. * Allows using the bump map in parallax occlusion mode.
  48492. */
  48493. useParallaxOcclusion: boolean;
  48494. /**
  48495. * Controls the scale bias of the parallax mode.
  48496. */
  48497. parallaxScaleBias: number;
  48498. /**
  48499. * If sets to true, disables all the lights affecting the material.
  48500. */
  48501. disableLighting: boolean;
  48502. /**
  48503. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48504. */
  48505. forceIrradianceInFragment: boolean;
  48506. /**
  48507. * Number of Simultaneous lights allowed on the material.
  48508. */
  48509. maxSimultaneousLights: number;
  48510. /**
  48511. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48512. */
  48513. invertNormalMapX: boolean;
  48514. /**
  48515. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48516. */
  48517. invertNormalMapY: boolean;
  48518. /**
  48519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48520. */
  48521. twoSidedLighting: boolean;
  48522. /**
  48523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48524. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48525. */
  48526. useAlphaFresnel: boolean;
  48527. /**
  48528. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48529. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48530. */
  48531. useLinearAlphaFresnel: boolean;
  48532. /**
  48533. * Let user defines the brdf lookup texture used for IBL.
  48534. * A default 8bit version is embedded but you could point at :
  48535. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48536. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48537. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48538. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48539. */
  48540. environmentBRDFTexture: Nullable<BaseTexture>;
  48541. /**
  48542. * Force normal to face away from face.
  48543. */
  48544. forceNormalForward: boolean;
  48545. /**
  48546. * Enables specular anti aliasing in the PBR shader.
  48547. * It will both interacts on the Geometry for analytical and IBL lighting.
  48548. * It also prefilter the roughness map based on the bump values.
  48549. */
  48550. enableSpecularAntiAliasing: boolean;
  48551. /**
  48552. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48553. * makes the reflect vector face the model (under horizon).
  48554. */
  48555. useHorizonOcclusion: boolean;
  48556. /**
  48557. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48558. * too much the area relying on ambient texture to define their ambient occlusion.
  48559. */
  48560. useRadianceOcclusion: boolean;
  48561. /**
  48562. * If set to true, no lighting calculations will be applied.
  48563. */
  48564. unlit: boolean;
  48565. /**
  48566. * Gets the image processing configuration used either in this material.
  48567. */
  48568. /**
  48569. * Sets the Default image processing configuration used either in the this material.
  48570. *
  48571. * If sets to null, the scene one is in use.
  48572. */
  48573. imageProcessingConfiguration: ImageProcessingConfiguration;
  48574. /**
  48575. * Gets wether the color curves effect is enabled.
  48576. */
  48577. /**
  48578. * Sets wether the color curves effect is enabled.
  48579. */
  48580. cameraColorCurvesEnabled: boolean;
  48581. /**
  48582. * Gets wether the color grading effect is enabled.
  48583. */
  48584. /**
  48585. * Gets wether the color grading effect is enabled.
  48586. */
  48587. cameraColorGradingEnabled: boolean;
  48588. /**
  48589. * Gets wether tonemapping is enabled or not.
  48590. */
  48591. /**
  48592. * Sets wether tonemapping is enabled or not
  48593. */
  48594. cameraToneMappingEnabled: boolean;
  48595. /**
  48596. * The camera exposure used on this material.
  48597. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48598. * This corresponds to a photographic exposure.
  48599. */
  48600. /**
  48601. * The camera exposure used on this material.
  48602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48603. * This corresponds to a photographic exposure.
  48604. */
  48605. cameraExposure: number;
  48606. /**
  48607. * Gets The camera contrast used on this material.
  48608. */
  48609. /**
  48610. * Sets The camera contrast used on this material.
  48611. */
  48612. cameraContrast: number;
  48613. /**
  48614. * Gets the Color Grading 2D Lookup Texture.
  48615. */
  48616. /**
  48617. * Sets the Color Grading 2D Lookup Texture.
  48618. */
  48619. cameraColorGradingTexture: Nullable<BaseTexture>;
  48620. /**
  48621. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48622. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48623. * 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;
  48624. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48625. */
  48626. /**
  48627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48629. * 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;
  48630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48631. */
  48632. cameraColorCurves: Nullable<ColorCurves>;
  48633. /**
  48634. * Instantiates a new PBRMaterial instance.
  48635. *
  48636. * @param name The material name
  48637. * @param scene The scene the material will be use in.
  48638. */
  48639. constructor(name: string, scene: Scene);
  48640. /**
  48641. * Returns the name of this material class.
  48642. */
  48643. getClassName(): string;
  48644. /**
  48645. * Makes a duplicate of the current material.
  48646. * @param name - name to use for the new material.
  48647. */
  48648. clone(name: string): PBRMaterial;
  48649. /**
  48650. * Serializes this PBR Material.
  48651. * @returns - An object with the serialized material.
  48652. */
  48653. serialize(): any;
  48654. /**
  48655. * Parses a PBR Material from a serialized object.
  48656. * @param source - Serialized object.
  48657. * @param scene - BJS scene instance.
  48658. * @param rootUrl - url for the scene object
  48659. * @returns - PBRMaterial
  48660. */
  48661. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48662. }
  48663. }
  48664. declare module BABYLON {
  48665. /**
  48666. * Direct draw surface info
  48667. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48668. */
  48669. export interface DDSInfo {
  48670. /**
  48671. * Width of the texture
  48672. */
  48673. width: number;
  48674. /**
  48675. * Width of the texture
  48676. */
  48677. height: number;
  48678. /**
  48679. * Number of Mipmaps for the texture
  48680. * @see https://en.wikipedia.org/wiki/Mipmap
  48681. */
  48682. mipmapCount: number;
  48683. /**
  48684. * If the textures format is a known fourCC format
  48685. * @see https://www.fourcc.org/
  48686. */
  48687. isFourCC: boolean;
  48688. /**
  48689. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48690. */
  48691. isRGB: boolean;
  48692. /**
  48693. * If the texture is a lumincance format
  48694. */
  48695. isLuminance: boolean;
  48696. /**
  48697. * If this is a cube texture
  48698. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48699. */
  48700. isCube: boolean;
  48701. /**
  48702. * If the texture is a compressed format eg. FOURCC_DXT1
  48703. */
  48704. isCompressed: boolean;
  48705. /**
  48706. * The dxgiFormat of the texture
  48707. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48708. */
  48709. dxgiFormat: number;
  48710. /**
  48711. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48712. */
  48713. textureType: number;
  48714. /**
  48715. * Sphericle polynomial created for the dds texture
  48716. */
  48717. sphericalPolynomial?: SphericalPolynomial;
  48718. }
  48719. /**
  48720. * Class used to provide DDS decompression tools
  48721. */
  48722. export class DDSTools {
  48723. /**
  48724. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48725. */
  48726. static StoreLODInAlphaChannel: boolean;
  48727. /**
  48728. * Gets DDS information from an array buffer
  48729. * @param arrayBuffer defines the array buffer to read data from
  48730. * @returns the DDS information
  48731. */
  48732. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48733. private static _FloatView;
  48734. private static _Int32View;
  48735. private static _ToHalfFloat;
  48736. private static _FromHalfFloat;
  48737. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48738. private static _GetHalfFloatRGBAArrayBuffer;
  48739. private static _GetFloatRGBAArrayBuffer;
  48740. private static _GetFloatAsUIntRGBAArrayBuffer;
  48741. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48742. private static _GetRGBAArrayBuffer;
  48743. private static _ExtractLongWordOrder;
  48744. private static _GetRGBArrayBuffer;
  48745. private static _GetLuminanceArrayBuffer;
  48746. /**
  48747. * Uploads DDS Levels to a Babylon Texture
  48748. * @hidden
  48749. */
  48750. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48751. }
  48752. interface ThinEngine {
  48753. /**
  48754. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48755. * @param rootUrl defines the url where the file to load is located
  48756. * @param scene defines the current scene
  48757. * @param lodScale defines scale to apply to the mip map selection
  48758. * @param lodOffset defines offset to apply to the mip map selection
  48759. * @param onLoad defines an optional callback raised when the texture is loaded
  48760. * @param onError defines an optional callback raised if there is an issue to load the texture
  48761. * @param format defines the format of the data
  48762. * @param forcedExtension defines the extension to use to pick the right loader
  48763. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48764. * @returns the cube texture as an InternalTexture
  48765. */
  48766. 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;
  48767. }
  48768. }
  48769. declare module BABYLON {
  48770. /**
  48771. * Implementation of the DDS Texture Loader.
  48772. * @hidden
  48773. */
  48774. export class _DDSTextureLoader implements IInternalTextureLoader {
  48775. /**
  48776. * Defines wether the loader supports cascade loading the different faces.
  48777. */
  48778. readonly supportCascades: boolean;
  48779. /**
  48780. * This returns if the loader support the current file information.
  48781. * @param extension defines the file extension of the file being loaded
  48782. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48783. * @param fallback defines the fallback internal texture if any
  48784. * @param isBase64 defines whether the texture is encoded as a base64
  48785. * @param isBuffer defines whether the texture data are stored as a buffer
  48786. * @returns true if the loader can load the specified file
  48787. */
  48788. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48789. /**
  48790. * Transform the url before loading if required.
  48791. * @param rootUrl the url of the texture
  48792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48793. * @returns the transformed texture
  48794. */
  48795. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48796. /**
  48797. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48798. * @param rootUrl the url of the texture
  48799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48800. * @returns the fallback texture
  48801. */
  48802. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48803. /**
  48804. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48805. * @param data contains the texture data
  48806. * @param texture defines the BabylonJS internal texture
  48807. * @param createPolynomials will be true if polynomials have been requested
  48808. * @param onLoad defines the callback to trigger once the texture is ready
  48809. * @param onError defines the callback to trigger in case of error
  48810. */
  48811. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48812. /**
  48813. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48814. * @param data contains the texture data
  48815. * @param texture defines the BabylonJS internal texture
  48816. * @param callback defines the method to call once ready to upload
  48817. */
  48818. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48819. }
  48820. }
  48821. declare module BABYLON {
  48822. /**
  48823. * Implementation of the ENV Texture Loader.
  48824. * @hidden
  48825. */
  48826. export class _ENVTextureLoader implements IInternalTextureLoader {
  48827. /**
  48828. * Defines wether the loader supports cascade loading the different faces.
  48829. */
  48830. readonly supportCascades: boolean;
  48831. /**
  48832. * This returns if the loader support the current file information.
  48833. * @param extension defines the file extension of the file being loaded
  48834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48835. * @param fallback defines the fallback internal texture if any
  48836. * @param isBase64 defines whether the texture is encoded as a base64
  48837. * @param isBuffer defines whether the texture data are stored as a buffer
  48838. * @returns true if the loader can load the specified file
  48839. */
  48840. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48841. /**
  48842. * Transform the url before loading if required.
  48843. * @param rootUrl the url of the texture
  48844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48845. * @returns the transformed texture
  48846. */
  48847. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48848. /**
  48849. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48850. * @param rootUrl the url of the texture
  48851. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48852. * @returns the fallback texture
  48853. */
  48854. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48855. /**
  48856. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48857. * @param data contains the texture data
  48858. * @param texture defines the BabylonJS internal texture
  48859. * @param createPolynomials will be true if polynomials have been requested
  48860. * @param onLoad defines the callback to trigger once the texture is ready
  48861. * @param onError defines the callback to trigger in case of error
  48862. */
  48863. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48864. /**
  48865. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48866. * @param data contains the texture data
  48867. * @param texture defines the BabylonJS internal texture
  48868. * @param callback defines the method to call once ready to upload
  48869. */
  48870. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48871. }
  48872. }
  48873. declare module BABYLON {
  48874. /**
  48875. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48876. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48877. */
  48878. export class KhronosTextureContainer {
  48879. /** contents of the KTX container file */
  48880. arrayBuffer: any;
  48881. private static HEADER_LEN;
  48882. private static COMPRESSED_2D;
  48883. private static COMPRESSED_3D;
  48884. private static TEX_2D;
  48885. private static TEX_3D;
  48886. /**
  48887. * Gets the openGL type
  48888. */
  48889. glType: number;
  48890. /**
  48891. * Gets the openGL type size
  48892. */
  48893. glTypeSize: number;
  48894. /**
  48895. * Gets the openGL format
  48896. */
  48897. glFormat: number;
  48898. /**
  48899. * Gets the openGL internal format
  48900. */
  48901. glInternalFormat: number;
  48902. /**
  48903. * Gets the base internal format
  48904. */
  48905. glBaseInternalFormat: number;
  48906. /**
  48907. * Gets image width in pixel
  48908. */
  48909. pixelWidth: number;
  48910. /**
  48911. * Gets image height in pixel
  48912. */
  48913. pixelHeight: number;
  48914. /**
  48915. * Gets image depth in pixels
  48916. */
  48917. pixelDepth: number;
  48918. /**
  48919. * Gets the number of array elements
  48920. */
  48921. numberOfArrayElements: number;
  48922. /**
  48923. * Gets the number of faces
  48924. */
  48925. numberOfFaces: number;
  48926. /**
  48927. * Gets the number of mipmap levels
  48928. */
  48929. numberOfMipmapLevels: number;
  48930. /**
  48931. * Gets the bytes of key value data
  48932. */
  48933. bytesOfKeyValueData: number;
  48934. /**
  48935. * Gets the load type
  48936. */
  48937. loadType: number;
  48938. /**
  48939. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48940. */
  48941. isInvalid: boolean;
  48942. /**
  48943. * Creates a new KhronosTextureContainer
  48944. * @param arrayBuffer contents of the KTX container file
  48945. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48946. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48947. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48948. */
  48949. constructor(
  48950. /** contents of the KTX container file */
  48951. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48952. /**
  48953. * Uploads KTX content to a Babylon Texture.
  48954. * It is assumed that the texture has already been created & is currently bound
  48955. * @hidden
  48956. */
  48957. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48958. private _upload2DCompressedLevels;
  48959. }
  48960. }
  48961. declare module BABYLON {
  48962. /**
  48963. * Implementation of the KTX Texture Loader.
  48964. * @hidden
  48965. */
  48966. export class _KTXTextureLoader implements IInternalTextureLoader {
  48967. /**
  48968. * Defines wether the loader supports cascade loading the different faces.
  48969. */
  48970. readonly supportCascades: boolean;
  48971. /**
  48972. * This returns if the loader support the current file information.
  48973. * @param extension defines the file extension of the file being loaded
  48974. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48975. * @param fallback defines the fallback internal texture if any
  48976. * @param isBase64 defines whether the texture is encoded as a base64
  48977. * @param isBuffer defines whether the texture data are stored as a buffer
  48978. * @returns true if the loader can load the specified file
  48979. */
  48980. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48981. /**
  48982. * Transform the url before loading if required.
  48983. * @param rootUrl the url of the texture
  48984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48985. * @returns the transformed texture
  48986. */
  48987. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48988. /**
  48989. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48990. * @param rootUrl the url of the texture
  48991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48992. * @returns the fallback texture
  48993. */
  48994. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48995. /**
  48996. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48997. * @param data contains the texture data
  48998. * @param texture defines the BabylonJS internal texture
  48999. * @param createPolynomials will be true if polynomials have been requested
  49000. * @param onLoad defines the callback to trigger once the texture is ready
  49001. * @param onError defines the callback to trigger in case of error
  49002. */
  49003. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49004. /**
  49005. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49006. * @param data contains the texture data
  49007. * @param texture defines the BabylonJS internal texture
  49008. * @param callback defines the method to call once ready to upload
  49009. */
  49010. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49011. }
  49012. }
  49013. declare module BABYLON {
  49014. /**
  49015. * Options for the default xr helper
  49016. */
  49017. export class WebXRDefaultExperienceOptions {
  49018. /**
  49019. * Floor meshes that should be used for teleporting
  49020. */
  49021. floorMeshes: Array<AbstractMesh>;
  49022. }
  49023. /**
  49024. * Default experience which provides a similar setup to the previous webVRExperience
  49025. */
  49026. export class WebXRDefaultExperience {
  49027. /**
  49028. * Base experience
  49029. */
  49030. baseExperience: WebXRExperienceHelper;
  49031. /**
  49032. * Input experience extension
  49033. */
  49034. input: WebXRInput;
  49035. /**
  49036. * Loads the controller models
  49037. */
  49038. controllerModelLoader: WebXRControllerModelLoader;
  49039. /**
  49040. * Enables laser pointer and selection
  49041. */
  49042. pointerSelection: WebXRControllerPointerSelection;
  49043. /**
  49044. * Enables teleportation
  49045. */
  49046. teleportation: WebXRControllerTeleportation;
  49047. /**
  49048. * Enables ui for enetering/exiting xr
  49049. */
  49050. enterExitUI: WebXREnterExitUI;
  49051. /**
  49052. * Default output canvas xr should render to
  49053. */
  49054. outputCanvas: WebXRManagedOutputCanvas;
  49055. /**
  49056. * Creates the default xr experience
  49057. * @param scene scene
  49058. * @param options options for basic configuration
  49059. * @returns resulting WebXRDefaultExperience
  49060. */
  49061. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49062. private constructor();
  49063. /**
  49064. * DIsposes of the experience helper
  49065. */
  49066. dispose(): void;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /** @hidden */
  49071. export var _forceSceneHelpersToBundle: boolean;
  49072. interface Scene {
  49073. /**
  49074. * Creates a default light for the scene.
  49075. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49076. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49077. */
  49078. createDefaultLight(replace?: boolean): void;
  49079. /**
  49080. * Creates a default camera for the scene.
  49081. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49082. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49083. * @param replace has default false, when true replaces the active camera in the scene
  49084. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49085. */
  49086. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49087. /**
  49088. * Creates a default camera and a default light.
  49089. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49090. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49091. * @param replace has the default false, when true replaces the active camera/light in the scene
  49092. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49093. */
  49094. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49095. /**
  49096. * Creates a new sky box
  49097. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49098. * @param environmentTexture defines the texture to use as environment texture
  49099. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49100. * @param scale defines the overall scale of the skybox
  49101. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49102. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49103. * @returns a new mesh holding the sky box
  49104. */
  49105. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49106. /**
  49107. * Creates a new environment
  49108. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49109. * @param options defines the options you can use to configure the environment
  49110. * @returns the new EnvironmentHelper
  49111. */
  49112. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49113. /**
  49114. * Creates a new VREXperienceHelper
  49115. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49116. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49117. * @returns a new VREXperienceHelper
  49118. */
  49119. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49120. /**
  49121. * Creates a new WebXRDefaultExperience
  49122. * @see http://doc.babylonjs.com/how_to/webxr
  49123. * @param options experience options
  49124. * @returns a promise for a new WebXRDefaultExperience
  49125. */
  49126. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49127. }
  49128. }
  49129. declare module BABYLON {
  49130. /**
  49131. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49132. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49133. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49134. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49135. */
  49136. export class VideoDome extends TransformNode {
  49137. /**
  49138. * Define the video source as a Monoscopic panoramic 360 video.
  49139. */
  49140. static readonly MODE_MONOSCOPIC: number;
  49141. /**
  49142. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49143. */
  49144. static readonly MODE_TOPBOTTOM: number;
  49145. /**
  49146. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49147. */
  49148. static readonly MODE_SIDEBYSIDE: number;
  49149. private _halfDome;
  49150. private _useDirectMapping;
  49151. /**
  49152. * The video texture being displayed on the sphere
  49153. */
  49154. protected _videoTexture: VideoTexture;
  49155. /**
  49156. * Gets the video texture being displayed on the sphere
  49157. */
  49158. readonly videoTexture: VideoTexture;
  49159. /**
  49160. * The skybox material
  49161. */
  49162. protected _material: BackgroundMaterial;
  49163. /**
  49164. * The surface used for the skybox
  49165. */
  49166. protected _mesh: Mesh;
  49167. /**
  49168. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  49169. */
  49170. private _halfDomeMask;
  49171. /**
  49172. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49173. * Also see the options.resolution property.
  49174. */
  49175. fovMultiplier: number;
  49176. private _videoMode;
  49177. /**
  49178. * Gets or set the current video mode for the video. It can be:
  49179. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49180. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49181. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49182. */
  49183. videoMode: number;
  49184. /**
  49185. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  49186. *
  49187. */
  49188. /**
  49189. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  49190. */
  49191. halfDome: boolean;
  49192. /**
  49193. * Oberserver used in Stereoscopic VR Mode.
  49194. */
  49195. private _onBeforeCameraRenderObserver;
  49196. /**
  49197. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49198. * @param name Element's name, child elements will append suffixes for their own names.
  49199. * @param urlsOrVideo defines the url(s) or the video element to use
  49200. * @param options An object containing optional or exposed sub element properties
  49201. */
  49202. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49203. resolution?: number;
  49204. clickToPlay?: boolean;
  49205. autoPlay?: boolean;
  49206. loop?: boolean;
  49207. size?: number;
  49208. poster?: string;
  49209. faceForward?: boolean;
  49210. useDirectMapping?: boolean;
  49211. halfDomeMode?: boolean;
  49212. }, scene: Scene);
  49213. private _changeVideoMode;
  49214. /**
  49215. * Releases resources associated with this node.
  49216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49218. */
  49219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49220. }
  49221. }
  49222. declare module BABYLON {
  49223. /**
  49224. * This class can be used to get instrumentation data from a Babylon engine
  49225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49226. */
  49227. export class EngineInstrumentation implements IDisposable {
  49228. /**
  49229. * Define the instrumented engine.
  49230. */
  49231. engine: Engine;
  49232. private _captureGPUFrameTime;
  49233. private _gpuFrameTimeToken;
  49234. private _gpuFrameTime;
  49235. private _captureShaderCompilationTime;
  49236. private _shaderCompilationTime;
  49237. private _onBeginFrameObserver;
  49238. private _onEndFrameObserver;
  49239. private _onBeforeShaderCompilationObserver;
  49240. private _onAfterShaderCompilationObserver;
  49241. /**
  49242. * Gets the perf counter used for GPU frame time
  49243. */
  49244. readonly gpuFrameTimeCounter: PerfCounter;
  49245. /**
  49246. * Gets the GPU frame time capture status
  49247. */
  49248. /**
  49249. * Enable or disable the GPU frame time capture
  49250. */
  49251. captureGPUFrameTime: boolean;
  49252. /**
  49253. * Gets the perf counter used for shader compilation time
  49254. */
  49255. readonly shaderCompilationTimeCounter: PerfCounter;
  49256. /**
  49257. * Gets the shader compilation time capture status
  49258. */
  49259. /**
  49260. * Enable or disable the shader compilation time capture
  49261. */
  49262. captureShaderCompilationTime: boolean;
  49263. /**
  49264. * Instantiates a new engine instrumentation.
  49265. * This class can be used to get instrumentation data from a Babylon engine
  49266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49267. * @param engine Defines the engine to instrument
  49268. */
  49269. constructor(
  49270. /**
  49271. * Define the instrumented engine.
  49272. */
  49273. engine: Engine);
  49274. /**
  49275. * Dispose and release associated resources.
  49276. */
  49277. dispose(): void;
  49278. }
  49279. }
  49280. declare module BABYLON {
  49281. /**
  49282. * This class can be used to get instrumentation data from a Babylon engine
  49283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49284. */
  49285. export class SceneInstrumentation implements IDisposable {
  49286. /**
  49287. * Defines the scene to instrument
  49288. */
  49289. scene: Scene;
  49290. private _captureActiveMeshesEvaluationTime;
  49291. private _activeMeshesEvaluationTime;
  49292. private _captureRenderTargetsRenderTime;
  49293. private _renderTargetsRenderTime;
  49294. private _captureFrameTime;
  49295. private _frameTime;
  49296. private _captureRenderTime;
  49297. private _renderTime;
  49298. private _captureInterFrameTime;
  49299. private _interFrameTime;
  49300. private _captureParticlesRenderTime;
  49301. private _particlesRenderTime;
  49302. private _captureSpritesRenderTime;
  49303. private _spritesRenderTime;
  49304. private _capturePhysicsTime;
  49305. private _physicsTime;
  49306. private _captureAnimationsTime;
  49307. private _animationsTime;
  49308. private _captureCameraRenderTime;
  49309. private _cameraRenderTime;
  49310. private _onBeforeActiveMeshesEvaluationObserver;
  49311. private _onAfterActiveMeshesEvaluationObserver;
  49312. private _onBeforeRenderTargetsRenderObserver;
  49313. private _onAfterRenderTargetsRenderObserver;
  49314. private _onAfterRenderObserver;
  49315. private _onBeforeDrawPhaseObserver;
  49316. private _onAfterDrawPhaseObserver;
  49317. private _onBeforeAnimationsObserver;
  49318. private _onBeforeParticlesRenderingObserver;
  49319. private _onAfterParticlesRenderingObserver;
  49320. private _onBeforeSpritesRenderingObserver;
  49321. private _onAfterSpritesRenderingObserver;
  49322. private _onBeforePhysicsObserver;
  49323. private _onAfterPhysicsObserver;
  49324. private _onAfterAnimationsObserver;
  49325. private _onBeforeCameraRenderObserver;
  49326. private _onAfterCameraRenderObserver;
  49327. /**
  49328. * Gets the perf counter used for active meshes evaluation time
  49329. */
  49330. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49331. /**
  49332. * Gets the active meshes evaluation time capture status
  49333. */
  49334. /**
  49335. * Enable or disable the active meshes evaluation time capture
  49336. */
  49337. captureActiveMeshesEvaluationTime: boolean;
  49338. /**
  49339. * Gets the perf counter used for render targets render time
  49340. */
  49341. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49342. /**
  49343. * Gets the render targets render time capture status
  49344. */
  49345. /**
  49346. * Enable or disable the render targets render time capture
  49347. */
  49348. captureRenderTargetsRenderTime: boolean;
  49349. /**
  49350. * Gets the perf counter used for particles render time
  49351. */
  49352. readonly particlesRenderTimeCounter: PerfCounter;
  49353. /**
  49354. * Gets the particles render time capture status
  49355. */
  49356. /**
  49357. * Enable or disable the particles render time capture
  49358. */
  49359. captureParticlesRenderTime: boolean;
  49360. /**
  49361. * Gets the perf counter used for sprites render time
  49362. */
  49363. readonly spritesRenderTimeCounter: PerfCounter;
  49364. /**
  49365. * Gets the sprites render time capture status
  49366. */
  49367. /**
  49368. * Enable or disable the sprites render time capture
  49369. */
  49370. captureSpritesRenderTime: boolean;
  49371. /**
  49372. * Gets the perf counter used for physics time
  49373. */
  49374. readonly physicsTimeCounter: PerfCounter;
  49375. /**
  49376. * Gets the physics time capture status
  49377. */
  49378. /**
  49379. * Enable or disable the physics time capture
  49380. */
  49381. capturePhysicsTime: boolean;
  49382. /**
  49383. * Gets the perf counter used for animations time
  49384. */
  49385. readonly animationsTimeCounter: PerfCounter;
  49386. /**
  49387. * Gets the animations time capture status
  49388. */
  49389. /**
  49390. * Enable or disable the animations time capture
  49391. */
  49392. captureAnimationsTime: boolean;
  49393. /**
  49394. * Gets the perf counter used for frame time capture
  49395. */
  49396. readonly frameTimeCounter: PerfCounter;
  49397. /**
  49398. * Gets the frame time capture status
  49399. */
  49400. /**
  49401. * Enable or disable the frame time capture
  49402. */
  49403. captureFrameTime: boolean;
  49404. /**
  49405. * Gets the perf counter used for inter-frames time capture
  49406. */
  49407. readonly interFrameTimeCounter: PerfCounter;
  49408. /**
  49409. * Gets the inter-frames time capture status
  49410. */
  49411. /**
  49412. * Enable or disable the inter-frames time capture
  49413. */
  49414. captureInterFrameTime: boolean;
  49415. /**
  49416. * Gets the perf counter used for render time capture
  49417. */
  49418. readonly renderTimeCounter: PerfCounter;
  49419. /**
  49420. * Gets the render time capture status
  49421. */
  49422. /**
  49423. * Enable or disable the render time capture
  49424. */
  49425. captureRenderTime: boolean;
  49426. /**
  49427. * Gets the perf counter used for camera render time capture
  49428. */
  49429. readonly cameraRenderTimeCounter: PerfCounter;
  49430. /**
  49431. * Gets the camera render time capture status
  49432. */
  49433. /**
  49434. * Enable or disable the camera render time capture
  49435. */
  49436. captureCameraRenderTime: boolean;
  49437. /**
  49438. * Gets the perf counter used for draw calls
  49439. */
  49440. readonly drawCallsCounter: PerfCounter;
  49441. /**
  49442. * Instantiates a new scene instrumentation.
  49443. * This class can be used to get instrumentation data from a Babylon engine
  49444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49445. * @param scene Defines the scene to instrument
  49446. */
  49447. constructor(
  49448. /**
  49449. * Defines the scene to instrument
  49450. */
  49451. scene: Scene);
  49452. /**
  49453. * Dispose and release associated resources.
  49454. */
  49455. dispose(): void;
  49456. }
  49457. }
  49458. declare module BABYLON {
  49459. /** @hidden */
  49460. export var glowMapGenerationPixelShader: {
  49461. name: string;
  49462. shader: string;
  49463. };
  49464. }
  49465. declare module BABYLON {
  49466. /** @hidden */
  49467. export var glowMapGenerationVertexShader: {
  49468. name: string;
  49469. shader: string;
  49470. };
  49471. }
  49472. declare module BABYLON {
  49473. /**
  49474. * Effect layer options. This helps customizing the behaviour
  49475. * of the effect layer.
  49476. */
  49477. export interface IEffectLayerOptions {
  49478. /**
  49479. * Multiplication factor apply to the canvas size to compute the render target size
  49480. * used to generated the objects (the smaller the faster).
  49481. */
  49482. mainTextureRatio: number;
  49483. /**
  49484. * Enforces a fixed size texture to ensure effect stability across devices.
  49485. */
  49486. mainTextureFixedSize?: number;
  49487. /**
  49488. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49489. */
  49490. alphaBlendingMode: number;
  49491. /**
  49492. * The camera attached to the layer.
  49493. */
  49494. camera: Nullable<Camera>;
  49495. /**
  49496. * The rendering group to draw the layer in.
  49497. */
  49498. renderingGroupId: number;
  49499. }
  49500. /**
  49501. * The effect layer Helps adding post process effect blended with the main pass.
  49502. *
  49503. * This can be for instance use to generate glow or higlight effects on the scene.
  49504. *
  49505. * The effect layer class can not be used directly and is intented to inherited from to be
  49506. * customized per effects.
  49507. */
  49508. export abstract class EffectLayer {
  49509. private _vertexBuffers;
  49510. private _indexBuffer;
  49511. private _cachedDefines;
  49512. private _effectLayerMapGenerationEffect;
  49513. private _effectLayerOptions;
  49514. private _mergeEffect;
  49515. protected _scene: Scene;
  49516. protected _engine: Engine;
  49517. protected _maxSize: number;
  49518. protected _mainTextureDesiredSize: ISize;
  49519. protected _mainTexture: RenderTargetTexture;
  49520. protected _shouldRender: boolean;
  49521. protected _postProcesses: PostProcess[];
  49522. protected _textures: BaseTexture[];
  49523. protected _emissiveTextureAndColor: {
  49524. texture: Nullable<BaseTexture>;
  49525. color: Color4;
  49526. };
  49527. /**
  49528. * The name of the layer
  49529. */
  49530. name: string;
  49531. /**
  49532. * The clear color of the texture used to generate the glow map.
  49533. */
  49534. neutralColor: Color4;
  49535. /**
  49536. * Specifies wether the highlight layer is enabled or not.
  49537. */
  49538. isEnabled: boolean;
  49539. /**
  49540. * Gets the camera attached to the layer.
  49541. */
  49542. readonly camera: Nullable<Camera>;
  49543. /**
  49544. * Gets the rendering group id the layer should render in.
  49545. */
  49546. renderingGroupId: number;
  49547. /**
  49548. * An event triggered when the effect layer has been disposed.
  49549. */
  49550. onDisposeObservable: Observable<EffectLayer>;
  49551. /**
  49552. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49553. */
  49554. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49555. /**
  49556. * An event triggered when the generated texture is being merged in the scene.
  49557. */
  49558. onBeforeComposeObservable: Observable<EffectLayer>;
  49559. /**
  49560. * An event triggered when the generated texture has been merged in the scene.
  49561. */
  49562. onAfterComposeObservable: Observable<EffectLayer>;
  49563. /**
  49564. * An event triggered when the efffect layer changes its size.
  49565. */
  49566. onSizeChangedObservable: Observable<EffectLayer>;
  49567. /** @hidden */
  49568. static _SceneComponentInitialization: (scene: Scene) => void;
  49569. /**
  49570. * Instantiates a new effect Layer and references it in the scene.
  49571. * @param name The name of the layer
  49572. * @param scene The scene to use the layer in
  49573. */
  49574. constructor(
  49575. /** The Friendly of the effect in the scene */
  49576. name: string, scene: Scene);
  49577. /**
  49578. * Get the effect name of the layer.
  49579. * @return The effect name
  49580. */
  49581. abstract getEffectName(): string;
  49582. /**
  49583. * Checks for the readiness of the element composing the layer.
  49584. * @param subMesh the mesh to check for
  49585. * @param useInstances specify wether or not to use instances to render the mesh
  49586. * @return true if ready otherwise, false
  49587. */
  49588. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49589. /**
  49590. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49591. * @returns true if the effect requires stencil during the main canvas render pass.
  49592. */
  49593. abstract needStencil(): boolean;
  49594. /**
  49595. * Create the merge effect. This is the shader use to blit the information back
  49596. * to the main canvas at the end of the scene rendering.
  49597. * @returns The effect containing the shader used to merge the effect on the main canvas
  49598. */
  49599. protected abstract _createMergeEffect(): Effect;
  49600. /**
  49601. * Creates the render target textures and post processes used in the effect layer.
  49602. */
  49603. protected abstract _createTextureAndPostProcesses(): void;
  49604. /**
  49605. * Implementation specific of rendering the generating effect on the main canvas.
  49606. * @param effect The effect used to render through
  49607. */
  49608. protected abstract _internalRender(effect: Effect): void;
  49609. /**
  49610. * Sets the required values for both the emissive texture and and the main color.
  49611. */
  49612. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49613. /**
  49614. * Free any resources and references associated to a mesh.
  49615. * Internal use
  49616. * @param mesh The mesh to free.
  49617. */
  49618. abstract _disposeMesh(mesh: Mesh): void;
  49619. /**
  49620. * Serializes this layer (Glow or Highlight for example)
  49621. * @returns a serialized layer object
  49622. */
  49623. abstract serialize?(): any;
  49624. /**
  49625. * Initializes the effect layer with the required options.
  49626. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49627. */
  49628. protected _init(options: Partial<IEffectLayerOptions>): void;
  49629. /**
  49630. * Generates the index buffer of the full screen quad blending to the main canvas.
  49631. */
  49632. private _generateIndexBuffer;
  49633. /**
  49634. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49635. */
  49636. private _generateVertexBuffer;
  49637. /**
  49638. * Sets the main texture desired size which is the closest power of two
  49639. * of the engine canvas size.
  49640. */
  49641. private _setMainTextureSize;
  49642. /**
  49643. * Creates the main texture for the effect layer.
  49644. */
  49645. protected _createMainTexture(): void;
  49646. /**
  49647. * Adds specific effects defines.
  49648. * @param defines The defines to add specifics to.
  49649. */
  49650. protected _addCustomEffectDefines(defines: string[]): void;
  49651. /**
  49652. * Checks for the readiness of the element composing the layer.
  49653. * @param subMesh the mesh to check for
  49654. * @param useInstances specify wether or not to use instances to render the mesh
  49655. * @param emissiveTexture the associated emissive texture used to generate the glow
  49656. * @return true if ready otherwise, false
  49657. */
  49658. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49659. /**
  49660. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49661. */
  49662. render(): void;
  49663. /**
  49664. * Determine if a given mesh will be used in the current effect.
  49665. * @param mesh mesh to test
  49666. * @returns true if the mesh will be used
  49667. */
  49668. hasMesh(mesh: AbstractMesh): boolean;
  49669. /**
  49670. * Returns true if the layer contains information to display, otherwise false.
  49671. * @returns true if the glow layer should be rendered
  49672. */
  49673. shouldRender(): boolean;
  49674. /**
  49675. * Returns true if the mesh should render, otherwise false.
  49676. * @param mesh The mesh to render
  49677. * @returns true if it should render otherwise false
  49678. */
  49679. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49680. /**
  49681. * Returns true if the mesh can be rendered, otherwise false.
  49682. * @param mesh The mesh to render
  49683. * @param material The material used on the mesh
  49684. * @returns true if it can be rendered otherwise false
  49685. */
  49686. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49687. /**
  49688. * Returns true if the mesh should render, otherwise false.
  49689. * @param mesh The mesh to render
  49690. * @returns true if it should render otherwise false
  49691. */
  49692. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49693. /**
  49694. * Renders the submesh passed in parameter to the generation map.
  49695. */
  49696. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49697. /**
  49698. * Rebuild the required buffers.
  49699. * @hidden Internal use only.
  49700. */
  49701. _rebuild(): void;
  49702. /**
  49703. * Dispose only the render target textures and post process.
  49704. */
  49705. private _disposeTextureAndPostProcesses;
  49706. /**
  49707. * Dispose the highlight layer and free resources.
  49708. */
  49709. dispose(): void;
  49710. /**
  49711. * Gets the class name of the effect layer
  49712. * @returns the string with the class name of the effect layer
  49713. */
  49714. getClassName(): string;
  49715. /**
  49716. * Creates an effect layer from parsed effect layer data
  49717. * @param parsedEffectLayer defines effect layer data
  49718. * @param scene defines the current scene
  49719. * @param rootUrl defines the root URL containing the effect layer information
  49720. * @returns a parsed effect Layer
  49721. */
  49722. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49723. }
  49724. }
  49725. declare module BABYLON {
  49726. interface AbstractScene {
  49727. /**
  49728. * The list of effect layers (highlights/glow) added to the scene
  49729. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49730. * @see http://doc.babylonjs.com/how_to/glow_layer
  49731. */
  49732. effectLayers: Array<EffectLayer>;
  49733. /**
  49734. * Removes the given effect layer from this scene.
  49735. * @param toRemove defines the effect layer to remove
  49736. * @returns the index of the removed effect layer
  49737. */
  49738. removeEffectLayer(toRemove: EffectLayer): number;
  49739. /**
  49740. * Adds the given effect layer to this scene
  49741. * @param newEffectLayer defines the effect layer to add
  49742. */
  49743. addEffectLayer(newEffectLayer: EffectLayer): void;
  49744. }
  49745. /**
  49746. * Defines the layer scene component responsible to manage any effect layers
  49747. * in a given scene.
  49748. */
  49749. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49750. /**
  49751. * The component name helpfull to identify the component in the list of scene components.
  49752. */
  49753. readonly name: string;
  49754. /**
  49755. * The scene the component belongs to.
  49756. */
  49757. scene: Scene;
  49758. private _engine;
  49759. private _renderEffects;
  49760. private _needStencil;
  49761. private _previousStencilState;
  49762. /**
  49763. * Creates a new instance of the component for the given scene
  49764. * @param scene Defines the scene to register the component in
  49765. */
  49766. constructor(scene: Scene);
  49767. /**
  49768. * Registers the component in a given scene
  49769. */
  49770. register(): void;
  49771. /**
  49772. * Rebuilds the elements related to this component in case of
  49773. * context lost for instance.
  49774. */
  49775. rebuild(): void;
  49776. /**
  49777. * Serializes the component data to the specified json object
  49778. * @param serializationObject The object to serialize to
  49779. */
  49780. serialize(serializationObject: any): void;
  49781. /**
  49782. * Adds all the elements from the container to the scene
  49783. * @param container the container holding the elements
  49784. */
  49785. addFromContainer(container: AbstractScene): void;
  49786. /**
  49787. * Removes all the elements in the container from the scene
  49788. * @param container contains the elements to remove
  49789. * @param dispose if the removed element should be disposed (default: false)
  49790. */
  49791. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49792. /**
  49793. * Disposes the component and the associated ressources.
  49794. */
  49795. dispose(): void;
  49796. private _isReadyForMesh;
  49797. private _renderMainTexture;
  49798. private _setStencil;
  49799. private _setStencilBack;
  49800. private _draw;
  49801. private _drawCamera;
  49802. private _drawRenderingGroup;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /** @hidden */
  49807. export var glowMapMergePixelShader: {
  49808. name: string;
  49809. shader: string;
  49810. };
  49811. }
  49812. declare module BABYLON {
  49813. /** @hidden */
  49814. export var glowMapMergeVertexShader: {
  49815. name: string;
  49816. shader: string;
  49817. };
  49818. }
  49819. declare module BABYLON {
  49820. interface AbstractScene {
  49821. /**
  49822. * Return a the first highlight layer of the scene with a given name.
  49823. * @param name The name of the highlight layer to look for.
  49824. * @return The highlight layer if found otherwise null.
  49825. */
  49826. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49827. }
  49828. /**
  49829. * Glow layer options. This helps customizing the behaviour
  49830. * of the glow layer.
  49831. */
  49832. export interface IGlowLayerOptions {
  49833. /**
  49834. * Multiplication factor apply to the canvas size to compute the render target size
  49835. * used to generated the glowing objects (the smaller the faster).
  49836. */
  49837. mainTextureRatio: number;
  49838. /**
  49839. * Enforces a fixed size texture to ensure resize independant blur.
  49840. */
  49841. mainTextureFixedSize?: number;
  49842. /**
  49843. * How big is the kernel of the blur texture.
  49844. */
  49845. blurKernelSize: number;
  49846. /**
  49847. * The camera attached to the layer.
  49848. */
  49849. camera: Nullable<Camera>;
  49850. /**
  49851. * Enable MSAA by chosing the number of samples.
  49852. */
  49853. mainTextureSamples?: number;
  49854. /**
  49855. * The rendering group to draw the layer in.
  49856. */
  49857. renderingGroupId: number;
  49858. }
  49859. /**
  49860. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49861. *
  49862. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49863. * glowy meshes to your scene.
  49864. *
  49865. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49866. */
  49867. export class GlowLayer extends EffectLayer {
  49868. /**
  49869. * Effect Name of the layer.
  49870. */
  49871. static readonly EffectName: string;
  49872. /**
  49873. * The default blur kernel size used for the glow.
  49874. */
  49875. static DefaultBlurKernelSize: number;
  49876. /**
  49877. * The default texture size ratio used for the glow.
  49878. */
  49879. static DefaultTextureRatio: number;
  49880. /**
  49881. * Sets the kernel size of the blur.
  49882. */
  49883. /**
  49884. * Gets the kernel size of the blur.
  49885. */
  49886. blurKernelSize: number;
  49887. /**
  49888. * Sets the glow intensity.
  49889. */
  49890. /**
  49891. * Gets the glow intensity.
  49892. */
  49893. intensity: number;
  49894. private _options;
  49895. private _intensity;
  49896. private _horizontalBlurPostprocess1;
  49897. private _verticalBlurPostprocess1;
  49898. private _horizontalBlurPostprocess2;
  49899. private _verticalBlurPostprocess2;
  49900. private _blurTexture1;
  49901. private _blurTexture2;
  49902. private _postProcesses1;
  49903. private _postProcesses2;
  49904. private _includedOnlyMeshes;
  49905. private _excludedMeshes;
  49906. /**
  49907. * Callback used to let the user override the color selection on a per mesh basis
  49908. */
  49909. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49910. /**
  49911. * Callback used to let the user override the texture selection on a per mesh basis
  49912. */
  49913. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49914. /**
  49915. * Instantiates a new glow Layer and references it to the scene.
  49916. * @param name The name of the layer
  49917. * @param scene The scene to use the layer in
  49918. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49919. */
  49920. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49921. /**
  49922. * Get the effect name of the layer.
  49923. * @return The effect name
  49924. */
  49925. getEffectName(): string;
  49926. /**
  49927. * Create the merge effect. This is the shader use to blit the information back
  49928. * to the main canvas at the end of the scene rendering.
  49929. */
  49930. protected _createMergeEffect(): Effect;
  49931. /**
  49932. * Creates the render target textures and post processes used in the glow layer.
  49933. */
  49934. protected _createTextureAndPostProcesses(): void;
  49935. /**
  49936. * Checks for the readiness of the element composing the layer.
  49937. * @param subMesh the mesh to check for
  49938. * @param useInstances specify wether or not to use instances to render the mesh
  49939. * @param emissiveTexture the associated emissive texture used to generate the glow
  49940. * @return true if ready otherwise, false
  49941. */
  49942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49943. /**
  49944. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49945. */
  49946. needStencil(): boolean;
  49947. /**
  49948. * Returns true if the mesh can be rendered, otherwise false.
  49949. * @param mesh The mesh to render
  49950. * @param material The material used on the mesh
  49951. * @returns true if it can be rendered otherwise false
  49952. */
  49953. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49954. /**
  49955. * Implementation specific of rendering the generating effect on the main canvas.
  49956. * @param effect The effect used to render through
  49957. */
  49958. protected _internalRender(effect: Effect): void;
  49959. /**
  49960. * Sets the required values for both the emissive texture and and the main color.
  49961. */
  49962. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49963. /**
  49964. * Returns true if the mesh should render, otherwise false.
  49965. * @param mesh The mesh to render
  49966. * @returns true if it should render otherwise false
  49967. */
  49968. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49969. /**
  49970. * Adds specific effects defines.
  49971. * @param defines The defines to add specifics to.
  49972. */
  49973. protected _addCustomEffectDefines(defines: string[]): void;
  49974. /**
  49975. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49976. * @param mesh The mesh to exclude from the glow layer
  49977. */
  49978. addExcludedMesh(mesh: Mesh): void;
  49979. /**
  49980. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49981. * @param mesh The mesh to remove
  49982. */
  49983. removeExcludedMesh(mesh: Mesh): void;
  49984. /**
  49985. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49986. * @param mesh The mesh to include in the glow layer
  49987. */
  49988. addIncludedOnlyMesh(mesh: Mesh): void;
  49989. /**
  49990. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49991. * @param mesh The mesh to remove
  49992. */
  49993. removeIncludedOnlyMesh(mesh: Mesh): void;
  49994. /**
  49995. * Determine if a given mesh will be used in the glow layer
  49996. * @param mesh The mesh to test
  49997. * @returns true if the mesh will be highlighted by the current glow layer
  49998. */
  49999. hasMesh(mesh: AbstractMesh): boolean;
  50000. /**
  50001. * Free any resources and references associated to a mesh.
  50002. * Internal use
  50003. * @param mesh The mesh to free.
  50004. * @hidden
  50005. */
  50006. _disposeMesh(mesh: Mesh): void;
  50007. /**
  50008. * Gets the class name of the effect layer
  50009. * @returns the string with the class name of the effect layer
  50010. */
  50011. getClassName(): string;
  50012. /**
  50013. * Serializes this glow layer
  50014. * @returns a serialized glow layer object
  50015. */
  50016. serialize(): any;
  50017. /**
  50018. * Creates a Glow Layer from parsed glow layer data
  50019. * @param parsedGlowLayer defines glow layer data
  50020. * @param scene defines the current scene
  50021. * @param rootUrl defines the root URL containing the glow layer information
  50022. * @returns a parsed Glow Layer
  50023. */
  50024. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50025. }
  50026. }
  50027. declare module BABYLON {
  50028. /** @hidden */
  50029. export var glowBlurPostProcessPixelShader: {
  50030. name: string;
  50031. shader: string;
  50032. };
  50033. }
  50034. declare module BABYLON {
  50035. interface AbstractScene {
  50036. /**
  50037. * Return a the first highlight layer of the scene with a given name.
  50038. * @param name The name of the highlight layer to look for.
  50039. * @return The highlight layer if found otherwise null.
  50040. */
  50041. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50042. }
  50043. /**
  50044. * Highlight layer options. This helps customizing the behaviour
  50045. * of the highlight layer.
  50046. */
  50047. export interface IHighlightLayerOptions {
  50048. /**
  50049. * Multiplication factor apply to the canvas size to compute the render target size
  50050. * used to generated the glowing objects (the smaller the faster).
  50051. */
  50052. mainTextureRatio: number;
  50053. /**
  50054. * Enforces a fixed size texture to ensure resize independant blur.
  50055. */
  50056. mainTextureFixedSize?: number;
  50057. /**
  50058. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50059. * of the picture to blur (the smaller the faster).
  50060. */
  50061. blurTextureSizeRatio: number;
  50062. /**
  50063. * How big in texel of the blur texture is the vertical blur.
  50064. */
  50065. blurVerticalSize: number;
  50066. /**
  50067. * How big in texel of the blur texture is the horizontal blur.
  50068. */
  50069. blurHorizontalSize: number;
  50070. /**
  50071. * Alpha blending mode used to apply the blur. Default is combine.
  50072. */
  50073. alphaBlendingMode: number;
  50074. /**
  50075. * The camera attached to the layer.
  50076. */
  50077. camera: Nullable<Camera>;
  50078. /**
  50079. * Should we display highlight as a solid stroke?
  50080. */
  50081. isStroke?: boolean;
  50082. /**
  50083. * The rendering group to draw the layer in.
  50084. */
  50085. renderingGroupId: number;
  50086. }
  50087. /**
  50088. * The highlight layer Helps adding a glow effect around a mesh.
  50089. *
  50090. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50091. * glowy meshes to your scene.
  50092. *
  50093. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50094. */
  50095. export class HighlightLayer extends EffectLayer {
  50096. name: string;
  50097. /**
  50098. * Effect Name of the highlight layer.
  50099. */
  50100. static readonly EffectName: string;
  50101. /**
  50102. * The neutral color used during the preparation of the glow effect.
  50103. * This is black by default as the blend operation is a blend operation.
  50104. */
  50105. static NeutralColor: Color4;
  50106. /**
  50107. * Stencil value used for glowing meshes.
  50108. */
  50109. static GlowingMeshStencilReference: number;
  50110. /**
  50111. * Stencil value used for the other meshes in the scene.
  50112. */
  50113. static NormalMeshStencilReference: number;
  50114. /**
  50115. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50116. */
  50117. innerGlow: boolean;
  50118. /**
  50119. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50120. */
  50121. outerGlow: boolean;
  50122. /**
  50123. * Specifies the horizontal size of the blur.
  50124. */
  50125. /**
  50126. * Gets the horizontal size of the blur.
  50127. */
  50128. blurHorizontalSize: number;
  50129. /**
  50130. * Specifies the vertical size of the blur.
  50131. */
  50132. /**
  50133. * Gets the vertical size of the blur.
  50134. */
  50135. blurVerticalSize: number;
  50136. /**
  50137. * An event triggered when the highlight layer is being blurred.
  50138. */
  50139. onBeforeBlurObservable: Observable<HighlightLayer>;
  50140. /**
  50141. * An event triggered when the highlight layer has been blurred.
  50142. */
  50143. onAfterBlurObservable: Observable<HighlightLayer>;
  50144. private _instanceGlowingMeshStencilReference;
  50145. private _options;
  50146. private _downSamplePostprocess;
  50147. private _horizontalBlurPostprocess;
  50148. private _verticalBlurPostprocess;
  50149. private _blurTexture;
  50150. private _meshes;
  50151. private _excludedMeshes;
  50152. /**
  50153. * Instantiates a new highlight Layer and references it to the scene..
  50154. * @param name The name of the layer
  50155. * @param scene The scene to use the layer in
  50156. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50157. */
  50158. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50159. /**
  50160. * Get the effect name of the layer.
  50161. * @return The effect name
  50162. */
  50163. getEffectName(): string;
  50164. /**
  50165. * Create the merge effect. This is the shader use to blit the information back
  50166. * to the main canvas at the end of the scene rendering.
  50167. */
  50168. protected _createMergeEffect(): Effect;
  50169. /**
  50170. * Creates the render target textures and post processes used in the highlight layer.
  50171. */
  50172. protected _createTextureAndPostProcesses(): void;
  50173. /**
  50174. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50175. */
  50176. needStencil(): boolean;
  50177. /**
  50178. * Checks for the readiness of the element composing the layer.
  50179. * @param subMesh the mesh to check for
  50180. * @param useInstances specify wether or not to use instances to render the mesh
  50181. * @param emissiveTexture the associated emissive texture used to generate the glow
  50182. * @return true if ready otherwise, false
  50183. */
  50184. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50185. /**
  50186. * Implementation specific of rendering the generating effect on the main canvas.
  50187. * @param effect The effect used to render through
  50188. */
  50189. protected _internalRender(effect: Effect): void;
  50190. /**
  50191. * Returns true if the layer contains information to display, otherwise false.
  50192. */
  50193. shouldRender(): boolean;
  50194. /**
  50195. * Returns true if the mesh should render, otherwise false.
  50196. * @param mesh The mesh to render
  50197. * @returns true if it should render otherwise false
  50198. */
  50199. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50200. /**
  50201. * Sets the required values for both the emissive texture and and the main color.
  50202. */
  50203. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50204. /**
  50205. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50206. * @param mesh The mesh to exclude from the highlight layer
  50207. */
  50208. addExcludedMesh(mesh: Mesh): void;
  50209. /**
  50210. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50211. * @param mesh The mesh to highlight
  50212. */
  50213. removeExcludedMesh(mesh: Mesh): void;
  50214. /**
  50215. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50216. * @param mesh mesh to test
  50217. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50218. */
  50219. hasMesh(mesh: AbstractMesh): boolean;
  50220. /**
  50221. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50222. * @param mesh The mesh to highlight
  50223. * @param color The color of the highlight
  50224. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50225. */
  50226. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50227. /**
  50228. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50229. * @param mesh The mesh to highlight
  50230. */
  50231. removeMesh(mesh: Mesh): void;
  50232. /**
  50233. * Force the stencil to the normal expected value for none glowing parts
  50234. */
  50235. private _defaultStencilReference;
  50236. /**
  50237. * Free any resources and references associated to a mesh.
  50238. * Internal use
  50239. * @param mesh The mesh to free.
  50240. * @hidden
  50241. */
  50242. _disposeMesh(mesh: Mesh): void;
  50243. /**
  50244. * Dispose the highlight layer and free resources.
  50245. */
  50246. dispose(): void;
  50247. /**
  50248. * Gets the class name of the effect layer
  50249. * @returns the string with the class name of the effect layer
  50250. */
  50251. getClassName(): string;
  50252. /**
  50253. * Serializes this Highlight layer
  50254. * @returns a serialized Highlight layer object
  50255. */
  50256. serialize(): any;
  50257. /**
  50258. * Creates a Highlight layer from parsed Highlight layer data
  50259. * @param parsedHightlightLayer defines the Highlight layer data
  50260. * @param scene defines the current scene
  50261. * @param rootUrl defines the root URL containing the Highlight layer information
  50262. * @returns a parsed Highlight layer
  50263. */
  50264. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50265. }
  50266. }
  50267. declare module BABYLON {
  50268. interface AbstractScene {
  50269. /**
  50270. * The list of layers (background and foreground) of the scene
  50271. */
  50272. layers: Array<Layer>;
  50273. }
  50274. /**
  50275. * Defines the layer scene component responsible to manage any layers
  50276. * in a given scene.
  50277. */
  50278. export class LayerSceneComponent implements ISceneComponent {
  50279. /**
  50280. * The component name helpfull to identify the component in the list of scene components.
  50281. */
  50282. readonly name: string;
  50283. /**
  50284. * The scene the component belongs to.
  50285. */
  50286. scene: Scene;
  50287. private _engine;
  50288. /**
  50289. * Creates a new instance of the component for the given scene
  50290. * @param scene Defines the scene to register the component in
  50291. */
  50292. constructor(scene: Scene);
  50293. /**
  50294. * Registers the component in a given scene
  50295. */
  50296. register(): void;
  50297. /**
  50298. * Rebuilds the elements related to this component in case of
  50299. * context lost for instance.
  50300. */
  50301. rebuild(): void;
  50302. /**
  50303. * Disposes the component and the associated ressources.
  50304. */
  50305. dispose(): void;
  50306. private _draw;
  50307. private _drawCameraPredicate;
  50308. private _drawCameraBackground;
  50309. private _drawCameraForeground;
  50310. private _drawRenderTargetPredicate;
  50311. private _drawRenderTargetBackground;
  50312. private _drawRenderTargetForeground;
  50313. /**
  50314. * Adds all the elements from the container to the scene
  50315. * @param container the container holding the elements
  50316. */
  50317. addFromContainer(container: AbstractScene): void;
  50318. /**
  50319. * Removes all the elements in the container from the scene
  50320. * @param container contains the elements to remove
  50321. * @param dispose if the removed element should be disposed (default: false)
  50322. */
  50323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50324. }
  50325. }
  50326. declare module BABYLON {
  50327. /** @hidden */
  50328. export var layerPixelShader: {
  50329. name: string;
  50330. shader: string;
  50331. };
  50332. }
  50333. declare module BABYLON {
  50334. /** @hidden */
  50335. export var layerVertexShader: {
  50336. name: string;
  50337. shader: string;
  50338. };
  50339. }
  50340. declare module BABYLON {
  50341. /**
  50342. * This represents a full screen 2d layer.
  50343. * This can be useful to display a picture in the background of your scene for instance.
  50344. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50345. */
  50346. export class Layer {
  50347. /**
  50348. * Define the name of the layer.
  50349. */
  50350. name: string;
  50351. /**
  50352. * Define the texture the layer should display.
  50353. */
  50354. texture: Nullable<Texture>;
  50355. /**
  50356. * Is the layer in background or foreground.
  50357. */
  50358. isBackground: boolean;
  50359. /**
  50360. * Define the color of the layer (instead of texture).
  50361. */
  50362. color: Color4;
  50363. /**
  50364. * Define the scale of the layer in order to zoom in out of the texture.
  50365. */
  50366. scale: Vector2;
  50367. /**
  50368. * Define an offset for the layer in order to shift the texture.
  50369. */
  50370. offset: Vector2;
  50371. /**
  50372. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50373. */
  50374. alphaBlendingMode: number;
  50375. /**
  50376. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50377. * Alpha test will not mix with the background color in case of transparency.
  50378. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50379. */
  50380. alphaTest: boolean;
  50381. /**
  50382. * Define a mask to restrict the layer to only some of the scene cameras.
  50383. */
  50384. layerMask: number;
  50385. /**
  50386. * Define the list of render target the layer is visible into.
  50387. */
  50388. renderTargetTextures: RenderTargetTexture[];
  50389. /**
  50390. * Define if the layer is only used in renderTarget or if it also
  50391. * renders in the main frame buffer of the canvas.
  50392. */
  50393. renderOnlyInRenderTargetTextures: boolean;
  50394. private _scene;
  50395. private _vertexBuffers;
  50396. private _indexBuffer;
  50397. private _effect;
  50398. private _alphaTestEffect;
  50399. /**
  50400. * An event triggered when the layer is disposed.
  50401. */
  50402. onDisposeObservable: Observable<Layer>;
  50403. private _onDisposeObserver;
  50404. /**
  50405. * Back compatibility with callback before the onDisposeObservable existed.
  50406. * The set callback will be triggered when the layer has been disposed.
  50407. */
  50408. onDispose: () => void;
  50409. /**
  50410. * An event triggered before rendering the scene
  50411. */
  50412. onBeforeRenderObservable: Observable<Layer>;
  50413. private _onBeforeRenderObserver;
  50414. /**
  50415. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50416. * The set callback will be triggered just before rendering the layer.
  50417. */
  50418. onBeforeRender: () => void;
  50419. /**
  50420. * An event triggered after rendering the scene
  50421. */
  50422. onAfterRenderObservable: Observable<Layer>;
  50423. private _onAfterRenderObserver;
  50424. /**
  50425. * Back compatibility with callback before the onAfterRenderObservable existed.
  50426. * The set callback will be triggered just after rendering the layer.
  50427. */
  50428. onAfterRender: () => void;
  50429. /**
  50430. * Instantiates a new layer.
  50431. * This represents a full screen 2d layer.
  50432. * This can be useful to display a picture in the background of your scene for instance.
  50433. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50434. * @param name Define the name of the layer in the scene
  50435. * @param imgUrl Define the url of the texture to display in the layer
  50436. * @param scene Define the scene the layer belongs to
  50437. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50438. * @param color Defines a color for the layer
  50439. */
  50440. constructor(
  50441. /**
  50442. * Define the name of the layer.
  50443. */
  50444. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50445. private _createIndexBuffer;
  50446. /** @hidden */
  50447. _rebuild(): void;
  50448. /**
  50449. * Renders the layer in the scene.
  50450. */
  50451. render(): void;
  50452. /**
  50453. * Disposes and releases the associated ressources.
  50454. */
  50455. dispose(): void;
  50456. }
  50457. }
  50458. declare module BABYLON {
  50459. /** @hidden */
  50460. export var lensFlarePixelShader: {
  50461. name: string;
  50462. shader: string;
  50463. };
  50464. }
  50465. declare module BABYLON {
  50466. /** @hidden */
  50467. export var lensFlareVertexShader: {
  50468. name: string;
  50469. shader: string;
  50470. };
  50471. }
  50472. declare module BABYLON {
  50473. /**
  50474. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50475. * It is usually composed of several `lensFlare`.
  50476. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50477. */
  50478. export class LensFlareSystem {
  50479. /**
  50480. * Define the name of the lens flare system
  50481. */
  50482. name: string;
  50483. /**
  50484. * List of lens flares used in this system.
  50485. */
  50486. lensFlares: LensFlare[];
  50487. /**
  50488. * Define a limit from the border the lens flare can be visible.
  50489. */
  50490. borderLimit: number;
  50491. /**
  50492. * Define a viewport border we do not want to see the lens flare in.
  50493. */
  50494. viewportBorder: number;
  50495. /**
  50496. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50497. */
  50498. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50499. /**
  50500. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50501. */
  50502. layerMask: number;
  50503. /**
  50504. * Define the id of the lens flare system in the scene.
  50505. * (equal to name by default)
  50506. */
  50507. id: string;
  50508. private _scene;
  50509. private _emitter;
  50510. private _vertexBuffers;
  50511. private _indexBuffer;
  50512. private _effect;
  50513. private _positionX;
  50514. private _positionY;
  50515. private _isEnabled;
  50516. /** @hidden */
  50517. static _SceneComponentInitialization: (scene: Scene) => void;
  50518. /**
  50519. * Instantiates a lens flare system.
  50520. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50521. * It is usually composed of several `lensFlare`.
  50522. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50523. * @param name Define the name of the lens flare system in the scene
  50524. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50525. * @param scene Define the scene the lens flare system belongs to
  50526. */
  50527. constructor(
  50528. /**
  50529. * Define the name of the lens flare system
  50530. */
  50531. name: string, emitter: any, scene: Scene);
  50532. /**
  50533. * Define if the lens flare system is enabled.
  50534. */
  50535. isEnabled: boolean;
  50536. /**
  50537. * Get the scene the effects belongs to.
  50538. * @returns the scene holding the lens flare system
  50539. */
  50540. getScene(): Scene;
  50541. /**
  50542. * Get the emitter of the lens flare system.
  50543. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50544. * @returns the emitter of the lens flare system
  50545. */
  50546. getEmitter(): any;
  50547. /**
  50548. * Set the emitter of the lens flare system.
  50549. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50550. * @param newEmitter Define the new emitter of the system
  50551. */
  50552. setEmitter(newEmitter: any): void;
  50553. /**
  50554. * Get the lens flare system emitter position.
  50555. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50556. * @returns the position
  50557. */
  50558. getEmitterPosition(): Vector3;
  50559. /**
  50560. * @hidden
  50561. */
  50562. computeEffectivePosition(globalViewport: Viewport): boolean;
  50563. /** @hidden */
  50564. _isVisible(): boolean;
  50565. /**
  50566. * @hidden
  50567. */
  50568. render(): boolean;
  50569. /**
  50570. * Dispose and release the lens flare with its associated resources.
  50571. */
  50572. dispose(): void;
  50573. /**
  50574. * Parse a lens flare system from a JSON repressentation
  50575. * @param parsedLensFlareSystem Define the JSON to parse
  50576. * @param scene Define the scene the parsed system should be instantiated in
  50577. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50578. * @returns the parsed system
  50579. */
  50580. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50581. /**
  50582. * Serialize the current Lens Flare System into a JSON representation.
  50583. * @returns the serialized JSON
  50584. */
  50585. serialize(): any;
  50586. }
  50587. }
  50588. declare module BABYLON {
  50589. /**
  50590. * This represents one of the lens effect in a `lensFlareSystem`.
  50591. * It controls one of the indiviual texture used in the effect.
  50592. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50593. */
  50594. export class LensFlare {
  50595. /**
  50596. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50597. */
  50598. size: number;
  50599. /**
  50600. * 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.
  50601. */
  50602. position: number;
  50603. /**
  50604. * Define the lens color.
  50605. */
  50606. color: Color3;
  50607. /**
  50608. * Define the lens texture.
  50609. */
  50610. texture: Nullable<Texture>;
  50611. /**
  50612. * Define the alpha mode to render this particular lens.
  50613. */
  50614. alphaMode: number;
  50615. private _system;
  50616. /**
  50617. * Creates a new Lens Flare.
  50618. * This represents one of the lens effect in a `lensFlareSystem`.
  50619. * It controls one of the indiviual texture used in the effect.
  50620. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50621. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50622. * @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.
  50623. * @param color Define the lens color
  50624. * @param imgUrl Define the lens texture url
  50625. * @param system Define the `lensFlareSystem` this flare is part of
  50626. * @returns The newly created Lens Flare
  50627. */
  50628. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50629. /**
  50630. * Instantiates a new Lens Flare.
  50631. * This represents one of the lens effect in a `lensFlareSystem`.
  50632. * It controls one of the indiviual texture used in the effect.
  50633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50634. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50635. * @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.
  50636. * @param color Define the lens color
  50637. * @param imgUrl Define the lens texture url
  50638. * @param system Define the `lensFlareSystem` this flare is part of
  50639. */
  50640. constructor(
  50641. /**
  50642. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50643. */
  50644. size: number,
  50645. /**
  50646. * 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.
  50647. */
  50648. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50649. /**
  50650. * Dispose and release the lens flare with its associated resources.
  50651. */
  50652. dispose(): void;
  50653. }
  50654. }
  50655. declare module BABYLON {
  50656. interface AbstractScene {
  50657. /**
  50658. * The list of lens flare system added to the scene
  50659. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50660. */
  50661. lensFlareSystems: Array<LensFlareSystem>;
  50662. /**
  50663. * Removes the given lens flare system from this scene.
  50664. * @param toRemove The lens flare system to remove
  50665. * @returns The index of the removed lens flare system
  50666. */
  50667. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50668. /**
  50669. * Adds the given lens flare system to this scene
  50670. * @param newLensFlareSystem The lens flare system to add
  50671. */
  50672. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50673. /**
  50674. * Gets a lens flare system using its name
  50675. * @param name defines the name to look for
  50676. * @returns the lens flare system or null if not found
  50677. */
  50678. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50679. /**
  50680. * Gets a lens flare system using its id
  50681. * @param id defines the id to look for
  50682. * @returns the lens flare system or null if not found
  50683. */
  50684. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50685. }
  50686. /**
  50687. * Defines the lens flare scene component responsible to manage any lens flares
  50688. * in a given scene.
  50689. */
  50690. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50691. /**
  50692. * The component name helpfull to identify the component in the list of scene components.
  50693. */
  50694. readonly name: string;
  50695. /**
  50696. * The scene the component belongs to.
  50697. */
  50698. scene: Scene;
  50699. /**
  50700. * Creates a new instance of the component for the given scene
  50701. * @param scene Defines the scene to register the component in
  50702. */
  50703. constructor(scene: Scene);
  50704. /**
  50705. * Registers the component in a given scene
  50706. */
  50707. register(): void;
  50708. /**
  50709. * Rebuilds the elements related to this component in case of
  50710. * context lost for instance.
  50711. */
  50712. rebuild(): void;
  50713. /**
  50714. * Adds all the elements from the container to the scene
  50715. * @param container the container holding the elements
  50716. */
  50717. addFromContainer(container: AbstractScene): void;
  50718. /**
  50719. * Removes all the elements in the container from the scene
  50720. * @param container contains the elements to remove
  50721. * @param dispose if the removed element should be disposed (default: false)
  50722. */
  50723. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50724. /**
  50725. * Serializes the component data to the specified json object
  50726. * @param serializationObject The object to serialize to
  50727. */
  50728. serialize(serializationObject: any): void;
  50729. /**
  50730. * Disposes the component and the associated ressources.
  50731. */
  50732. dispose(): void;
  50733. private _draw;
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * Defines the shadow generator component responsible to manage any shadow generators
  50739. * in a given scene.
  50740. */
  50741. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50742. /**
  50743. * The component name helpfull to identify the component in the list of scene components.
  50744. */
  50745. readonly name: string;
  50746. /**
  50747. * The scene the component belongs to.
  50748. */
  50749. scene: Scene;
  50750. /**
  50751. * Creates a new instance of the component for the given scene
  50752. * @param scene Defines the scene to register the component in
  50753. */
  50754. constructor(scene: Scene);
  50755. /**
  50756. * Registers the component in a given scene
  50757. */
  50758. register(): void;
  50759. /**
  50760. * Rebuilds the elements related to this component in case of
  50761. * context lost for instance.
  50762. */
  50763. rebuild(): void;
  50764. /**
  50765. * Serializes the component data to the specified json object
  50766. * @param serializationObject The object to serialize to
  50767. */
  50768. serialize(serializationObject: any): void;
  50769. /**
  50770. * Adds all the elements from the container to the scene
  50771. * @param container the container holding the elements
  50772. */
  50773. addFromContainer(container: AbstractScene): void;
  50774. /**
  50775. * Removes all the elements in the container from the scene
  50776. * @param container contains the elements to remove
  50777. * @param dispose if the removed element should be disposed (default: false)
  50778. */
  50779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50780. /**
  50781. * Rebuilds the elements related to this component in case of
  50782. * context lost for instance.
  50783. */
  50784. dispose(): void;
  50785. private _gatherRenderTargets;
  50786. }
  50787. }
  50788. declare module BABYLON {
  50789. /**
  50790. * A point light is a light defined by an unique point in world space.
  50791. * The light is emitted in every direction from this point.
  50792. * A good example of a point light is a standard light bulb.
  50793. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50794. */
  50795. export class PointLight extends ShadowLight {
  50796. private _shadowAngle;
  50797. /**
  50798. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50799. * This specifies what angle the shadow will use to be created.
  50800. *
  50801. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50802. */
  50803. /**
  50804. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50805. * This specifies what angle the shadow will use to be created.
  50806. *
  50807. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50808. */
  50809. shadowAngle: number;
  50810. /**
  50811. * Gets the direction if it has been set.
  50812. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50813. */
  50814. /**
  50815. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50816. */
  50817. direction: Vector3;
  50818. /**
  50819. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50820. * A PointLight emits the light in every direction.
  50821. * It can cast shadows.
  50822. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50823. * ```javascript
  50824. * var pointLight = new PointLight("pl", camera.position, scene);
  50825. * ```
  50826. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50827. * @param name The light friendly name
  50828. * @param position The position of the point light in the scene
  50829. * @param scene The scene the lights belongs to
  50830. */
  50831. constructor(name: string, position: Vector3, scene: Scene);
  50832. /**
  50833. * Returns the string "PointLight"
  50834. * @returns the class name
  50835. */
  50836. getClassName(): string;
  50837. /**
  50838. * Returns the integer 0.
  50839. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50840. */
  50841. getTypeID(): number;
  50842. /**
  50843. * Specifies wether or not the shadowmap should be a cube texture.
  50844. * @returns true if the shadowmap needs to be a cube texture.
  50845. */
  50846. needCube(): boolean;
  50847. /**
  50848. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50849. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50850. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50851. */
  50852. getShadowDirection(faceIndex?: number): Vector3;
  50853. /**
  50854. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50855. * - fov = PI / 2
  50856. * - aspect ratio : 1.0
  50857. * - z-near and far equal to the active camera minZ and maxZ.
  50858. * Returns the PointLight.
  50859. */
  50860. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50861. protected _buildUniformLayout(): void;
  50862. /**
  50863. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50864. * @param effect The effect to update
  50865. * @param lightIndex The index of the light in the effect to update
  50866. * @returns The point light
  50867. */
  50868. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50869. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50870. /**
  50871. * Prepares the list of defines specific to the light type.
  50872. * @param defines the list of defines
  50873. * @param lightIndex defines the index of the light for the effect
  50874. */
  50875. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50876. }
  50877. }
  50878. declare module BABYLON {
  50879. /**
  50880. * Header information of HDR texture files.
  50881. */
  50882. export interface HDRInfo {
  50883. /**
  50884. * The height of the texture in pixels.
  50885. */
  50886. height: number;
  50887. /**
  50888. * The width of the texture in pixels.
  50889. */
  50890. width: number;
  50891. /**
  50892. * The index of the beginning of the data in the binary file.
  50893. */
  50894. dataPosition: number;
  50895. }
  50896. /**
  50897. * This groups tools to convert HDR texture to native colors array.
  50898. */
  50899. export class HDRTools {
  50900. private static Ldexp;
  50901. private static Rgbe2float;
  50902. private static readStringLine;
  50903. /**
  50904. * Reads header information from an RGBE texture stored in a native array.
  50905. * More information on this format are available here:
  50906. * https://en.wikipedia.org/wiki/RGBE_image_format
  50907. *
  50908. * @param uint8array The binary file stored in native array.
  50909. * @return The header information.
  50910. */
  50911. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50912. /**
  50913. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50914. * This RGBE texture needs to store the information as a panorama.
  50915. *
  50916. * More information on this format are available here:
  50917. * https://en.wikipedia.org/wiki/RGBE_image_format
  50918. *
  50919. * @param buffer The binary file stored in an array buffer.
  50920. * @param size The expected size of the extracted cubemap.
  50921. * @return The Cube Map information.
  50922. */
  50923. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50924. /**
  50925. * Returns the pixels data extracted from an RGBE texture.
  50926. * This pixels will be stored left to right up to down in the R G B order in one array.
  50927. *
  50928. * More information on this format are available here:
  50929. * https://en.wikipedia.org/wiki/RGBE_image_format
  50930. *
  50931. * @param uint8array The binary file stored in an array buffer.
  50932. * @param hdrInfo The header information of the file.
  50933. * @return The pixels data in RGB right to left up to down order.
  50934. */
  50935. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50936. private static RGBE_ReadPixels_RLE;
  50937. }
  50938. }
  50939. declare module BABYLON {
  50940. /**
  50941. * This represents a texture coming from an HDR input.
  50942. *
  50943. * The only supported format is currently panorama picture stored in RGBE format.
  50944. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50945. */
  50946. export class HDRCubeTexture extends BaseTexture {
  50947. private static _facesMapping;
  50948. private _generateHarmonics;
  50949. private _noMipmap;
  50950. private _textureMatrix;
  50951. private _size;
  50952. private _onLoad;
  50953. private _onError;
  50954. /**
  50955. * The texture URL.
  50956. */
  50957. url: string;
  50958. /**
  50959. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50960. */
  50961. coordinatesMode: number;
  50962. protected _isBlocking: boolean;
  50963. /**
  50964. * Sets wether or not the texture is blocking during loading.
  50965. */
  50966. /**
  50967. * Gets wether or not the texture is blocking during loading.
  50968. */
  50969. isBlocking: boolean;
  50970. protected _rotationY: number;
  50971. /**
  50972. * Sets texture matrix rotation angle around Y axis in radians.
  50973. */
  50974. /**
  50975. * Gets texture matrix rotation angle around Y axis radians.
  50976. */
  50977. rotationY: number;
  50978. /**
  50979. * Gets or sets the center of the bounding box associated with the cube texture
  50980. * It must define where the camera used to render the texture was set
  50981. */
  50982. boundingBoxPosition: Vector3;
  50983. private _boundingBoxSize;
  50984. /**
  50985. * Gets or sets the size of the bounding box associated with the cube texture
  50986. * When defined, the cubemap will switch to local mode
  50987. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50988. * @example https://www.babylonjs-playground.com/#RNASML
  50989. */
  50990. boundingBoxSize: Vector3;
  50991. /**
  50992. * Instantiates an HDRTexture from the following parameters.
  50993. *
  50994. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50995. * @param scene The scene the texture will be used in
  50996. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50997. * @param noMipmap Forces to not generate the mipmap if true
  50998. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50999. * @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)
  51000. * @param reserved Reserved flag for internal use.
  51001. */
  51002. 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>);
  51003. /**
  51004. * Get the current class name of the texture useful for serialization or dynamic coding.
  51005. * @returns "HDRCubeTexture"
  51006. */
  51007. getClassName(): string;
  51008. /**
  51009. * Occurs when the file is raw .hdr file.
  51010. */
  51011. private loadTexture;
  51012. clone(): HDRCubeTexture;
  51013. delayLoad(): void;
  51014. /**
  51015. * Get the texture reflection matrix used to rotate/transform the reflection.
  51016. * @returns the reflection matrix
  51017. */
  51018. getReflectionTextureMatrix(): Matrix;
  51019. /**
  51020. * Set the texture reflection matrix used to rotate/transform the reflection.
  51021. * @param value Define the reflection matrix to set
  51022. */
  51023. setReflectionTextureMatrix(value: Matrix): void;
  51024. /**
  51025. * Parses a JSON representation of an HDR Texture in order to create the texture
  51026. * @param parsedTexture Define the JSON representation
  51027. * @param scene Define the scene the texture should be created in
  51028. * @param rootUrl Define the root url in case we need to load relative dependencies
  51029. * @returns the newly created texture after parsing
  51030. */
  51031. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51032. serialize(): any;
  51033. }
  51034. }
  51035. declare module BABYLON {
  51036. /**
  51037. * Class used to control physics engine
  51038. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51039. */
  51040. export class PhysicsEngine implements IPhysicsEngine {
  51041. private _physicsPlugin;
  51042. /**
  51043. * Global value used to control the smallest number supported by the simulation
  51044. */
  51045. static Epsilon: number;
  51046. private _impostors;
  51047. private _joints;
  51048. /**
  51049. * Gets the gravity vector used by the simulation
  51050. */
  51051. gravity: Vector3;
  51052. /**
  51053. * Factory used to create the default physics plugin.
  51054. * @returns The default physics plugin
  51055. */
  51056. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51057. /**
  51058. * Creates a new Physics Engine
  51059. * @param gravity defines the gravity vector used by the simulation
  51060. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51061. */
  51062. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51063. /**
  51064. * Sets the gravity vector used by the simulation
  51065. * @param gravity defines the gravity vector to use
  51066. */
  51067. setGravity(gravity: Vector3): void;
  51068. /**
  51069. * Set the time step of the physics engine.
  51070. * Default is 1/60.
  51071. * To slow it down, enter 1/600 for example.
  51072. * To speed it up, 1/30
  51073. * @param newTimeStep defines the new timestep to apply to this world.
  51074. */
  51075. setTimeStep(newTimeStep?: number): void;
  51076. /**
  51077. * Get the time step of the physics engine.
  51078. * @returns the current time step
  51079. */
  51080. getTimeStep(): number;
  51081. /**
  51082. * Release all resources
  51083. */
  51084. dispose(): void;
  51085. /**
  51086. * Gets the name of the current physics plugin
  51087. * @returns the name of the plugin
  51088. */
  51089. getPhysicsPluginName(): string;
  51090. /**
  51091. * Adding a new impostor for the impostor tracking.
  51092. * This will be done by the impostor itself.
  51093. * @param impostor the impostor to add
  51094. */
  51095. addImpostor(impostor: PhysicsImpostor): void;
  51096. /**
  51097. * Remove an impostor from the engine.
  51098. * This impostor and its mesh will not longer be updated by the physics engine.
  51099. * @param impostor the impostor to remove
  51100. */
  51101. removeImpostor(impostor: PhysicsImpostor): void;
  51102. /**
  51103. * Add a joint to the physics engine
  51104. * @param mainImpostor defines the main impostor to which the joint is added.
  51105. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51106. * @param joint defines the joint that will connect both impostors.
  51107. */
  51108. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51109. /**
  51110. * Removes a joint from the simulation
  51111. * @param mainImpostor defines the impostor used with the joint
  51112. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51113. * @param joint defines the joint to remove
  51114. */
  51115. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51116. /**
  51117. * Called by the scene. No need to call it.
  51118. * @param delta defines the timespam between frames
  51119. */
  51120. _step(delta: number): void;
  51121. /**
  51122. * Gets the current plugin used to run the simulation
  51123. * @returns current plugin
  51124. */
  51125. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51126. /**
  51127. * Gets the list of physic impostors
  51128. * @returns an array of PhysicsImpostor
  51129. */
  51130. getImpostors(): Array<PhysicsImpostor>;
  51131. /**
  51132. * Gets the impostor for a physics enabled object
  51133. * @param object defines the object impersonated by the impostor
  51134. * @returns the PhysicsImpostor or null if not found
  51135. */
  51136. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51137. /**
  51138. * Gets the impostor for a physics body object
  51139. * @param body defines physics body used by the impostor
  51140. * @returns the PhysicsImpostor or null if not found
  51141. */
  51142. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51143. /**
  51144. * Does a raycast in the physics world
  51145. * @param from when should the ray start?
  51146. * @param to when should the ray end?
  51147. * @returns PhysicsRaycastResult
  51148. */
  51149. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51150. }
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51155. private _useDeltaForWorldStep;
  51156. world: any;
  51157. name: string;
  51158. private _physicsMaterials;
  51159. private _fixedTimeStep;
  51160. private _cannonRaycastResult;
  51161. private _raycastResult;
  51162. private _physicsBodysToRemoveAfterStep;
  51163. BJSCANNON: any;
  51164. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51165. setGravity(gravity: Vector3): void;
  51166. setTimeStep(timeStep: number): void;
  51167. getTimeStep(): number;
  51168. executeStep(delta: number): void;
  51169. private _removeMarkedPhysicsBodiesFromWorld;
  51170. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51171. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51172. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51173. private _processChildMeshes;
  51174. removePhysicsBody(impostor: PhysicsImpostor): void;
  51175. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51176. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51177. private _addMaterial;
  51178. private _checkWithEpsilon;
  51179. private _createShape;
  51180. private _createHeightmap;
  51181. private _minus90X;
  51182. private _plus90X;
  51183. private _tmpPosition;
  51184. private _tmpDeltaPosition;
  51185. private _tmpUnityRotation;
  51186. private _updatePhysicsBodyTransformation;
  51187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51189. isSupported(): boolean;
  51190. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51191. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51192. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51193. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51194. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51195. getBodyMass(impostor: PhysicsImpostor): number;
  51196. getBodyFriction(impostor: PhysicsImpostor): number;
  51197. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51198. getBodyRestitution(impostor: PhysicsImpostor): number;
  51199. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51200. sleepBody(impostor: PhysicsImpostor): void;
  51201. wakeUpBody(impostor: PhysicsImpostor): void;
  51202. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51203. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51204. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51206. getRadius(impostor: PhysicsImpostor): number;
  51207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51208. dispose(): void;
  51209. private _extendNamespace;
  51210. /**
  51211. * Does a raycast in the physics world
  51212. * @param from when should the ray start?
  51213. * @param to when should the ray end?
  51214. * @returns PhysicsRaycastResult
  51215. */
  51216. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51217. }
  51218. }
  51219. declare module BABYLON {
  51220. /** @hidden */
  51221. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51222. world: any;
  51223. name: string;
  51224. BJSOIMO: any;
  51225. private _raycastResult;
  51226. constructor(iterations?: number, oimoInjection?: any);
  51227. setGravity(gravity: Vector3): void;
  51228. setTimeStep(timeStep: number): void;
  51229. getTimeStep(): number;
  51230. private _tmpImpostorsArray;
  51231. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51232. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51234. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51235. private _tmpPositionVector;
  51236. removePhysicsBody(impostor: PhysicsImpostor): void;
  51237. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51238. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51239. isSupported(): boolean;
  51240. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51241. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51242. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51243. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51244. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51245. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51246. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51247. getBodyMass(impostor: PhysicsImpostor): number;
  51248. getBodyFriction(impostor: PhysicsImpostor): number;
  51249. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51250. getBodyRestitution(impostor: PhysicsImpostor): number;
  51251. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51252. sleepBody(impostor: PhysicsImpostor): void;
  51253. wakeUpBody(impostor: PhysicsImpostor): void;
  51254. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51255. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51256. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51257. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51258. getRadius(impostor: PhysicsImpostor): number;
  51259. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51260. dispose(): void;
  51261. /**
  51262. * Does a raycast in the physics world
  51263. * @param from when should the ray start?
  51264. * @param to when should the ray end?
  51265. * @returns PhysicsRaycastResult
  51266. */
  51267. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51268. }
  51269. }
  51270. declare module BABYLON {
  51271. /**
  51272. * Class containing static functions to help procedurally build meshes
  51273. */
  51274. export class RibbonBuilder {
  51275. /**
  51276. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51277. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51278. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51279. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51280. * * 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
  51281. * * 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
  51282. * * 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
  51283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51284. * * 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
  51285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51286. * * 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
  51287. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51288. * * 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
  51289. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51291. * @param name defines the name of the mesh
  51292. * @param options defines the options used to create the mesh
  51293. * @param scene defines the hosting scene
  51294. * @returns the ribbon mesh
  51295. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51296. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51297. */
  51298. static CreateRibbon(name: string, options: {
  51299. pathArray: Vector3[][];
  51300. closeArray?: boolean;
  51301. closePath?: boolean;
  51302. offset?: number;
  51303. updatable?: boolean;
  51304. sideOrientation?: number;
  51305. frontUVs?: Vector4;
  51306. backUVs?: Vector4;
  51307. instance?: Mesh;
  51308. invertUV?: boolean;
  51309. uvs?: Vector2[];
  51310. colors?: Color4[];
  51311. }, scene?: Nullable<Scene>): Mesh;
  51312. }
  51313. }
  51314. declare module BABYLON {
  51315. /**
  51316. * Class containing static functions to help procedurally build meshes
  51317. */
  51318. export class ShapeBuilder {
  51319. /**
  51320. * 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.
  51321. * * 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.
  51322. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51323. * * 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.
  51324. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51325. * * 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
  51326. * * 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
  51327. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51329. * * 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
  51330. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51332. * @param name defines the name of the mesh
  51333. * @param options defines the options used to create the mesh
  51334. * @param scene defines the hosting scene
  51335. * @returns the extruded shape mesh
  51336. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51338. */
  51339. static ExtrudeShape(name: string, options: {
  51340. shape: Vector3[];
  51341. path: Vector3[];
  51342. scale?: number;
  51343. rotation?: number;
  51344. cap?: number;
  51345. updatable?: boolean;
  51346. sideOrientation?: number;
  51347. frontUVs?: Vector4;
  51348. backUVs?: Vector4;
  51349. instance?: Mesh;
  51350. invertUV?: boolean;
  51351. }, scene?: Nullable<Scene>): Mesh;
  51352. /**
  51353. * Creates an custom extruded shape mesh.
  51354. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51355. * * 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.
  51356. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51357. * * 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
  51358. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51359. * * 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
  51360. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51361. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51362. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51363. * * 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
  51364. * * 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
  51365. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51367. * * 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
  51368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51370. * @param name defines the name of the mesh
  51371. * @param options defines the options used to create the mesh
  51372. * @param scene defines the hosting scene
  51373. * @returns the custom extruded shape mesh
  51374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51375. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51377. */
  51378. static ExtrudeShapeCustom(name: string, options: {
  51379. shape: Vector3[];
  51380. path: Vector3[];
  51381. scaleFunction?: any;
  51382. rotationFunction?: any;
  51383. ribbonCloseArray?: boolean;
  51384. ribbonClosePath?: boolean;
  51385. cap?: number;
  51386. updatable?: boolean;
  51387. sideOrientation?: number;
  51388. frontUVs?: Vector4;
  51389. backUVs?: Vector4;
  51390. instance?: Mesh;
  51391. invertUV?: boolean;
  51392. }, scene?: Nullable<Scene>): Mesh;
  51393. private static _ExtrudeShapeGeneric;
  51394. }
  51395. }
  51396. declare module BABYLON {
  51397. /**
  51398. * AmmoJS Physics plugin
  51399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51400. * @see https://github.com/kripken/ammo.js/
  51401. */
  51402. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51403. private _useDeltaForWorldStep;
  51404. /**
  51405. * Reference to the Ammo library
  51406. */
  51407. bjsAMMO: any;
  51408. /**
  51409. * Created ammoJS world which physics bodies are added to
  51410. */
  51411. world: any;
  51412. /**
  51413. * Name of the plugin
  51414. */
  51415. name: string;
  51416. private _timeStep;
  51417. private _fixedTimeStep;
  51418. private _maxSteps;
  51419. private _tmpQuaternion;
  51420. private _tmpAmmoTransform;
  51421. private _tmpAmmoQuaternion;
  51422. private _tmpAmmoConcreteContactResultCallback;
  51423. private _collisionConfiguration;
  51424. private _dispatcher;
  51425. private _overlappingPairCache;
  51426. private _solver;
  51427. private _softBodySolver;
  51428. private _tmpAmmoVectorA;
  51429. private _tmpAmmoVectorB;
  51430. private _tmpAmmoVectorC;
  51431. private _tmpAmmoVectorD;
  51432. private _tmpContactCallbackResult;
  51433. private _tmpAmmoVectorRCA;
  51434. private _tmpAmmoVectorRCB;
  51435. private _raycastResult;
  51436. private static readonly DISABLE_COLLISION_FLAG;
  51437. private static readonly KINEMATIC_FLAG;
  51438. private static readonly DISABLE_DEACTIVATION_FLAG;
  51439. /**
  51440. * Initializes the ammoJS plugin
  51441. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51442. * @param ammoInjection can be used to inject your own ammo reference
  51443. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51444. */
  51445. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51446. /**
  51447. * Sets the gravity of the physics world (m/(s^2))
  51448. * @param gravity Gravity to set
  51449. */
  51450. setGravity(gravity: Vector3): void;
  51451. /**
  51452. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51453. * @param timeStep timestep to use in seconds
  51454. */
  51455. setTimeStep(timeStep: number): void;
  51456. /**
  51457. * 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)
  51458. * @param fixedTimeStep fixedTimeStep to use in seconds
  51459. */
  51460. setFixedTimeStep(fixedTimeStep: number): void;
  51461. /**
  51462. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51463. * @param maxSteps the maximum number of steps by the physics engine per frame
  51464. */
  51465. setMaxSteps(maxSteps: number): void;
  51466. /**
  51467. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51468. * @returns the current timestep in seconds
  51469. */
  51470. getTimeStep(): number;
  51471. private _isImpostorInContact;
  51472. private _isImpostorPairInContact;
  51473. private _stepSimulation;
  51474. /**
  51475. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51476. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51477. * After the step the babylon meshes are set to the position of the physics imposters
  51478. * @param delta amount of time to step forward
  51479. * @param impostors array of imposters to update before/after the step
  51480. */
  51481. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51482. /**
  51483. * Update babylon mesh to match physics world object
  51484. * @param impostor imposter to match
  51485. */
  51486. private _afterSoftStep;
  51487. /**
  51488. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51489. * @param impostor imposter to match
  51490. */
  51491. private _ropeStep;
  51492. /**
  51493. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51494. * @param impostor imposter to match
  51495. */
  51496. private _softbodyOrClothStep;
  51497. private _tmpVector;
  51498. private _tmpMatrix;
  51499. /**
  51500. * Applies an impulse on the imposter
  51501. * @param impostor imposter to apply impulse to
  51502. * @param force amount of force to be applied to the imposter
  51503. * @param contactPoint the location to apply the impulse on the imposter
  51504. */
  51505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51506. /**
  51507. * Applies a force on the imposter
  51508. * @param impostor imposter to apply force
  51509. * @param force amount of force to be applied to the imposter
  51510. * @param contactPoint the location to apply the force on the imposter
  51511. */
  51512. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51513. /**
  51514. * Creates a physics body using the plugin
  51515. * @param impostor the imposter to create the physics body on
  51516. */
  51517. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51518. /**
  51519. * Removes the physics body from the imposter and disposes of the body's memory
  51520. * @param impostor imposter to remove the physics body from
  51521. */
  51522. removePhysicsBody(impostor: PhysicsImpostor): void;
  51523. /**
  51524. * Generates a joint
  51525. * @param impostorJoint the imposter joint to create the joint with
  51526. */
  51527. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51528. /**
  51529. * Removes a joint
  51530. * @param impostorJoint the imposter joint to remove the joint from
  51531. */
  51532. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51533. private _addMeshVerts;
  51534. /**
  51535. * Initialise the soft body vertices to match its object's (mesh) vertices
  51536. * Softbody vertices (nodes) are in world space and to match this
  51537. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51538. * @param impostor to create the softbody for
  51539. */
  51540. private _softVertexData;
  51541. /**
  51542. * Create an impostor's soft body
  51543. * @param impostor to create the softbody for
  51544. */
  51545. private _createSoftbody;
  51546. /**
  51547. * Create cloth for an impostor
  51548. * @param impostor to create the softbody for
  51549. */
  51550. private _createCloth;
  51551. /**
  51552. * Create rope for an impostor
  51553. * @param impostor to create the softbody for
  51554. */
  51555. private _createRope;
  51556. private _addHullVerts;
  51557. private _createShape;
  51558. /**
  51559. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51560. * @param impostor imposter containing the physics body and babylon object
  51561. */
  51562. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51563. /**
  51564. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51565. * @param impostor imposter containing the physics body and babylon object
  51566. * @param newPosition new position
  51567. * @param newRotation new rotation
  51568. */
  51569. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51570. /**
  51571. * If this plugin is supported
  51572. * @returns true if its supported
  51573. */
  51574. isSupported(): boolean;
  51575. /**
  51576. * Sets the linear velocity of the physics body
  51577. * @param impostor imposter to set the velocity on
  51578. * @param velocity velocity to set
  51579. */
  51580. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51581. /**
  51582. * Sets the angular velocity of the physics body
  51583. * @param impostor imposter to set the velocity on
  51584. * @param velocity velocity to set
  51585. */
  51586. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51587. /**
  51588. * gets the linear velocity
  51589. * @param impostor imposter to get linear velocity from
  51590. * @returns linear velocity
  51591. */
  51592. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51593. /**
  51594. * gets the angular velocity
  51595. * @param impostor imposter to get angular velocity from
  51596. * @returns angular velocity
  51597. */
  51598. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51599. /**
  51600. * Sets the mass of physics body
  51601. * @param impostor imposter to set the mass on
  51602. * @param mass mass to set
  51603. */
  51604. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51605. /**
  51606. * Gets the mass of the physics body
  51607. * @param impostor imposter to get the mass from
  51608. * @returns mass
  51609. */
  51610. getBodyMass(impostor: PhysicsImpostor): number;
  51611. /**
  51612. * Gets friction of the impostor
  51613. * @param impostor impostor to get friction from
  51614. * @returns friction value
  51615. */
  51616. getBodyFriction(impostor: PhysicsImpostor): number;
  51617. /**
  51618. * Sets friction of the impostor
  51619. * @param impostor impostor to set friction on
  51620. * @param friction friction value
  51621. */
  51622. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51623. /**
  51624. * Gets restitution of the impostor
  51625. * @param impostor impostor to get restitution from
  51626. * @returns restitution value
  51627. */
  51628. getBodyRestitution(impostor: PhysicsImpostor): number;
  51629. /**
  51630. * Sets resitution of the impostor
  51631. * @param impostor impostor to set resitution on
  51632. * @param restitution resitution value
  51633. */
  51634. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51635. /**
  51636. * Gets pressure inside the impostor
  51637. * @param impostor impostor to get pressure from
  51638. * @returns pressure value
  51639. */
  51640. getBodyPressure(impostor: PhysicsImpostor): number;
  51641. /**
  51642. * Sets pressure inside a soft body impostor
  51643. * Cloth and rope must remain 0 pressure
  51644. * @param impostor impostor to set pressure on
  51645. * @param pressure pressure value
  51646. */
  51647. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51648. /**
  51649. * Gets stiffness of the impostor
  51650. * @param impostor impostor to get stiffness from
  51651. * @returns pressure value
  51652. */
  51653. getBodyStiffness(impostor: PhysicsImpostor): number;
  51654. /**
  51655. * Sets stiffness of the impostor
  51656. * @param impostor impostor to set stiffness on
  51657. * @param stiffness stiffness value from 0 to 1
  51658. */
  51659. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51660. /**
  51661. * Gets velocityIterations of the impostor
  51662. * @param impostor impostor to get velocity iterations from
  51663. * @returns velocityIterations value
  51664. */
  51665. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51666. /**
  51667. * Sets velocityIterations of the impostor
  51668. * @param impostor impostor to set velocity iterations on
  51669. * @param velocityIterations velocityIterations value
  51670. */
  51671. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51672. /**
  51673. * Gets positionIterations of the impostor
  51674. * @param impostor impostor to get position iterations from
  51675. * @returns positionIterations value
  51676. */
  51677. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51678. /**
  51679. * Sets positionIterations of the impostor
  51680. * @param impostor impostor to set position on
  51681. * @param positionIterations positionIterations value
  51682. */
  51683. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51684. /**
  51685. * Append an anchor to a cloth object
  51686. * @param impostor is the cloth impostor to add anchor to
  51687. * @param otherImpostor is the rigid impostor to anchor to
  51688. * @param width ratio across width from 0 to 1
  51689. * @param height ratio up height from 0 to 1
  51690. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51691. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51692. */
  51693. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51694. /**
  51695. * Append an hook to a rope object
  51696. * @param impostor is the rope impostor to add hook to
  51697. * @param otherImpostor is the rigid impostor to hook to
  51698. * @param length ratio along the rope from 0 to 1
  51699. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51700. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51701. */
  51702. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51703. /**
  51704. * Sleeps the physics body and stops it from being active
  51705. * @param impostor impostor to sleep
  51706. */
  51707. sleepBody(impostor: PhysicsImpostor): void;
  51708. /**
  51709. * Activates the physics body
  51710. * @param impostor impostor to activate
  51711. */
  51712. wakeUpBody(impostor: PhysicsImpostor): void;
  51713. /**
  51714. * Updates the distance parameters of the joint
  51715. * @param joint joint to update
  51716. * @param maxDistance maximum distance of the joint
  51717. * @param minDistance minimum distance of the joint
  51718. */
  51719. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51720. /**
  51721. * Sets a motor on the joint
  51722. * @param joint joint to set motor on
  51723. * @param speed speed of the motor
  51724. * @param maxForce maximum force of the motor
  51725. * @param motorIndex index of the motor
  51726. */
  51727. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51728. /**
  51729. * Sets the motors limit
  51730. * @param joint joint to set limit on
  51731. * @param upperLimit upper limit
  51732. * @param lowerLimit lower limit
  51733. */
  51734. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51735. /**
  51736. * Syncs the position and rotation of a mesh with the impostor
  51737. * @param mesh mesh to sync
  51738. * @param impostor impostor to update the mesh with
  51739. */
  51740. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51741. /**
  51742. * Gets the radius of the impostor
  51743. * @param impostor impostor to get radius from
  51744. * @returns the radius
  51745. */
  51746. getRadius(impostor: PhysicsImpostor): number;
  51747. /**
  51748. * Gets the box size of the impostor
  51749. * @param impostor impostor to get box size from
  51750. * @param result the resulting box size
  51751. */
  51752. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51753. /**
  51754. * Disposes of the impostor
  51755. */
  51756. dispose(): void;
  51757. /**
  51758. * Does a raycast in the physics world
  51759. * @param from when should the ray start?
  51760. * @param to when should the ray end?
  51761. * @returns PhysicsRaycastResult
  51762. */
  51763. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51764. }
  51765. }
  51766. declare module BABYLON {
  51767. interface AbstractScene {
  51768. /**
  51769. * The list of reflection probes added to the scene
  51770. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51771. */
  51772. reflectionProbes: Array<ReflectionProbe>;
  51773. /**
  51774. * Removes the given reflection probe from this scene.
  51775. * @param toRemove The reflection probe to remove
  51776. * @returns The index of the removed reflection probe
  51777. */
  51778. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51779. /**
  51780. * Adds the given reflection probe to this scene.
  51781. * @param newReflectionProbe The reflection probe to add
  51782. */
  51783. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51784. }
  51785. /**
  51786. * Class used to generate realtime reflection / refraction cube textures
  51787. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51788. */
  51789. export class ReflectionProbe {
  51790. /** defines the name of the probe */
  51791. name: string;
  51792. private _scene;
  51793. private _renderTargetTexture;
  51794. private _projectionMatrix;
  51795. private _viewMatrix;
  51796. private _target;
  51797. private _add;
  51798. private _attachedMesh;
  51799. private _invertYAxis;
  51800. /** Gets or sets probe position (center of the cube map) */
  51801. position: Vector3;
  51802. /**
  51803. * Creates a new reflection probe
  51804. * @param name defines the name of the probe
  51805. * @param size defines the texture resolution (for each face)
  51806. * @param scene defines the hosting scene
  51807. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51808. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51809. */
  51810. constructor(
  51811. /** defines the name of the probe */
  51812. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51813. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51814. samples: number;
  51815. /** Gets or sets the refresh rate to use (on every frame by default) */
  51816. refreshRate: number;
  51817. /**
  51818. * Gets the hosting scene
  51819. * @returns a Scene
  51820. */
  51821. getScene(): Scene;
  51822. /** Gets the internal CubeTexture used to render to */
  51823. readonly cubeTexture: RenderTargetTexture;
  51824. /** Gets the list of meshes to render */
  51825. readonly renderList: Nullable<AbstractMesh[]>;
  51826. /**
  51827. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51828. * @param mesh defines the mesh to attach to
  51829. */
  51830. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51831. /**
  51832. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51833. * @param renderingGroupId The rendering group id corresponding to its index
  51834. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51835. */
  51836. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51837. /**
  51838. * Clean all associated resources
  51839. */
  51840. dispose(): void;
  51841. /**
  51842. * Converts the reflection probe information to a readable string for debug purpose.
  51843. * @param fullDetails Supports for multiple levels of logging within scene loading
  51844. * @returns the human readable reflection probe info
  51845. */
  51846. toString(fullDetails?: boolean): string;
  51847. /**
  51848. * Get the class name of the relfection probe.
  51849. * @returns "ReflectionProbe"
  51850. */
  51851. getClassName(): string;
  51852. /**
  51853. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51854. * @returns The JSON representation of the texture
  51855. */
  51856. serialize(): any;
  51857. /**
  51858. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51859. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51860. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51861. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51862. * @returns The parsed reflection probe if successful
  51863. */
  51864. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51865. }
  51866. }
  51867. declare module BABYLON {
  51868. /** @hidden */
  51869. export var _BabylonLoaderRegistered: boolean;
  51870. }
  51871. declare module BABYLON {
  51872. /**
  51873. * The Physically based simple base material of BJS.
  51874. *
  51875. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51876. * It is used as the base class for both the specGloss and metalRough conventions.
  51877. */
  51878. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51879. /**
  51880. * Number of Simultaneous lights allowed on the material.
  51881. */
  51882. maxSimultaneousLights: number;
  51883. /**
  51884. * If sets to true, disables all the lights affecting the material.
  51885. */
  51886. disableLighting: boolean;
  51887. /**
  51888. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51889. */
  51890. environmentTexture: BaseTexture;
  51891. /**
  51892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51893. */
  51894. invertNormalMapX: boolean;
  51895. /**
  51896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51897. */
  51898. invertNormalMapY: boolean;
  51899. /**
  51900. * Normal map used in the model.
  51901. */
  51902. normalTexture: BaseTexture;
  51903. /**
  51904. * Emissivie color used to self-illuminate the model.
  51905. */
  51906. emissiveColor: Color3;
  51907. /**
  51908. * Emissivie texture used to self-illuminate the model.
  51909. */
  51910. emissiveTexture: BaseTexture;
  51911. /**
  51912. * Occlusion Channel Strenght.
  51913. */
  51914. occlusionStrength: number;
  51915. /**
  51916. * Occlusion Texture of the material (adding extra occlusion effects).
  51917. */
  51918. occlusionTexture: BaseTexture;
  51919. /**
  51920. * Defines the alpha limits in alpha test mode.
  51921. */
  51922. alphaCutOff: number;
  51923. /**
  51924. * Gets the current double sided mode.
  51925. */
  51926. /**
  51927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51928. */
  51929. doubleSided: boolean;
  51930. /**
  51931. * Stores the pre-calculated light information of a mesh in a texture.
  51932. */
  51933. lightmapTexture: BaseTexture;
  51934. /**
  51935. * If true, the light map contains occlusion information instead of lighting info.
  51936. */
  51937. useLightmapAsShadowmap: boolean;
  51938. /**
  51939. * Instantiates a new PBRMaterial instance.
  51940. *
  51941. * @param name The material name
  51942. * @param scene The scene the material will be use in.
  51943. */
  51944. constructor(name: string, scene: Scene);
  51945. getClassName(): string;
  51946. }
  51947. }
  51948. declare module BABYLON {
  51949. /**
  51950. * The PBR material of BJS following the metal roughness convention.
  51951. *
  51952. * This fits to the PBR convention in the GLTF definition:
  51953. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51954. */
  51955. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51956. /**
  51957. * The base color has two different interpretations depending on the value of metalness.
  51958. * When the material is a metal, the base color is the specific measured reflectance value
  51959. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51960. * of the material.
  51961. */
  51962. baseColor: Color3;
  51963. /**
  51964. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51965. * well as opacity information in the alpha channel.
  51966. */
  51967. baseTexture: BaseTexture;
  51968. /**
  51969. * Specifies the metallic scalar value of the material.
  51970. * Can also be used to scale the metalness values of the metallic texture.
  51971. */
  51972. metallic: number;
  51973. /**
  51974. * Specifies the roughness scalar value of the material.
  51975. * Can also be used to scale the roughness values of the metallic texture.
  51976. */
  51977. roughness: number;
  51978. /**
  51979. * Texture containing both the metallic value in the B channel and the
  51980. * roughness value in the G channel to keep better precision.
  51981. */
  51982. metallicRoughnessTexture: BaseTexture;
  51983. /**
  51984. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51985. *
  51986. * @param name The material name
  51987. * @param scene The scene the material will be use in.
  51988. */
  51989. constructor(name: string, scene: Scene);
  51990. /**
  51991. * Return the currrent class name of the material.
  51992. */
  51993. getClassName(): string;
  51994. /**
  51995. * Makes a duplicate of the current material.
  51996. * @param name - name to use for the new material.
  51997. */
  51998. clone(name: string): PBRMetallicRoughnessMaterial;
  51999. /**
  52000. * Serialize the material to a parsable JSON object.
  52001. */
  52002. serialize(): any;
  52003. /**
  52004. * Parses a JSON object correponding to the serialize function.
  52005. */
  52006. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * The PBR material of BJS following the specular glossiness convention.
  52012. *
  52013. * This fits to the PBR convention in the GLTF definition:
  52014. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52015. */
  52016. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52017. /**
  52018. * Specifies the diffuse color of the material.
  52019. */
  52020. diffuseColor: Color3;
  52021. /**
  52022. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52023. * channel.
  52024. */
  52025. diffuseTexture: BaseTexture;
  52026. /**
  52027. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52028. */
  52029. specularColor: Color3;
  52030. /**
  52031. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52032. */
  52033. glossiness: number;
  52034. /**
  52035. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52036. */
  52037. specularGlossinessTexture: BaseTexture;
  52038. /**
  52039. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52040. *
  52041. * @param name The material name
  52042. * @param scene The scene the material will be use in.
  52043. */
  52044. constructor(name: string, scene: Scene);
  52045. /**
  52046. * Return the currrent class name of the material.
  52047. */
  52048. getClassName(): string;
  52049. /**
  52050. * Makes a duplicate of the current material.
  52051. * @param name - name to use for the new material.
  52052. */
  52053. clone(name: string): PBRSpecularGlossinessMaterial;
  52054. /**
  52055. * Serialize the material to a parsable JSON object.
  52056. */
  52057. serialize(): any;
  52058. /**
  52059. * Parses a JSON object correponding to the serialize function.
  52060. */
  52061. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52062. }
  52063. }
  52064. declare module BABYLON {
  52065. /**
  52066. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52067. * It can help converting any input color in a desired output one. This can then be used to create effects
  52068. * from sepia, black and white to sixties or futuristic rendering...
  52069. *
  52070. * The only supported format is currently 3dl.
  52071. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52072. */
  52073. export class ColorGradingTexture extends BaseTexture {
  52074. /**
  52075. * The current texture matrix. (will always be identity in color grading texture)
  52076. */
  52077. private _textureMatrix;
  52078. /**
  52079. * The texture URL.
  52080. */
  52081. url: string;
  52082. /**
  52083. * Empty line regex stored for GC.
  52084. */
  52085. private static _noneEmptyLineRegex;
  52086. private _engine;
  52087. /**
  52088. * Instantiates a ColorGradingTexture from the following parameters.
  52089. *
  52090. * @param url The location of the color gradind data (currently only supporting 3dl)
  52091. * @param scene The scene the texture will be used in
  52092. */
  52093. constructor(url: string, scene: Scene);
  52094. /**
  52095. * Returns the texture matrix used in most of the material.
  52096. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52097. */
  52098. getTextureMatrix(): Matrix;
  52099. /**
  52100. * Occurs when the file being loaded is a .3dl LUT file.
  52101. */
  52102. private load3dlTexture;
  52103. /**
  52104. * Starts the loading process of the texture.
  52105. */
  52106. private loadTexture;
  52107. /**
  52108. * Clones the color gradind texture.
  52109. */
  52110. clone(): ColorGradingTexture;
  52111. /**
  52112. * Called during delayed load for textures.
  52113. */
  52114. delayLoad(): void;
  52115. /**
  52116. * Parses a color grading texture serialized by Babylon.
  52117. * @param parsedTexture The texture information being parsedTexture
  52118. * @param scene The scene to load the texture in
  52119. * @param rootUrl The root url of the data assets to load
  52120. * @return A color gradind texture
  52121. */
  52122. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52123. /**
  52124. * Serializes the LUT texture to json format.
  52125. */
  52126. serialize(): any;
  52127. }
  52128. }
  52129. declare module BABYLON {
  52130. /**
  52131. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52132. */
  52133. export class EquiRectangularCubeTexture extends BaseTexture {
  52134. /** The six faces of the cube. */
  52135. private static _FacesMapping;
  52136. private _noMipmap;
  52137. private _onLoad;
  52138. private _onError;
  52139. /** The size of the cubemap. */
  52140. private _size;
  52141. /** The buffer of the image. */
  52142. private _buffer;
  52143. /** The width of the input image. */
  52144. private _width;
  52145. /** The height of the input image. */
  52146. private _height;
  52147. /** The URL to the image. */
  52148. url: string;
  52149. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52150. coordinatesMode: number;
  52151. /**
  52152. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52153. * @param url The location of the image
  52154. * @param scene The scene the texture will be used in
  52155. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52156. * @param noMipmap Forces to not generate the mipmap if true
  52157. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52158. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52159. * @param onLoad — defines a callback called when texture is loaded
  52160. * @param onError — defines a callback called if there is an error
  52161. */
  52162. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52163. /**
  52164. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52165. */
  52166. private loadImage;
  52167. /**
  52168. * Convert the image buffer into a cubemap and create a CubeTexture.
  52169. */
  52170. private loadTexture;
  52171. /**
  52172. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52173. * @param buffer The ArrayBuffer that should be converted.
  52174. * @returns The buffer as Float32Array.
  52175. */
  52176. private getFloat32ArrayFromArrayBuffer;
  52177. /**
  52178. * Get the current class name of the texture useful for serialization or dynamic coding.
  52179. * @returns "EquiRectangularCubeTexture"
  52180. */
  52181. getClassName(): string;
  52182. /**
  52183. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52184. * @returns A clone of the current EquiRectangularCubeTexture.
  52185. */
  52186. clone(): EquiRectangularCubeTexture;
  52187. }
  52188. }
  52189. declare module BABYLON {
  52190. /**
  52191. * Based on jsTGALoader - Javascript loader for TGA file
  52192. * By Vincent Thibault
  52193. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52194. */
  52195. export class TGATools {
  52196. private static _TYPE_INDEXED;
  52197. private static _TYPE_RGB;
  52198. private static _TYPE_GREY;
  52199. private static _TYPE_RLE_INDEXED;
  52200. private static _TYPE_RLE_RGB;
  52201. private static _TYPE_RLE_GREY;
  52202. private static _ORIGIN_MASK;
  52203. private static _ORIGIN_SHIFT;
  52204. private static _ORIGIN_BL;
  52205. private static _ORIGIN_BR;
  52206. private static _ORIGIN_UL;
  52207. private static _ORIGIN_UR;
  52208. /**
  52209. * Gets the header of a TGA file
  52210. * @param data defines the TGA data
  52211. * @returns the header
  52212. */
  52213. static GetTGAHeader(data: Uint8Array): any;
  52214. /**
  52215. * Uploads TGA content to a Babylon Texture
  52216. * @hidden
  52217. */
  52218. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52219. /** @hidden */
  52220. 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;
  52221. /** @hidden */
  52222. 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;
  52223. /** @hidden */
  52224. 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;
  52225. /** @hidden */
  52226. 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;
  52227. /** @hidden */
  52228. 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;
  52229. /** @hidden */
  52230. 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;
  52231. }
  52232. }
  52233. declare module BABYLON {
  52234. /**
  52235. * Implementation of the TGA Texture Loader.
  52236. * @hidden
  52237. */
  52238. export class _TGATextureLoader implements IInternalTextureLoader {
  52239. /**
  52240. * Defines wether the loader supports cascade loading the different faces.
  52241. */
  52242. readonly supportCascades: boolean;
  52243. /**
  52244. * This returns if the loader support the current file information.
  52245. * @param extension defines the file extension of the file being loaded
  52246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52247. * @param fallback defines the fallback internal texture if any
  52248. * @param isBase64 defines whether the texture is encoded as a base64
  52249. * @param isBuffer defines whether the texture data are stored as a buffer
  52250. * @returns true if the loader can load the specified file
  52251. */
  52252. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52253. /**
  52254. * Transform the url before loading if required.
  52255. * @param rootUrl the url of the texture
  52256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52257. * @returns the transformed texture
  52258. */
  52259. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52260. /**
  52261. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52262. * @param rootUrl the url of the texture
  52263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52264. * @returns the fallback texture
  52265. */
  52266. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52267. /**
  52268. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52269. * @param data contains the texture data
  52270. * @param texture defines the BabylonJS internal texture
  52271. * @param createPolynomials will be true if polynomials have been requested
  52272. * @param onLoad defines the callback to trigger once the texture is ready
  52273. * @param onError defines the callback to trigger in case of error
  52274. */
  52275. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52276. /**
  52277. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52278. * @param data contains the texture data
  52279. * @param texture defines the BabylonJS internal texture
  52280. * @param callback defines the method to call once ready to upload
  52281. */
  52282. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52283. }
  52284. }
  52285. declare module BABYLON {
  52286. /**
  52287. * Info about the .basis files
  52288. */
  52289. class BasisFileInfo {
  52290. /**
  52291. * If the file has alpha
  52292. */
  52293. hasAlpha: boolean;
  52294. /**
  52295. * Info about each image of the basis file
  52296. */
  52297. images: Array<{
  52298. levels: Array<{
  52299. width: number;
  52300. height: number;
  52301. transcodedPixels: ArrayBufferView;
  52302. }>;
  52303. }>;
  52304. }
  52305. /**
  52306. * Result of transcoding a basis file
  52307. */
  52308. class TranscodeResult {
  52309. /**
  52310. * Info about the .basis file
  52311. */
  52312. fileInfo: BasisFileInfo;
  52313. /**
  52314. * Format to use when loading the file
  52315. */
  52316. format: number;
  52317. }
  52318. /**
  52319. * Configuration options for the Basis transcoder
  52320. */
  52321. export class BasisTranscodeConfiguration {
  52322. /**
  52323. * Supported compression formats used to determine the supported output format of the transcoder
  52324. */
  52325. supportedCompressionFormats?: {
  52326. /**
  52327. * etc1 compression format
  52328. */
  52329. etc1?: boolean;
  52330. /**
  52331. * s3tc compression format
  52332. */
  52333. s3tc?: boolean;
  52334. /**
  52335. * pvrtc compression format
  52336. */
  52337. pvrtc?: boolean;
  52338. /**
  52339. * etc2 compression format
  52340. */
  52341. etc2?: boolean;
  52342. };
  52343. /**
  52344. * If mipmap levels should be loaded for transcoded images (Default: true)
  52345. */
  52346. loadMipmapLevels?: boolean;
  52347. /**
  52348. * Index of a single image to load (Default: all images)
  52349. */
  52350. loadSingleImage?: number;
  52351. }
  52352. /**
  52353. * Used to load .Basis files
  52354. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52355. */
  52356. export class BasisTools {
  52357. private static _IgnoreSupportedFormats;
  52358. /**
  52359. * URL to use when loading the basis transcoder
  52360. */
  52361. static JSModuleURL: string;
  52362. /**
  52363. * URL to use when loading the wasm module for the transcoder
  52364. */
  52365. static WasmModuleURL: string;
  52366. /**
  52367. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52368. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52369. * @returns internal format corresponding to the Basis format
  52370. */
  52371. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52372. private static _WorkerPromise;
  52373. private static _Worker;
  52374. private static _actionId;
  52375. private static _CreateWorkerAsync;
  52376. /**
  52377. * Transcodes a loaded image file to compressed pixel data
  52378. * @param imageData image data to transcode
  52379. * @param config configuration options for the transcoding
  52380. * @returns a promise resulting in the transcoded image
  52381. */
  52382. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52383. /**
  52384. * Loads a texture from the transcode result
  52385. * @param texture texture load to
  52386. * @param transcodeResult the result of transcoding the basis file to load from
  52387. */
  52388. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /**
  52393. * Loader for .basis file format
  52394. */
  52395. export class _BasisTextureLoader implements IInternalTextureLoader {
  52396. /**
  52397. * Defines whether the loader supports cascade loading the different faces.
  52398. */
  52399. readonly supportCascades: boolean;
  52400. /**
  52401. * This returns if the loader support the current file information.
  52402. * @param extension defines the file extension of the file being loaded
  52403. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52404. * @param fallback defines the fallback internal texture if any
  52405. * @param isBase64 defines whether the texture is encoded as a base64
  52406. * @param isBuffer defines whether the texture data are stored as a buffer
  52407. * @returns true if the loader can load the specified file
  52408. */
  52409. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52410. /**
  52411. * Transform the url before loading if required.
  52412. * @param rootUrl the url of the texture
  52413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52414. * @returns the transformed texture
  52415. */
  52416. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52417. /**
  52418. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52419. * @param rootUrl the url of the texture
  52420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52421. * @returns the fallback texture
  52422. */
  52423. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52424. /**
  52425. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52426. * @param data contains the texture data
  52427. * @param texture defines the BabylonJS internal texture
  52428. * @param createPolynomials will be true if polynomials have been requested
  52429. * @param onLoad defines the callback to trigger once the texture is ready
  52430. * @param onError defines the callback to trigger in case of error
  52431. */
  52432. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52433. /**
  52434. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52435. * @param data contains the texture data
  52436. * @param texture defines the BabylonJS internal texture
  52437. * @param callback defines the method to call once ready to upload
  52438. */
  52439. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52440. }
  52441. }
  52442. declare module BABYLON {
  52443. /**
  52444. * 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.
  52445. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52446. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52447. */
  52448. export class CustomProceduralTexture extends ProceduralTexture {
  52449. private _animate;
  52450. private _time;
  52451. private _config;
  52452. private _texturePath;
  52453. /**
  52454. * Instantiates a new Custom Procedural Texture.
  52455. * 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.
  52456. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52457. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52458. * @param name Define the name of the texture
  52459. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52460. * @param size Define the size of the texture to create
  52461. * @param scene Define the scene the texture belongs to
  52462. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52463. * @param generateMipMaps Define if the texture should creates mip maps or not
  52464. */
  52465. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52466. private _loadJson;
  52467. /**
  52468. * Is the texture ready to be used ? (rendered at least once)
  52469. * @returns true if ready, otherwise, false.
  52470. */
  52471. isReady(): boolean;
  52472. /**
  52473. * Render the texture to its associated render target.
  52474. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52475. */
  52476. render(useCameraPostProcess?: boolean): void;
  52477. /**
  52478. * Update the list of dependant textures samplers in the shader.
  52479. */
  52480. updateTextures(): void;
  52481. /**
  52482. * Update the uniform values of the procedural texture in the shader.
  52483. */
  52484. updateShaderUniforms(): void;
  52485. /**
  52486. * Define if the texture animates or not.
  52487. */
  52488. animate: boolean;
  52489. }
  52490. }
  52491. declare module BABYLON {
  52492. /** @hidden */
  52493. export var noisePixelShader: {
  52494. name: string;
  52495. shader: string;
  52496. };
  52497. }
  52498. declare module BABYLON {
  52499. /**
  52500. * Class used to generate noise procedural textures
  52501. */
  52502. export class NoiseProceduralTexture extends ProceduralTexture {
  52503. private _time;
  52504. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52505. brightness: number;
  52506. /** Defines the number of octaves to process */
  52507. octaves: number;
  52508. /** Defines the level of persistence (0.8 by default) */
  52509. persistence: number;
  52510. /** Gets or sets animation speed factor (default is 1) */
  52511. animationSpeedFactor: number;
  52512. /**
  52513. * Creates a new NoiseProceduralTexture
  52514. * @param name defines the name fo the texture
  52515. * @param size defines the size of the texture (default is 256)
  52516. * @param scene defines the hosting scene
  52517. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52518. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52519. */
  52520. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52521. private _updateShaderUniforms;
  52522. protected _getDefines(): string;
  52523. /** Generate the current state of the procedural texture */
  52524. render(useCameraPostProcess?: boolean): void;
  52525. /**
  52526. * Serializes this noise procedural texture
  52527. * @returns a serialized noise procedural texture object
  52528. */
  52529. serialize(): any;
  52530. /**
  52531. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52532. * @param parsedTexture defines parsed texture data
  52533. * @param scene defines the current scene
  52534. * @param rootUrl defines the root URL containing noise procedural texture information
  52535. * @returns a parsed NoiseProceduralTexture
  52536. */
  52537. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52538. }
  52539. }
  52540. declare module BABYLON {
  52541. /**
  52542. * Raw cube texture where the raw buffers are passed in
  52543. */
  52544. export class RawCubeTexture extends CubeTexture {
  52545. /**
  52546. * Creates a cube texture where the raw buffers are passed in.
  52547. * @param scene defines the scene the texture is attached to
  52548. * @param data defines the array of data to use to create each face
  52549. * @param size defines the size of the textures
  52550. * @param format defines the format of the data
  52551. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52552. * @param generateMipMaps defines if the engine should generate the mip levels
  52553. * @param invertY defines if data must be stored with Y axis inverted
  52554. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52555. * @param compression defines the compression used (null by default)
  52556. */
  52557. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52558. /**
  52559. * Updates the raw cube texture.
  52560. * @param data defines the data to store
  52561. * @param format defines the data format
  52562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52563. * @param invertY defines if data must be stored with Y axis inverted
  52564. * @param compression defines the compression used (null by default)
  52565. * @param level defines which level of the texture to update
  52566. */
  52567. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52568. /**
  52569. * Updates a raw cube texture with RGBD encoded data.
  52570. * @param data defines the array of data [mipmap][face] to use to create each face
  52571. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52572. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52573. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52574. * @returns a promsie that resolves when the operation is complete
  52575. */
  52576. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52577. /**
  52578. * Clones the raw cube texture.
  52579. * @return a new cube texture
  52580. */
  52581. clone(): CubeTexture;
  52582. /** @hidden */
  52583. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52584. }
  52585. }
  52586. declare module BABYLON {
  52587. /**
  52588. * Class used to store 3D textures containing user data
  52589. */
  52590. export class RawTexture3D extends Texture {
  52591. /** Gets or sets the texture format to use */
  52592. format: number;
  52593. private _engine;
  52594. /**
  52595. * Create a new RawTexture3D
  52596. * @param data defines the data of the texture
  52597. * @param width defines the width of the texture
  52598. * @param height defines the height of the texture
  52599. * @param depth defines the depth of the texture
  52600. * @param format defines the texture format to use
  52601. * @param scene defines the hosting scene
  52602. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52603. * @param invertY defines if texture must be stored with Y axis inverted
  52604. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52605. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52606. */
  52607. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52608. /** Gets or sets the texture format to use */
  52609. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52610. /**
  52611. * Update the texture with new data
  52612. * @param data defines the data to store in the texture
  52613. */
  52614. update(data: ArrayBufferView): void;
  52615. }
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * Creates a refraction texture used by refraction channel of the standard material.
  52620. * It is like a mirror but to see through a material.
  52621. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52622. */
  52623. export class RefractionTexture extends RenderTargetTexture {
  52624. /**
  52625. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52626. * 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.
  52627. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52628. */
  52629. refractionPlane: Plane;
  52630. /**
  52631. * Define how deep under the surface we should see.
  52632. */
  52633. depth: number;
  52634. /**
  52635. * Creates a refraction texture used by refraction channel of the standard material.
  52636. * It is like a mirror but to see through a material.
  52637. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52638. * @param name Define the texture name
  52639. * @param size Define the size of the underlying texture
  52640. * @param scene Define the scene the refraction belongs to
  52641. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52642. */
  52643. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52644. /**
  52645. * Clone the refraction texture.
  52646. * @returns the cloned texture
  52647. */
  52648. clone(): RefractionTexture;
  52649. /**
  52650. * Serialize the texture to a JSON representation you could use in Parse later on
  52651. * @returns the serialized JSON representation
  52652. */
  52653. serialize(): any;
  52654. }
  52655. }
  52656. declare module BABYLON {
  52657. /**
  52658. * Defines the options related to the creation of an HtmlElementTexture
  52659. */
  52660. export interface IHtmlElementTextureOptions {
  52661. /**
  52662. * Defines wether mip maps should be created or not.
  52663. */
  52664. generateMipMaps?: boolean;
  52665. /**
  52666. * Defines the sampling mode of the texture.
  52667. */
  52668. samplingMode?: number;
  52669. /**
  52670. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52671. */
  52672. engine: Nullable<ThinEngine>;
  52673. /**
  52674. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52675. */
  52676. scene: Nullable<Scene>;
  52677. }
  52678. /**
  52679. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52680. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52681. * is automatically managed.
  52682. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52683. * in your application.
  52684. *
  52685. * As the update is not automatic, you need to call them manually.
  52686. */
  52687. export class HtmlElementTexture extends BaseTexture {
  52688. /**
  52689. * The texture URL.
  52690. */
  52691. element: HTMLVideoElement | HTMLCanvasElement;
  52692. private static readonly DefaultOptions;
  52693. private _textureMatrix;
  52694. private _engine;
  52695. private _isVideo;
  52696. private _generateMipMaps;
  52697. private _samplingMode;
  52698. /**
  52699. * Instantiates a HtmlElementTexture from the following parameters.
  52700. *
  52701. * @param name Defines the name of the texture
  52702. * @param element Defines the video or canvas the texture is filled with
  52703. * @param options Defines the other none mandatory texture creation options
  52704. */
  52705. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52706. private _createInternalTexture;
  52707. /**
  52708. * Returns the texture matrix used in most of the material.
  52709. */
  52710. getTextureMatrix(): Matrix;
  52711. /**
  52712. * Updates the content of the texture.
  52713. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52714. */
  52715. update(invertY?: Nullable<boolean>): void;
  52716. }
  52717. }
  52718. declare module BABYLON {
  52719. /**
  52720. * Enum used to define the target of a block
  52721. */
  52722. export enum NodeMaterialBlockTargets {
  52723. /** Vertex shader */
  52724. Vertex = 1,
  52725. /** Fragment shader */
  52726. Fragment = 2,
  52727. /** Neutral */
  52728. Neutral = 4,
  52729. /** Vertex and Fragment */
  52730. VertexAndFragment = 3
  52731. }
  52732. }
  52733. declare module BABYLON {
  52734. /**
  52735. * Defines the kind of connection point for node based material
  52736. */
  52737. export enum NodeMaterialBlockConnectionPointTypes {
  52738. /** Float */
  52739. Float = 1,
  52740. /** Int */
  52741. Int = 2,
  52742. /** Vector2 */
  52743. Vector2 = 4,
  52744. /** Vector3 */
  52745. Vector3 = 8,
  52746. /** Vector4 */
  52747. Vector4 = 16,
  52748. /** Color3 */
  52749. Color3 = 32,
  52750. /** Color4 */
  52751. Color4 = 64,
  52752. /** Matrix */
  52753. Matrix = 128,
  52754. /** Detect type based on connection */
  52755. AutoDetect = 1024,
  52756. /** Output type that will be defined by input type */
  52757. BasedOnInput = 2048
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52763. */
  52764. export enum NodeMaterialBlockConnectionPointMode {
  52765. /** Value is an uniform */
  52766. Uniform = 0,
  52767. /** Value is a mesh attribute */
  52768. Attribute = 1,
  52769. /** Value is a varying between vertex and fragment shaders */
  52770. Varying = 2,
  52771. /** Mode is undefined */
  52772. Undefined = 3
  52773. }
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * Enum used to define system values e.g. values automatically provided by the system
  52778. */
  52779. export enum NodeMaterialSystemValues {
  52780. /** World */
  52781. World = 1,
  52782. /** View */
  52783. View = 2,
  52784. /** Projection */
  52785. Projection = 3,
  52786. /** ViewProjection */
  52787. ViewProjection = 4,
  52788. /** WorldView */
  52789. WorldView = 5,
  52790. /** WorldViewProjection */
  52791. WorldViewProjection = 6,
  52792. /** CameraPosition */
  52793. CameraPosition = 7,
  52794. /** Fog Color */
  52795. FogColor = 8,
  52796. /** Delta time */
  52797. DeltaTime = 9
  52798. }
  52799. }
  52800. declare module BABYLON {
  52801. /**
  52802. * Root class for all node material optimizers
  52803. */
  52804. export class NodeMaterialOptimizer {
  52805. /**
  52806. * Function used to optimize a NodeMaterial graph
  52807. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52808. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52809. */
  52810. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52811. }
  52812. }
  52813. declare module BABYLON {
  52814. /**
  52815. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52816. */
  52817. export class TransformBlock extends NodeMaterialBlock {
  52818. /**
  52819. * Defines the value to use to complement W value to transform it to a Vector4
  52820. */
  52821. complementW: number;
  52822. /**
  52823. * Defines the value to use to complement z value to transform it to a Vector4
  52824. */
  52825. complementZ: number;
  52826. /**
  52827. * Creates a new TransformBlock
  52828. * @param name defines the block name
  52829. */
  52830. constructor(name: string);
  52831. /**
  52832. * Gets the current class name
  52833. * @returns the class name
  52834. */
  52835. getClassName(): string;
  52836. /**
  52837. * Gets the vector input
  52838. */
  52839. readonly vector: NodeMaterialConnectionPoint;
  52840. /**
  52841. * Gets the output component
  52842. */
  52843. readonly output: NodeMaterialConnectionPoint;
  52844. /**
  52845. * Gets the matrix transform input
  52846. */
  52847. readonly transform: NodeMaterialConnectionPoint;
  52848. protected _buildBlock(state: NodeMaterialBuildState): this;
  52849. serialize(): any;
  52850. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52851. protected _dumpPropertiesCode(): string;
  52852. }
  52853. }
  52854. declare module BABYLON {
  52855. /**
  52856. * Block used to output the vertex position
  52857. */
  52858. export class VertexOutputBlock extends NodeMaterialBlock {
  52859. /**
  52860. * Creates a new VertexOutputBlock
  52861. * @param name defines the block name
  52862. */
  52863. constructor(name: string);
  52864. /**
  52865. * Gets the current class name
  52866. * @returns the class name
  52867. */
  52868. getClassName(): string;
  52869. /**
  52870. * Gets the vector input component
  52871. */
  52872. readonly vector: NodeMaterialConnectionPoint;
  52873. protected _buildBlock(state: NodeMaterialBuildState): this;
  52874. }
  52875. }
  52876. declare module BABYLON {
  52877. /**
  52878. * Block used to output the final color
  52879. */
  52880. export class FragmentOutputBlock extends NodeMaterialBlock {
  52881. /**
  52882. * Create a new FragmentOutputBlock
  52883. * @param name defines the block name
  52884. */
  52885. constructor(name: string);
  52886. /**
  52887. * Gets the current class name
  52888. * @returns the class name
  52889. */
  52890. getClassName(): string;
  52891. /**
  52892. * Gets the rgba input component
  52893. */
  52894. readonly rgba: NodeMaterialConnectionPoint;
  52895. /**
  52896. * Gets the rgb input component
  52897. */
  52898. readonly rgb: NodeMaterialConnectionPoint;
  52899. /**
  52900. * Gets the a input component
  52901. */
  52902. readonly a: NodeMaterialConnectionPoint;
  52903. protected _buildBlock(state: NodeMaterialBuildState): this;
  52904. }
  52905. }
  52906. declare module BABYLON {
  52907. /**
  52908. * Block used to read a reflection texture from a sampler
  52909. */
  52910. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52911. private _define3DName;
  52912. private _defineCubicName;
  52913. private _defineExplicitName;
  52914. private _defineProjectionName;
  52915. private _defineLocalCubicName;
  52916. private _defineSphericalName;
  52917. private _definePlanarName;
  52918. private _defineEquirectangularName;
  52919. private _defineMirroredEquirectangularFixedName;
  52920. private _defineEquirectangularFixedName;
  52921. private _defineSkyboxName;
  52922. private _cubeSamplerName;
  52923. private _2DSamplerName;
  52924. private _positionUVWName;
  52925. private _directionWName;
  52926. private _reflectionCoordsName;
  52927. private _reflection2DCoordsName;
  52928. private _reflectionColorName;
  52929. private _reflectionMatrixName;
  52930. /**
  52931. * Gets or sets the texture associated with the node
  52932. */
  52933. texture: Nullable<BaseTexture>;
  52934. /**
  52935. * Create a new TextureBlock
  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 world position input component
  52946. */
  52947. readonly position: NodeMaterialConnectionPoint;
  52948. /**
  52949. * Gets the world position input component
  52950. */
  52951. readonly worldPosition: NodeMaterialConnectionPoint;
  52952. /**
  52953. * Gets the world normal input component
  52954. */
  52955. readonly worldNormal: NodeMaterialConnectionPoint;
  52956. /**
  52957. * Gets the world input component
  52958. */
  52959. readonly world: NodeMaterialConnectionPoint;
  52960. /**
  52961. * Gets the camera (or eye) position component
  52962. */
  52963. readonly cameraPosition: NodeMaterialConnectionPoint;
  52964. /**
  52965. * Gets the view input component
  52966. */
  52967. readonly view: NodeMaterialConnectionPoint;
  52968. /**
  52969. * Gets the rgb output component
  52970. */
  52971. readonly rgb: NodeMaterialConnectionPoint;
  52972. /**
  52973. * Gets the r output component
  52974. */
  52975. readonly r: NodeMaterialConnectionPoint;
  52976. /**
  52977. * Gets the g output component
  52978. */
  52979. readonly g: NodeMaterialConnectionPoint;
  52980. /**
  52981. * Gets the b output component
  52982. */
  52983. readonly b: NodeMaterialConnectionPoint;
  52984. autoConfigure(material: NodeMaterial): void;
  52985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52986. isReady(): boolean;
  52987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52988. private _injectVertexCode;
  52989. private _writeOutput;
  52990. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52991. serialize(): any;
  52992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * Interface used to configure the node material editor
  52998. */
  52999. export interface INodeMaterialEditorOptions {
  53000. /** Define the URl to load node editor script */
  53001. editorURL?: string;
  53002. }
  53003. /** @hidden */
  53004. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53005. /** BONES */
  53006. NUM_BONE_INFLUENCERS: number;
  53007. BonesPerMesh: number;
  53008. BONETEXTURE: boolean;
  53009. /** MORPH TARGETS */
  53010. MORPHTARGETS: boolean;
  53011. MORPHTARGETS_NORMAL: boolean;
  53012. MORPHTARGETS_TANGENT: boolean;
  53013. MORPHTARGETS_UV: boolean;
  53014. NUM_MORPH_INFLUENCERS: number;
  53015. /** IMAGE PROCESSING */
  53016. IMAGEPROCESSING: boolean;
  53017. VIGNETTE: boolean;
  53018. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53019. VIGNETTEBLENDMODEOPAQUE: boolean;
  53020. TONEMAPPING: boolean;
  53021. TONEMAPPING_ACES: boolean;
  53022. CONTRAST: boolean;
  53023. EXPOSURE: boolean;
  53024. COLORCURVES: boolean;
  53025. COLORGRADING: boolean;
  53026. COLORGRADING3D: boolean;
  53027. SAMPLER3DGREENDEPTH: boolean;
  53028. SAMPLER3DBGRMAP: boolean;
  53029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53030. /** MISC. */
  53031. BUMPDIRECTUV: number;
  53032. constructor();
  53033. setValue(name: string, value: boolean): void;
  53034. }
  53035. /**
  53036. * Class used to configure NodeMaterial
  53037. */
  53038. export interface INodeMaterialOptions {
  53039. /**
  53040. * Defines if blocks should emit comments
  53041. */
  53042. emitComments: boolean;
  53043. }
  53044. /**
  53045. * Class used to create a node based material built by assembling shader blocks
  53046. */
  53047. export class NodeMaterial extends PushMaterial {
  53048. private static _BuildIdGenerator;
  53049. private _options;
  53050. private _vertexCompilationState;
  53051. private _fragmentCompilationState;
  53052. private _sharedData;
  53053. private _buildId;
  53054. private _buildWasSuccessful;
  53055. private _cachedWorldViewMatrix;
  53056. private _cachedWorldViewProjectionMatrix;
  53057. private _optimizers;
  53058. private _animationFrame;
  53059. /** Define the URl to load node editor script */
  53060. static EditorURL: string;
  53061. private BJSNODEMATERIALEDITOR;
  53062. /** Get the inspector from bundle or global */
  53063. private _getGlobalNodeMaterialEditor;
  53064. /**
  53065. * 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)
  53066. */
  53067. ignoreAlpha: boolean;
  53068. /**
  53069. * Defines the maximum number of lights that can be used in the material
  53070. */
  53071. maxSimultaneousLights: number;
  53072. /**
  53073. * Observable raised when the material is built
  53074. */
  53075. onBuildObservable: Observable<NodeMaterial>;
  53076. /**
  53077. * Gets or sets the root nodes of the material vertex shader
  53078. */
  53079. _vertexOutputNodes: NodeMaterialBlock[];
  53080. /**
  53081. * Gets or sets the root nodes of the material fragment (pixel) shader
  53082. */
  53083. _fragmentOutputNodes: NodeMaterialBlock[];
  53084. /** Gets or sets options to control the node material overall behavior */
  53085. options: INodeMaterialOptions;
  53086. /**
  53087. * Default configuration related to image processing available in the standard Material.
  53088. */
  53089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53090. /**
  53091. * Gets the image processing configuration used either in this material.
  53092. */
  53093. /**
  53094. * Sets the Default image processing configuration used either in the this material.
  53095. *
  53096. * If sets to null, the scene one is in use.
  53097. */
  53098. imageProcessingConfiguration: ImageProcessingConfiguration;
  53099. /**
  53100. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53101. */
  53102. attachedBlocks: NodeMaterialBlock[];
  53103. /**
  53104. * Create a new node based material
  53105. * @param name defines the material name
  53106. * @param scene defines the hosting scene
  53107. * @param options defines creation option
  53108. */
  53109. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53110. /**
  53111. * Gets the current class name of the material e.g. "NodeMaterial"
  53112. * @returns the class name
  53113. */
  53114. getClassName(): string;
  53115. /**
  53116. * Keep track of the image processing observer to allow dispose and replace.
  53117. */
  53118. private _imageProcessingObserver;
  53119. /**
  53120. * Attaches a new image processing configuration to the Standard Material.
  53121. * @param configuration
  53122. */
  53123. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53124. /**
  53125. * Get a block by its name
  53126. * @param name defines the name of the block to retrieve
  53127. * @returns the required block or null if not found
  53128. */
  53129. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  53130. /**
  53131. * Get a block by its name
  53132. * @param predicate defines the predicate used to find the good candidate
  53133. * @returns the required block or null if not found
  53134. */
  53135. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  53136. /**
  53137. * Get an input block by its name
  53138. * @param predicate defines the predicate used to find the good candidate
  53139. * @returns the required input block or null if not found
  53140. */
  53141. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  53142. /**
  53143. * Gets the list of input blocks attached to this material
  53144. * @returns an array of InputBlocks
  53145. */
  53146. getInputBlocks(): InputBlock[];
  53147. /**
  53148. * Adds a new optimizer to the list of optimizers
  53149. * @param optimizer defines the optimizers to add
  53150. * @returns the current material
  53151. */
  53152. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53153. /**
  53154. * Remove an optimizer from the list of optimizers
  53155. * @param optimizer defines the optimizers to remove
  53156. * @returns the current material
  53157. */
  53158. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53159. /**
  53160. * Add a new block to the list of output nodes
  53161. * @param node defines the node to add
  53162. * @returns the current material
  53163. */
  53164. addOutputNode(node: NodeMaterialBlock): this;
  53165. /**
  53166. * Remove a block from the list of root nodes
  53167. * @param node defines the node to remove
  53168. * @returns the current material
  53169. */
  53170. removeOutputNode(node: NodeMaterialBlock): this;
  53171. private _addVertexOutputNode;
  53172. private _removeVertexOutputNode;
  53173. private _addFragmentOutputNode;
  53174. private _removeFragmentOutputNode;
  53175. /**
  53176. * Specifies if the material will require alpha blending
  53177. * @returns a boolean specifying if alpha blending is needed
  53178. */
  53179. needAlphaBlending(): boolean;
  53180. /**
  53181. * Specifies if this material should be rendered in alpha test mode
  53182. * @returns a boolean specifying if an alpha test is needed.
  53183. */
  53184. needAlphaTesting(): boolean;
  53185. private _initializeBlock;
  53186. private _resetDualBlocks;
  53187. /**
  53188. * Build the material and generates the inner effect
  53189. * @param verbose defines if the build should log activity
  53190. */
  53191. build(verbose?: boolean): void;
  53192. /**
  53193. * Runs an otpimization phase to try to improve the shader code
  53194. */
  53195. optimize(): void;
  53196. private _prepareDefinesForAttributes;
  53197. /**
  53198. * Get if the submesh is ready to be used and all its information available.
  53199. * Child classes can use it to update shaders
  53200. * @param mesh defines the mesh to check
  53201. * @param subMesh defines which submesh to check
  53202. * @param useInstances specifies that instances should be used
  53203. * @returns a boolean indicating that the submesh is ready or not
  53204. */
  53205. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53206. /**
  53207. * Get a string representing the shaders built by the current node graph
  53208. */
  53209. readonly compiledShaders: string;
  53210. /**
  53211. * Binds the world matrix to the material
  53212. * @param world defines the world transformation matrix
  53213. */
  53214. bindOnlyWorldMatrix(world: Matrix): void;
  53215. /**
  53216. * Binds the submesh to this material by preparing the effect and shader to draw
  53217. * @param world defines the world transformation matrix
  53218. * @param mesh defines the mesh containing the submesh
  53219. * @param subMesh defines the submesh to bind the material to
  53220. */
  53221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53222. /**
  53223. * Gets the active textures from the material
  53224. * @returns an array of textures
  53225. */
  53226. getActiveTextures(): BaseTexture[];
  53227. /**
  53228. * Gets the list of texture blocks
  53229. * @returns an array of texture blocks
  53230. */
  53231. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  53232. /**
  53233. * Specifies if the material uses a texture
  53234. * @param texture defines the texture to check against the material
  53235. * @returns a boolean specifying if the material uses the texture
  53236. */
  53237. hasTexture(texture: BaseTexture): boolean;
  53238. /**
  53239. * Disposes the material
  53240. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53241. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53242. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53243. */
  53244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53245. /** Creates the node editor window. */
  53246. private _createNodeEditor;
  53247. /**
  53248. * Launch the node material editor
  53249. * @param config Define the configuration of the editor
  53250. * @return a promise fulfilled when the node editor is visible
  53251. */
  53252. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53253. /**
  53254. * Clear the current material
  53255. */
  53256. clear(): void;
  53257. /**
  53258. * Clear the current material and set it to a default state
  53259. */
  53260. setToDefault(): void;
  53261. /**
  53262. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  53263. * @param url defines the url to load from
  53264. * @returns a promise that will fullfil when the material is fully loaded
  53265. */
  53266. loadAsync(url: string): Promise<void>;
  53267. private _gatherBlocks;
  53268. /**
  53269. * Generate a string containing the code declaration required to create an equivalent of this material
  53270. * @returns a string
  53271. */
  53272. generateCode(): string;
  53273. /**
  53274. * Serializes this material in a JSON representation
  53275. * @returns the serialized material object
  53276. */
  53277. serialize(): any;
  53278. private _restoreConnections;
  53279. /**
  53280. * Clear the current graph and load a new one from a serialization object
  53281. * @param source defines the JSON representation of the material
  53282. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53283. */
  53284. loadFromSerialization(source: any, rootUrl?: string): void;
  53285. /**
  53286. * Creates a node material from parsed material data
  53287. * @param source defines the JSON representation of the material
  53288. * @param scene defines the hosting scene
  53289. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53290. * @returns a new node material
  53291. */
  53292. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53293. /**
  53294. * Creates a new node material set to default basic configuration
  53295. * @param name defines the name of the material
  53296. * @param scene defines the hosting scene
  53297. * @returns a new NodeMaterial
  53298. */
  53299. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53300. }
  53301. }
  53302. declare module BABYLON {
  53303. /**
  53304. * Block used to read a texture from a sampler
  53305. */
  53306. export class TextureBlock extends NodeMaterialBlock {
  53307. private _defineName;
  53308. private _linearDefineName;
  53309. private _samplerName;
  53310. private _transformedUVName;
  53311. private _textureTransformName;
  53312. private _textureInfoName;
  53313. private _mainUVName;
  53314. private _mainUVDefineName;
  53315. /**
  53316. * Gets or sets the texture associated with the node
  53317. */
  53318. texture: Nullable<Texture>;
  53319. /**
  53320. * Create a new TextureBlock
  53321. * @param name defines the block name
  53322. */
  53323. constructor(name: string);
  53324. /**
  53325. * Gets the current class name
  53326. * @returns the class name
  53327. */
  53328. getClassName(): string;
  53329. /**
  53330. * Gets the uv input component
  53331. */
  53332. readonly uv: NodeMaterialConnectionPoint;
  53333. /**
  53334. * Gets the rgba output component
  53335. */
  53336. readonly rgba: NodeMaterialConnectionPoint;
  53337. /**
  53338. * Gets the rgb output component
  53339. */
  53340. readonly rgb: NodeMaterialConnectionPoint;
  53341. /**
  53342. * Gets the r output component
  53343. */
  53344. readonly r: NodeMaterialConnectionPoint;
  53345. /**
  53346. * Gets the g output component
  53347. */
  53348. readonly g: NodeMaterialConnectionPoint;
  53349. /**
  53350. * Gets the b output component
  53351. */
  53352. readonly b: NodeMaterialConnectionPoint;
  53353. /**
  53354. * Gets the a output component
  53355. */
  53356. readonly a: NodeMaterialConnectionPoint;
  53357. readonly target: NodeMaterialBlockTargets;
  53358. autoConfigure(material: NodeMaterial): void;
  53359. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53361. isReady(): boolean;
  53362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53363. private readonly _isMixed;
  53364. private _injectVertexCode;
  53365. private _writeOutput;
  53366. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53367. protected _dumpPropertiesCode(): string;
  53368. serialize(): any;
  53369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53370. }
  53371. }
  53372. declare module BABYLON {
  53373. /**
  53374. * Class used to store shared data between 2 NodeMaterialBuildState
  53375. */
  53376. export class NodeMaterialBuildStateSharedData {
  53377. /**
  53378. * Gets the list of emitted varyings
  53379. */
  53380. temps: string[];
  53381. /**
  53382. * Gets the list of emitted varyings
  53383. */
  53384. varyings: string[];
  53385. /**
  53386. * Gets the varying declaration string
  53387. */
  53388. varyingDeclaration: string;
  53389. /**
  53390. * Input blocks
  53391. */
  53392. inputBlocks: InputBlock[];
  53393. /**
  53394. * Input blocks
  53395. */
  53396. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53397. /**
  53398. * Bindable blocks (Blocks that need to set data to the effect)
  53399. */
  53400. bindableBlocks: NodeMaterialBlock[];
  53401. /**
  53402. * List of blocks that can provide a compilation fallback
  53403. */
  53404. blocksWithFallbacks: NodeMaterialBlock[];
  53405. /**
  53406. * List of blocks that can provide a define update
  53407. */
  53408. blocksWithDefines: NodeMaterialBlock[];
  53409. /**
  53410. * List of blocks that can provide a repeatable content
  53411. */
  53412. repeatableContentBlocks: NodeMaterialBlock[];
  53413. /**
  53414. * List of blocks that can provide a dynamic list of uniforms
  53415. */
  53416. dynamicUniformBlocks: NodeMaterialBlock[];
  53417. /**
  53418. * List of blocks that can block the isReady function for the material
  53419. */
  53420. blockingBlocks: NodeMaterialBlock[];
  53421. /**
  53422. * Gets the list of animated inputs
  53423. */
  53424. animatedInputs: InputBlock[];
  53425. /**
  53426. * Build Id used to avoid multiple recompilations
  53427. */
  53428. buildId: number;
  53429. /** List of emitted variables */
  53430. variableNames: {
  53431. [key: string]: number;
  53432. };
  53433. /** List of emitted defines */
  53434. defineNames: {
  53435. [key: string]: number;
  53436. };
  53437. /** Should emit comments? */
  53438. emitComments: boolean;
  53439. /** Emit build activity */
  53440. verbose: boolean;
  53441. /** Gets or sets the hosting scene */
  53442. scene: Scene;
  53443. /**
  53444. * Gets the compilation hints emitted at compilation time
  53445. */
  53446. hints: {
  53447. needWorldViewMatrix: boolean;
  53448. needWorldViewProjectionMatrix: boolean;
  53449. needAlphaBlending: boolean;
  53450. needAlphaTesting: boolean;
  53451. };
  53452. /**
  53453. * List of compilation checks
  53454. */
  53455. checks: {
  53456. emitVertex: boolean;
  53457. emitFragment: boolean;
  53458. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53459. };
  53460. /** Creates a new shared data */
  53461. constructor();
  53462. /**
  53463. * Emits console errors and exceptions if there is a failing check
  53464. */
  53465. emitErrors(): void;
  53466. }
  53467. }
  53468. declare module BABYLON {
  53469. /**
  53470. * Class used to store node based material build state
  53471. */
  53472. export class NodeMaterialBuildState {
  53473. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53474. supportUniformBuffers: boolean;
  53475. /**
  53476. * Gets the list of emitted attributes
  53477. */
  53478. attributes: string[];
  53479. /**
  53480. * Gets the list of emitted uniforms
  53481. */
  53482. uniforms: string[];
  53483. /**
  53484. * Gets the list of emitted constants
  53485. */
  53486. constants: string[];
  53487. /**
  53488. * Gets the list of emitted samplers
  53489. */
  53490. samplers: string[];
  53491. /**
  53492. * Gets the list of emitted functions
  53493. */
  53494. functions: {
  53495. [key: string]: string;
  53496. };
  53497. /**
  53498. * Gets the list of emitted extensions
  53499. */
  53500. extensions: {
  53501. [key: string]: string;
  53502. };
  53503. /**
  53504. * Gets the target of the compilation state
  53505. */
  53506. target: NodeMaterialBlockTargets;
  53507. /**
  53508. * Gets the list of emitted counters
  53509. */
  53510. counters: {
  53511. [key: string]: number;
  53512. };
  53513. /**
  53514. * Shared data between multiple NodeMaterialBuildState instances
  53515. */
  53516. sharedData: NodeMaterialBuildStateSharedData;
  53517. /** @hidden */
  53518. _vertexState: NodeMaterialBuildState;
  53519. /** @hidden */
  53520. _attributeDeclaration: string;
  53521. /** @hidden */
  53522. _uniformDeclaration: string;
  53523. /** @hidden */
  53524. _constantDeclaration: string;
  53525. /** @hidden */
  53526. _samplerDeclaration: string;
  53527. /** @hidden */
  53528. _varyingTransfer: string;
  53529. private _repeatableContentAnchorIndex;
  53530. /** @hidden */
  53531. _builtCompilationString: string;
  53532. /**
  53533. * Gets the emitted compilation strings
  53534. */
  53535. compilationString: string;
  53536. /**
  53537. * Finalize the compilation strings
  53538. * @param state defines the current compilation state
  53539. */
  53540. finalize(state: NodeMaterialBuildState): void;
  53541. /** @hidden */
  53542. readonly _repeatableContentAnchor: string;
  53543. /** @hidden */
  53544. _getFreeVariableName(prefix: string): string;
  53545. /** @hidden */
  53546. _getFreeDefineName(prefix: string): string;
  53547. /** @hidden */
  53548. _excludeVariableName(name: string): void;
  53549. /** @hidden */
  53550. _emit2DSampler(name: string): void;
  53551. /** @hidden */
  53552. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53553. /** @hidden */
  53554. _emitExtension(name: string, extension: string): void;
  53555. /** @hidden */
  53556. _emitFunction(name: string, code: string, comments: string): void;
  53557. /** @hidden */
  53558. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53559. replaceStrings?: {
  53560. search: RegExp;
  53561. replace: string;
  53562. }[];
  53563. repeatKey?: string;
  53564. }): string;
  53565. /** @hidden */
  53566. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53567. repeatKey?: string;
  53568. removeAttributes?: boolean;
  53569. removeUniforms?: boolean;
  53570. removeVaryings?: boolean;
  53571. removeIfDef?: boolean;
  53572. replaceStrings?: {
  53573. search: RegExp;
  53574. replace: string;
  53575. }[];
  53576. }, storeKey?: string): void;
  53577. /** @hidden */
  53578. _registerTempVariable(name: string): boolean;
  53579. /** @hidden */
  53580. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53581. /** @hidden */
  53582. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53583. /** @hidden */
  53584. _emitFloat(value: number): string;
  53585. }
  53586. }
  53587. declare module BABYLON {
  53588. /**
  53589. * Defines a block that can be used inside a node based material
  53590. */
  53591. export class NodeMaterialBlock {
  53592. private _buildId;
  53593. private _buildTarget;
  53594. private _target;
  53595. private _isFinalMerger;
  53596. private _isInput;
  53597. /** @hidden */
  53598. _codeVariableName: string;
  53599. /** @hidden */
  53600. _inputs: NodeMaterialConnectionPoint[];
  53601. /** @hidden */
  53602. _outputs: NodeMaterialConnectionPoint[];
  53603. /** @hidden */
  53604. _preparationId: number;
  53605. /**
  53606. * Gets or sets the name of the block
  53607. */
  53608. name: string;
  53609. /**
  53610. * Gets or sets the unique id of the node
  53611. */
  53612. uniqueId: number;
  53613. /**
  53614. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53615. */
  53616. readonly isFinalMerger: boolean;
  53617. /**
  53618. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53619. */
  53620. readonly isInput: boolean;
  53621. /**
  53622. * Gets or sets the build Id
  53623. */
  53624. buildId: number;
  53625. /**
  53626. * Gets or sets the target of the block
  53627. */
  53628. target: NodeMaterialBlockTargets;
  53629. /**
  53630. * Gets the list of input points
  53631. */
  53632. readonly inputs: NodeMaterialConnectionPoint[];
  53633. /** Gets the list of output points */
  53634. readonly outputs: NodeMaterialConnectionPoint[];
  53635. /**
  53636. * Find an input by its name
  53637. * @param name defines the name of the input to look for
  53638. * @returns the input or null if not found
  53639. */
  53640. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53641. /**
  53642. * Find an output by its name
  53643. * @param name defines the name of the outputto look for
  53644. * @returns the output or null if not found
  53645. */
  53646. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53647. /**
  53648. * Creates a new NodeMaterialBlock
  53649. * @param name defines the block name
  53650. * @param target defines the target of that block (Vertex by default)
  53651. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53652. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53653. */
  53654. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53655. /**
  53656. * Initialize the block and prepare the context for build
  53657. * @param state defines the state that will be used for the build
  53658. */
  53659. initialize(state: NodeMaterialBuildState): void;
  53660. /**
  53661. * Bind data to effect. Will only be called for blocks with isBindable === true
  53662. * @param effect defines the effect to bind data to
  53663. * @param nodeMaterial defines the hosting NodeMaterial
  53664. * @param mesh defines the mesh that will be rendered
  53665. */
  53666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53667. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53668. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53669. protected _writeFloat(value: number): string;
  53670. /**
  53671. * Gets the current class name e.g. "NodeMaterialBlock"
  53672. * @returns the class name
  53673. */
  53674. getClassName(): string;
  53675. /**
  53676. * Register a new input. Must be called inside a block constructor
  53677. * @param name defines the connection point name
  53678. * @param type defines the connection point type
  53679. * @param isOptional defines a boolean indicating that this input can be omitted
  53680. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53681. * @returns the current block
  53682. */
  53683. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53684. /**
  53685. * Register a new output. Must be called inside a block constructor
  53686. * @param name defines the connection point name
  53687. * @param type defines the connection point type
  53688. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53689. * @returns the current block
  53690. */
  53691. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53692. /**
  53693. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53694. * @param forOutput defines an optional connection point to check compatibility with
  53695. * @returns the first available input or null
  53696. */
  53697. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53698. /**
  53699. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53700. * @param forBlock defines an optional block to check compatibility with
  53701. * @returns the first available input or null
  53702. */
  53703. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53704. /**
  53705. * Gets the sibling of the given output
  53706. * @param current defines the current output
  53707. * @returns the next output in the list or null
  53708. */
  53709. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53710. /**
  53711. * Connect current block with another block
  53712. * @param other defines the block to connect with
  53713. * @param options define the various options to help pick the right connections
  53714. * @returns the current block
  53715. */
  53716. connectTo(other: NodeMaterialBlock, options?: {
  53717. input?: string;
  53718. output?: string;
  53719. outputSwizzle?: string;
  53720. }): this | undefined;
  53721. protected _buildBlock(state: NodeMaterialBuildState): void;
  53722. /**
  53723. * Add uniforms, samplers and uniform buffers at compilation time
  53724. * @param state defines the state to update
  53725. * @param nodeMaterial defines the node material requesting the update
  53726. * @param defines defines the material defines to update
  53727. * @param uniformBuffers defines the list of uniform buffer names
  53728. */
  53729. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  53730. /**
  53731. * Add potential fallbacks if shader compilation fails
  53732. * @param mesh defines the mesh to be rendered
  53733. * @param fallbacks defines the current prioritized list of fallbacks
  53734. */
  53735. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53736. /**
  53737. * Initialize defines for shader compilation
  53738. * @param mesh defines the mesh to be rendered
  53739. * @param nodeMaterial defines the node material requesting the update
  53740. * @param defines defines the material defines to update
  53741. * @param useInstances specifies that instances should be used
  53742. */
  53743. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53744. /**
  53745. * Update defines for shader compilation
  53746. * @param mesh defines the mesh to be rendered
  53747. * @param nodeMaterial defines the node material requesting the update
  53748. * @param defines defines the material defines to update
  53749. * @param useInstances specifies that instances should be used
  53750. */
  53751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53752. /**
  53753. * Lets the block try to connect some inputs automatically
  53754. * @param material defines the hosting NodeMaterial
  53755. */
  53756. autoConfigure(material: NodeMaterial): void;
  53757. /**
  53758. * Function called when a block is declared as repeatable content generator
  53759. * @param vertexShaderState defines the current compilation state for the vertex shader
  53760. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53761. * @param mesh defines the mesh to be rendered
  53762. * @param defines defines the material defines to update
  53763. */
  53764. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53765. /**
  53766. * Checks if the block is ready
  53767. * @param mesh defines the mesh to be rendered
  53768. * @param nodeMaterial defines the node material requesting the update
  53769. * @param defines defines the material defines to update
  53770. * @param useInstances specifies that instances should be used
  53771. * @returns true if the block is ready
  53772. */
  53773. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53774. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53775. private _processBuild;
  53776. /**
  53777. * Compile the current node and generate the shader code
  53778. * @param state defines the current compilation state (uniforms, samplers, current string)
  53779. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53780. * @returns true if already built
  53781. */
  53782. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53783. protected _inputRename(name: string): string;
  53784. protected _outputRename(name: string): string;
  53785. protected _dumpPropertiesCode(): string;
  53786. /** @hidden */
  53787. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53788. /**
  53789. * Clone the current block to a new identical block
  53790. * @param scene defines the hosting scene
  53791. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53792. * @returns a copy of the current block
  53793. */
  53794. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53795. /**
  53796. * Serializes this block in a JSON representation
  53797. * @returns the serialized block object
  53798. */
  53799. serialize(): any;
  53800. /** @hidden */
  53801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53802. }
  53803. }
  53804. declare module BABYLON {
  53805. /**
  53806. * Enum defining the type of animations supported by InputBlock
  53807. */
  53808. export enum AnimatedInputBlockTypes {
  53809. /** No animation */
  53810. None = 0,
  53811. /** Time based animation. Will only work for floats */
  53812. Time = 1
  53813. }
  53814. }
  53815. declare module BABYLON {
  53816. /**
  53817. * Block used to expose an input value
  53818. */
  53819. export class InputBlock extends NodeMaterialBlock {
  53820. private _mode;
  53821. private _associatedVariableName;
  53822. private _storedValue;
  53823. private _valueCallback;
  53824. private _type;
  53825. private _animationType;
  53826. /** Gets or set a value used to limit the range of float values */
  53827. min: number;
  53828. /** Gets or set a value used to limit the range of float values */
  53829. max: number;
  53830. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53831. matrixMode: number;
  53832. /** @hidden */
  53833. _systemValue: Nullable<NodeMaterialSystemValues>;
  53834. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53835. visibleInInspector: boolean;
  53836. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53837. isConstant: boolean;
  53838. /**
  53839. * Gets or sets the connection point type (default is float)
  53840. */
  53841. readonly type: NodeMaterialBlockConnectionPointTypes;
  53842. /**
  53843. * Creates a new InputBlock
  53844. * @param name defines the block name
  53845. * @param target defines the target of that block (Vertex by default)
  53846. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53847. */
  53848. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53849. /**
  53850. * Gets the output component
  53851. */
  53852. readonly output: NodeMaterialConnectionPoint;
  53853. /**
  53854. * Set the source of this connection point to a vertex attribute
  53855. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53856. * @returns the current connection point
  53857. */
  53858. setAsAttribute(attributeName?: string): InputBlock;
  53859. /**
  53860. * Set the source of this connection point to a system value
  53861. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53862. * @returns the current connection point
  53863. */
  53864. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53865. /**
  53866. * Gets or sets the value of that point.
  53867. * Please note that this value will be ignored if valueCallback is defined
  53868. */
  53869. value: any;
  53870. /**
  53871. * Gets or sets a callback used to get the value of that point.
  53872. * Please note that setting this value will force the connection point to ignore the value property
  53873. */
  53874. valueCallback: () => any;
  53875. /**
  53876. * Gets or sets the associated variable name in the shader
  53877. */
  53878. associatedVariableName: string;
  53879. /** Gets or sets the type of animation applied to the input */
  53880. animationType: AnimatedInputBlockTypes;
  53881. /**
  53882. * Gets a boolean indicating that this connection point not defined yet
  53883. */
  53884. readonly isUndefined: boolean;
  53885. /**
  53886. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53887. * In this case the connection point name must be the name of the uniform to use.
  53888. * Can only be set on inputs
  53889. */
  53890. isUniform: boolean;
  53891. /**
  53892. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53893. * In this case the connection point name must be the name of the attribute to use
  53894. * Can only be set on inputs
  53895. */
  53896. isAttribute: boolean;
  53897. /**
  53898. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53899. * Can only be set on exit points
  53900. */
  53901. isVarying: boolean;
  53902. /**
  53903. * Gets a boolean indicating that the current connection point is a system value
  53904. */
  53905. readonly isSystemValue: boolean;
  53906. /**
  53907. * Gets or sets the current well known value or null if not defined as a system value
  53908. */
  53909. systemValue: Nullable<NodeMaterialSystemValues>;
  53910. /**
  53911. * Gets the current class name
  53912. * @returns the class name
  53913. */
  53914. getClassName(): string;
  53915. /**
  53916. * Animate the input if animationType !== None
  53917. * @param scene defines the rendering scene
  53918. */
  53919. animate(scene: Scene): void;
  53920. private _emitDefine;
  53921. initialize(state: NodeMaterialBuildState): void;
  53922. /**
  53923. * Set the input block to its default value (based on its type)
  53924. */
  53925. setDefaultValue(): void;
  53926. private _emitConstant;
  53927. private _emit;
  53928. /** @hidden */
  53929. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53930. /** @hidden */
  53931. _transmit(effect: Effect, scene: Scene): void;
  53932. protected _buildBlock(state: NodeMaterialBuildState): void;
  53933. protected _dumpPropertiesCode(): string;
  53934. serialize(): any;
  53935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53936. }
  53937. }
  53938. declare module BABYLON {
  53939. /**
  53940. * Defines a connection point for a block
  53941. */
  53942. export class NodeMaterialConnectionPoint {
  53943. /** @hidden */
  53944. _ownerBlock: NodeMaterialBlock;
  53945. /** @hidden */
  53946. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53947. private _endpoints;
  53948. private _associatedVariableName;
  53949. /** @hidden */
  53950. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53951. /** @hidden */
  53952. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53953. private _type;
  53954. /** @hidden */
  53955. _enforceAssociatedVariableName: boolean;
  53956. /**
  53957. * Gets or sets the additional types supported by this connection point
  53958. */
  53959. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53960. /**
  53961. * Gets or sets the additional types excluded by this connection point
  53962. */
  53963. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53964. /**
  53965. * Gets or sets the associated variable name in the shader
  53966. */
  53967. associatedVariableName: string;
  53968. /**
  53969. * Gets or sets the connection point type (default is float)
  53970. */
  53971. type: NodeMaterialBlockConnectionPointTypes;
  53972. /**
  53973. * Gets or sets the connection point name
  53974. */
  53975. name: string;
  53976. /**
  53977. * Gets or sets a boolean indicating that this connection point can be omitted
  53978. */
  53979. isOptional: boolean;
  53980. /**
  53981. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53982. */
  53983. define: string;
  53984. /** Gets or sets the target of that connection point */
  53985. target: NodeMaterialBlockTargets;
  53986. /**
  53987. * Gets a boolean indicating that the current point is connected
  53988. */
  53989. readonly isConnected: boolean;
  53990. /**
  53991. * Gets a boolean indicating that the current point is connected to an input block
  53992. */
  53993. readonly isConnectedToInputBlock: boolean;
  53994. /**
  53995. * Gets a the connected input block (if any)
  53996. */
  53997. readonly connectInputBlock: Nullable<InputBlock>;
  53998. /** Get the other side of the connection (if any) */
  53999. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54000. /** Get the block that owns this connection point */
  54001. readonly ownerBlock: NodeMaterialBlock;
  54002. /** Get the block connected on the other side of this connection (if any) */
  54003. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54004. /** Get the block connected on the endpoints of this connection (if any) */
  54005. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54006. /** Gets the list of connected endpoints */
  54007. readonly endpoints: NodeMaterialConnectionPoint[];
  54008. /** Gets a boolean indicating if that output point is connected to at least one input */
  54009. readonly hasEndpoints: boolean;
  54010. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  54011. readonly isConnectedInVertexShader: boolean;
  54012. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  54013. readonly isConnectedInFragmentShader: boolean;
  54014. /**
  54015. * Creates a new connection point
  54016. * @param name defines the connection point name
  54017. * @param ownerBlock defines the block hosting this connection point
  54018. */
  54019. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54020. /**
  54021. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54022. * @returns the class name
  54023. */
  54024. getClassName(): string;
  54025. /**
  54026. * Gets an boolean indicating if the current point can be connected to another point
  54027. * @param connectionPoint defines the other connection point
  54028. * @returns true if the connection is possible
  54029. */
  54030. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54031. /**
  54032. * Connect this point to another connection point
  54033. * @param connectionPoint defines the other connection point
  54034. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  54035. * @returns the current connection point
  54036. */
  54037. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  54038. /**
  54039. * Disconnect this point from one of his endpoint
  54040. * @param endpoint defines the other connection point
  54041. * @returns the current connection point
  54042. */
  54043. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54044. /**
  54045. * Serializes this point in a JSON representation
  54046. * @returns the serialized point object
  54047. */
  54048. serialize(): any;
  54049. }
  54050. }
  54051. declare module BABYLON {
  54052. /**
  54053. * Block used to add support for vertex skinning (bones)
  54054. */
  54055. export class BonesBlock extends NodeMaterialBlock {
  54056. /**
  54057. * Creates a new BonesBlock
  54058. * @param name defines the block name
  54059. */
  54060. constructor(name: string);
  54061. /**
  54062. * Initialize the block and prepare the context for build
  54063. * @param state defines the state that will be used for the build
  54064. */
  54065. initialize(state: NodeMaterialBuildState): void;
  54066. /**
  54067. * Gets the current class name
  54068. * @returns the class name
  54069. */
  54070. getClassName(): string;
  54071. /**
  54072. * Gets the matrix indices input component
  54073. */
  54074. readonly matricesIndices: NodeMaterialConnectionPoint;
  54075. /**
  54076. * Gets the matrix weights input component
  54077. */
  54078. readonly matricesWeights: NodeMaterialConnectionPoint;
  54079. /**
  54080. * Gets the extra matrix indices input component
  54081. */
  54082. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54083. /**
  54084. * Gets the extra matrix weights input component
  54085. */
  54086. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54087. /**
  54088. * Gets the world input component
  54089. */
  54090. readonly world: NodeMaterialConnectionPoint;
  54091. /**
  54092. * Gets the output component
  54093. */
  54094. readonly output: NodeMaterialConnectionPoint;
  54095. autoConfigure(material: NodeMaterial): void;
  54096. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54099. protected _buildBlock(state: NodeMaterialBuildState): this;
  54100. }
  54101. }
  54102. declare module BABYLON {
  54103. /**
  54104. * Block used to add support for instances
  54105. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54106. */
  54107. export class InstancesBlock extends NodeMaterialBlock {
  54108. /**
  54109. * Creates a new InstancesBlock
  54110. * @param name defines the block name
  54111. */
  54112. constructor(name: string);
  54113. /**
  54114. * Gets the current class name
  54115. * @returns the class name
  54116. */
  54117. getClassName(): string;
  54118. /**
  54119. * Gets the first world row input component
  54120. */
  54121. readonly world0: NodeMaterialConnectionPoint;
  54122. /**
  54123. * Gets the second world row input component
  54124. */
  54125. readonly world1: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the third world row input component
  54128. */
  54129. readonly world2: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the forth world row input component
  54132. */
  54133. readonly world3: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the world input component
  54136. */
  54137. readonly world: NodeMaterialConnectionPoint;
  54138. /**
  54139. * Gets the output component
  54140. */
  54141. readonly output: NodeMaterialConnectionPoint;
  54142. autoConfigure(material: NodeMaterial): void;
  54143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54144. protected _buildBlock(state: NodeMaterialBuildState): this;
  54145. }
  54146. }
  54147. declare module BABYLON {
  54148. /**
  54149. * Block used to add morph targets support to vertex shader
  54150. */
  54151. export class MorphTargetsBlock extends NodeMaterialBlock {
  54152. private _repeatableContentAnchor;
  54153. private _repeatebleContentGenerated;
  54154. /**
  54155. * Create a new MorphTargetsBlock
  54156. * @param name defines the block name
  54157. */
  54158. constructor(name: string);
  54159. /**
  54160. * Gets the current class name
  54161. * @returns the class name
  54162. */
  54163. getClassName(): string;
  54164. /**
  54165. * Gets the position input component
  54166. */
  54167. readonly position: NodeMaterialConnectionPoint;
  54168. /**
  54169. * Gets the normal input component
  54170. */
  54171. readonly normal: NodeMaterialConnectionPoint;
  54172. /**
  54173. * Gets the tangent input component
  54174. */
  54175. readonly tangent: NodeMaterialConnectionPoint;
  54176. /**
  54177. * Gets the tangent input component
  54178. */
  54179. readonly uv: NodeMaterialConnectionPoint;
  54180. /**
  54181. * Gets the position output component
  54182. */
  54183. readonly positionOutput: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the normal output component
  54186. */
  54187. readonly normalOutput: NodeMaterialConnectionPoint;
  54188. /**
  54189. * Gets the tangent output component
  54190. */
  54191. readonly tangentOutput: NodeMaterialConnectionPoint;
  54192. /**
  54193. * Gets the tangent output component
  54194. */
  54195. readonly uvOutput: NodeMaterialConnectionPoint;
  54196. initialize(state: NodeMaterialBuildState): void;
  54197. autoConfigure(material: NodeMaterial): void;
  54198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54200. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54201. protected _buildBlock(state: NodeMaterialBuildState): this;
  54202. }
  54203. }
  54204. declare module BABYLON {
  54205. /**
  54206. * Block used to get data information from a light
  54207. */
  54208. export class LightInformationBlock extends NodeMaterialBlock {
  54209. private _lightDataUniformName;
  54210. private _lightColorUniformName;
  54211. private _lightTypeDefineName;
  54212. /**
  54213. * Gets or sets the light associated with this block
  54214. */
  54215. light: Nullable<Light>;
  54216. /**
  54217. * Creates a new LightInformationBlock
  54218. * @param name defines the block name
  54219. */
  54220. constructor(name: string);
  54221. /**
  54222. * Gets the current class name
  54223. * @returns the class name
  54224. */
  54225. getClassName(): string;
  54226. /**
  54227. * Gets the world position input component
  54228. */
  54229. readonly worldPosition: NodeMaterialConnectionPoint;
  54230. /**
  54231. * Gets the direction output component
  54232. */
  54233. readonly direction: NodeMaterialConnectionPoint;
  54234. /**
  54235. * Gets the direction output component
  54236. */
  54237. readonly color: NodeMaterialConnectionPoint;
  54238. /**
  54239. * Gets the direction output component
  54240. */
  54241. readonly intensity: NodeMaterialConnectionPoint;
  54242. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54244. protected _buildBlock(state: NodeMaterialBuildState): this;
  54245. serialize(): any;
  54246. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54247. }
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * Block used to add image processing support to fragment shader
  54252. */
  54253. export class ImageProcessingBlock extends NodeMaterialBlock {
  54254. /**
  54255. * Create a new ImageProcessingBlock
  54256. * @param name defines the block name
  54257. */
  54258. constructor(name: string);
  54259. /**
  54260. * Gets the current class name
  54261. * @returns the class name
  54262. */
  54263. getClassName(): string;
  54264. /**
  54265. * Gets the color input component
  54266. */
  54267. readonly color: NodeMaterialConnectionPoint;
  54268. /**
  54269. * Gets the output component
  54270. */
  54271. readonly output: NodeMaterialConnectionPoint;
  54272. /**
  54273. * Initialize the block and prepare the context for build
  54274. * @param state defines the state that will be used for the build
  54275. */
  54276. initialize(state: NodeMaterialBuildState): void;
  54277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54280. protected _buildBlock(state: NodeMaterialBuildState): this;
  54281. }
  54282. }
  54283. declare module BABYLON {
  54284. /**
  54285. * Block used to pertub normals based on a normal map
  54286. */
  54287. export class PerturbNormalBlock extends NodeMaterialBlock {
  54288. private _tangentSpaceParameterName;
  54289. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54290. invertX: boolean;
  54291. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54292. invertY: boolean;
  54293. /**
  54294. * Create a new PerturbNormalBlock
  54295. * @param name defines the block name
  54296. */
  54297. constructor(name: string);
  54298. /**
  54299. * Gets the current class name
  54300. * @returns the class name
  54301. */
  54302. getClassName(): string;
  54303. /**
  54304. * Gets the world position input component
  54305. */
  54306. readonly worldPosition: NodeMaterialConnectionPoint;
  54307. /**
  54308. * Gets the world normal input component
  54309. */
  54310. readonly worldNormal: NodeMaterialConnectionPoint;
  54311. /**
  54312. * Gets the uv input component
  54313. */
  54314. readonly uv: NodeMaterialConnectionPoint;
  54315. /**
  54316. * Gets the normal map color input component
  54317. */
  54318. readonly normalMapColor: NodeMaterialConnectionPoint;
  54319. /**
  54320. * Gets the strength input component
  54321. */
  54322. readonly strength: NodeMaterialConnectionPoint;
  54323. /**
  54324. * Gets the output component
  54325. */
  54326. readonly output: NodeMaterialConnectionPoint;
  54327. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54329. autoConfigure(material: NodeMaterial): void;
  54330. protected _buildBlock(state: NodeMaterialBuildState): this;
  54331. protected _dumpPropertiesCode(): string;
  54332. serialize(): any;
  54333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54334. }
  54335. }
  54336. declare module BABYLON {
  54337. /**
  54338. * Block used to discard a pixel if a value is smaller than a cutoff
  54339. */
  54340. export class DiscardBlock extends NodeMaterialBlock {
  54341. /**
  54342. * Create a new DiscardBlock
  54343. * @param name defines the block name
  54344. */
  54345. constructor(name: string);
  54346. /**
  54347. * Gets the current class name
  54348. * @returns the class name
  54349. */
  54350. getClassName(): string;
  54351. /**
  54352. * Gets the color input component
  54353. */
  54354. readonly value: NodeMaterialConnectionPoint;
  54355. /**
  54356. * Gets the cutoff input component
  54357. */
  54358. readonly cutoff: NodeMaterialConnectionPoint;
  54359. protected _buildBlock(state: NodeMaterialBuildState): this;
  54360. }
  54361. }
  54362. declare module BABYLON {
  54363. /**
  54364. * Block used to add support for scene fog
  54365. */
  54366. export class FogBlock extends NodeMaterialBlock {
  54367. private _fogDistanceName;
  54368. private _fogParameters;
  54369. /**
  54370. * Create a new FogBlock
  54371. * @param name defines the block name
  54372. */
  54373. constructor(name: string);
  54374. /**
  54375. * Gets the current class name
  54376. * @returns the class name
  54377. */
  54378. getClassName(): string;
  54379. /**
  54380. * Gets the world position input component
  54381. */
  54382. readonly worldPosition: NodeMaterialConnectionPoint;
  54383. /**
  54384. * Gets the view input component
  54385. */
  54386. readonly view: NodeMaterialConnectionPoint;
  54387. /**
  54388. * Gets the color input component
  54389. */
  54390. readonly input: NodeMaterialConnectionPoint;
  54391. /**
  54392. * Gets the fog color input component
  54393. */
  54394. readonly fogColor: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the output component
  54397. */
  54398. readonly output: NodeMaterialConnectionPoint;
  54399. autoConfigure(material: NodeMaterial): void;
  54400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54401. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54402. protected _buildBlock(state: NodeMaterialBuildState): this;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Block used to add light in the fragment shader
  54408. */
  54409. export class LightBlock extends NodeMaterialBlock {
  54410. private _lightId;
  54411. /**
  54412. * Gets or sets the light associated with this block
  54413. */
  54414. light: Nullable<Light>;
  54415. /**
  54416. * Create a new LightBlock
  54417. * @param name defines the block name
  54418. */
  54419. constructor(name: string);
  54420. /**
  54421. * Gets the current class name
  54422. * @returns the class name
  54423. */
  54424. getClassName(): string;
  54425. /**
  54426. * Gets the world position input component
  54427. */
  54428. readonly worldPosition: NodeMaterialConnectionPoint;
  54429. /**
  54430. * Gets the world normal input component
  54431. */
  54432. readonly worldNormal: NodeMaterialConnectionPoint;
  54433. /**
  54434. * Gets the camera (or eye) position component
  54435. */
  54436. readonly cameraPosition: NodeMaterialConnectionPoint;
  54437. /**
  54438. * Gets the glossiness component
  54439. */
  54440. readonly glossiness: NodeMaterialConnectionPoint;
  54441. /**
  54442. * Gets the glossinness power component
  54443. */
  54444. readonly glossPower: NodeMaterialConnectionPoint;
  54445. /**
  54446. * Gets the diffuse color component
  54447. */
  54448. readonly diffuseColor: NodeMaterialConnectionPoint;
  54449. /**
  54450. * Gets the specular color component
  54451. */
  54452. readonly specularColor: NodeMaterialConnectionPoint;
  54453. /**
  54454. * Gets the diffuse output component
  54455. */
  54456. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54457. /**
  54458. * Gets the specular output component
  54459. */
  54460. readonly specularOutput: NodeMaterialConnectionPoint;
  54461. autoConfigure(material: NodeMaterial): void;
  54462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54463. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  54464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54465. private _injectVertexCode;
  54466. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54467. serialize(): any;
  54468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54469. }
  54470. }
  54471. declare module BABYLON {
  54472. /**
  54473. * Block used to multiply 2 values
  54474. */
  54475. export class MultiplyBlock extends NodeMaterialBlock {
  54476. /**
  54477. * Creates a new MultiplyBlock
  54478. * @param name defines the block name
  54479. */
  54480. constructor(name: string);
  54481. /**
  54482. * Gets the current class name
  54483. * @returns the class name
  54484. */
  54485. getClassName(): string;
  54486. /**
  54487. * Gets the left operand input component
  54488. */
  54489. readonly left: NodeMaterialConnectionPoint;
  54490. /**
  54491. * Gets the right operand input component
  54492. */
  54493. readonly right: NodeMaterialConnectionPoint;
  54494. /**
  54495. * Gets the output component
  54496. */
  54497. readonly output: NodeMaterialConnectionPoint;
  54498. protected _buildBlock(state: NodeMaterialBuildState): this;
  54499. }
  54500. }
  54501. declare module BABYLON {
  54502. /**
  54503. * Block used to add 2 vectors
  54504. */
  54505. export class AddBlock extends NodeMaterialBlock {
  54506. /**
  54507. * Creates a new AddBlock
  54508. * @param name defines the block name
  54509. */
  54510. constructor(name: string);
  54511. /**
  54512. * Gets the current class name
  54513. * @returns the class name
  54514. */
  54515. getClassName(): string;
  54516. /**
  54517. * Gets the left operand input component
  54518. */
  54519. readonly left: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the right operand input component
  54522. */
  54523. readonly right: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the output component
  54526. */
  54527. readonly output: NodeMaterialConnectionPoint;
  54528. protected _buildBlock(state: NodeMaterialBuildState): this;
  54529. }
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * Block used to scale a vector by a float
  54534. */
  54535. export class ScaleBlock extends NodeMaterialBlock {
  54536. /**
  54537. * Creates a new ScaleBlock
  54538. * @param name defines the block name
  54539. */
  54540. constructor(name: string);
  54541. /**
  54542. * Gets the current class name
  54543. * @returns the class name
  54544. */
  54545. getClassName(): string;
  54546. /**
  54547. * Gets the input component
  54548. */
  54549. readonly input: NodeMaterialConnectionPoint;
  54550. /**
  54551. * Gets the factor input component
  54552. */
  54553. readonly factor: NodeMaterialConnectionPoint;
  54554. /**
  54555. * Gets the output component
  54556. */
  54557. readonly output: NodeMaterialConnectionPoint;
  54558. protected _buildBlock(state: NodeMaterialBuildState): this;
  54559. }
  54560. }
  54561. declare module BABYLON {
  54562. /**
  54563. * Block used to clamp a float
  54564. */
  54565. export class ClampBlock extends NodeMaterialBlock {
  54566. /** Gets or sets the minimum range */
  54567. minimum: number;
  54568. /** Gets or sets the maximum range */
  54569. maximum: number;
  54570. /**
  54571. * Creates a new ClampBlock
  54572. * @param name defines the block name
  54573. */
  54574. constructor(name: string);
  54575. /**
  54576. * Gets the current class name
  54577. * @returns the class name
  54578. */
  54579. getClassName(): string;
  54580. /**
  54581. * Gets the value input component
  54582. */
  54583. readonly value: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the output component
  54586. */
  54587. readonly output: NodeMaterialConnectionPoint;
  54588. protected _buildBlock(state: NodeMaterialBuildState): this;
  54589. protected _dumpPropertiesCode(): string;
  54590. serialize(): any;
  54591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54592. }
  54593. }
  54594. declare module BABYLON {
  54595. /**
  54596. * Block used to apply a cross product between 2 vectors
  54597. */
  54598. export class CrossBlock extends NodeMaterialBlock {
  54599. /**
  54600. * Creates a new CrossBlock
  54601. * @param name defines the block name
  54602. */
  54603. constructor(name: string);
  54604. /**
  54605. * Gets the current class name
  54606. * @returns the class name
  54607. */
  54608. getClassName(): string;
  54609. /**
  54610. * Gets the left operand input component
  54611. */
  54612. readonly left: NodeMaterialConnectionPoint;
  54613. /**
  54614. * Gets the right operand input component
  54615. */
  54616. readonly right: NodeMaterialConnectionPoint;
  54617. /**
  54618. * Gets the output component
  54619. */
  54620. readonly output: NodeMaterialConnectionPoint;
  54621. protected _buildBlock(state: NodeMaterialBuildState): this;
  54622. }
  54623. }
  54624. declare module BABYLON {
  54625. /**
  54626. * Block used to apply a dot product between 2 vectors
  54627. */
  54628. export class DotBlock extends NodeMaterialBlock {
  54629. /**
  54630. * Creates a new DotBlock
  54631. * @param name defines the block name
  54632. */
  54633. constructor(name: string);
  54634. /**
  54635. * Gets the current class name
  54636. * @returns the class name
  54637. */
  54638. getClassName(): string;
  54639. /**
  54640. * Gets the left operand input component
  54641. */
  54642. readonly left: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the right operand input component
  54645. */
  54646. readonly right: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the output component
  54649. */
  54650. readonly output: NodeMaterialConnectionPoint;
  54651. protected _buildBlock(state: NodeMaterialBuildState): this;
  54652. }
  54653. }
  54654. declare module BABYLON {
  54655. /**
  54656. * Block used to remap a float from a range to a new one
  54657. */
  54658. export class RemapBlock extends NodeMaterialBlock {
  54659. /**
  54660. * Gets or sets the source range
  54661. */
  54662. sourceRange: Vector2;
  54663. /**
  54664. * Gets or sets the target range
  54665. */
  54666. targetRange: Vector2;
  54667. /**
  54668. * Creates a new RemapBlock
  54669. * @param name defines the block name
  54670. */
  54671. constructor(name: string);
  54672. /**
  54673. * Gets the current class name
  54674. * @returns the class name
  54675. */
  54676. getClassName(): string;
  54677. /**
  54678. * Gets the input component
  54679. */
  54680. readonly input: NodeMaterialConnectionPoint;
  54681. /**
  54682. * Gets the source min input component
  54683. */
  54684. readonly sourceMin: NodeMaterialConnectionPoint;
  54685. /**
  54686. * Gets the source max input component
  54687. */
  54688. readonly sourceMax: NodeMaterialConnectionPoint;
  54689. /**
  54690. * Gets the target min input component
  54691. */
  54692. readonly targetMin: NodeMaterialConnectionPoint;
  54693. /**
  54694. * Gets the target max input component
  54695. */
  54696. readonly targetMax: NodeMaterialConnectionPoint;
  54697. /**
  54698. * Gets the output component
  54699. */
  54700. readonly output: NodeMaterialConnectionPoint;
  54701. protected _buildBlock(state: NodeMaterialBuildState): this;
  54702. protected _dumpPropertiesCode(): string;
  54703. serialize(): any;
  54704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54705. }
  54706. }
  54707. declare module BABYLON {
  54708. /**
  54709. * Block used to normalize a vector
  54710. */
  54711. export class NormalizeBlock extends NodeMaterialBlock {
  54712. /**
  54713. * Creates a new NormalizeBlock
  54714. * @param name defines the block name
  54715. */
  54716. constructor(name: string);
  54717. /**
  54718. * Gets the current class name
  54719. * @returns the class name
  54720. */
  54721. getClassName(): string;
  54722. /**
  54723. * Gets the input component
  54724. */
  54725. readonly input: NodeMaterialConnectionPoint;
  54726. /**
  54727. * Gets the output component
  54728. */
  54729. readonly output: NodeMaterialConnectionPoint;
  54730. protected _buildBlock(state: NodeMaterialBuildState): this;
  54731. }
  54732. }
  54733. declare module BABYLON {
  54734. /**
  54735. * Operations supported by the Trigonometry block
  54736. */
  54737. export enum TrigonometryBlockOperations {
  54738. /** Cos */
  54739. Cos = 0,
  54740. /** Sin */
  54741. Sin = 1,
  54742. /** Abs */
  54743. Abs = 2,
  54744. /** Exp */
  54745. Exp = 3,
  54746. /** Exp2 */
  54747. Exp2 = 4,
  54748. /** Round */
  54749. Round = 5,
  54750. /** Floor */
  54751. Floor = 6,
  54752. /** Ceiling */
  54753. Ceiling = 7,
  54754. /** Square root */
  54755. Sqrt = 8,
  54756. /** Log */
  54757. Log = 9,
  54758. /** Tangent */
  54759. Tan = 10,
  54760. /** Arc tangent */
  54761. ArcTan = 11,
  54762. /** Arc cosinus */
  54763. ArcCos = 12,
  54764. /** Arc sinus */
  54765. ArcSin = 13,
  54766. /** Fraction */
  54767. Fract = 14,
  54768. /** Sign */
  54769. Sign = 15,
  54770. /** To radians (from degrees) */
  54771. Radians = 16,
  54772. /** To degrees (from radians) */
  54773. Degrees = 17
  54774. }
  54775. /**
  54776. * Block used to apply trigonometry operation to floats
  54777. */
  54778. export class TrigonometryBlock extends NodeMaterialBlock {
  54779. /**
  54780. * Gets or sets the operation applied by the block
  54781. */
  54782. operation: TrigonometryBlockOperations;
  54783. /**
  54784. * Creates a new TrigonometryBlock
  54785. * @param name defines the block name
  54786. */
  54787. constructor(name: string);
  54788. /**
  54789. * Gets the current class name
  54790. * @returns the class name
  54791. */
  54792. getClassName(): string;
  54793. /**
  54794. * Gets the input component
  54795. */
  54796. readonly input: NodeMaterialConnectionPoint;
  54797. /**
  54798. * Gets the output component
  54799. */
  54800. readonly output: NodeMaterialConnectionPoint;
  54801. protected _buildBlock(state: NodeMaterialBuildState): this;
  54802. serialize(): any;
  54803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54804. }
  54805. }
  54806. declare module BABYLON {
  54807. /**
  54808. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54809. */
  54810. export class ColorMergerBlock extends NodeMaterialBlock {
  54811. /**
  54812. * Create a new ColorMergerBlock
  54813. * @param name defines the block name
  54814. */
  54815. constructor(name: string);
  54816. /**
  54817. * Gets the current class name
  54818. * @returns the class name
  54819. */
  54820. getClassName(): string;
  54821. /**
  54822. * Gets the r component (input)
  54823. */
  54824. readonly r: NodeMaterialConnectionPoint;
  54825. /**
  54826. * Gets the g component (input)
  54827. */
  54828. readonly g: NodeMaterialConnectionPoint;
  54829. /**
  54830. * Gets the b component (input)
  54831. */
  54832. readonly b: NodeMaterialConnectionPoint;
  54833. /**
  54834. * Gets the a component (input)
  54835. */
  54836. readonly a: NodeMaterialConnectionPoint;
  54837. /**
  54838. * Gets the rgba component (output)
  54839. */
  54840. readonly rgba: NodeMaterialConnectionPoint;
  54841. /**
  54842. * Gets the rgb component (output)
  54843. */
  54844. readonly rgb: NodeMaterialConnectionPoint;
  54845. protected _buildBlock(state: NodeMaterialBuildState): this;
  54846. }
  54847. }
  54848. declare module BABYLON {
  54849. /**
  54850. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54851. */
  54852. export class VectorMergerBlock extends NodeMaterialBlock {
  54853. /**
  54854. * Create a new VectorMergerBlock
  54855. * @param name defines the block name
  54856. */
  54857. constructor(name: string);
  54858. /**
  54859. * Gets the current class name
  54860. * @returns the class name
  54861. */
  54862. getClassName(): string;
  54863. /**
  54864. * Gets the x component (input)
  54865. */
  54866. readonly x: NodeMaterialConnectionPoint;
  54867. /**
  54868. * Gets the y component (input)
  54869. */
  54870. readonly y: NodeMaterialConnectionPoint;
  54871. /**
  54872. * Gets the z component (input)
  54873. */
  54874. readonly z: NodeMaterialConnectionPoint;
  54875. /**
  54876. * Gets the w component (input)
  54877. */
  54878. readonly w: NodeMaterialConnectionPoint;
  54879. /**
  54880. * Gets the xyzw component (output)
  54881. */
  54882. readonly xyzw: NodeMaterialConnectionPoint;
  54883. /**
  54884. * Gets the xyz component (output)
  54885. */
  54886. readonly xyz: NodeMaterialConnectionPoint;
  54887. /**
  54888. * Gets the xy component (output)
  54889. */
  54890. readonly xy: NodeMaterialConnectionPoint;
  54891. protected _buildBlock(state: NodeMaterialBuildState): this;
  54892. }
  54893. }
  54894. declare module BABYLON {
  54895. /**
  54896. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54897. */
  54898. export class ColorSplitterBlock extends NodeMaterialBlock {
  54899. /**
  54900. * Create a new ColorSplitterBlock
  54901. * @param name defines the block name
  54902. */
  54903. constructor(name: string);
  54904. /**
  54905. * Gets the current class name
  54906. * @returns the class name
  54907. */
  54908. getClassName(): string;
  54909. /**
  54910. * Gets the rgba component (input)
  54911. */
  54912. readonly rgba: NodeMaterialConnectionPoint;
  54913. /**
  54914. * Gets the rgb component (input)
  54915. */
  54916. readonly rgbIn: NodeMaterialConnectionPoint;
  54917. /**
  54918. * Gets the rgb component (output)
  54919. */
  54920. readonly rgbOut: NodeMaterialConnectionPoint;
  54921. /**
  54922. * Gets the r component (output)
  54923. */
  54924. readonly r: NodeMaterialConnectionPoint;
  54925. /**
  54926. * Gets the g component (output)
  54927. */
  54928. readonly g: NodeMaterialConnectionPoint;
  54929. /**
  54930. * Gets the b component (output)
  54931. */
  54932. readonly b: NodeMaterialConnectionPoint;
  54933. /**
  54934. * Gets the a component (output)
  54935. */
  54936. readonly a: NodeMaterialConnectionPoint;
  54937. protected _inputRename(name: string): string;
  54938. protected _outputRename(name: string): string;
  54939. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54940. }
  54941. }
  54942. declare module BABYLON {
  54943. /**
  54944. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54945. */
  54946. export class VectorSplitterBlock extends NodeMaterialBlock {
  54947. /**
  54948. * Create a new VectorSplitterBlock
  54949. * @param name defines the block name
  54950. */
  54951. constructor(name: string);
  54952. /**
  54953. * Gets the current class name
  54954. * @returns the class name
  54955. */
  54956. getClassName(): string;
  54957. /**
  54958. * Gets the xyzw component (input)
  54959. */
  54960. readonly xyzw: NodeMaterialConnectionPoint;
  54961. /**
  54962. * Gets the xyz component (input)
  54963. */
  54964. readonly xyzIn: NodeMaterialConnectionPoint;
  54965. /**
  54966. * Gets the xy component (input)
  54967. */
  54968. readonly xyIn: NodeMaterialConnectionPoint;
  54969. /**
  54970. * Gets the xyz component (output)
  54971. */
  54972. readonly xyzOut: NodeMaterialConnectionPoint;
  54973. /**
  54974. * Gets the xy component (output)
  54975. */
  54976. readonly xyOut: NodeMaterialConnectionPoint;
  54977. /**
  54978. * Gets the x component (output)
  54979. */
  54980. readonly x: NodeMaterialConnectionPoint;
  54981. /**
  54982. * Gets the y component (output)
  54983. */
  54984. readonly y: NodeMaterialConnectionPoint;
  54985. /**
  54986. * Gets the z component (output)
  54987. */
  54988. readonly z: NodeMaterialConnectionPoint;
  54989. /**
  54990. * Gets the w component (output)
  54991. */
  54992. readonly w: NodeMaterialConnectionPoint;
  54993. protected _inputRename(name: string): string;
  54994. protected _outputRename(name: string): string;
  54995. protected _buildBlock(state: NodeMaterialBuildState): this;
  54996. }
  54997. }
  54998. declare module BABYLON {
  54999. /**
  55000. * Block used to lerp between 2 values
  55001. */
  55002. export class LerpBlock extends NodeMaterialBlock {
  55003. /**
  55004. * Creates a new LerpBlock
  55005. * @param name defines the block name
  55006. */
  55007. constructor(name: string);
  55008. /**
  55009. * Gets the current class name
  55010. * @returns the class name
  55011. */
  55012. getClassName(): string;
  55013. /**
  55014. * Gets the left operand input component
  55015. */
  55016. readonly left: NodeMaterialConnectionPoint;
  55017. /**
  55018. * Gets the right operand input component
  55019. */
  55020. readonly right: NodeMaterialConnectionPoint;
  55021. /**
  55022. * Gets the gradient operand input component
  55023. */
  55024. readonly gradient: NodeMaterialConnectionPoint;
  55025. /**
  55026. * Gets the output component
  55027. */
  55028. readonly output: NodeMaterialConnectionPoint;
  55029. protected _buildBlock(state: NodeMaterialBuildState): this;
  55030. }
  55031. }
  55032. declare module BABYLON {
  55033. /**
  55034. * Block used to divide 2 vectors
  55035. */
  55036. export class DivideBlock extends NodeMaterialBlock {
  55037. /**
  55038. * Creates a new DivideBlock
  55039. * @param name defines the block name
  55040. */
  55041. constructor(name: string);
  55042. /**
  55043. * Gets the current class name
  55044. * @returns the class name
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Gets the left operand input component
  55049. */
  55050. readonly left: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the right operand input component
  55053. */
  55054. readonly right: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the output component
  55057. */
  55058. readonly output: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Block used to subtract 2 vectors
  55065. */
  55066. export class SubtractBlock extends NodeMaterialBlock {
  55067. /**
  55068. * Creates a new SubtractBlock
  55069. * @param name defines the block name
  55070. */
  55071. constructor(name: string);
  55072. /**
  55073. * Gets the current class name
  55074. * @returns the class name
  55075. */
  55076. getClassName(): string;
  55077. /**
  55078. * Gets the left operand input component
  55079. */
  55080. readonly left: NodeMaterialConnectionPoint;
  55081. /**
  55082. * Gets the right operand input component
  55083. */
  55084. readonly right: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the output component
  55087. */
  55088. readonly output: NodeMaterialConnectionPoint;
  55089. protected _buildBlock(state: NodeMaterialBuildState): this;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /**
  55094. * Block used to step a value
  55095. */
  55096. export class StepBlock extends NodeMaterialBlock {
  55097. /**
  55098. * Creates a new StepBlock
  55099. * @param name defines the block name
  55100. */
  55101. constructor(name: string);
  55102. /**
  55103. * Gets the current class name
  55104. * @returns the class name
  55105. */
  55106. getClassName(): string;
  55107. /**
  55108. * Gets the value operand input component
  55109. */
  55110. readonly value: NodeMaterialConnectionPoint;
  55111. /**
  55112. * Gets the edge operand input component
  55113. */
  55114. readonly edge: NodeMaterialConnectionPoint;
  55115. /**
  55116. * Gets the output component
  55117. */
  55118. readonly output: NodeMaterialConnectionPoint;
  55119. protected _buildBlock(state: NodeMaterialBuildState): this;
  55120. }
  55121. }
  55122. declare module BABYLON {
  55123. /**
  55124. * Block used to get the opposite (1 - x) of a value
  55125. */
  55126. export class OneMinusBlock extends NodeMaterialBlock {
  55127. /**
  55128. * Creates a new OneMinusBlock
  55129. * @param name defines the block name
  55130. */
  55131. constructor(name: string);
  55132. /**
  55133. * Gets the current class name
  55134. * @returns the class name
  55135. */
  55136. getClassName(): string;
  55137. /**
  55138. * Gets the input component
  55139. */
  55140. readonly input: NodeMaterialConnectionPoint;
  55141. /**
  55142. * Gets the output component
  55143. */
  55144. readonly output: NodeMaterialConnectionPoint;
  55145. protected _buildBlock(state: NodeMaterialBuildState): this;
  55146. }
  55147. }
  55148. declare module BABYLON {
  55149. /**
  55150. * Block used to get the view direction
  55151. */
  55152. export class ViewDirectionBlock extends NodeMaterialBlock {
  55153. /**
  55154. * Creates a new ViewDirectionBlock
  55155. * @param name defines the block name
  55156. */
  55157. constructor(name: string);
  55158. /**
  55159. * Gets the current class name
  55160. * @returns the class name
  55161. */
  55162. getClassName(): string;
  55163. /**
  55164. * Gets the world position component
  55165. */
  55166. readonly worldPosition: NodeMaterialConnectionPoint;
  55167. /**
  55168. * Gets the camera position component
  55169. */
  55170. readonly cameraPosition: NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the output component
  55173. */
  55174. readonly output: NodeMaterialConnectionPoint;
  55175. autoConfigure(material: NodeMaterial): void;
  55176. protected _buildBlock(state: NodeMaterialBuildState): this;
  55177. }
  55178. }
  55179. declare module BABYLON {
  55180. /**
  55181. * Block used to compute fresnel value
  55182. */
  55183. export class FresnelBlock extends NodeMaterialBlock {
  55184. /**
  55185. * Create a new FresnelBlock
  55186. * @param name defines the block name
  55187. */
  55188. constructor(name: string);
  55189. /**
  55190. * Gets the current class name
  55191. * @returns the class name
  55192. */
  55193. getClassName(): string;
  55194. /**
  55195. * Gets the world normal input component
  55196. */
  55197. readonly worldNormal: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the view direction input component
  55200. */
  55201. readonly viewDirection: NodeMaterialConnectionPoint;
  55202. /**
  55203. * Gets the bias input component
  55204. */
  55205. readonly bias: NodeMaterialConnectionPoint;
  55206. /**
  55207. * Gets the camera (or eye) position component
  55208. */
  55209. readonly power: NodeMaterialConnectionPoint;
  55210. /**
  55211. * Gets the fresnel output component
  55212. */
  55213. readonly fresnel: NodeMaterialConnectionPoint;
  55214. autoConfigure(material: NodeMaterial): void;
  55215. protected _buildBlock(state: NodeMaterialBuildState): this;
  55216. }
  55217. }
  55218. declare module BABYLON {
  55219. /**
  55220. * Block used to get the max of 2 values
  55221. */
  55222. export class MaxBlock extends NodeMaterialBlock {
  55223. /**
  55224. * Creates a new MaxBlock
  55225. * @param name defines the block name
  55226. */
  55227. constructor(name: string);
  55228. /**
  55229. * Gets the current class name
  55230. * @returns the class name
  55231. */
  55232. getClassName(): string;
  55233. /**
  55234. * Gets the left operand input component
  55235. */
  55236. readonly left: NodeMaterialConnectionPoint;
  55237. /**
  55238. * Gets the right operand input component
  55239. */
  55240. readonly right: NodeMaterialConnectionPoint;
  55241. /**
  55242. * Gets the output component
  55243. */
  55244. readonly output: NodeMaterialConnectionPoint;
  55245. protected _buildBlock(state: NodeMaterialBuildState): this;
  55246. }
  55247. }
  55248. declare module BABYLON {
  55249. /**
  55250. * Block used to get the min of 2 values
  55251. */
  55252. export class MinBlock extends NodeMaterialBlock {
  55253. /**
  55254. * Creates a new MinBlock
  55255. * @param name defines the block name
  55256. */
  55257. constructor(name: string);
  55258. /**
  55259. * Gets the current class name
  55260. * @returns the class name
  55261. */
  55262. getClassName(): string;
  55263. /**
  55264. * Gets the left operand input component
  55265. */
  55266. readonly left: NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the right operand input component
  55269. */
  55270. readonly right: NodeMaterialConnectionPoint;
  55271. /**
  55272. * Gets the output component
  55273. */
  55274. readonly output: NodeMaterialConnectionPoint;
  55275. protected _buildBlock(state: NodeMaterialBuildState): this;
  55276. }
  55277. }
  55278. declare module BABYLON {
  55279. /**
  55280. * Block used to get the distance between 2 values
  55281. */
  55282. export class DistanceBlock extends NodeMaterialBlock {
  55283. /**
  55284. * Creates a new DistanceBlock
  55285. * @param name defines the block name
  55286. */
  55287. constructor(name: string);
  55288. /**
  55289. * Gets the current class name
  55290. * @returns the class name
  55291. */
  55292. getClassName(): string;
  55293. /**
  55294. * Gets the left operand input component
  55295. */
  55296. readonly left: NodeMaterialConnectionPoint;
  55297. /**
  55298. * Gets the right operand input component
  55299. */
  55300. readonly right: NodeMaterialConnectionPoint;
  55301. /**
  55302. * Gets the output component
  55303. */
  55304. readonly output: NodeMaterialConnectionPoint;
  55305. protected _buildBlock(state: NodeMaterialBuildState): this;
  55306. }
  55307. }
  55308. declare module BABYLON {
  55309. /**
  55310. * Block used to get the length of a vector
  55311. */
  55312. export class LengthBlock extends NodeMaterialBlock {
  55313. /**
  55314. * Creates a new LengthBlock
  55315. * @param name defines the block name
  55316. */
  55317. constructor(name: string);
  55318. /**
  55319. * Gets the current class name
  55320. * @returns the class name
  55321. */
  55322. getClassName(): string;
  55323. /**
  55324. * Gets the value input component
  55325. */
  55326. readonly value: NodeMaterialConnectionPoint;
  55327. /**
  55328. * Gets the output component
  55329. */
  55330. readonly output: NodeMaterialConnectionPoint;
  55331. protected _buildBlock(state: NodeMaterialBuildState): this;
  55332. }
  55333. }
  55334. declare module BABYLON {
  55335. /**
  55336. * Block used to get negative version of a value (i.e. x * -1)
  55337. */
  55338. export class NegateBlock extends NodeMaterialBlock {
  55339. /**
  55340. * Creates a new NegateBlock
  55341. * @param name defines the block name
  55342. */
  55343. constructor(name: string);
  55344. /**
  55345. * Gets the current class name
  55346. * @returns the class name
  55347. */
  55348. getClassName(): string;
  55349. /**
  55350. * Gets the value input component
  55351. */
  55352. readonly value: NodeMaterialConnectionPoint;
  55353. /**
  55354. * Gets the output component
  55355. */
  55356. readonly output: NodeMaterialConnectionPoint;
  55357. protected _buildBlock(state: NodeMaterialBuildState): this;
  55358. }
  55359. }
  55360. declare module BABYLON {
  55361. /**
  55362. * Block used to get the value of the first parameter raised to the power of the second
  55363. */
  55364. export class PowBlock extends NodeMaterialBlock {
  55365. /**
  55366. * Creates a new PowBlock
  55367. * @param name defines the block name
  55368. */
  55369. constructor(name: string);
  55370. /**
  55371. * Gets the current class name
  55372. * @returns the class name
  55373. */
  55374. getClassName(): string;
  55375. /**
  55376. * Gets the value operand input component
  55377. */
  55378. readonly value: NodeMaterialConnectionPoint;
  55379. /**
  55380. * Gets the power operand input component
  55381. */
  55382. readonly power: NodeMaterialConnectionPoint;
  55383. /**
  55384. * Gets the output component
  55385. */
  55386. readonly output: NodeMaterialConnectionPoint;
  55387. protected _buildBlock(state: NodeMaterialBuildState): this;
  55388. }
  55389. }
  55390. declare module BABYLON {
  55391. /**
  55392. * Block used to get a random number
  55393. */
  55394. export class RandomNumberBlock extends NodeMaterialBlock {
  55395. /**
  55396. * Creates a new RandomNumberBlock
  55397. * @param name defines the block name
  55398. */
  55399. constructor(name: string);
  55400. /**
  55401. * Gets the current class name
  55402. * @returns the class name
  55403. */
  55404. getClassName(): string;
  55405. /**
  55406. * Gets the seed input component
  55407. */
  55408. readonly seed: NodeMaterialConnectionPoint;
  55409. /**
  55410. * Gets the output component
  55411. */
  55412. readonly output: NodeMaterialConnectionPoint;
  55413. protected _buildBlock(state: NodeMaterialBuildState): this;
  55414. }
  55415. }
  55416. declare module BABYLON {
  55417. /**
  55418. * Block used to compute arc tangent of 2 values
  55419. */
  55420. export class ArcTan2Block extends NodeMaterialBlock {
  55421. /**
  55422. * Creates a new ArcTan2Block
  55423. * @param name defines the block name
  55424. */
  55425. constructor(name: string);
  55426. /**
  55427. * Gets the current class name
  55428. * @returns the class name
  55429. */
  55430. getClassName(): string;
  55431. /**
  55432. * Gets the x operand input component
  55433. */
  55434. readonly x: NodeMaterialConnectionPoint;
  55435. /**
  55436. * Gets the y operand input component
  55437. */
  55438. readonly y: NodeMaterialConnectionPoint;
  55439. /**
  55440. * Gets the output component
  55441. */
  55442. readonly output: NodeMaterialConnectionPoint;
  55443. protected _buildBlock(state: NodeMaterialBuildState): this;
  55444. }
  55445. }
  55446. declare module BABYLON {
  55447. /**
  55448. * Block used to smooth step a value
  55449. */
  55450. export class SmoothStepBlock extends NodeMaterialBlock {
  55451. /**
  55452. * Creates a new SmoothStepBlock
  55453. * @param name defines the block name
  55454. */
  55455. constructor(name: string);
  55456. /**
  55457. * Gets the current class name
  55458. * @returns the class name
  55459. */
  55460. getClassName(): string;
  55461. /**
  55462. * Gets the value operand input component
  55463. */
  55464. readonly value: NodeMaterialConnectionPoint;
  55465. /**
  55466. * Gets the first edge operand input component
  55467. */
  55468. readonly edge0: NodeMaterialConnectionPoint;
  55469. /**
  55470. * Gets the second edge operand input component
  55471. */
  55472. readonly edge1: NodeMaterialConnectionPoint;
  55473. /**
  55474. * Gets the output component
  55475. */
  55476. readonly output: NodeMaterialConnectionPoint;
  55477. protected _buildBlock(state: NodeMaterialBuildState): this;
  55478. }
  55479. }
  55480. declare module BABYLON {
  55481. /**
  55482. * Block used to get the reciprocal (1 / x) of a value
  55483. */
  55484. export class ReciprocalBlock extends NodeMaterialBlock {
  55485. /**
  55486. * Creates a new ReciprocalBlock
  55487. * @param name defines the block name
  55488. */
  55489. constructor(name: string);
  55490. /**
  55491. * Gets the current class name
  55492. * @returns the class name
  55493. */
  55494. getClassName(): string;
  55495. /**
  55496. * Gets the input component
  55497. */
  55498. readonly input: NodeMaterialConnectionPoint;
  55499. /**
  55500. * Gets the output component
  55501. */
  55502. readonly output: NodeMaterialConnectionPoint;
  55503. protected _buildBlock(state: NodeMaterialBuildState): this;
  55504. }
  55505. }
  55506. declare module BABYLON {
  55507. /**
  55508. * Block used to replace a color by another one
  55509. */
  55510. export class ReplaceColorBlock extends NodeMaterialBlock {
  55511. /**
  55512. * Creates a new ReplaceColorBlock
  55513. * @param name defines the block name
  55514. */
  55515. constructor(name: string);
  55516. /**
  55517. * Gets the current class name
  55518. * @returns the class name
  55519. */
  55520. getClassName(): string;
  55521. /**
  55522. * Gets the value input component
  55523. */
  55524. readonly value: NodeMaterialConnectionPoint;
  55525. /**
  55526. * Gets the reference input component
  55527. */
  55528. readonly reference: NodeMaterialConnectionPoint;
  55529. /**
  55530. * Gets the distance input component
  55531. */
  55532. readonly distance: NodeMaterialConnectionPoint;
  55533. /**
  55534. * Gets the replacement input component
  55535. */
  55536. readonly replacement: NodeMaterialConnectionPoint;
  55537. /**
  55538. * Gets the output component
  55539. */
  55540. readonly output: NodeMaterialConnectionPoint;
  55541. protected _buildBlock(state: NodeMaterialBuildState): this;
  55542. }
  55543. }
  55544. declare module BABYLON {
  55545. /**
  55546. * Block used to posterize a value
  55547. * @see https://en.wikipedia.org/wiki/Posterization
  55548. */
  55549. export class PosterizeBlock extends NodeMaterialBlock {
  55550. /**
  55551. * Creates a new PosterizeBlock
  55552. * @param name defines the block name
  55553. */
  55554. constructor(name: string);
  55555. /**
  55556. * Gets the current class name
  55557. * @returns the class name
  55558. */
  55559. getClassName(): string;
  55560. /**
  55561. * Gets the value input component
  55562. */
  55563. readonly value: NodeMaterialConnectionPoint;
  55564. /**
  55565. * Gets the steps input component
  55566. */
  55567. readonly steps: NodeMaterialConnectionPoint;
  55568. /**
  55569. * Gets the output component
  55570. */
  55571. readonly output: NodeMaterialConnectionPoint;
  55572. protected _buildBlock(state: NodeMaterialBuildState): this;
  55573. }
  55574. }
  55575. declare module BABYLON {
  55576. /**
  55577. * Operations supported by the Wave block
  55578. */
  55579. export enum WaveBlockKind {
  55580. /** SawTooth */
  55581. SawTooth = 0,
  55582. /** Square */
  55583. Square = 1,
  55584. /** Triangle */
  55585. Triangle = 2
  55586. }
  55587. /**
  55588. * Block used to apply wave operation to floats
  55589. */
  55590. export class WaveBlock extends NodeMaterialBlock {
  55591. /**
  55592. * Gets or sets the kibnd of wave to be applied by the block
  55593. */
  55594. kind: WaveBlockKind;
  55595. /**
  55596. * Creates a new WaveBlock
  55597. * @param name defines the block name
  55598. */
  55599. constructor(name: string);
  55600. /**
  55601. * Gets the current class name
  55602. * @returns the class name
  55603. */
  55604. getClassName(): string;
  55605. /**
  55606. * Gets the input component
  55607. */
  55608. readonly input: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the output component
  55611. */
  55612. readonly output: NodeMaterialConnectionPoint;
  55613. protected _buildBlock(state: NodeMaterialBuildState): this;
  55614. serialize(): any;
  55615. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55616. }
  55617. }
  55618. declare module BABYLON {
  55619. /**
  55620. * Class used to store a color step for the GradientBlock
  55621. */
  55622. export class GradientBlockColorStep {
  55623. /**
  55624. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55625. */
  55626. step: number;
  55627. /**
  55628. * Gets or sets the color associated with this step
  55629. */
  55630. color: Color3;
  55631. /**
  55632. * Creates a new GradientBlockColorStep
  55633. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  55634. * @param color defines the color associated with this step
  55635. */
  55636. constructor(
  55637. /**
  55638. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  55639. */
  55640. step: number,
  55641. /**
  55642. * Gets or sets the color associated with this step
  55643. */
  55644. color: Color3);
  55645. }
  55646. /**
  55647. * Block used to return a color from a gradient based on an input value between 0 and 1
  55648. */
  55649. export class GradientBlock extends NodeMaterialBlock {
  55650. /**
  55651. * Gets or sets the list of color steps
  55652. */
  55653. colorSteps: GradientBlockColorStep[];
  55654. /**
  55655. * Creates a new GradientBlock
  55656. * @param name defines the block name
  55657. */
  55658. constructor(name: string);
  55659. /**
  55660. * Gets the current class name
  55661. * @returns the class name
  55662. */
  55663. getClassName(): string;
  55664. /**
  55665. * Gets the gradient input component
  55666. */
  55667. readonly gradient: NodeMaterialConnectionPoint;
  55668. /**
  55669. * Gets the output component
  55670. */
  55671. readonly output: NodeMaterialConnectionPoint;
  55672. private _writeColorConstant;
  55673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55674. serialize(): any;
  55675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55676. protected _dumpPropertiesCode(): string;
  55677. }
  55678. }
  55679. declare module BABYLON {
  55680. /**
  55681. * Block used to normalize lerp between 2 values
  55682. */
  55683. export class NLerpBlock extends NodeMaterialBlock {
  55684. /**
  55685. * Creates a new NLerpBlock
  55686. * @param name defines the block name
  55687. */
  55688. constructor(name: string);
  55689. /**
  55690. * Gets the current class name
  55691. * @returns the class name
  55692. */
  55693. getClassName(): string;
  55694. /**
  55695. * Gets the left operand input component
  55696. */
  55697. readonly left: NodeMaterialConnectionPoint;
  55698. /**
  55699. * Gets the right operand input component
  55700. */
  55701. readonly right: NodeMaterialConnectionPoint;
  55702. /**
  55703. * Gets the gradient operand input component
  55704. */
  55705. readonly gradient: NodeMaterialConnectionPoint;
  55706. /**
  55707. * Gets the output component
  55708. */
  55709. readonly output: NodeMaterialConnectionPoint;
  55710. protected _buildBlock(state: NodeMaterialBuildState): this;
  55711. }
  55712. }
  55713. declare module BABYLON {
  55714. /**
  55715. * Effect Render Options
  55716. */
  55717. export interface IEffectRendererOptions {
  55718. /**
  55719. * Defines the vertices positions.
  55720. */
  55721. positions?: number[];
  55722. /**
  55723. * Defines the indices.
  55724. */
  55725. indices?: number[];
  55726. }
  55727. /**
  55728. * Helper class to render one or more effects
  55729. */
  55730. export class EffectRenderer {
  55731. private engine;
  55732. private static _DefaultOptions;
  55733. private _vertexBuffers;
  55734. private _indexBuffer;
  55735. private _ringBufferIndex;
  55736. private _ringScreenBuffer;
  55737. private _fullscreenViewport;
  55738. private _getNextFrameBuffer;
  55739. /**
  55740. * Creates an effect renderer
  55741. * @param engine the engine to use for rendering
  55742. * @param options defines the options of the effect renderer
  55743. */
  55744. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  55745. /**
  55746. * Sets the current viewport in normalized coordinates 0-1
  55747. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55748. */
  55749. setViewport(viewport?: Viewport): void;
  55750. /**
  55751. * Binds the embedded attributes buffer to the effect.
  55752. * @param effect Defines the effect to bind the attributes for
  55753. */
  55754. bindBuffers(effect: Effect): void;
  55755. /**
  55756. * Sets the current effect wrapper to use during draw.
  55757. * The effect needs to be ready before calling this api.
  55758. * This also sets the default full screen position attribute.
  55759. * @param effectWrapper Defines the effect to draw with
  55760. */
  55761. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55762. /**
  55763. * Draws a full screen quad.
  55764. */
  55765. draw(): void;
  55766. /**
  55767. * renders one or more effects to a specified texture
  55768. * @param effectWrappers list of effects to renderer
  55769. * @param outputTexture texture to draw to, if null it will render to the screen
  55770. */
  55771. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55772. /**
  55773. * Disposes of the effect renderer
  55774. */
  55775. dispose(): void;
  55776. }
  55777. /**
  55778. * Options to create an EffectWrapper
  55779. */
  55780. interface EffectWrapperCreationOptions {
  55781. /**
  55782. * Engine to use to create the effect
  55783. */
  55784. engine: ThinEngine;
  55785. /**
  55786. * Fragment shader for the effect
  55787. */
  55788. fragmentShader: string;
  55789. /**
  55790. * Vertex shader for the effect
  55791. */
  55792. vertexShader?: string;
  55793. /**
  55794. * Attributes to use in the shader
  55795. */
  55796. attributeNames?: Array<string>;
  55797. /**
  55798. * Uniforms to use in the shader
  55799. */
  55800. uniformNames?: Array<string>;
  55801. /**
  55802. * Texture sampler names to use in the shader
  55803. */
  55804. samplerNames?: Array<string>;
  55805. /**
  55806. * The friendly name of the effect displayed in Spector.
  55807. */
  55808. name?: string;
  55809. }
  55810. /**
  55811. * Wraps an effect to be used for rendering
  55812. */
  55813. export class EffectWrapper {
  55814. /**
  55815. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55816. */
  55817. onApplyObservable: Observable<{}>;
  55818. /**
  55819. * The underlying effect
  55820. */
  55821. effect: Effect;
  55822. /**
  55823. * Creates an effect to be renderer
  55824. * @param creationOptions options to create the effect
  55825. */
  55826. constructor(creationOptions: EffectWrapperCreationOptions);
  55827. /**
  55828. * Disposes of the effect wrapper
  55829. */
  55830. dispose(): void;
  55831. }
  55832. }
  55833. declare module BABYLON {
  55834. /**
  55835. * Helper class to push actions to a pool of workers.
  55836. */
  55837. export class WorkerPool implements IDisposable {
  55838. private _workerInfos;
  55839. private _pendingActions;
  55840. /**
  55841. * Constructor
  55842. * @param workers Array of workers to use for actions
  55843. */
  55844. constructor(workers: Array<Worker>);
  55845. /**
  55846. * Terminates all workers and clears any pending actions.
  55847. */
  55848. dispose(): void;
  55849. /**
  55850. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55851. * pended until a worker has completed its action.
  55852. * @param action The action to perform. Call onComplete when the action is complete.
  55853. */
  55854. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55855. private _execute;
  55856. }
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * Configuration for Draco compression
  55861. */
  55862. export interface IDracoCompressionConfiguration {
  55863. /**
  55864. * Configuration for the decoder.
  55865. */
  55866. decoder: {
  55867. /**
  55868. * The url to the WebAssembly module.
  55869. */
  55870. wasmUrl?: string;
  55871. /**
  55872. * The url to the WebAssembly binary.
  55873. */
  55874. wasmBinaryUrl?: string;
  55875. /**
  55876. * The url to the fallback JavaScript module.
  55877. */
  55878. fallbackUrl?: string;
  55879. };
  55880. }
  55881. /**
  55882. * Draco compression (https://google.github.io/draco/)
  55883. *
  55884. * This class wraps the Draco module.
  55885. *
  55886. * **Encoder**
  55887. *
  55888. * The encoder is not currently implemented.
  55889. *
  55890. * **Decoder**
  55891. *
  55892. * 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.
  55893. *
  55894. * To update the configuration, use the following code:
  55895. * ```javascript
  55896. * DracoCompression.Configuration = {
  55897. * decoder: {
  55898. * wasmUrl: "<url to the WebAssembly library>",
  55899. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55900. * fallbackUrl: "<url to the fallback JavaScript library>",
  55901. * }
  55902. * };
  55903. * ```
  55904. *
  55905. * 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.
  55906. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55907. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55908. *
  55909. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55910. * ```javascript
  55911. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55912. * ```
  55913. *
  55914. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55915. */
  55916. export class DracoCompression implements IDisposable {
  55917. private _workerPoolPromise?;
  55918. private _decoderModulePromise?;
  55919. /**
  55920. * The configuration. Defaults to the following urls:
  55921. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55922. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55923. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55924. */
  55925. static Configuration: IDracoCompressionConfiguration;
  55926. /**
  55927. * Returns true if the decoder configuration is available.
  55928. */
  55929. static readonly DecoderAvailable: boolean;
  55930. /**
  55931. * Default number of workers to create when creating the draco compression object.
  55932. */
  55933. static DefaultNumWorkers: number;
  55934. private static GetDefaultNumWorkers;
  55935. private static _Default;
  55936. /**
  55937. * Default instance for the draco compression object.
  55938. */
  55939. static readonly Default: DracoCompression;
  55940. /**
  55941. * Constructor
  55942. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55943. */
  55944. constructor(numWorkers?: number);
  55945. /**
  55946. * Stop all async operations and release resources.
  55947. */
  55948. dispose(): void;
  55949. /**
  55950. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55951. * @returns a promise that resolves when ready
  55952. */
  55953. whenReadyAsync(): Promise<void>;
  55954. /**
  55955. * Decode Draco compressed mesh data to vertex data.
  55956. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55957. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55958. * @returns A promise that resolves with the decoded vertex data
  55959. */
  55960. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55961. [kind: string]: number;
  55962. }): Promise<VertexData>;
  55963. }
  55964. }
  55965. declare module BABYLON {
  55966. /**
  55967. * Class for building Constructive Solid Geometry
  55968. */
  55969. export class CSG {
  55970. private polygons;
  55971. /**
  55972. * The world matrix
  55973. */
  55974. matrix: Matrix;
  55975. /**
  55976. * Stores the position
  55977. */
  55978. position: Vector3;
  55979. /**
  55980. * Stores the rotation
  55981. */
  55982. rotation: Vector3;
  55983. /**
  55984. * Stores the rotation quaternion
  55985. */
  55986. rotationQuaternion: Nullable<Quaternion>;
  55987. /**
  55988. * Stores the scaling vector
  55989. */
  55990. scaling: Vector3;
  55991. /**
  55992. * Convert the Mesh to CSG
  55993. * @param mesh The Mesh to convert to CSG
  55994. * @returns A new CSG from the Mesh
  55995. */
  55996. static FromMesh(mesh: Mesh): CSG;
  55997. /**
  55998. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55999. * @param polygons Polygons used to construct a CSG solid
  56000. */
  56001. private static FromPolygons;
  56002. /**
  56003. * Clones, or makes a deep copy, of the CSG
  56004. * @returns A new CSG
  56005. */
  56006. clone(): CSG;
  56007. /**
  56008. * Unions this CSG with another CSG
  56009. * @param csg The CSG to union against this CSG
  56010. * @returns The unioned CSG
  56011. */
  56012. union(csg: CSG): CSG;
  56013. /**
  56014. * Unions this CSG with another CSG in place
  56015. * @param csg The CSG to union against this CSG
  56016. */
  56017. unionInPlace(csg: CSG): void;
  56018. /**
  56019. * Subtracts this CSG with another CSG
  56020. * @param csg The CSG to subtract against this CSG
  56021. * @returns A new CSG
  56022. */
  56023. subtract(csg: CSG): CSG;
  56024. /**
  56025. * Subtracts this CSG with another CSG in place
  56026. * @param csg The CSG to subtact against this CSG
  56027. */
  56028. subtractInPlace(csg: CSG): void;
  56029. /**
  56030. * Intersect this CSG with another CSG
  56031. * @param csg The CSG to intersect against this CSG
  56032. * @returns A new CSG
  56033. */
  56034. intersect(csg: CSG): CSG;
  56035. /**
  56036. * Intersects this CSG with another CSG in place
  56037. * @param csg The CSG to intersect against this CSG
  56038. */
  56039. intersectInPlace(csg: CSG): void;
  56040. /**
  56041. * Return a new CSG solid with solid and empty space switched. This solid is
  56042. * not modified.
  56043. * @returns A new CSG solid with solid and empty space switched
  56044. */
  56045. inverse(): CSG;
  56046. /**
  56047. * Inverses the CSG in place
  56048. */
  56049. inverseInPlace(): void;
  56050. /**
  56051. * This is used to keep meshes transformations so they can be restored
  56052. * when we build back a Babylon Mesh
  56053. * NB : All CSG operations are performed in world coordinates
  56054. * @param csg The CSG to copy the transform attributes from
  56055. * @returns This CSG
  56056. */
  56057. copyTransformAttributes(csg: CSG): CSG;
  56058. /**
  56059. * Build Raw mesh from CSG
  56060. * Coordinates here are in world space
  56061. * @param name The name of the mesh geometry
  56062. * @param scene The Scene
  56063. * @param keepSubMeshes Specifies if the submeshes should be kept
  56064. * @returns A new Mesh
  56065. */
  56066. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56067. /**
  56068. * Build Mesh from CSG taking material and transforms into account
  56069. * @param name The name of the Mesh
  56070. * @param material The material of the Mesh
  56071. * @param scene The Scene
  56072. * @param keepSubMeshes Specifies if submeshes should be kept
  56073. * @returns The new Mesh
  56074. */
  56075. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  56076. }
  56077. }
  56078. declare module BABYLON {
  56079. /**
  56080. * Class used to create a trail following a mesh
  56081. */
  56082. export class TrailMesh extends Mesh {
  56083. private _generator;
  56084. private _autoStart;
  56085. private _running;
  56086. private _diameter;
  56087. private _length;
  56088. private _sectionPolygonPointsCount;
  56089. private _sectionVectors;
  56090. private _sectionNormalVectors;
  56091. private _beforeRenderObserver;
  56092. /**
  56093. * @constructor
  56094. * @param name The value used by scene.getMeshByName() to do a lookup.
  56095. * @param generator The mesh to generate a trail.
  56096. * @param scene The scene to add this mesh to.
  56097. * @param diameter Diameter of trailing mesh. Default is 1.
  56098. * @param length Length of trailing mesh. Default is 60.
  56099. * @param autoStart Automatically start trailing mesh. Default true.
  56100. */
  56101. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56102. /**
  56103. * "TrailMesh"
  56104. * @returns "TrailMesh"
  56105. */
  56106. getClassName(): string;
  56107. private _createMesh;
  56108. /**
  56109. * Start trailing mesh.
  56110. */
  56111. start(): void;
  56112. /**
  56113. * Stop trailing mesh.
  56114. */
  56115. stop(): void;
  56116. /**
  56117. * Update trailing mesh geometry.
  56118. */
  56119. update(): void;
  56120. /**
  56121. * Returns a new TrailMesh object.
  56122. * @param name is a string, the name given to the new mesh
  56123. * @param newGenerator use new generator object for cloned trail mesh
  56124. * @returns a new mesh
  56125. */
  56126. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56127. /**
  56128. * Serializes this trail mesh
  56129. * @param serializationObject object to write serialization to
  56130. */
  56131. serialize(serializationObject: any): void;
  56132. /**
  56133. * Parses a serialized trail mesh
  56134. * @param parsedMesh the serialized mesh
  56135. * @param scene the scene to create the trail mesh in
  56136. * @returns the created trail mesh
  56137. */
  56138. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56139. }
  56140. }
  56141. declare module BABYLON {
  56142. /**
  56143. * Class containing static functions to help procedurally build meshes
  56144. */
  56145. export class TiledBoxBuilder {
  56146. /**
  56147. * Creates a box mesh
  56148. * 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)
  56149. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56151. * * 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
  56152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56153. * @param name defines the name of the mesh
  56154. * @param options defines the options used to create the mesh
  56155. * @param scene defines the hosting scene
  56156. * @returns the box mesh
  56157. */
  56158. static CreateTiledBox(name: string, options: {
  56159. pattern?: number;
  56160. width?: number;
  56161. height?: number;
  56162. depth?: number;
  56163. tileSize?: number;
  56164. tileWidth?: number;
  56165. tileHeight?: number;
  56166. alignHorizontal?: number;
  56167. alignVertical?: number;
  56168. faceUV?: Vector4[];
  56169. faceColors?: Color4[];
  56170. sideOrientation?: number;
  56171. updatable?: boolean;
  56172. }, scene?: Nullable<Scene>): Mesh;
  56173. }
  56174. }
  56175. declare module BABYLON {
  56176. /**
  56177. * Class containing static functions to help procedurally build meshes
  56178. */
  56179. export class TorusKnotBuilder {
  56180. /**
  56181. * Creates a torus knot mesh
  56182. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56183. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56184. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56185. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56187. * * 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
  56188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56189. * @param name defines the name of the mesh
  56190. * @param options defines the options used to create the mesh
  56191. * @param scene defines the hosting scene
  56192. * @returns the torus knot mesh
  56193. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56194. */
  56195. static CreateTorusKnot(name: string, options: {
  56196. radius?: number;
  56197. tube?: number;
  56198. radialSegments?: number;
  56199. tubularSegments?: number;
  56200. p?: number;
  56201. q?: number;
  56202. updatable?: boolean;
  56203. sideOrientation?: number;
  56204. frontUVs?: Vector4;
  56205. backUVs?: Vector4;
  56206. }, scene: any): Mesh;
  56207. }
  56208. }
  56209. declare module BABYLON {
  56210. /**
  56211. * Polygon
  56212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56213. */
  56214. export class Polygon {
  56215. /**
  56216. * Creates a rectangle
  56217. * @param xmin bottom X coord
  56218. * @param ymin bottom Y coord
  56219. * @param xmax top X coord
  56220. * @param ymax top Y coord
  56221. * @returns points that make the resulting rectation
  56222. */
  56223. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56224. /**
  56225. * Creates a circle
  56226. * @param radius radius of circle
  56227. * @param cx scale in x
  56228. * @param cy scale in y
  56229. * @param numberOfSides number of sides that make up the circle
  56230. * @returns points that make the resulting circle
  56231. */
  56232. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56233. /**
  56234. * Creates a polygon from input string
  56235. * @param input Input polygon data
  56236. * @returns the parsed points
  56237. */
  56238. static Parse(input: string): Vector2[];
  56239. /**
  56240. * Starts building a polygon from x and y coordinates
  56241. * @param x x coordinate
  56242. * @param y y coordinate
  56243. * @returns the started path2
  56244. */
  56245. static StartingAt(x: number, y: number): Path2;
  56246. }
  56247. /**
  56248. * Builds a polygon
  56249. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56250. */
  56251. export class PolygonMeshBuilder {
  56252. private _points;
  56253. private _outlinepoints;
  56254. private _holes;
  56255. private _name;
  56256. private _scene;
  56257. private _epoints;
  56258. private _eholes;
  56259. private _addToepoint;
  56260. /**
  56261. * Babylon reference to the earcut plugin.
  56262. */
  56263. bjsEarcut: any;
  56264. /**
  56265. * Creates a PolygonMeshBuilder
  56266. * @param name name of the builder
  56267. * @param contours Path of the polygon
  56268. * @param scene scene to add to when creating the mesh
  56269. * @param earcutInjection can be used to inject your own earcut reference
  56270. */
  56271. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56272. /**
  56273. * Adds a whole within the polygon
  56274. * @param hole Array of points defining the hole
  56275. * @returns this
  56276. */
  56277. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56278. /**
  56279. * Creates the polygon
  56280. * @param updatable If the mesh should be updatable
  56281. * @param depth The depth of the mesh created
  56282. * @returns the created mesh
  56283. */
  56284. build(updatable?: boolean, depth?: number): Mesh;
  56285. /**
  56286. * Creates the polygon
  56287. * @param depth The depth of the mesh created
  56288. * @returns the created VertexData
  56289. */
  56290. buildVertexData(depth?: number): VertexData;
  56291. /**
  56292. * Adds a side to the polygon
  56293. * @param positions points that make the polygon
  56294. * @param normals normals of the polygon
  56295. * @param uvs uvs of the polygon
  56296. * @param indices indices of the polygon
  56297. * @param bounds bounds of the polygon
  56298. * @param points points of the polygon
  56299. * @param depth depth of the polygon
  56300. * @param flip flip of the polygon
  56301. */
  56302. private addSide;
  56303. }
  56304. }
  56305. declare module BABYLON {
  56306. /**
  56307. * Class containing static functions to help procedurally build meshes
  56308. */
  56309. export class PolygonBuilder {
  56310. /**
  56311. * Creates a polygon mesh
  56312. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56313. * * 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
  56314. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56316. * * 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)
  56317. * * Remember you can only change the shape positions, not their number when updating a polygon
  56318. * @param name defines the name of the mesh
  56319. * @param options defines the options used to create the mesh
  56320. * @param scene defines the hosting scene
  56321. * @param earcutInjection can be used to inject your own earcut reference
  56322. * @returns the polygon mesh
  56323. */
  56324. static CreatePolygon(name: string, options: {
  56325. shape: Vector3[];
  56326. holes?: Vector3[][];
  56327. depth?: number;
  56328. faceUV?: Vector4[];
  56329. faceColors?: Color4[];
  56330. updatable?: boolean;
  56331. sideOrientation?: number;
  56332. frontUVs?: Vector4;
  56333. backUVs?: Vector4;
  56334. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56335. /**
  56336. * Creates an extruded polygon mesh, with depth in the Y direction.
  56337. * * 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)
  56338. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56339. * @param name defines the name of the mesh
  56340. * @param options defines the options used to create the mesh
  56341. * @param scene defines the hosting scene
  56342. * @param earcutInjection can be used to inject your own earcut reference
  56343. * @returns the polygon mesh
  56344. */
  56345. static ExtrudePolygon(name: string, options: {
  56346. shape: Vector3[];
  56347. holes?: Vector3[][];
  56348. depth?: number;
  56349. faceUV?: Vector4[];
  56350. faceColors?: Color4[];
  56351. updatable?: boolean;
  56352. sideOrientation?: number;
  56353. frontUVs?: Vector4;
  56354. backUVs?: Vector4;
  56355. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56356. }
  56357. }
  56358. declare module BABYLON {
  56359. /**
  56360. * Class containing static functions to help procedurally build meshes
  56361. */
  56362. export class LatheBuilder {
  56363. /**
  56364. * Creates lathe mesh.
  56365. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56366. * * 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
  56367. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56368. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56369. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56370. * * 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
  56371. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56372. * * 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
  56373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56374. * * 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
  56375. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56377. * @param name defines the name of the mesh
  56378. * @param options defines the options used to create the mesh
  56379. * @param scene defines the hosting scene
  56380. * @returns the lathe mesh
  56381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56382. */
  56383. static CreateLathe(name: string, options: {
  56384. shape: Vector3[];
  56385. radius?: number;
  56386. tessellation?: number;
  56387. clip?: number;
  56388. arc?: number;
  56389. closed?: boolean;
  56390. updatable?: boolean;
  56391. sideOrientation?: number;
  56392. frontUVs?: Vector4;
  56393. backUVs?: Vector4;
  56394. cap?: number;
  56395. invertUV?: boolean;
  56396. }, scene?: Nullable<Scene>): Mesh;
  56397. }
  56398. }
  56399. declare module BABYLON {
  56400. /**
  56401. * Class containing static functions to help procedurally build meshes
  56402. */
  56403. export class TiledPlaneBuilder {
  56404. /**
  56405. * Creates a tiled plane mesh
  56406. * * The parameter `pattern` will, depending on value, do nothing or
  56407. * * * flip (reflect about central vertical) alternate tiles across and up
  56408. * * * flip every tile on alternate rows
  56409. * * * rotate (180 degs) alternate tiles across and up
  56410. * * * rotate every tile on alternate rows
  56411. * * * flip and rotate alternate tiles across and up
  56412. * * * flip and rotate every tile on alternate rows
  56413. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56414. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56415. * * 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
  56416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56417. * * 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)
  56418. * * 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)
  56419. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56420. * @param name defines the name of the mesh
  56421. * @param options defines the options used to create the mesh
  56422. * @param scene defines the hosting scene
  56423. * @returns the box mesh
  56424. */
  56425. static CreateTiledPlane(name: string, options: {
  56426. pattern?: number;
  56427. tileSize?: number;
  56428. tileWidth?: number;
  56429. tileHeight?: number;
  56430. size?: number;
  56431. width?: number;
  56432. height?: number;
  56433. alignHorizontal?: number;
  56434. alignVertical?: number;
  56435. sideOrientation?: number;
  56436. frontUVs?: Vector4;
  56437. backUVs?: Vector4;
  56438. updatable?: boolean;
  56439. }, scene?: Nullable<Scene>): Mesh;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /**
  56444. * Class containing static functions to help procedurally build meshes
  56445. */
  56446. export class TubeBuilder {
  56447. /**
  56448. * Creates a tube mesh.
  56449. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56450. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56451. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56452. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56453. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56454. * * 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)
  56455. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56456. * * 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
  56457. * * 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
  56458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56459. * * 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
  56460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56462. * @param name defines the name of the mesh
  56463. * @param options defines the options used to create the mesh
  56464. * @param scene defines the hosting scene
  56465. * @returns the tube mesh
  56466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56467. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56468. */
  56469. static CreateTube(name: string, options: {
  56470. path: Vector3[];
  56471. radius?: number;
  56472. tessellation?: number;
  56473. radiusFunction?: {
  56474. (i: number, distance: number): number;
  56475. };
  56476. cap?: number;
  56477. arc?: number;
  56478. updatable?: boolean;
  56479. sideOrientation?: number;
  56480. frontUVs?: Vector4;
  56481. backUVs?: Vector4;
  56482. instance?: Mesh;
  56483. invertUV?: boolean;
  56484. }, scene?: Nullable<Scene>): Mesh;
  56485. }
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * Class containing static functions to help procedurally build meshes
  56490. */
  56491. export class IcoSphereBuilder {
  56492. /**
  56493. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56494. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56495. * * 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`)
  56496. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56497. * * 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
  56498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56499. * * 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
  56500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56501. * @param name defines the name of the mesh
  56502. * @param options defines the options used to create the mesh
  56503. * @param scene defines the hosting scene
  56504. * @returns the icosahedron mesh
  56505. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56506. */
  56507. static CreateIcoSphere(name: string, options: {
  56508. radius?: number;
  56509. radiusX?: number;
  56510. radiusY?: number;
  56511. radiusZ?: number;
  56512. flat?: boolean;
  56513. subdivisions?: number;
  56514. sideOrientation?: number;
  56515. frontUVs?: Vector4;
  56516. backUVs?: Vector4;
  56517. updatable?: boolean;
  56518. }, scene?: Nullable<Scene>): Mesh;
  56519. }
  56520. }
  56521. declare module BABYLON {
  56522. /**
  56523. * Class containing static functions to help procedurally build meshes
  56524. */
  56525. export class DecalBuilder {
  56526. /**
  56527. * Creates a decal mesh.
  56528. * 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
  56529. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56530. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56531. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56532. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56533. * @param name defines the name of the mesh
  56534. * @param sourceMesh defines the mesh where the decal must be applied
  56535. * @param options defines the options used to create the mesh
  56536. * @param scene defines the hosting scene
  56537. * @returns the decal mesh
  56538. * @see https://doc.babylonjs.com/how_to/decals
  56539. */
  56540. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56541. position?: Vector3;
  56542. normal?: Vector3;
  56543. size?: Vector3;
  56544. angle?: number;
  56545. }): Mesh;
  56546. }
  56547. }
  56548. declare module BABYLON {
  56549. /**
  56550. * Class containing static functions to help procedurally build meshes
  56551. */
  56552. export class MeshBuilder {
  56553. /**
  56554. * Creates a box mesh
  56555. * * The parameter `size` sets the size (float) of each box side (default 1)
  56556. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56557. * * 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)
  56558. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56560. * * 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
  56561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56562. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56563. * @param name defines the name of the mesh
  56564. * @param options defines the options used to create the mesh
  56565. * @param scene defines the hosting scene
  56566. * @returns the box mesh
  56567. */
  56568. static CreateBox(name: string, options: {
  56569. size?: number;
  56570. width?: number;
  56571. height?: number;
  56572. depth?: number;
  56573. faceUV?: Vector4[];
  56574. faceColors?: Color4[];
  56575. sideOrientation?: number;
  56576. frontUVs?: Vector4;
  56577. backUVs?: Vector4;
  56578. updatable?: boolean;
  56579. }, scene?: Nullable<Scene>): Mesh;
  56580. /**
  56581. * Creates a tiled box mesh
  56582. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56584. * @param name defines the name of the mesh
  56585. * @param options defines the options used to create the mesh
  56586. * @param scene defines the hosting scene
  56587. * @returns the tiled box mesh
  56588. */
  56589. static CreateTiledBox(name: string, options: {
  56590. pattern?: number;
  56591. size?: number;
  56592. width?: number;
  56593. height?: number;
  56594. depth: number;
  56595. tileSize?: number;
  56596. tileWidth?: number;
  56597. tileHeight?: number;
  56598. faceUV?: Vector4[];
  56599. faceColors?: Color4[];
  56600. alignHorizontal?: number;
  56601. alignVertical?: number;
  56602. sideOrientation?: number;
  56603. updatable?: boolean;
  56604. }, scene?: Nullable<Scene>): Mesh;
  56605. /**
  56606. * Creates a sphere mesh
  56607. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56608. * * 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`)
  56609. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56610. * * 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
  56611. * * 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)
  56612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56613. * * 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
  56614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56615. * @param name defines the name of the mesh
  56616. * @param options defines the options used to create the mesh
  56617. * @param scene defines the hosting scene
  56618. * @returns the sphere mesh
  56619. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56620. */
  56621. static CreateSphere(name: string, options: {
  56622. segments?: number;
  56623. diameter?: number;
  56624. diameterX?: number;
  56625. diameterY?: number;
  56626. diameterZ?: number;
  56627. arc?: number;
  56628. slice?: number;
  56629. sideOrientation?: number;
  56630. frontUVs?: Vector4;
  56631. backUVs?: Vector4;
  56632. updatable?: boolean;
  56633. }, scene?: Nullable<Scene>): Mesh;
  56634. /**
  56635. * Creates a plane polygonal mesh. By default, this is a disc
  56636. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56637. * * 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
  56638. * * 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
  56639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56640. * * 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
  56641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56642. * @param name defines the name of the mesh
  56643. * @param options defines the options used to create the mesh
  56644. * @param scene defines the hosting scene
  56645. * @returns the plane polygonal mesh
  56646. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56647. */
  56648. static CreateDisc(name: string, options: {
  56649. radius?: number;
  56650. tessellation?: number;
  56651. arc?: number;
  56652. updatable?: boolean;
  56653. sideOrientation?: number;
  56654. frontUVs?: Vector4;
  56655. backUVs?: Vector4;
  56656. }, scene?: Nullable<Scene>): Mesh;
  56657. /**
  56658. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56659. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56660. * * 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`)
  56661. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56662. * * 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
  56663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56664. * * 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
  56665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56666. * @param name defines the name of the mesh
  56667. * @param options defines the options used to create the mesh
  56668. * @param scene defines the hosting scene
  56669. * @returns the icosahedron mesh
  56670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56671. */
  56672. static CreateIcoSphere(name: string, options: {
  56673. radius?: number;
  56674. radiusX?: number;
  56675. radiusY?: number;
  56676. radiusZ?: number;
  56677. flat?: boolean;
  56678. subdivisions?: number;
  56679. sideOrientation?: number;
  56680. frontUVs?: Vector4;
  56681. backUVs?: Vector4;
  56682. updatable?: boolean;
  56683. }, scene?: Nullable<Scene>): Mesh;
  56684. /**
  56685. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56686. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56687. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56688. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56689. * * 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
  56690. * * 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
  56691. * * 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
  56692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56693. * * 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
  56694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56695. * * 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
  56696. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56697. * * 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
  56698. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56700. * @param name defines the name of the mesh
  56701. * @param options defines the options used to create the mesh
  56702. * @param scene defines the hosting scene
  56703. * @returns the ribbon mesh
  56704. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56706. */
  56707. static CreateRibbon(name: string, options: {
  56708. pathArray: Vector3[][];
  56709. closeArray?: boolean;
  56710. closePath?: boolean;
  56711. offset?: number;
  56712. updatable?: boolean;
  56713. sideOrientation?: number;
  56714. frontUVs?: Vector4;
  56715. backUVs?: Vector4;
  56716. instance?: Mesh;
  56717. invertUV?: boolean;
  56718. uvs?: Vector2[];
  56719. colors?: Color4[];
  56720. }, scene?: Nullable<Scene>): Mesh;
  56721. /**
  56722. * Creates a cylinder or a cone mesh
  56723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56725. * * 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.
  56726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56730. * * 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).
  56731. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56732. * * 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).
  56733. * * 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
  56734. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56735. * * 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
  56736. * * 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.
  56737. * * If `enclose` is false, a ring surface is one element.
  56738. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56739. * * 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
  56740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56741. * * 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
  56742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56743. * @param name defines the name of the mesh
  56744. * @param options defines the options used to create the mesh
  56745. * @param scene defines the hosting scene
  56746. * @returns the cylinder mesh
  56747. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56748. */
  56749. static CreateCylinder(name: string, options: {
  56750. height?: number;
  56751. diameterTop?: number;
  56752. diameterBottom?: number;
  56753. diameter?: number;
  56754. tessellation?: number;
  56755. subdivisions?: number;
  56756. arc?: number;
  56757. faceColors?: Color4[];
  56758. faceUV?: Vector4[];
  56759. updatable?: boolean;
  56760. hasRings?: boolean;
  56761. enclose?: boolean;
  56762. cap?: number;
  56763. sideOrientation?: number;
  56764. frontUVs?: Vector4;
  56765. backUVs?: Vector4;
  56766. }, scene?: Nullable<Scene>): Mesh;
  56767. /**
  56768. * Creates a torus mesh
  56769. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56770. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56771. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56773. * * 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
  56774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56775. * @param name defines the name of the mesh
  56776. * @param options defines the options used to create the mesh
  56777. * @param scene defines the hosting scene
  56778. * @returns the torus mesh
  56779. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56780. */
  56781. static CreateTorus(name: string, options: {
  56782. diameter?: number;
  56783. thickness?: number;
  56784. tessellation?: number;
  56785. updatable?: boolean;
  56786. sideOrientation?: number;
  56787. frontUVs?: Vector4;
  56788. backUVs?: Vector4;
  56789. }, scene?: Nullable<Scene>): Mesh;
  56790. /**
  56791. * Creates a torus knot mesh
  56792. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56793. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56794. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56795. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56797. * * 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
  56798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56799. * @param name defines the name of the mesh
  56800. * @param options defines the options used to create the mesh
  56801. * @param scene defines the hosting scene
  56802. * @returns the torus knot mesh
  56803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56804. */
  56805. static CreateTorusKnot(name: string, options: {
  56806. radius?: number;
  56807. tube?: number;
  56808. radialSegments?: number;
  56809. tubularSegments?: number;
  56810. p?: number;
  56811. q?: number;
  56812. updatable?: boolean;
  56813. sideOrientation?: number;
  56814. frontUVs?: Vector4;
  56815. backUVs?: Vector4;
  56816. }, scene?: Nullable<Scene>): Mesh;
  56817. /**
  56818. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56819. * * 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
  56820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56821. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56822. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56823. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56824. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56825. * * 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
  56826. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56829. * @param name defines the name of the new line system
  56830. * @param options defines the options used to create the line system
  56831. * @param scene defines the hosting scene
  56832. * @returns a new line system mesh
  56833. */
  56834. static CreateLineSystem(name: string, options: {
  56835. lines: Vector3[][];
  56836. updatable?: boolean;
  56837. instance?: Nullable<LinesMesh>;
  56838. colors?: Nullable<Color4[][]>;
  56839. useVertexAlpha?: boolean;
  56840. }, scene: Nullable<Scene>): LinesMesh;
  56841. /**
  56842. * Creates a line mesh
  56843. * 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
  56844. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56845. * * The parameter `points` is an array successive Vector3
  56846. * * 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
  56847. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56848. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56849. * * When updating an instance, remember that only point positions can change, not the number of points
  56850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56851. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56852. * @param name defines the name of the new line system
  56853. * @param options defines the options used to create the line system
  56854. * @param scene defines the hosting scene
  56855. * @returns a new line mesh
  56856. */
  56857. static CreateLines(name: string, options: {
  56858. points: Vector3[];
  56859. updatable?: boolean;
  56860. instance?: Nullable<LinesMesh>;
  56861. colors?: Color4[];
  56862. useVertexAlpha?: boolean;
  56863. }, scene?: Nullable<Scene>): LinesMesh;
  56864. /**
  56865. * Creates a dashed line mesh
  56866. * * 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
  56867. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56868. * * The parameter `points` is an array successive Vector3
  56869. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56870. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56871. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56872. * * 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
  56873. * * When updating an instance, remember that only point positions can change, not the number of points
  56874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56875. * @param name defines the name of the mesh
  56876. * @param options defines the options used to create the mesh
  56877. * @param scene defines the hosting scene
  56878. * @returns the dashed line mesh
  56879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56880. */
  56881. static CreateDashedLines(name: string, options: {
  56882. points: Vector3[];
  56883. dashSize?: number;
  56884. gapSize?: number;
  56885. dashNb?: number;
  56886. updatable?: boolean;
  56887. instance?: LinesMesh;
  56888. }, scene?: Nullable<Scene>): LinesMesh;
  56889. /**
  56890. * 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.
  56891. * * 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.
  56892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56893. * * 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.
  56894. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56895. * * 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
  56896. * * 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
  56897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56899. * * 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
  56900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56902. * @param name defines the name of the mesh
  56903. * @param options defines the options used to create the mesh
  56904. * @param scene defines the hosting scene
  56905. * @returns the extruded shape mesh
  56906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56908. */
  56909. static ExtrudeShape(name: string, options: {
  56910. shape: Vector3[];
  56911. path: Vector3[];
  56912. scale?: number;
  56913. rotation?: number;
  56914. cap?: number;
  56915. updatable?: boolean;
  56916. sideOrientation?: number;
  56917. frontUVs?: Vector4;
  56918. backUVs?: Vector4;
  56919. instance?: Mesh;
  56920. invertUV?: boolean;
  56921. }, scene?: Nullable<Scene>): Mesh;
  56922. /**
  56923. * Creates an custom extruded shape mesh.
  56924. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56925. * * 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.
  56926. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56927. * * 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
  56928. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56929. * * 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
  56930. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56931. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56932. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56933. * * 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
  56934. * * 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
  56935. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56937. * * 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
  56938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56940. * @param name defines the name of the mesh
  56941. * @param options defines the options used to create the mesh
  56942. * @param scene defines the hosting scene
  56943. * @returns the custom extruded shape mesh
  56944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56947. */
  56948. static ExtrudeShapeCustom(name: string, options: {
  56949. shape: Vector3[];
  56950. path: Vector3[];
  56951. scaleFunction?: any;
  56952. rotationFunction?: any;
  56953. ribbonCloseArray?: boolean;
  56954. ribbonClosePath?: boolean;
  56955. cap?: number;
  56956. updatable?: boolean;
  56957. sideOrientation?: number;
  56958. frontUVs?: Vector4;
  56959. backUVs?: Vector4;
  56960. instance?: Mesh;
  56961. invertUV?: boolean;
  56962. }, scene?: Nullable<Scene>): Mesh;
  56963. /**
  56964. * Creates lathe mesh.
  56965. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56966. * * 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
  56967. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56968. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56969. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56970. * * 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
  56971. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56972. * * 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
  56973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56974. * * 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
  56975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56977. * @param name defines the name of the mesh
  56978. * @param options defines the options used to create the mesh
  56979. * @param scene defines the hosting scene
  56980. * @returns the lathe mesh
  56981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56982. */
  56983. static CreateLathe(name: string, options: {
  56984. shape: Vector3[];
  56985. radius?: number;
  56986. tessellation?: number;
  56987. clip?: number;
  56988. arc?: number;
  56989. closed?: boolean;
  56990. updatable?: boolean;
  56991. sideOrientation?: number;
  56992. frontUVs?: Vector4;
  56993. backUVs?: Vector4;
  56994. cap?: number;
  56995. invertUV?: boolean;
  56996. }, scene?: Nullable<Scene>): Mesh;
  56997. /**
  56998. * Creates a tiled plane mesh
  56999. * * You can set a limited pattern arrangement with the tiles
  57000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57001. * * 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
  57002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57003. * @param name defines the name of the mesh
  57004. * @param options defines the options used to create the mesh
  57005. * @param scene defines the hosting scene
  57006. * @returns the plane mesh
  57007. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57008. */
  57009. static CreateTiledPlane(name: string, options: {
  57010. pattern?: number;
  57011. tileSize?: number;
  57012. tileWidth?: number;
  57013. tileHeight?: number;
  57014. size?: number;
  57015. width?: number;
  57016. height?: number;
  57017. alignHorizontal?: number;
  57018. alignVertical?: number;
  57019. sideOrientation?: number;
  57020. frontUVs?: Vector4;
  57021. backUVs?: Vector4;
  57022. updatable?: boolean;
  57023. }, scene?: Nullable<Scene>): Mesh;
  57024. /**
  57025. * Creates a plane mesh
  57026. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57027. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57028. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57030. * * 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
  57031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57032. * @param name defines the name of the mesh
  57033. * @param options defines the options used to create the mesh
  57034. * @param scene defines the hosting scene
  57035. * @returns the plane mesh
  57036. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57037. */
  57038. static CreatePlane(name: string, options: {
  57039. size?: number;
  57040. width?: number;
  57041. height?: number;
  57042. sideOrientation?: number;
  57043. frontUVs?: Vector4;
  57044. backUVs?: Vector4;
  57045. updatable?: boolean;
  57046. sourcePlane?: Plane;
  57047. }, scene?: Nullable<Scene>): Mesh;
  57048. /**
  57049. * Creates a ground mesh
  57050. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57051. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57053. * @param name defines the name of the mesh
  57054. * @param options defines the options used to create the mesh
  57055. * @param scene defines the hosting scene
  57056. * @returns the ground mesh
  57057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57058. */
  57059. static CreateGround(name: string, options: {
  57060. width?: number;
  57061. height?: number;
  57062. subdivisions?: number;
  57063. subdivisionsX?: number;
  57064. subdivisionsY?: number;
  57065. updatable?: boolean;
  57066. }, scene?: Nullable<Scene>): Mesh;
  57067. /**
  57068. * Creates a tiled ground mesh
  57069. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57070. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57071. * * 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
  57072. * * 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
  57073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57074. * @param name defines the name of the mesh
  57075. * @param options defines the options used to create the mesh
  57076. * @param scene defines the hosting scene
  57077. * @returns the tiled ground mesh
  57078. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57079. */
  57080. static CreateTiledGround(name: string, options: {
  57081. xmin: number;
  57082. zmin: number;
  57083. xmax: number;
  57084. zmax: number;
  57085. subdivisions?: {
  57086. w: number;
  57087. h: number;
  57088. };
  57089. precision?: {
  57090. w: number;
  57091. h: number;
  57092. };
  57093. updatable?: boolean;
  57094. }, scene?: Nullable<Scene>): Mesh;
  57095. /**
  57096. * Creates a ground mesh from a height map
  57097. * * The parameter `url` sets the URL of the height map image resource.
  57098. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57099. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57100. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57101. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57102. * * 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.
  57103. * * 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).
  57104. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57106. * @param name defines the name of the mesh
  57107. * @param url defines the url to the height map
  57108. * @param options defines the options used to create the mesh
  57109. * @param scene defines the hosting scene
  57110. * @returns the ground mesh
  57111. * @see https://doc.babylonjs.com/babylon101/height_map
  57112. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57113. */
  57114. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57115. width?: number;
  57116. height?: number;
  57117. subdivisions?: number;
  57118. minHeight?: number;
  57119. maxHeight?: number;
  57120. colorFilter?: Color3;
  57121. alphaFilter?: number;
  57122. updatable?: boolean;
  57123. onReady?: (mesh: GroundMesh) => void;
  57124. }, scene?: Nullable<Scene>): GroundMesh;
  57125. /**
  57126. * Creates a polygon mesh
  57127. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57128. * * 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
  57129. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57131. * * 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)
  57132. * * Remember you can only change the shape positions, not their number when updating a polygon
  57133. * @param name defines the name of the mesh
  57134. * @param options defines the options used to create the mesh
  57135. * @param scene defines the hosting scene
  57136. * @param earcutInjection can be used to inject your own earcut reference
  57137. * @returns the polygon mesh
  57138. */
  57139. static CreatePolygon(name: string, options: {
  57140. shape: Vector3[];
  57141. holes?: Vector3[][];
  57142. depth?: number;
  57143. faceUV?: Vector4[];
  57144. faceColors?: Color4[];
  57145. updatable?: boolean;
  57146. sideOrientation?: number;
  57147. frontUVs?: Vector4;
  57148. backUVs?: Vector4;
  57149. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57150. /**
  57151. * Creates an extruded polygon mesh, with depth in the Y direction.
  57152. * * 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)
  57153. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57154. * @param name defines the name of the mesh
  57155. * @param options defines the options used to create the mesh
  57156. * @param scene defines the hosting scene
  57157. * @param earcutInjection can be used to inject your own earcut reference
  57158. * @returns the polygon mesh
  57159. */
  57160. static ExtrudePolygon(name: string, options: {
  57161. shape: Vector3[];
  57162. holes?: Vector3[][];
  57163. depth?: number;
  57164. faceUV?: Vector4[];
  57165. faceColors?: Color4[];
  57166. updatable?: boolean;
  57167. sideOrientation?: number;
  57168. frontUVs?: Vector4;
  57169. backUVs?: Vector4;
  57170. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57171. /**
  57172. * Creates a tube mesh.
  57173. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57174. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57175. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57176. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57177. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57178. * * 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)
  57179. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57180. * * 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
  57181. * * 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
  57182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57183. * * 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
  57184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57186. * @param name defines the name of the mesh
  57187. * @param options defines the options used to create the mesh
  57188. * @param scene defines the hosting scene
  57189. * @returns the tube mesh
  57190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57191. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57192. */
  57193. static CreateTube(name: string, options: {
  57194. path: Vector3[];
  57195. radius?: number;
  57196. tessellation?: number;
  57197. radiusFunction?: {
  57198. (i: number, distance: number): number;
  57199. };
  57200. cap?: number;
  57201. arc?: number;
  57202. updatable?: boolean;
  57203. sideOrientation?: number;
  57204. frontUVs?: Vector4;
  57205. backUVs?: Vector4;
  57206. instance?: Mesh;
  57207. invertUV?: boolean;
  57208. }, scene?: Nullable<Scene>): Mesh;
  57209. /**
  57210. * Creates a polyhedron mesh
  57211. * * 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
  57212. * * The parameter `size` (positive float, default 1) sets the polygon size
  57213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57214. * * 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`
  57215. * * 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
  57216. * * 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)`)
  57217. * * 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
  57218. * * 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
  57219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57220. * * 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
  57221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57222. * @param name defines the name of the mesh
  57223. * @param options defines the options used to create the mesh
  57224. * @param scene defines the hosting scene
  57225. * @returns the polyhedron mesh
  57226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57227. */
  57228. static CreatePolyhedron(name: string, options: {
  57229. type?: number;
  57230. size?: number;
  57231. sizeX?: number;
  57232. sizeY?: number;
  57233. sizeZ?: number;
  57234. custom?: any;
  57235. faceUV?: Vector4[];
  57236. faceColors?: Color4[];
  57237. flat?: boolean;
  57238. updatable?: boolean;
  57239. sideOrientation?: number;
  57240. frontUVs?: Vector4;
  57241. backUVs?: Vector4;
  57242. }, scene?: Nullable<Scene>): Mesh;
  57243. /**
  57244. * Creates a decal mesh.
  57245. * 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
  57246. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57247. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57248. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57249. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57250. * @param name defines the name of the mesh
  57251. * @param sourceMesh defines the mesh where the decal must be applied
  57252. * @param options defines the options used to create the mesh
  57253. * @param scene defines the hosting scene
  57254. * @returns the decal mesh
  57255. * @see https://doc.babylonjs.com/how_to/decals
  57256. */
  57257. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57258. position?: Vector3;
  57259. normal?: Vector3;
  57260. size?: Vector3;
  57261. angle?: number;
  57262. }): Mesh;
  57263. }
  57264. }
  57265. declare module BABYLON {
  57266. /**
  57267. * A simplifier interface for future simplification implementations
  57268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57269. */
  57270. export interface ISimplifier {
  57271. /**
  57272. * Simplification of a given mesh according to the given settings.
  57273. * Since this requires computation, it is assumed that the function runs async.
  57274. * @param settings The settings of the simplification, including quality and distance
  57275. * @param successCallback A callback that will be called after the mesh was simplified.
  57276. * @param errorCallback in case of an error, this callback will be called. optional.
  57277. */
  57278. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57279. }
  57280. /**
  57281. * Expected simplification settings.
  57282. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57283. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57284. */
  57285. export interface ISimplificationSettings {
  57286. /**
  57287. * Gets or sets the expected quality
  57288. */
  57289. quality: number;
  57290. /**
  57291. * Gets or sets the distance when this optimized version should be used
  57292. */
  57293. distance: number;
  57294. /**
  57295. * Gets an already optimized mesh
  57296. */
  57297. optimizeMesh?: boolean;
  57298. }
  57299. /**
  57300. * Class used to specify simplification options
  57301. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57302. */
  57303. export class SimplificationSettings implements ISimplificationSettings {
  57304. /** expected quality */
  57305. quality: number;
  57306. /** distance when this optimized version should be used */
  57307. distance: number;
  57308. /** already optimized mesh */
  57309. optimizeMesh?: boolean | undefined;
  57310. /**
  57311. * Creates a SimplificationSettings
  57312. * @param quality expected quality
  57313. * @param distance distance when this optimized version should be used
  57314. * @param optimizeMesh already optimized mesh
  57315. */
  57316. constructor(
  57317. /** expected quality */
  57318. quality: number,
  57319. /** distance when this optimized version should be used */
  57320. distance: number,
  57321. /** already optimized mesh */
  57322. optimizeMesh?: boolean | undefined);
  57323. }
  57324. /**
  57325. * Interface used to define a simplification task
  57326. */
  57327. export interface ISimplificationTask {
  57328. /**
  57329. * Array of settings
  57330. */
  57331. settings: Array<ISimplificationSettings>;
  57332. /**
  57333. * Simplification type
  57334. */
  57335. simplificationType: SimplificationType;
  57336. /**
  57337. * Mesh to simplify
  57338. */
  57339. mesh: Mesh;
  57340. /**
  57341. * Callback called on success
  57342. */
  57343. successCallback?: () => void;
  57344. /**
  57345. * Defines if parallel processing can be used
  57346. */
  57347. parallelProcessing: boolean;
  57348. }
  57349. /**
  57350. * Queue used to order the simplification tasks
  57351. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57352. */
  57353. export class SimplificationQueue {
  57354. private _simplificationArray;
  57355. /**
  57356. * Gets a boolean indicating that the process is still running
  57357. */
  57358. running: boolean;
  57359. /**
  57360. * Creates a new queue
  57361. */
  57362. constructor();
  57363. /**
  57364. * Adds a new simplification task
  57365. * @param task defines a task to add
  57366. */
  57367. addTask(task: ISimplificationTask): void;
  57368. /**
  57369. * Execute next task
  57370. */
  57371. executeNext(): void;
  57372. /**
  57373. * Execute a simplification task
  57374. * @param task defines the task to run
  57375. */
  57376. runSimplification(task: ISimplificationTask): void;
  57377. private getSimplifier;
  57378. }
  57379. /**
  57380. * The implemented types of simplification
  57381. * At the moment only Quadratic Error Decimation is implemented
  57382. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57383. */
  57384. export enum SimplificationType {
  57385. /** Quadratic error decimation */
  57386. QUADRATIC = 0
  57387. }
  57388. }
  57389. declare module BABYLON {
  57390. interface Scene {
  57391. /** @hidden (Backing field) */
  57392. _simplificationQueue: SimplificationQueue;
  57393. /**
  57394. * Gets or sets the simplification queue attached to the scene
  57395. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57396. */
  57397. simplificationQueue: SimplificationQueue;
  57398. }
  57399. interface Mesh {
  57400. /**
  57401. * Simplify the mesh according to the given array of settings.
  57402. * Function will return immediately and will simplify async
  57403. * @param settings a collection of simplification settings
  57404. * @param parallelProcessing should all levels calculate parallel or one after the other
  57405. * @param simplificationType the type of simplification to run
  57406. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57407. * @returns the current mesh
  57408. */
  57409. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57410. }
  57411. /**
  57412. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57413. * created in a scene
  57414. */
  57415. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57416. /**
  57417. * The component name helpfull to identify the component in the list of scene components.
  57418. */
  57419. readonly name: string;
  57420. /**
  57421. * The scene the component belongs to.
  57422. */
  57423. scene: Scene;
  57424. /**
  57425. * Creates a new instance of the component for the given scene
  57426. * @param scene Defines the scene to register the component in
  57427. */
  57428. constructor(scene: Scene);
  57429. /**
  57430. * Registers the component in a given scene
  57431. */
  57432. register(): void;
  57433. /**
  57434. * Rebuilds the elements related to this component in case of
  57435. * context lost for instance.
  57436. */
  57437. rebuild(): void;
  57438. /**
  57439. * Disposes the component and the associated ressources
  57440. */
  57441. dispose(): void;
  57442. private _beforeCameraUpdate;
  57443. }
  57444. }
  57445. declare module BABYLON {
  57446. /**
  57447. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57448. */
  57449. export interface INavigationEnginePlugin {
  57450. /**
  57451. * plugin name
  57452. */
  57453. name: string;
  57454. /**
  57455. * Creates a navigation mesh
  57456. * @param meshes array of all the geometry used to compute the navigatio mesh
  57457. * @param parameters bunch of parameters used to filter geometry
  57458. */
  57459. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57460. /**
  57461. * Create a navigation mesh debug mesh
  57462. * @param scene is where the mesh will be added
  57463. * @returns debug display mesh
  57464. */
  57465. createDebugNavMesh(scene: Scene): Mesh;
  57466. /**
  57467. * Get a navigation mesh constrained position, closest to the parameter position
  57468. * @param position world position
  57469. * @returns the closest point to position constrained by the navigation mesh
  57470. */
  57471. getClosestPoint(position: Vector3): Vector3;
  57472. /**
  57473. * Get a navigation mesh constrained position, within a particular radius
  57474. * @param position world position
  57475. * @param maxRadius the maximum distance to the constrained world position
  57476. * @returns the closest point to position constrained by the navigation mesh
  57477. */
  57478. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57479. /**
  57480. * Compute the final position from a segment made of destination-position
  57481. * @param position world position
  57482. * @param destination world position
  57483. * @returns the resulting point along the navmesh
  57484. */
  57485. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57486. /**
  57487. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57488. * @param start world position
  57489. * @param end world position
  57490. * @returns array containing world position composing the path
  57491. */
  57492. computePath(start: Vector3, end: Vector3): Vector3[];
  57493. /**
  57494. * If this plugin is supported
  57495. * @returns true if plugin is supported
  57496. */
  57497. isSupported(): boolean;
  57498. /**
  57499. * Create a new Crowd so you can add agents
  57500. * @param maxAgents the maximum agent count in the crowd
  57501. * @param maxAgentRadius the maximum radius an agent can have
  57502. * @param scene to attach the crowd to
  57503. * @returns the crowd you can add agents to
  57504. */
  57505. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57506. /**
  57507. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57508. * The queries will try to find a solution within those bounds
  57509. * default is (1,1,1)
  57510. * @param extent x,y,z value that define the extent around the queries point of reference
  57511. */
  57512. setDefaultQueryExtent(extent: Vector3): void;
  57513. /**
  57514. * Get the Bounding box extent specified by setDefaultQueryExtent
  57515. * @returns the box extent values
  57516. */
  57517. getDefaultQueryExtent(): Vector3;
  57518. /**
  57519. * Release all resources
  57520. */
  57521. dispose(): void;
  57522. }
  57523. /**
  57524. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57525. */
  57526. export interface ICrowd {
  57527. /**
  57528. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57529. * You can attach anything to that node. The node position is updated in the scene update tick.
  57530. * @param pos world position that will be constrained by the navigation mesh
  57531. * @param parameters agent parameters
  57532. * @param transform hooked to the agent that will be update by the scene
  57533. * @returns agent index
  57534. */
  57535. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57536. /**
  57537. * Returns the agent position in world space
  57538. * @param index agent index returned by addAgent
  57539. * @returns world space position
  57540. */
  57541. getAgentPosition(index: number): Vector3;
  57542. /**
  57543. * Gets the agent velocity in world space
  57544. * @param index agent index returned by addAgent
  57545. * @returns world space velocity
  57546. */
  57547. getAgentVelocity(index: number): Vector3;
  57548. /**
  57549. * remove a particular agent previously created
  57550. * @param index agent index returned by addAgent
  57551. */
  57552. removeAgent(index: number): void;
  57553. /**
  57554. * get the list of all agents attached to this crowd
  57555. * @returns list of agent indices
  57556. */
  57557. getAgents(): number[];
  57558. /**
  57559. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57560. * @param deltaTime in seconds
  57561. */
  57562. update(deltaTime: number): void;
  57563. /**
  57564. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57565. * @param index agent index returned by addAgent
  57566. * @param destination targeted world position
  57567. */
  57568. agentGoto(index: number, destination: Vector3): void;
  57569. /**
  57570. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57571. * The queries will try to find a solution within those bounds
  57572. * default is (1,1,1)
  57573. * @param extent x,y,z value that define the extent around the queries point of reference
  57574. */
  57575. setDefaultQueryExtent(extent: Vector3): void;
  57576. /**
  57577. * Get the Bounding box extent specified by setDefaultQueryExtent
  57578. * @returns the box extent values
  57579. */
  57580. getDefaultQueryExtent(): Vector3;
  57581. /**
  57582. * Release all resources
  57583. */
  57584. dispose(): void;
  57585. }
  57586. /**
  57587. * Configures an agent
  57588. */
  57589. export interface IAgentParameters {
  57590. /**
  57591. * Agent radius. [Limit: >= 0]
  57592. */
  57593. radius: number;
  57594. /**
  57595. * Agent height. [Limit: > 0]
  57596. */
  57597. height: number;
  57598. /**
  57599. * Maximum allowed acceleration. [Limit: >= 0]
  57600. */
  57601. maxAcceleration: number;
  57602. /**
  57603. * Maximum allowed speed. [Limit: >= 0]
  57604. */
  57605. maxSpeed: number;
  57606. /**
  57607. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57608. */
  57609. collisionQueryRange: number;
  57610. /**
  57611. * The path visibility optimization range. [Limit: > 0]
  57612. */
  57613. pathOptimizationRange: number;
  57614. /**
  57615. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57616. */
  57617. separationWeight: number;
  57618. }
  57619. /**
  57620. * Configures the navigation mesh creation
  57621. */
  57622. export interface INavMeshParameters {
  57623. /**
  57624. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57625. */
  57626. cs: number;
  57627. /**
  57628. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57629. */
  57630. ch: number;
  57631. /**
  57632. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57633. */
  57634. walkableSlopeAngle: number;
  57635. /**
  57636. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57637. * be considered walkable. [Limit: >= 3] [Units: vx]
  57638. */
  57639. walkableHeight: number;
  57640. /**
  57641. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57642. */
  57643. walkableClimb: number;
  57644. /**
  57645. * The distance to erode/shrink the walkable area of the heightfield away from
  57646. * obstructions. [Limit: >=0] [Units: vx]
  57647. */
  57648. walkableRadius: number;
  57649. /**
  57650. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57651. */
  57652. maxEdgeLen: number;
  57653. /**
  57654. * The maximum distance a simplfied contour's border edges should deviate
  57655. * the original raw contour. [Limit: >=0] [Units: vx]
  57656. */
  57657. maxSimplificationError: number;
  57658. /**
  57659. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57660. */
  57661. minRegionArea: number;
  57662. /**
  57663. * Any regions with a span count smaller than this value will, if possible,
  57664. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57665. */
  57666. mergeRegionArea: number;
  57667. /**
  57668. * The maximum number of vertices allowed for polygons generated during the
  57669. * contour to polygon conversion process. [Limit: >= 3]
  57670. */
  57671. maxVertsPerPoly: number;
  57672. /**
  57673. * Sets the sampling distance to use when generating the detail mesh.
  57674. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57675. */
  57676. detailSampleDist: number;
  57677. /**
  57678. * The maximum distance the detail mesh surface should deviate from heightfield
  57679. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57680. */
  57681. detailSampleMaxError: number;
  57682. }
  57683. }
  57684. declare module BABYLON {
  57685. /**
  57686. * RecastJS navigation plugin
  57687. */
  57688. export class RecastJSPlugin implements INavigationEnginePlugin {
  57689. /**
  57690. * Reference to the Recast library
  57691. */
  57692. bjsRECAST: any;
  57693. /**
  57694. * plugin name
  57695. */
  57696. name: string;
  57697. /**
  57698. * the first navmesh created. We might extend this to support multiple navmeshes
  57699. */
  57700. navMesh: any;
  57701. /**
  57702. * Initializes the recastJS plugin
  57703. * @param recastInjection can be used to inject your own recast reference
  57704. */
  57705. constructor(recastInjection?: any);
  57706. /**
  57707. * Creates a navigation mesh
  57708. * @param meshes array of all the geometry used to compute the navigatio mesh
  57709. * @param parameters bunch of parameters used to filter geometry
  57710. */
  57711. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57712. /**
  57713. * Create a navigation mesh debug mesh
  57714. * @param scene is where the mesh will be added
  57715. * @returns debug display mesh
  57716. */
  57717. createDebugNavMesh(scene: Scene): Mesh;
  57718. /**
  57719. * Get a navigation mesh constrained position, closest to the parameter position
  57720. * @param position world position
  57721. * @returns the closest point to position constrained by the navigation mesh
  57722. */
  57723. getClosestPoint(position: Vector3): Vector3;
  57724. /**
  57725. * Get a navigation mesh constrained position, within a particular radius
  57726. * @param position world position
  57727. * @param maxRadius the maximum distance to the constrained world position
  57728. * @returns the closest point to position constrained by the navigation mesh
  57729. */
  57730. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57731. /**
  57732. * Compute the final position from a segment made of destination-position
  57733. * @param position world position
  57734. * @param destination world position
  57735. * @returns the resulting point along the navmesh
  57736. */
  57737. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57738. /**
  57739. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57740. * @param start world position
  57741. * @param end world position
  57742. * @returns array containing world position composing the path
  57743. */
  57744. computePath(start: Vector3, end: Vector3): Vector3[];
  57745. /**
  57746. * Create a new Crowd so you can add agents
  57747. * @param maxAgents the maximum agent count in the crowd
  57748. * @param maxAgentRadius the maximum radius an agent can have
  57749. * @param scene to attach the crowd to
  57750. * @returns the crowd you can add agents to
  57751. */
  57752. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57753. /**
  57754. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57755. * The queries will try to find a solution within those bounds
  57756. * default is (1,1,1)
  57757. * @param extent x,y,z value that define the extent around the queries point of reference
  57758. */
  57759. setDefaultQueryExtent(extent: Vector3): void;
  57760. /**
  57761. * Get the Bounding box extent specified by setDefaultQueryExtent
  57762. * @returns the box extent values
  57763. */
  57764. getDefaultQueryExtent(): Vector3;
  57765. /**
  57766. * Disposes
  57767. */
  57768. dispose(): void;
  57769. /**
  57770. * If this plugin is supported
  57771. * @returns true if plugin is supported
  57772. */
  57773. isSupported(): boolean;
  57774. }
  57775. /**
  57776. * Recast detour crowd implementation
  57777. */
  57778. export class RecastJSCrowd implements ICrowd {
  57779. /**
  57780. * Recast/detour plugin
  57781. */
  57782. bjsRECASTPlugin: RecastJSPlugin;
  57783. /**
  57784. * Link to the detour crowd
  57785. */
  57786. recastCrowd: any;
  57787. /**
  57788. * One transform per agent
  57789. */
  57790. transforms: TransformNode[];
  57791. /**
  57792. * All agents created
  57793. */
  57794. agents: number[];
  57795. /**
  57796. * Link to the scene is kept to unregister the crowd from the scene
  57797. */
  57798. private _scene;
  57799. /**
  57800. * Observer for crowd updates
  57801. */
  57802. private _onBeforeAnimationsObserver;
  57803. /**
  57804. * Constructor
  57805. * @param plugin recastJS plugin
  57806. * @param maxAgents the maximum agent count in the crowd
  57807. * @param maxAgentRadius the maximum radius an agent can have
  57808. * @param scene to attach the crowd to
  57809. * @returns the crowd you can add agents to
  57810. */
  57811. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57812. /**
  57813. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57814. * You can attach anything to that node. The node position is updated in the scene update tick.
  57815. * @param pos world position that will be constrained by the navigation mesh
  57816. * @param parameters agent parameters
  57817. * @param transform hooked to the agent that will be update by the scene
  57818. * @returns agent index
  57819. */
  57820. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57821. /**
  57822. * Returns the agent position in world space
  57823. * @param index agent index returned by addAgent
  57824. * @returns world space position
  57825. */
  57826. getAgentPosition(index: number): Vector3;
  57827. /**
  57828. * Returns the agent velocity in world space
  57829. * @param index agent index returned by addAgent
  57830. * @returns world space velocity
  57831. */
  57832. getAgentVelocity(index: number): Vector3;
  57833. /**
  57834. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57835. * @param index agent index returned by addAgent
  57836. * @param destination targeted world position
  57837. */
  57838. agentGoto(index: number, destination: Vector3): void;
  57839. /**
  57840. * remove a particular agent previously created
  57841. * @param index agent index returned by addAgent
  57842. */
  57843. removeAgent(index: number): void;
  57844. /**
  57845. * get the list of all agents attached to this crowd
  57846. * @returns list of agent indices
  57847. */
  57848. getAgents(): number[];
  57849. /**
  57850. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57851. * @param deltaTime in seconds
  57852. */
  57853. update(deltaTime: number): void;
  57854. /**
  57855. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57856. * The queries will try to find a solution within those bounds
  57857. * default is (1,1,1)
  57858. * @param extent x,y,z value that define the extent around the queries point of reference
  57859. */
  57860. setDefaultQueryExtent(extent: Vector3): void;
  57861. /**
  57862. * Get the Bounding box extent specified by setDefaultQueryExtent
  57863. * @returns the box extent values
  57864. */
  57865. getDefaultQueryExtent(): Vector3;
  57866. /**
  57867. * Release all resources
  57868. */
  57869. dispose(): void;
  57870. }
  57871. }
  57872. declare module BABYLON {
  57873. /**
  57874. * Class used to enable access to IndexedDB
  57875. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57876. */
  57877. export class Database implements IOfflineProvider {
  57878. private _callbackManifestChecked;
  57879. private _currentSceneUrl;
  57880. private _db;
  57881. private _enableSceneOffline;
  57882. private _enableTexturesOffline;
  57883. private _manifestVersionFound;
  57884. private _mustUpdateRessources;
  57885. private _hasReachedQuota;
  57886. private _isSupported;
  57887. private _idbFactory;
  57888. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57889. private static IsUASupportingBlobStorage;
  57890. /**
  57891. * Gets a boolean indicating if Database storate is enabled (off by default)
  57892. */
  57893. static IDBStorageEnabled: boolean;
  57894. /**
  57895. * Gets a boolean indicating if scene must be saved in the database
  57896. */
  57897. readonly enableSceneOffline: boolean;
  57898. /**
  57899. * Gets a boolean indicating if textures must be saved in the database
  57900. */
  57901. readonly enableTexturesOffline: boolean;
  57902. /**
  57903. * Creates a new Database
  57904. * @param urlToScene defines the url to load the scene
  57905. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57906. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57907. */
  57908. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57909. private static _ParseURL;
  57910. private static _ReturnFullUrlLocation;
  57911. private _checkManifestFile;
  57912. /**
  57913. * Open the database and make it available
  57914. * @param successCallback defines the callback to call on success
  57915. * @param errorCallback defines the callback to call on error
  57916. */
  57917. open(successCallback: () => void, errorCallback: () => void): void;
  57918. /**
  57919. * Loads an image from the database
  57920. * @param url defines the url to load from
  57921. * @param image defines the target DOM image
  57922. */
  57923. loadImage(url: string, image: HTMLImageElement): void;
  57924. private _loadImageFromDBAsync;
  57925. private _saveImageIntoDBAsync;
  57926. private _checkVersionFromDB;
  57927. private _loadVersionFromDBAsync;
  57928. private _saveVersionIntoDBAsync;
  57929. /**
  57930. * Loads a file from database
  57931. * @param url defines the URL to load from
  57932. * @param sceneLoaded defines a callback to call on success
  57933. * @param progressCallBack defines a callback to call when progress changed
  57934. * @param errorCallback defines a callback to call on error
  57935. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57936. */
  57937. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57938. private _loadFileAsync;
  57939. private _saveFileAsync;
  57940. /**
  57941. * Validates if xhr data is correct
  57942. * @param xhr defines the request to validate
  57943. * @param dataType defines the expected data type
  57944. * @returns true if data is correct
  57945. */
  57946. private static _ValidateXHRData;
  57947. }
  57948. }
  57949. declare module BABYLON {
  57950. /** @hidden */
  57951. export var gpuUpdateParticlesPixelShader: {
  57952. name: string;
  57953. shader: string;
  57954. };
  57955. }
  57956. declare module BABYLON {
  57957. /** @hidden */
  57958. export var gpuUpdateParticlesVertexShader: {
  57959. name: string;
  57960. shader: string;
  57961. };
  57962. }
  57963. declare module BABYLON {
  57964. /** @hidden */
  57965. export var clipPlaneFragmentDeclaration2: {
  57966. name: string;
  57967. shader: string;
  57968. };
  57969. }
  57970. declare module BABYLON {
  57971. /** @hidden */
  57972. export var gpuRenderParticlesPixelShader: {
  57973. name: string;
  57974. shader: string;
  57975. };
  57976. }
  57977. declare module BABYLON {
  57978. /** @hidden */
  57979. export var clipPlaneVertexDeclaration2: {
  57980. name: string;
  57981. shader: string;
  57982. };
  57983. }
  57984. declare module BABYLON {
  57985. /** @hidden */
  57986. export var gpuRenderParticlesVertexShader: {
  57987. name: string;
  57988. shader: string;
  57989. };
  57990. }
  57991. declare module BABYLON {
  57992. /**
  57993. * This represents a GPU particle system in Babylon
  57994. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57995. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57996. */
  57997. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57998. /**
  57999. * The layer mask we are rendering the particles through.
  58000. */
  58001. layerMask: number;
  58002. private _capacity;
  58003. private _activeCount;
  58004. private _currentActiveCount;
  58005. private _accumulatedCount;
  58006. private _renderEffect;
  58007. private _updateEffect;
  58008. private _buffer0;
  58009. private _buffer1;
  58010. private _spriteBuffer;
  58011. private _updateVAO;
  58012. private _renderVAO;
  58013. private _targetIndex;
  58014. private _sourceBuffer;
  58015. private _targetBuffer;
  58016. private _engine;
  58017. private _currentRenderId;
  58018. private _started;
  58019. private _stopped;
  58020. private _timeDelta;
  58021. private _randomTexture;
  58022. private _randomTexture2;
  58023. private _attributesStrideSize;
  58024. private _updateEffectOptions;
  58025. private _randomTextureSize;
  58026. private _actualFrame;
  58027. private readonly _rawTextureWidth;
  58028. /**
  58029. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58030. */
  58031. static readonly IsSupported: boolean;
  58032. /**
  58033. * An event triggered when the system is disposed.
  58034. */
  58035. onDisposeObservable: Observable<GPUParticleSystem>;
  58036. /**
  58037. * Gets the maximum number of particles active at the same time.
  58038. * @returns The max number of active particles.
  58039. */
  58040. getCapacity(): number;
  58041. /**
  58042. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58043. * to override the particles.
  58044. */
  58045. forceDepthWrite: boolean;
  58046. /**
  58047. * Gets or set the number of active particles
  58048. */
  58049. activeParticleCount: number;
  58050. private _preWarmDone;
  58051. /**
  58052. * Is this system ready to be used/rendered
  58053. * @return true if the system is ready
  58054. */
  58055. isReady(): boolean;
  58056. /**
  58057. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58058. * @returns True if it has been started, otherwise false.
  58059. */
  58060. isStarted(): boolean;
  58061. /**
  58062. * Starts the particle system and begins to emit
  58063. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58064. */
  58065. start(delay?: number): void;
  58066. /**
  58067. * Stops the particle system.
  58068. */
  58069. stop(): void;
  58070. /**
  58071. * Remove all active particles
  58072. */
  58073. reset(): void;
  58074. /**
  58075. * Returns the string "GPUParticleSystem"
  58076. * @returns a string containing the class name
  58077. */
  58078. getClassName(): string;
  58079. private _colorGradientsTexture;
  58080. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58081. /**
  58082. * Adds a new color gradient
  58083. * @param gradient defines the gradient to use (between 0 and 1)
  58084. * @param color1 defines the color to affect to the specified gradient
  58085. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58086. * @returns the current particle system
  58087. */
  58088. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58089. /**
  58090. * Remove a specific color gradient
  58091. * @param gradient defines the gradient to remove
  58092. * @returns the current particle system
  58093. */
  58094. removeColorGradient(gradient: number): GPUParticleSystem;
  58095. private _angularSpeedGradientsTexture;
  58096. private _sizeGradientsTexture;
  58097. private _velocityGradientsTexture;
  58098. private _limitVelocityGradientsTexture;
  58099. private _dragGradientsTexture;
  58100. private _addFactorGradient;
  58101. /**
  58102. * Adds a new size gradient
  58103. * @param gradient defines the gradient to use (between 0 and 1)
  58104. * @param factor defines the size factor to affect to the specified gradient
  58105. * @returns the current particle system
  58106. */
  58107. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58108. /**
  58109. * Remove a specific size gradient
  58110. * @param gradient defines the gradient to remove
  58111. * @returns the current particle system
  58112. */
  58113. removeSizeGradient(gradient: number): GPUParticleSystem;
  58114. /**
  58115. * Adds a new angular speed gradient
  58116. * @param gradient defines the gradient to use (between 0 and 1)
  58117. * @param factor defines the angular speed to affect to the specified gradient
  58118. * @returns the current particle system
  58119. */
  58120. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58121. /**
  58122. * Remove a specific angular speed gradient
  58123. * @param gradient defines the gradient to remove
  58124. * @returns the current particle system
  58125. */
  58126. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58127. /**
  58128. * Adds a new velocity gradient
  58129. * @param gradient defines the gradient to use (between 0 and 1)
  58130. * @param factor defines the velocity to affect to the specified gradient
  58131. * @returns the current particle system
  58132. */
  58133. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58134. /**
  58135. * Remove a specific velocity gradient
  58136. * @param gradient defines the gradient to remove
  58137. * @returns the current particle system
  58138. */
  58139. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58140. /**
  58141. * Adds a new limit velocity gradient
  58142. * @param gradient defines the gradient to use (between 0 and 1)
  58143. * @param factor defines the limit velocity value to affect to the specified gradient
  58144. * @returns the current particle system
  58145. */
  58146. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58147. /**
  58148. * Remove a specific limit velocity gradient
  58149. * @param gradient defines the gradient to remove
  58150. * @returns the current particle system
  58151. */
  58152. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58153. /**
  58154. * Adds a new drag gradient
  58155. * @param gradient defines the gradient to use (between 0 and 1)
  58156. * @param factor defines the drag value to affect to the specified gradient
  58157. * @returns the current particle system
  58158. */
  58159. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58160. /**
  58161. * Remove a specific drag gradient
  58162. * @param gradient defines the gradient to remove
  58163. * @returns the current particle system
  58164. */
  58165. removeDragGradient(gradient: number): GPUParticleSystem;
  58166. /**
  58167. * Not supported by GPUParticleSystem
  58168. * @param gradient defines the gradient to use (between 0 and 1)
  58169. * @param factor defines the emit rate value to affect to the specified gradient
  58170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58171. * @returns the current particle system
  58172. */
  58173. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58174. /**
  58175. * Not supported by GPUParticleSystem
  58176. * @param gradient defines the gradient to remove
  58177. * @returns the current particle system
  58178. */
  58179. removeEmitRateGradient(gradient: number): IParticleSystem;
  58180. /**
  58181. * Not supported by GPUParticleSystem
  58182. * @param gradient defines the gradient to use (between 0 and 1)
  58183. * @param factor defines the start size value to affect to the specified gradient
  58184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58185. * @returns the current particle system
  58186. */
  58187. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58188. /**
  58189. * Not supported by GPUParticleSystem
  58190. * @param gradient defines the gradient to remove
  58191. * @returns the current particle system
  58192. */
  58193. removeStartSizeGradient(gradient: number): IParticleSystem;
  58194. /**
  58195. * Not supported by GPUParticleSystem
  58196. * @param gradient defines the gradient to use (between 0 and 1)
  58197. * @param min defines the color remap minimal range
  58198. * @param max defines the color remap maximal range
  58199. * @returns the current particle system
  58200. */
  58201. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58202. /**
  58203. * Not supported by GPUParticleSystem
  58204. * @param gradient defines the gradient to remove
  58205. * @returns the current particle system
  58206. */
  58207. removeColorRemapGradient(): IParticleSystem;
  58208. /**
  58209. * Not supported by GPUParticleSystem
  58210. * @param gradient defines the gradient to use (between 0 and 1)
  58211. * @param min defines the alpha remap minimal range
  58212. * @param max defines the alpha remap maximal range
  58213. * @returns the current particle system
  58214. */
  58215. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58216. /**
  58217. * Not supported by GPUParticleSystem
  58218. * @param gradient defines the gradient to remove
  58219. * @returns the current particle system
  58220. */
  58221. removeAlphaRemapGradient(): IParticleSystem;
  58222. /**
  58223. * Not supported by GPUParticleSystem
  58224. * @param gradient defines the gradient to use (between 0 and 1)
  58225. * @param color defines the color to affect to the specified gradient
  58226. * @returns the current particle system
  58227. */
  58228. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58229. /**
  58230. * Not supported by GPUParticleSystem
  58231. * @param gradient defines the gradient to remove
  58232. * @returns the current particle system
  58233. */
  58234. removeRampGradient(): IParticleSystem;
  58235. /**
  58236. * Not supported by GPUParticleSystem
  58237. * @returns the list of ramp gradients
  58238. */
  58239. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58240. /**
  58241. * Not supported by GPUParticleSystem
  58242. * Gets or sets a boolean indicating that ramp gradients must be used
  58243. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58244. */
  58245. useRampGradients: boolean;
  58246. /**
  58247. * Not supported by GPUParticleSystem
  58248. * @param gradient defines the gradient to use (between 0 and 1)
  58249. * @param factor defines the life time factor to affect to the specified gradient
  58250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58251. * @returns the current particle system
  58252. */
  58253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58254. /**
  58255. * Not supported by GPUParticleSystem
  58256. * @param gradient defines the gradient to remove
  58257. * @returns the current particle system
  58258. */
  58259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58260. /**
  58261. * Instantiates a GPU particle system.
  58262. * 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.
  58263. * @param name The name of the particle system
  58264. * @param options The options used to create the system
  58265. * @param scene The scene the particle system belongs to
  58266. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58267. */
  58268. constructor(name: string, options: Partial<{
  58269. capacity: number;
  58270. randomTextureSize: number;
  58271. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58272. protected _reset(): void;
  58273. private _createUpdateVAO;
  58274. private _createRenderVAO;
  58275. private _initialize;
  58276. /** @hidden */
  58277. _recreateUpdateEffect(): void;
  58278. /** @hidden */
  58279. _recreateRenderEffect(): void;
  58280. /**
  58281. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58282. * @param preWarm defines if we are in the pre-warmimg phase
  58283. */
  58284. animate(preWarm?: boolean): void;
  58285. private _createFactorGradientTexture;
  58286. private _createSizeGradientTexture;
  58287. private _createAngularSpeedGradientTexture;
  58288. private _createVelocityGradientTexture;
  58289. private _createLimitVelocityGradientTexture;
  58290. private _createDragGradientTexture;
  58291. private _createColorGradientTexture;
  58292. /**
  58293. * Renders the particle system in its current state
  58294. * @param preWarm defines if the system should only update the particles but not render them
  58295. * @returns the current number of particles
  58296. */
  58297. render(preWarm?: boolean): number;
  58298. /**
  58299. * Rebuilds the particle system
  58300. */
  58301. rebuild(): void;
  58302. private _releaseBuffers;
  58303. private _releaseVAOs;
  58304. /**
  58305. * Disposes the particle system and free the associated resources
  58306. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58307. */
  58308. dispose(disposeTexture?: boolean): void;
  58309. /**
  58310. * Clones the particle system.
  58311. * @param name The name of the cloned object
  58312. * @param newEmitter The new emitter to use
  58313. * @returns the cloned particle system
  58314. */
  58315. clone(name: string, newEmitter: any): GPUParticleSystem;
  58316. /**
  58317. * Serializes the particle system to a JSON object.
  58318. * @returns the JSON object
  58319. */
  58320. serialize(): any;
  58321. /**
  58322. * Parses a JSON object to create a GPU particle system.
  58323. * @param parsedParticleSystem The JSON object to parse
  58324. * @param scene The scene to create the particle system in
  58325. * @param rootUrl The root url to use to load external dependencies like texture
  58326. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58327. * @returns the parsed GPU particle system
  58328. */
  58329. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58330. }
  58331. }
  58332. declare module BABYLON {
  58333. /**
  58334. * Represents a set of particle systems working together to create a specific effect
  58335. */
  58336. export class ParticleSystemSet implements IDisposable {
  58337. /**
  58338. * Gets or sets base Assets URL
  58339. */
  58340. static BaseAssetsUrl: string;
  58341. private _emitterCreationOptions;
  58342. private _emitterNode;
  58343. /**
  58344. * Gets the particle system list
  58345. */
  58346. systems: IParticleSystem[];
  58347. /**
  58348. * Gets the emitter node used with this set
  58349. */
  58350. readonly emitterNode: Nullable<TransformNode>;
  58351. /**
  58352. * Creates a new emitter mesh as a sphere
  58353. * @param options defines the options used to create the sphere
  58354. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58355. * @param scene defines the hosting scene
  58356. */
  58357. setEmitterAsSphere(options: {
  58358. diameter: number;
  58359. segments: number;
  58360. color: Color3;
  58361. }, renderingGroupId: number, scene: Scene): void;
  58362. /**
  58363. * Starts all particle systems of the set
  58364. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58365. */
  58366. start(emitter?: AbstractMesh): void;
  58367. /**
  58368. * Release all associated resources
  58369. */
  58370. dispose(): void;
  58371. /**
  58372. * Serialize the set into a JSON compatible object
  58373. * @returns a JSON compatible representation of the set
  58374. */
  58375. serialize(): any;
  58376. /**
  58377. * Parse a new ParticleSystemSet from a serialized source
  58378. * @param data defines a JSON compatible representation of the set
  58379. * @param scene defines the hosting scene
  58380. * @param gpu defines if we want GPU particles or CPU particles
  58381. * @returns a new ParticleSystemSet
  58382. */
  58383. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58384. }
  58385. }
  58386. declare module BABYLON {
  58387. /**
  58388. * This class is made for on one-liner static method to help creating particle system set.
  58389. */
  58390. export class ParticleHelper {
  58391. /**
  58392. * Gets or sets base Assets URL
  58393. */
  58394. static BaseAssetsUrl: string;
  58395. /**
  58396. * Create a default particle system that you can tweak
  58397. * @param emitter defines the emitter to use
  58398. * @param capacity defines the system capacity (default is 500 particles)
  58399. * @param scene defines the hosting scene
  58400. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58401. * @returns the new Particle system
  58402. */
  58403. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58404. /**
  58405. * This is the main static method (one-liner) of this helper to create different particle systems
  58406. * @param type This string represents the type to the particle system to create
  58407. * @param scene The scene where the particle system should live
  58408. * @param gpu If the system will use gpu
  58409. * @returns the ParticleSystemSet created
  58410. */
  58411. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58412. /**
  58413. * Static function used to export a particle system to a ParticleSystemSet variable.
  58414. * Please note that the emitter shape is not exported
  58415. * @param systems defines the particle systems to export
  58416. * @returns the created particle system set
  58417. */
  58418. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. interface Engine {
  58423. /**
  58424. * Create an effect to use with particle systems.
  58425. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58426. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58427. * @param uniformsNames defines a list of attribute names
  58428. * @param samplers defines an array of string used to represent textures
  58429. * @param defines defines the string containing the defines to use to compile the shaders
  58430. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58431. * @param onCompiled defines a function to call when the effect creation is successful
  58432. * @param onError defines a function to call when the effect creation has failed
  58433. * @returns the new Effect
  58434. */
  58435. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58436. }
  58437. interface Mesh {
  58438. /**
  58439. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58440. * @returns an array of IParticleSystem
  58441. */
  58442. getEmittedParticleSystems(): IParticleSystem[];
  58443. /**
  58444. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58445. * @returns an array of IParticleSystem
  58446. */
  58447. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58448. }
  58449. /**
  58450. * @hidden
  58451. */
  58452. export var _IDoNeedToBeInTheBuild: number;
  58453. }
  58454. declare module BABYLON {
  58455. /** Defines the 4 color options */
  58456. export enum PointColor {
  58457. /** color value */
  58458. Color = 2,
  58459. /** uv value */
  58460. UV = 1,
  58461. /** random value */
  58462. Random = 0,
  58463. /** stated value */
  58464. Stated = 3
  58465. }
  58466. /**
  58467. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  58468. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  58469. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  58470. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  58471. *
  58472. * Full documentation here : TO BE ENTERED
  58473. */
  58474. export class PointsCloudSystem implements IDisposable {
  58475. /**
  58476. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  58477. * Example : var p = SPS.particles[i];
  58478. */
  58479. particles: CloudPoint[];
  58480. /**
  58481. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  58482. */
  58483. nbParticles: number;
  58484. /**
  58485. * This a counter for your own usage. It's not set by any SPS functions.
  58486. */
  58487. counter: number;
  58488. /**
  58489. * The PCS name. This name is also given to the underlying mesh.
  58490. */
  58491. name: string;
  58492. /**
  58493. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  58494. */
  58495. mesh: Mesh;
  58496. /**
  58497. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  58498. * Please read :
  58499. */
  58500. vars: any;
  58501. /**
  58502. * @hidden
  58503. */
  58504. _size: number;
  58505. private _scene;
  58506. private _promises;
  58507. private _positions;
  58508. private _indices;
  58509. private _normals;
  58510. private _colors;
  58511. private _uvs;
  58512. private _indices32;
  58513. private _positions32;
  58514. private _colors32;
  58515. private _uvs32;
  58516. private _updatable;
  58517. private _isVisibilityBoxLocked;
  58518. private _alwaysVisible;
  58519. private _groups;
  58520. private _groupCounter;
  58521. private _computeParticleColor;
  58522. private _computeParticleTexture;
  58523. private _computeParticleRotation;
  58524. private _computeBoundingBox;
  58525. private _isReady;
  58526. /**
  58527. * Creates a PCS (Points Cloud System) object
  58528. * @param name (String) is the PCS name, this will be the underlying mesh name
  58529. * @param pointSize (number) is the size for each point
  58530. * @param scene (Scene) is the scene in which the PCS is added
  58531. * @param options defines the options of the PCS e.g.
  58532. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  58533. */
  58534. constructor(name: string, pointSize: number, scene: Scene, options?: {
  58535. updatable?: boolean;
  58536. });
  58537. /**
  58538. * Builds the PCS underlying mesh. Returns a standard Mesh.
  58539. * If no points were added to the PCS, the returned mesh is just a single point.
  58540. * @returns a promise for the created mesh
  58541. */
  58542. buildMeshAsync(): Promise<Mesh>;
  58543. /**
  58544. * @hidden
  58545. */
  58546. private _buildMesh;
  58547. private _addParticle;
  58548. private _randomUnitVector;
  58549. private _getColorIndicesForCoord;
  58550. private _setPointsColorOrUV;
  58551. private _colorFromTexture;
  58552. private _calculateDensity;
  58553. /**
  58554. * Adds points to the PCS in random positions within a unit sphere
  58555. * @param nb (positive integer) the number of particles to be created from this model
  58556. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  58557. * @returns the number of groups in the system
  58558. */
  58559. addPoints(nb: number, pointFunction?: any): number;
  58560. /**
  58561. * Adds points to the PCS from the surface of the model shape
  58562. * @param mesh is any Mesh object that will be used as a surface model for the points
  58563. * @param nb (positive integer) the number of particles to be created from this model
  58564. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  58565. * @param color (color3) to be used when colorWith is stated
  58566. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58567. * @returns the number of groups in the system
  58568. */
  58569. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58570. /**
  58571. * Adds points to the PCS inside the model shape
  58572. * @param mesh is any Mesh object that will be used as a surface model for the points
  58573. * @param nb (positive integer) the number of particles to be created from this model
  58574. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  58575. * @param color (color4) to be used when colorWith is stated
  58576. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  58577. * @returns the number of groups in the system
  58578. */
  58579. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  58580. /**
  58581. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  58582. * This method calls `updateParticle()` for each particle of the SPS.
  58583. * For an animated SPS, it is usually called within the render loop.
  58584. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  58585. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  58586. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  58587. * @returns the PCS.
  58588. */
  58589. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  58590. /**
  58591. * Disposes the PCS.
  58592. */
  58593. dispose(): void;
  58594. /**
  58595. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  58596. * doc :
  58597. * @returns the PCS.
  58598. */
  58599. refreshVisibleSize(): PointsCloudSystem;
  58600. /**
  58601. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  58602. * @param size the size (float) of the visibility box
  58603. * note : this doesn't lock the PCS mesh bounding box.
  58604. * doc :
  58605. */
  58606. setVisibilityBox(size: number): void;
  58607. /**
  58608. * Gets whether the PCS is always visible or not
  58609. * doc :
  58610. */
  58611. /**
  58612. * Sets the PCS as always visible or not
  58613. * doc :
  58614. */
  58615. isAlwaysVisible: boolean;
  58616. /**
  58617. * Tells to `setParticles()` to compute the particle rotations or not
  58618. * Default value : false. The PCS is faster when it's set to false
  58619. * Note : particle rotations are only applied to parent particles
  58620. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  58621. */
  58622. computeParticleRotation: boolean;
  58623. /**
  58624. * Tells to `setParticles()` to compute the particle colors or not.
  58625. * Default value : true. The PCS is faster when it's set to false.
  58626. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58627. */
  58628. /**
  58629. * Gets if `setParticles()` computes the particle colors or not.
  58630. * Default value : false. The PCS is faster when it's set to false.
  58631. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  58632. */
  58633. computeParticleColor: boolean;
  58634. /**
  58635. * Gets if `setParticles()` computes the particle textures or not.
  58636. * Default value : false. The PCS is faster when it's set to false.
  58637. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  58638. */
  58639. computeParticleTexture: boolean;
  58640. /**
  58641. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  58642. */
  58643. /**
  58644. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  58645. */
  58646. computeBoundingBox: boolean;
  58647. /**
  58648. * This function does nothing. It may be overwritten to set all the particle first values.
  58649. * The PCS doesn't call this function, you may have to call it by your own.
  58650. * doc :
  58651. */
  58652. initParticles(): void;
  58653. /**
  58654. * This function does nothing. It may be overwritten to recycle a particle
  58655. * The PCS doesn't call this function, you can to call it
  58656. * doc :
  58657. * @param particle The particle to recycle
  58658. * @returns the recycled particle
  58659. */
  58660. recycleParticle(particle: CloudPoint): CloudPoint;
  58661. /**
  58662. * Updates a particle : this function should be overwritten by the user.
  58663. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  58664. * doc :
  58665. * @example : just set a particle position or velocity and recycle conditions
  58666. * @param particle The particle to update
  58667. * @returns the updated particle
  58668. */
  58669. updateParticle(particle: CloudPoint): CloudPoint;
  58670. /**
  58671. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  58672. * This does nothing and may be overwritten by the user.
  58673. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58674. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58675. * @param update the boolean update value actually passed to setParticles()
  58676. */
  58677. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58678. /**
  58679. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  58680. * This will be passed three parameters.
  58681. * This does nothing and may be overwritten by the user.
  58682. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  58683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  58684. * @param update the boolean update value actually passed to setParticles()
  58685. */
  58686. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  58687. }
  58688. }
  58689. declare module BABYLON {
  58690. /**
  58691. * Represents one particle of a points cloud system.
  58692. */
  58693. export class CloudPoint {
  58694. /**
  58695. * particle global index
  58696. */
  58697. idx: number;
  58698. /**
  58699. * The color of the particle
  58700. */
  58701. color: Nullable<Color4>;
  58702. /**
  58703. * The world space position of the particle.
  58704. */
  58705. position: Vector3;
  58706. /**
  58707. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  58708. */
  58709. rotation: Vector3;
  58710. /**
  58711. * The world space rotation quaternion of the particle.
  58712. */
  58713. rotationQuaternion: Nullable<Quaternion>;
  58714. /**
  58715. * The uv of the particle.
  58716. */
  58717. uv: Nullable<Vector2>;
  58718. /**
  58719. * The current speed of the particle.
  58720. */
  58721. velocity: Vector3;
  58722. /**
  58723. * The pivot point in the particle local space.
  58724. */
  58725. pivot: Vector3;
  58726. /**
  58727. * Must the particle be translated from its pivot point in its local space ?
  58728. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  58729. * Default : false
  58730. */
  58731. translateFromPivot: boolean;
  58732. /**
  58733. * Index of this particle in the global "positions" array (Internal use)
  58734. * @hidden
  58735. */
  58736. _pos: number;
  58737. /**
  58738. * @hidden Index of this particle in the global "indices" array (Internal use)
  58739. */
  58740. _ind: number;
  58741. /**
  58742. * Group this particle belongs to
  58743. */
  58744. _group: PointsGroup;
  58745. /**
  58746. * Group id of this particle
  58747. */
  58748. groupId: number;
  58749. /**
  58750. * Index of the particle in its group id (Internal use)
  58751. */
  58752. idxInGroup: number;
  58753. /**
  58754. * @hidden Particle BoundingInfo object (Internal use)
  58755. */
  58756. _boundingInfo: BoundingInfo;
  58757. /**
  58758. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  58759. */
  58760. _pcs: PointsCloudSystem;
  58761. /**
  58762. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  58763. */
  58764. _stillInvisible: boolean;
  58765. /**
  58766. * @hidden Last computed particle rotation matrix
  58767. */
  58768. _rotationMatrix: number[];
  58769. /**
  58770. * Parent particle Id, if any.
  58771. * Default null.
  58772. */
  58773. parentId: Nullable<number>;
  58774. /**
  58775. * @hidden Internal global position in the PCS.
  58776. */
  58777. _globalPosition: Vector3;
  58778. /**
  58779. * Creates a Point Cloud object.
  58780. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  58781. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  58782. * @param group (PointsGroup) is the group the particle belongs to
  58783. * @param groupId (integer) is the group identifier in the PCS.
  58784. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  58785. * @param pcs defines the PCS it is associated to
  58786. */
  58787. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  58788. /**
  58789. * get point size
  58790. */
  58791. /**
  58792. * Set point size
  58793. */
  58794. size: Vector3;
  58795. /**
  58796. * Legacy support, changed quaternion to rotationQuaternion
  58797. */
  58798. /**
  58799. * Legacy support, changed quaternion to rotationQuaternion
  58800. */
  58801. quaternion: Nullable<Quaternion>;
  58802. /**
  58803. * Returns a boolean. True if the particle intersects a mesh, else false
  58804. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  58805. * @param target is the object (point or mesh) what the intersection is computed against
  58806. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  58807. * @returns true if it intersects
  58808. */
  58809. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  58810. /**
  58811. * get the rotation matrix of the particle
  58812. * @hidden
  58813. */
  58814. getRotationMatrix(m: Matrix): void;
  58815. }
  58816. /**
  58817. * Represents a group of points in a points cloud system
  58818. * * PCS internal tool, don't use it manually.
  58819. */
  58820. export class PointsGroup {
  58821. /**
  58822. * The group id
  58823. * @hidden
  58824. */
  58825. groupID: number;
  58826. /**
  58827. * image data for group (internal use)
  58828. * @hidden
  58829. */
  58830. _groupImageData: Nullable<ArrayBufferView>;
  58831. /**
  58832. * Image Width (internal use)
  58833. * @hidden
  58834. */
  58835. _groupImgWidth: number;
  58836. /**
  58837. * Image Height (internal use)
  58838. * @hidden
  58839. */
  58840. _groupImgHeight: number;
  58841. /**
  58842. * Custom position function (internal use)
  58843. * @hidden
  58844. */
  58845. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  58846. /**
  58847. * density per facet for surface points
  58848. * @hidden
  58849. */
  58850. _groupDensity: number[];
  58851. /**
  58852. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  58853. * PCS internal tool, don't use it manually.
  58854. * @hidden
  58855. */
  58856. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  58857. }
  58858. }
  58859. declare module BABYLON {
  58860. interface Scene {
  58861. /** @hidden (Backing field) */
  58862. _physicsEngine: Nullable<IPhysicsEngine>;
  58863. /**
  58864. * Gets the current physics engine
  58865. * @returns a IPhysicsEngine or null if none attached
  58866. */
  58867. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58868. /**
  58869. * Enables physics to the current scene
  58870. * @param gravity defines the scene's gravity for the physics engine
  58871. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58872. * @return a boolean indicating if the physics engine was initialized
  58873. */
  58874. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58875. /**
  58876. * Disables and disposes the physics engine associated with the scene
  58877. */
  58878. disablePhysicsEngine(): void;
  58879. /**
  58880. * Gets a boolean indicating if there is an active physics engine
  58881. * @returns a boolean indicating if there is an active physics engine
  58882. */
  58883. isPhysicsEnabled(): boolean;
  58884. /**
  58885. * Deletes a physics compound impostor
  58886. * @param compound defines the compound to delete
  58887. */
  58888. deleteCompoundImpostor(compound: any): void;
  58889. /**
  58890. * An event triggered when physic simulation is about to be run
  58891. */
  58892. onBeforePhysicsObservable: Observable<Scene>;
  58893. /**
  58894. * An event triggered when physic simulation has been done
  58895. */
  58896. onAfterPhysicsObservable: Observable<Scene>;
  58897. }
  58898. interface AbstractMesh {
  58899. /** @hidden */
  58900. _physicsImpostor: Nullable<PhysicsImpostor>;
  58901. /**
  58902. * Gets or sets impostor used for physic simulation
  58903. * @see http://doc.babylonjs.com/features/physics_engine
  58904. */
  58905. physicsImpostor: Nullable<PhysicsImpostor>;
  58906. /**
  58907. * Gets the current physics impostor
  58908. * @see http://doc.babylonjs.com/features/physics_engine
  58909. * @returns a physics impostor or null
  58910. */
  58911. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58912. /** Apply a physic impulse to the mesh
  58913. * @param force defines the force to apply
  58914. * @param contactPoint defines where to apply the force
  58915. * @returns the current mesh
  58916. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58917. */
  58918. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58919. /**
  58920. * Creates a physic joint between two meshes
  58921. * @param otherMesh defines the other mesh to use
  58922. * @param pivot1 defines the pivot to use on this mesh
  58923. * @param pivot2 defines the pivot to use on the other mesh
  58924. * @param options defines additional options (can be plugin dependent)
  58925. * @returns the current mesh
  58926. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58927. */
  58928. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58929. /** @hidden */
  58930. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58931. }
  58932. /**
  58933. * Defines the physics engine scene component responsible to manage a physics engine
  58934. */
  58935. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58936. /**
  58937. * The component name helpful to identify the component in the list of scene components.
  58938. */
  58939. readonly name: string;
  58940. /**
  58941. * The scene the component belongs to.
  58942. */
  58943. scene: Scene;
  58944. /**
  58945. * Creates a new instance of the component for the given scene
  58946. * @param scene Defines the scene to register the component in
  58947. */
  58948. constructor(scene: Scene);
  58949. /**
  58950. * Registers the component in a given scene
  58951. */
  58952. register(): void;
  58953. /**
  58954. * Rebuilds the elements related to this component in case of
  58955. * context lost for instance.
  58956. */
  58957. rebuild(): void;
  58958. /**
  58959. * Disposes the component and the associated ressources
  58960. */
  58961. dispose(): void;
  58962. }
  58963. }
  58964. declare module BABYLON {
  58965. /**
  58966. * A helper for physics simulations
  58967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58968. */
  58969. export class PhysicsHelper {
  58970. private _scene;
  58971. private _physicsEngine;
  58972. /**
  58973. * Initializes the Physics helper
  58974. * @param scene Babylon.js scene
  58975. */
  58976. constructor(scene: Scene);
  58977. /**
  58978. * Applies a radial explosion impulse
  58979. * @param origin the origin of the explosion
  58980. * @param radiusOrEventOptions the radius or the options of radial explosion
  58981. * @param strength the explosion strength
  58982. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58983. * @returns A physics radial explosion event, or null
  58984. */
  58985. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58986. /**
  58987. * Applies a radial explosion force
  58988. * @param origin the origin of the explosion
  58989. * @param radiusOrEventOptions the radius or the options of radial explosion
  58990. * @param strength the explosion strength
  58991. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58992. * @returns A physics radial explosion event, or null
  58993. */
  58994. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58995. /**
  58996. * Creates a gravitational field
  58997. * @param origin the origin of the explosion
  58998. * @param radiusOrEventOptions the radius or the options of radial explosion
  58999. * @param strength the explosion strength
  59000. * @param falloff possible options: Constant & Linear. Defaults to Constant
  59001. * @returns A physics gravitational field event, or null
  59002. */
  59003. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  59004. /**
  59005. * Creates a physics updraft event
  59006. * @param origin the origin of the updraft
  59007. * @param radiusOrEventOptions the radius or the options of the updraft
  59008. * @param strength the strength of the updraft
  59009. * @param height the height of the updraft
  59010. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  59011. * @returns A physics updraft event, or null
  59012. */
  59013. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  59014. /**
  59015. * Creates a physics vortex event
  59016. * @param origin the of the vortex
  59017. * @param radiusOrEventOptions the radius or the options of the vortex
  59018. * @param strength the strength of the vortex
  59019. * @param height the height of the vortex
  59020. * @returns a Physics vortex event, or null
  59021. * A physics vortex event or null
  59022. */
  59023. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  59024. }
  59025. /**
  59026. * Represents a physics radial explosion event
  59027. */
  59028. class PhysicsRadialExplosionEvent {
  59029. private _scene;
  59030. private _options;
  59031. private _sphere;
  59032. private _dataFetched;
  59033. /**
  59034. * Initializes a radial explosioin event
  59035. * @param _scene BabylonJS scene
  59036. * @param _options The options for the vortex event
  59037. */
  59038. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  59039. /**
  59040. * Returns the data related to the radial explosion event (sphere).
  59041. * @returns The radial explosion event data
  59042. */
  59043. getData(): PhysicsRadialExplosionEventData;
  59044. /**
  59045. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  59046. * @param impostor A physics imposter
  59047. * @param origin the origin of the explosion
  59048. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  59049. */
  59050. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  59051. /**
  59052. * Triggers affecterd impostors callbacks
  59053. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  59054. */
  59055. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  59056. /**
  59057. * Disposes the sphere.
  59058. * @param force Specifies if the sphere should be disposed by force
  59059. */
  59060. dispose(force?: boolean): void;
  59061. /*** Helpers ***/
  59062. private _prepareSphere;
  59063. private _intersectsWithSphere;
  59064. }
  59065. /**
  59066. * Represents a gravitational field event
  59067. */
  59068. class PhysicsGravitationalFieldEvent {
  59069. private _physicsHelper;
  59070. private _scene;
  59071. private _origin;
  59072. private _options;
  59073. private _tickCallback;
  59074. private _sphere;
  59075. private _dataFetched;
  59076. /**
  59077. * Initializes the physics gravitational field event
  59078. * @param _physicsHelper A physics helper
  59079. * @param _scene BabylonJS scene
  59080. * @param _origin The origin position of the gravitational field event
  59081. * @param _options The options for the vortex event
  59082. */
  59083. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  59084. /**
  59085. * Returns the data related to the gravitational field event (sphere).
  59086. * @returns A gravitational field event
  59087. */
  59088. getData(): PhysicsGravitationalFieldEventData;
  59089. /**
  59090. * Enables the gravitational field.
  59091. */
  59092. enable(): void;
  59093. /**
  59094. * Disables the gravitational field.
  59095. */
  59096. disable(): void;
  59097. /**
  59098. * Disposes the sphere.
  59099. * @param force The force to dispose from the gravitational field event
  59100. */
  59101. dispose(force?: boolean): void;
  59102. private _tick;
  59103. }
  59104. /**
  59105. * Represents a physics updraft event
  59106. */
  59107. class PhysicsUpdraftEvent {
  59108. private _scene;
  59109. private _origin;
  59110. private _options;
  59111. private _physicsEngine;
  59112. private _originTop;
  59113. private _originDirection;
  59114. private _tickCallback;
  59115. private _cylinder;
  59116. private _cylinderPosition;
  59117. private _dataFetched;
  59118. /**
  59119. * Initializes the physics updraft event
  59120. * @param _scene BabylonJS scene
  59121. * @param _origin The origin position of the updraft
  59122. * @param _options The options for the updraft event
  59123. */
  59124. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59125. /**
  59126. * Returns the data related to the updraft event (cylinder).
  59127. * @returns A physics updraft event
  59128. */
  59129. getData(): PhysicsUpdraftEventData;
  59130. /**
  59131. * Enables the updraft.
  59132. */
  59133. enable(): void;
  59134. /**
  59135. * Disables the updraft.
  59136. */
  59137. disable(): void;
  59138. /**
  59139. * Disposes the cylinder.
  59140. * @param force Specifies if the updraft should be disposed by force
  59141. */
  59142. dispose(force?: boolean): void;
  59143. private getImpostorHitData;
  59144. private _tick;
  59145. /*** Helpers ***/
  59146. private _prepareCylinder;
  59147. private _intersectsWithCylinder;
  59148. }
  59149. /**
  59150. * Represents a physics vortex event
  59151. */
  59152. class PhysicsVortexEvent {
  59153. private _scene;
  59154. private _origin;
  59155. private _options;
  59156. private _physicsEngine;
  59157. private _originTop;
  59158. private _tickCallback;
  59159. private _cylinder;
  59160. private _cylinderPosition;
  59161. private _dataFetched;
  59162. /**
  59163. * Initializes the physics vortex event
  59164. * @param _scene The BabylonJS scene
  59165. * @param _origin The origin position of the vortex
  59166. * @param _options The options for the vortex event
  59167. */
  59168. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59169. /**
  59170. * Returns the data related to the vortex event (cylinder).
  59171. * @returns The physics vortex event data
  59172. */
  59173. getData(): PhysicsVortexEventData;
  59174. /**
  59175. * Enables the vortex.
  59176. */
  59177. enable(): void;
  59178. /**
  59179. * Disables the cortex.
  59180. */
  59181. disable(): void;
  59182. /**
  59183. * Disposes the sphere.
  59184. * @param force
  59185. */
  59186. dispose(force?: boolean): void;
  59187. private getImpostorHitData;
  59188. private _tick;
  59189. /*** Helpers ***/
  59190. private _prepareCylinder;
  59191. private _intersectsWithCylinder;
  59192. }
  59193. /**
  59194. * Options fot the radial explosion event
  59195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59196. */
  59197. export class PhysicsRadialExplosionEventOptions {
  59198. /**
  59199. * The radius of the sphere for the radial explosion.
  59200. */
  59201. radius: number;
  59202. /**
  59203. * The strenth of the explosion.
  59204. */
  59205. strength: number;
  59206. /**
  59207. * The strenght of the force in correspondence to the distance of the affected object
  59208. */
  59209. falloff: PhysicsRadialImpulseFalloff;
  59210. /**
  59211. * Sphere options for the radial explosion.
  59212. */
  59213. sphere: {
  59214. segments: number;
  59215. diameter: number;
  59216. };
  59217. /**
  59218. * Sphere options for the radial explosion.
  59219. */
  59220. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59221. }
  59222. /**
  59223. * Options fot the updraft event
  59224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59225. */
  59226. export class PhysicsUpdraftEventOptions {
  59227. /**
  59228. * The radius of the cylinder for the vortex
  59229. */
  59230. radius: number;
  59231. /**
  59232. * The strenth of the updraft.
  59233. */
  59234. strength: number;
  59235. /**
  59236. * The height of the cylinder for the updraft.
  59237. */
  59238. height: number;
  59239. /**
  59240. * The mode for the the updraft.
  59241. */
  59242. updraftMode: PhysicsUpdraftMode;
  59243. }
  59244. /**
  59245. * Options fot the vortex event
  59246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59247. */
  59248. export class PhysicsVortexEventOptions {
  59249. /**
  59250. * The radius of the cylinder for the vortex
  59251. */
  59252. radius: number;
  59253. /**
  59254. * The strenth of the vortex.
  59255. */
  59256. strength: number;
  59257. /**
  59258. * The height of the cylinder for the vortex.
  59259. */
  59260. height: number;
  59261. /**
  59262. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59263. */
  59264. centripetalForceThreshold: number;
  59265. /**
  59266. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59267. */
  59268. centripetalForceMultiplier: number;
  59269. /**
  59270. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59271. */
  59272. centrifugalForceMultiplier: number;
  59273. /**
  59274. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59275. */
  59276. updraftForceMultiplier: number;
  59277. }
  59278. /**
  59279. * The strenght of the force in correspondence to the distance of the affected object
  59280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59281. */
  59282. export enum PhysicsRadialImpulseFalloff {
  59283. /** Defines that impulse is constant in strength across it's whole radius */
  59284. Constant = 0,
  59285. /** Defines that impulse gets weaker if it's further from the origin */
  59286. Linear = 1
  59287. }
  59288. /**
  59289. * The strength of the force in correspondence to the distance of the affected object
  59290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59291. */
  59292. export enum PhysicsUpdraftMode {
  59293. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59294. Center = 0,
  59295. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59296. Perpendicular = 1
  59297. }
  59298. /**
  59299. * Interface for a physics hit data
  59300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59301. */
  59302. export interface PhysicsHitData {
  59303. /**
  59304. * The force applied at the contact point
  59305. */
  59306. force: Vector3;
  59307. /**
  59308. * The contact point
  59309. */
  59310. contactPoint: Vector3;
  59311. /**
  59312. * The distance from the origin to the contact point
  59313. */
  59314. distanceFromOrigin: number;
  59315. }
  59316. /**
  59317. * Interface for radial explosion event data
  59318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59319. */
  59320. export interface PhysicsRadialExplosionEventData {
  59321. /**
  59322. * A sphere used for the radial explosion event
  59323. */
  59324. sphere: Mesh;
  59325. }
  59326. /**
  59327. * Interface for gravitational field event data
  59328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59329. */
  59330. export interface PhysicsGravitationalFieldEventData {
  59331. /**
  59332. * A sphere mesh used for the gravitational field event
  59333. */
  59334. sphere: Mesh;
  59335. }
  59336. /**
  59337. * Interface for updraft event data
  59338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59339. */
  59340. export interface PhysicsUpdraftEventData {
  59341. /**
  59342. * A cylinder used for the updraft event
  59343. */
  59344. cylinder: Mesh;
  59345. }
  59346. /**
  59347. * Interface for vortex event data
  59348. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59349. */
  59350. export interface PhysicsVortexEventData {
  59351. /**
  59352. * A cylinder used for the vortex event
  59353. */
  59354. cylinder: Mesh;
  59355. }
  59356. /**
  59357. * Interface for an affected physics impostor
  59358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59359. */
  59360. export interface PhysicsAffectedImpostorWithData {
  59361. /**
  59362. * The impostor affected by the effect
  59363. */
  59364. impostor: PhysicsImpostor;
  59365. /**
  59366. * The data about the hit/horce from the explosion
  59367. */
  59368. hitData: PhysicsHitData;
  59369. }
  59370. }
  59371. declare module BABYLON {
  59372. /** @hidden */
  59373. export var blackAndWhitePixelShader: {
  59374. name: string;
  59375. shader: string;
  59376. };
  59377. }
  59378. declare module BABYLON {
  59379. /**
  59380. * Post process used to render in black and white
  59381. */
  59382. export class BlackAndWhitePostProcess extends PostProcess {
  59383. /**
  59384. * Linear about to convert he result to black and white (default: 1)
  59385. */
  59386. degree: number;
  59387. /**
  59388. * Creates a black and white post process
  59389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59390. * @param name The name of the effect.
  59391. * @param options The required width/height ratio to downsize to before computing the render pass.
  59392. * @param camera The camera to apply the render pass to.
  59393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59394. * @param engine The engine which the post process will be applied. (default: current engine)
  59395. * @param reusable If the post process can be reused on the same frame. (default: false)
  59396. */
  59397. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59398. }
  59399. }
  59400. declare module BABYLON {
  59401. /**
  59402. * This represents a set of one or more post processes in Babylon.
  59403. * A post process can be used to apply a shader to a texture after it is rendered.
  59404. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59405. */
  59406. export class PostProcessRenderEffect {
  59407. private _postProcesses;
  59408. private _getPostProcesses;
  59409. private _singleInstance;
  59410. private _cameras;
  59411. private _indicesForCamera;
  59412. /**
  59413. * Name of the effect
  59414. * @hidden
  59415. */
  59416. _name: string;
  59417. /**
  59418. * Instantiates a post process render effect.
  59419. * A post process can be used to apply a shader to a texture after it is rendered.
  59420. * @param engine The engine the effect is tied to
  59421. * @param name The name of the effect
  59422. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59423. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59424. */
  59425. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59426. /**
  59427. * Checks if all the post processes in the effect are supported.
  59428. */
  59429. readonly isSupported: boolean;
  59430. /**
  59431. * Updates the current state of the effect
  59432. * @hidden
  59433. */
  59434. _update(): void;
  59435. /**
  59436. * Attaches the effect on cameras
  59437. * @param cameras The camera to attach to.
  59438. * @hidden
  59439. */
  59440. _attachCameras(cameras: Camera): void;
  59441. /**
  59442. * Attaches the effect on cameras
  59443. * @param cameras The camera to attach to.
  59444. * @hidden
  59445. */
  59446. _attachCameras(cameras: Camera[]): void;
  59447. /**
  59448. * Detaches the effect on cameras
  59449. * @param cameras The camera to detatch from.
  59450. * @hidden
  59451. */
  59452. _detachCameras(cameras: Camera): void;
  59453. /**
  59454. * Detatches the effect on cameras
  59455. * @param cameras The camera to detatch from.
  59456. * @hidden
  59457. */
  59458. _detachCameras(cameras: Camera[]): void;
  59459. /**
  59460. * Enables the effect on given cameras
  59461. * @param cameras The camera to enable.
  59462. * @hidden
  59463. */
  59464. _enable(cameras: Camera): void;
  59465. /**
  59466. * Enables the effect on given cameras
  59467. * @param cameras The camera to enable.
  59468. * @hidden
  59469. */
  59470. _enable(cameras: Nullable<Camera[]>): void;
  59471. /**
  59472. * Disables the effect on the given cameras
  59473. * @param cameras The camera to disable.
  59474. * @hidden
  59475. */
  59476. _disable(cameras: Camera): void;
  59477. /**
  59478. * Disables the effect on the given cameras
  59479. * @param cameras The camera to disable.
  59480. * @hidden
  59481. */
  59482. _disable(cameras: Nullable<Camera[]>): void;
  59483. /**
  59484. * Gets a list of the post processes contained in the effect.
  59485. * @param camera The camera to get the post processes on.
  59486. * @returns The list of the post processes in the effect.
  59487. */
  59488. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59489. }
  59490. }
  59491. declare module BABYLON {
  59492. /** @hidden */
  59493. export var extractHighlightsPixelShader: {
  59494. name: string;
  59495. shader: string;
  59496. };
  59497. }
  59498. declare module BABYLON {
  59499. /**
  59500. * 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.
  59501. */
  59502. export class ExtractHighlightsPostProcess extends PostProcess {
  59503. /**
  59504. * The luminance threshold, pixels below this value will be set to black.
  59505. */
  59506. threshold: number;
  59507. /** @hidden */
  59508. _exposure: number;
  59509. /**
  59510. * Post process which has the input texture to be used when performing highlight extraction
  59511. * @hidden
  59512. */
  59513. _inputPostProcess: Nullable<PostProcess>;
  59514. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59515. }
  59516. }
  59517. declare module BABYLON {
  59518. /** @hidden */
  59519. export var bloomMergePixelShader: {
  59520. name: string;
  59521. shader: string;
  59522. };
  59523. }
  59524. declare module BABYLON {
  59525. /**
  59526. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59527. */
  59528. export class BloomMergePostProcess extends PostProcess {
  59529. /** Weight of the bloom to be added to the original input. */
  59530. weight: number;
  59531. /**
  59532. * Creates a new instance of @see BloomMergePostProcess
  59533. * @param name The name of the effect.
  59534. * @param originalFromInput Post process which's input will be used for the merge.
  59535. * @param blurred Blurred highlights post process which's output will be used.
  59536. * @param weight Weight of the bloom to be added to the original input.
  59537. * @param options The required width/height ratio to downsize to before computing the render pass.
  59538. * @param camera The camera to apply the render pass to.
  59539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59540. * @param engine The engine which the post process will be applied. (default: current engine)
  59541. * @param reusable If the post process can be reused on the same frame. (default: false)
  59542. * @param textureType Type of textures used when performing the post process. (default: 0)
  59543. * @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)
  59544. */
  59545. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59546. /** Weight of the bloom to be added to the original input. */
  59547. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59548. }
  59549. }
  59550. declare module BABYLON {
  59551. /**
  59552. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59553. */
  59554. export class BloomEffect extends PostProcessRenderEffect {
  59555. private bloomScale;
  59556. /**
  59557. * @hidden Internal
  59558. */
  59559. _effects: Array<PostProcess>;
  59560. /**
  59561. * @hidden Internal
  59562. */
  59563. _downscale: ExtractHighlightsPostProcess;
  59564. private _blurX;
  59565. private _blurY;
  59566. private _merge;
  59567. /**
  59568. * The luminance threshold to find bright areas of the image to bloom.
  59569. */
  59570. threshold: number;
  59571. /**
  59572. * The strength of the bloom.
  59573. */
  59574. weight: number;
  59575. /**
  59576. * Specifies the size of the bloom blur kernel, relative to the final output size
  59577. */
  59578. kernel: number;
  59579. /**
  59580. * Creates a new instance of @see BloomEffect
  59581. * @param scene The scene the effect belongs to.
  59582. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59583. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59584. * @param bloomWeight The the strength of bloom.
  59585. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59586. * @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)
  59587. */
  59588. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59589. /**
  59590. * Disposes each of the internal effects for a given camera.
  59591. * @param camera The camera to dispose the effect on.
  59592. */
  59593. disposeEffects(camera: Camera): void;
  59594. /**
  59595. * @hidden Internal
  59596. */
  59597. _updateEffects(): void;
  59598. /**
  59599. * Internal
  59600. * @returns if all the contained post processes are ready.
  59601. * @hidden
  59602. */
  59603. _isReady(): boolean;
  59604. }
  59605. }
  59606. declare module BABYLON {
  59607. /** @hidden */
  59608. export var chromaticAberrationPixelShader: {
  59609. name: string;
  59610. shader: string;
  59611. };
  59612. }
  59613. declare module BABYLON {
  59614. /**
  59615. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59616. */
  59617. export class ChromaticAberrationPostProcess extends PostProcess {
  59618. /**
  59619. * The amount of seperation of rgb channels (default: 30)
  59620. */
  59621. aberrationAmount: number;
  59622. /**
  59623. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59624. */
  59625. radialIntensity: number;
  59626. /**
  59627. * 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))
  59628. */
  59629. direction: Vector2;
  59630. /**
  59631. * 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))
  59632. */
  59633. centerPosition: Vector2;
  59634. /**
  59635. * Creates a new instance ChromaticAberrationPostProcess
  59636. * @param name The name of the effect.
  59637. * @param screenWidth The width of the screen to apply the effect on.
  59638. * @param screenHeight The height of the screen to apply the effect on.
  59639. * @param options The required width/height ratio to downsize to before computing the render pass.
  59640. * @param camera The camera to apply the render pass to.
  59641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59642. * @param engine The engine which the post process will be applied. (default: current engine)
  59643. * @param reusable If the post process can be reused on the same frame. (default: false)
  59644. * @param textureType Type of textures used when performing the post process. (default: 0)
  59645. * @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)
  59646. */
  59647. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. /** @hidden */
  59652. export var circleOfConfusionPixelShader: {
  59653. name: string;
  59654. shader: string;
  59655. };
  59656. }
  59657. declare module BABYLON {
  59658. /**
  59659. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59660. */
  59661. export class CircleOfConfusionPostProcess extends PostProcess {
  59662. /**
  59663. * 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.
  59664. */
  59665. lensSize: number;
  59666. /**
  59667. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59668. */
  59669. fStop: number;
  59670. /**
  59671. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59672. */
  59673. focusDistance: number;
  59674. /**
  59675. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59676. */
  59677. focalLength: number;
  59678. private _depthTexture;
  59679. /**
  59680. * Creates a new instance CircleOfConfusionPostProcess
  59681. * @param name The name of the effect.
  59682. * @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.
  59683. * @param options The required width/height ratio to downsize to before computing the render pass.
  59684. * @param camera The camera to apply the render pass to.
  59685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59686. * @param engine The engine which the post process will be applied. (default: current engine)
  59687. * @param reusable If the post process can be reused on the same frame. (default: false)
  59688. * @param textureType Type of textures used when performing the post process. (default: 0)
  59689. * @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)
  59690. */
  59691. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59692. /**
  59693. * 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.
  59694. */
  59695. depthTexture: RenderTargetTexture;
  59696. }
  59697. }
  59698. declare module BABYLON {
  59699. /** @hidden */
  59700. export var colorCorrectionPixelShader: {
  59701. name: string;
  59702. shader: string;
  59703. };
  59704. }
  59705. declare module BABYLON {
  59706. /**
  59707. *
  59708. * This post-process allows the modification of rendered colors by using
  59709. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59710. *
  59711. * The object needs to be provided an url to a texture containing the color
  59712. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59713. * Use an image editing software to tweak the LUT to match your needs.
  59714. *
  59715. * For an example of a color LUT, see here:
  59716. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59717. * For explanations on color grading, see here:
  59718. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59719. *
  59720. */
  59721. export class ColorCorrectionPostProcess extends PostProcess {
  59722. private _colorTableTexture;
  59723. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59724. }
  59725. }
  59726. declare module BABYLON {
  59727. /** @hidden */
  59728. export var convolutionPixelShader: {
  59729. name: string;
  59730. shader: string;
  59731. };
  59732. }
  59733. declare module BABYLON {
  59734. /**
  59735. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59736. * input texture to perform effects such as edge detection or sharpening
  59737. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59738. */
  59739. export class ConvolutionPostProcess extends PostProcess {
  59740. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59741. kernel: number[];
  59742. /**
  59743. * Creates a new instance ConvolutionPostProcess
  59744. * @param name The name of the effect.
  59745. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59746. * @param options The required width/height ratio to downsize to before computing the render pass.
  59747. * @param camera The camera to apply the render pass to.
  59748. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59749. * @param engine The engine which the post process will be applied. (default: current engine)
  59750. * @param reusable If the post process can be reused on the same frame. (default: false)
  59751. * @param textureType Type of textures used when performing the post process. (default: 0)
  59752. */
  59753. constructor(name: string,
  59754. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59755. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59756. /**
  59757. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59758. */
  59759. static EdgeDetect0Kernel: number[];
  59760. /**
  59761. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59762. */
  59763. static EdgeDetect1Kernel: number[];
  59764. /**
  59765. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59766. */
  59767. static EdgeDetect2Kernel: number[];
  59768. /**
  59769. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59770. */
  59771. static SharpenKernel: number[];
  59772. /**
  59773. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59774. */
  59775. static EmbossKernel: number[];
  59776. /**
  59777. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59778. */
  59779. static GaussianKernel: number[];
  59780. }
  59781. }
  59782. declare module BABYLON {
  59783. /**
  59784. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59785. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59786. * based on samples that have a large difference in distance than the center pixel.
  59787. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59788. */
  59789. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59790. direction: Vector2;
  59791. /**
  59792. * Creates a new instance CircleOfConfusionPostProcess
  59793. * @param name The name of the effect.
  59794. * @param scene The scene the effect belongs to.
  59795. * @param direction The direction the blur should be applied.
  59796. * @param kernel The size of the kernel used to blur.
  59797. * @param options The required width/height ratio to downsize to before computing the render pass.
  59798. * @param camera The camera to apply the render pass to.
  59799. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59800. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59801. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59802. * @param engine The engine which the post process will be applied. (default: current engine)
  59803. * @param reusable If the post process can be reused on the same frame. (default: false)
  59804. * @param textureType Type of textures used when performing the post process. (default: 0)
  59805. * @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)
  59806. */
  59807. 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);
  59808. }
  59809. }
  59810. declare module BABYLON {
  59811. /** @hidden */
  59812. export var depthOfFieldMergePixelShader: {
  59813. name: string;
  59814. shader: string;
  59815. };
  59816. }
  59817. declare module BABYLON {
  59818. /**
  59819. * Options to be set when merging outputs from the default pipeline.
  59820. */
  59821. export class DepthOfFieldMergePostProcessOptions {
  59822. /**
  59823. * The original image to merge on top of
  59824. */
  59825. originalFromInput: PostProcess;
  59826. /**
  59827. * Parameters to perform the merge of the depth of field effect
  59828. */
  59829. depthOfField?: {
  59830. circleOfConfusion: PostProcess;
  59831. blurSteps: Array<PostProcess>;
  59832. };
  59833. /**
  59834. * Parameters to perform the merge of bloom effect
  59835. */
  59836. bloom?: {
  59837. blurred: PostProcess;
  59838. weight: number;
  59839. };
  59840. }
  59841. /**
  59842. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59843. */
  59844. export class DepthOfFieldMergePostProcess extends PostProcess {
  59845. private blurSteps;
  59846. /**
  59847. * Creates a new instance of DepthOfFieldMergePostProcess
  59848. * @param name The name of the effect.
  59849. * @param originalFromInput Post process which's input will be used for the merge.
  59850. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59851. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59852. * @param options The required width/height ratio to downsize to before computing the render pass.
  59853. * @param camera The camera to apply the render pass to.
  59854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59855. * @param engine The engine which the post process will be applied. (default: current engine)
  59856. * @param reusable If the post process can be reused on the same frame. (default: false)
  59857. * @param textureType Type of textures used when performing the post process. (default: 0)
  59858. * @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)
  59859. */
  59860. 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);
  59861. /**
  59862. * Updates the effect with the current post process compile time values and recompiles the shader.
  59863. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59864. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59865. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59866. * @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
  59867. * @param onCompiled Called when the shader has been compiled.
  59868. * @param onError Called if there is an error when compiling a shader.
  59869. */
  59870. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59871. }
  59872. }
  59873. declare module BABYLON {
  59874. /**
  59875. * Specifies the level of max blur that should be applied when using the depth of field effect
  59876. */
  59877. export enum DepthOfFieldEffectBlurLevel {
  59878. /**
  59879. * Subtle blur
  59880. */
  59881. Low = 0,
  59882. /**
  59883. * Medium blur
  59884. */
  59885. Medium = 1,
  59886. /**
  59887. * Large blur
  59888. */
  59889. High = 2
  59890. }
  59891. /**
  59892. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59893. */
  59894. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59895. private _circleOfConfusion;
  59896. /**
  59897. * @hidden Internal, blurs from high to low
  59898. */
  59899. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59900. private _depthOfFieldBlurY;
  59901. private _dofMerge;
  59902. /**
  59903. * @hidden Internal post processes in depth of field effect
  59904. */
  59905. _effects: Array<PostProcess>;
  59906. /**
  59907. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59908. */
  59909. focalLength: number;
  59910. /**
  59911. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59912. */
  59913. fStop: number;
  59914. /**
  59915. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59916. */
  59917. focusDistance: number;
  59918. /**
  59919. * 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.
  59920. */
  59921. lensSize: number;
  59922. /**
  59923. * Creates a new instance DepthOfFieldEffect
  59924. * @param scene The scene the effect belongs to.
  59925. * @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.
  59926. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59927. * @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)
  59928. */
  59929. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59930. /**
  59931. * Get the current class name of the current effet
  59932. * @returns "DepthOfFieldEffect"
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * 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.
  59937. */
  59938. depthTexture: RenderTargetTexture;
  59939. /**
  59940. * Disposes each of the internal effects for a given camera.
  59941. * @param camera The camera to dispose the effect on.
  59942. */
  59943. disposeEffects(camera: Camera): void;
  59944. /**
  59945. * @hidden Internal
  59946. */
  59947. _updateEffects(): void;
  59948. /**
  59949. * Internal
  59950. * @returns if all the contained post processes are ready.
  59951. * @hidden
  59952. */
  59953. _isReady(): boolean;
  59954. }
  59955. }
  59956. declare module BABYLON {
  59957. /** @hidden */
  59958. export var displayPassPixelShader: {
  59959. name: string;
  59960. shader: string;
  59961. };
  59962. }
  59963. declare module BABYLON {
  59964. /**
  59965. * DisplayPassPostProcess which produces an output the same as it's input
  59966. */
  59967. export class DisplayPassPostProcess extends PostProcess {
  59968. /**
  59969. * Creates the DisplayPassPostProcess
  59970. * @param name The name of the effect.
  59971. * @param options The required width/height ratio to downsize to before computing the render pass.
  59972. * @param camera The camera to apply the render pass to.
  59973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59974. * @param engine The engine which the post process will be applied. (default: current engine)
  59975. * @param reusable If the post process can be reused on the same frame. (default: false)
  59976. */
  59977. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59978. }
  59979. }
  59980. declare module BABYLON {
  59981. /** @hidden */
  59982. export var filterPixelShader: {
  59983. name: string;
  59984. shader: string;
  59985. };
  59986. }
  59987. declare module BABYLON {
  59988. /**
  59989. * Applies a kernel filter to the image
  59990. */
  59991. export class FilterPostProcess extends PostProcess {
  59992. /** The matrix to be applied to the image */
  59993. kernelMatrix: Matrix;
  59994. /**
  59995. *
  59996. * @param name The name of the effect.
  59997. * @param kernelMatrix The matrix to be applied to the image
  59998. * @param options The required width/height ratio to downsize to before computing the render pass.
  59999. * @param camera The camera to apply the render pass to.
  60000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60001. * @param engine The engine which the post process will be applied. (default: current engine)
  60002. * @param reusable If the post process can be reused on the same frame. (default: false)
  60003. */
  60004. constructor(name: string,
  60005. /** The matrix to be applied to the image */
  60006. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60007. }
  60008. }
  60009. declare module BABYLON {
  60010. /** @hidden */
  60011. export var fxaaPixelShader: {
  60012. name: string;
  60013. shader: string;
  60014. };
  60015. }
  60016. declare module BABYLON {
  60017. /** @hidden */
  60018. export var fxaaVertexShader: {
  60019. name: string;
  60020. shader: string;
  60021. };
  60022. }
  60023. declare module BABYLON {
  60024. /**
  60025. * Fxaa post process
  60026. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60027. */
  60028. export class FxaaPostProcess extends PostProcess {
  60029. /** @hidden */
  60030. texelWidth: number;
  60031. /** @hidden */
  60032. texelHeight: number;
  60033. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60034. private _getDefines;
  60035. }
  60036. }
  60037. declare module BABYLON {
  60038. /** @hidden */
  60039. export var grainPixelShader: {
  60040. name: string;
  60041. shader: string;
  60042. };
  60043. }
  60044. declare module BABYLON {
  60045. /**
  60046. * The GrainPostProcess adds noise to the image at mid luminance levels
  60047. */
  60048. export class GrainPostProcess extends PostProcess {
  60049. /**
  60050. * The intensity of the grain added (default: 30)
  60051. */
  60052. intensity: number;
  60053. /**
  60054. * If the grain should be randomized on every frame
  60055. */
  60056. animated: boolean;
  60057. /**
  60058. * Creates a new instance of @see GrainPostProcess
  60059. * @param name The name of the effect.
  60060. * @param options The required width/height ratio to downsize to before computing the render pass.
  60061. * @param camera The camera to apply the render pass to.
  60062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60063. * @param engine The engine which the post process will be applied. (default: current engine)
  60064. * @param reusable If the post process can be reused on the same frame. (default: false)
  60065. * @param textureType Type of textures used when performing the post process. (default: 0)
  60066. * @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)
  60067. */
  60068. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /** @hidden */
  60073. export var highlightsPixelShader: {
  60074. name: string;
  60075. shader: string;
  60076. };
  60077. }
  60078. declare module BABYLON {
  60079. /**
  60080. * Extracts highlights from the image
  60081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60082. */
  60083. export class HighlightsPostProcess extends PostProcess {
  60084. /**
  60085. * Extracts highlights from the image
  60086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60087. * @param name The name of the effect.
  60088. * @param options The required width/height ratio to downsize to before computing the render pass.
  60089. * @param camera The camera to apply the render pass to.
  60090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60091. * @param engine The engine which the post process will be applied. (default: current engine)
  60092. * @param reusable If the post process can be reused on the same frame. (default: false)
  60093. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60094. */
  60095. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60096. }
  60097. }
  60098. declare module BABYLON {
  60099. /** @hidden */
  60100. export var mrtFragmentDeclaration: {
  60101. name: string;
  60102. shader: string;
  60103. };
  60104. }
  60105. declare module BABYLON {
  60106. /** @hidden */
  60107. export var geometryPixelShader: {
  60108. name: string;
  60109. shader: string;
  60110. };
  60111. }
  60112. declare module BABYLON {
  60113. /** @hidden */
  60114. export var geometryVertexShader: {
  60115. name: string;
  60116. shader: string;
  60117. };
  60118. }
  60119. declare module BABYLON {
  60120. /** @hidden */
  60121. interface ISavedTransformationMatrix {
  60122. world: Matrix;
  60123. viewProjection: Matrix;
  60124. }
  60125. /**
  60126. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60127. */
  60128. export class GeometryBufferRenderer {
  60129. /**
  60130. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60131. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60132. */
  60133. static readonly POSITION_TEXTURE_TYPE: number;
  60134. /**
  60135. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60136. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60137. */
  60138. static readonly VELOCITY_TEXTURE_TYPE: number;
  60139. /**
  60140. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60141. * in order to compute objects velocities when enableVelocity is set to "true"
  60142. * @hidden
  60143. */
  60144. _previousTransformationMatrices: {
  60145. [index: number]: ISavedTransformationMatrix;
  60146. };
  60147. /**
  60148. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60149. * in order to compute objects velocities when enableVelocity is set to "true"
  60150. * @hidden
  60151. */
  60152. _previousBonesTransformationMatrices: {
  60153. [index: number]: Float32Array;
  60154. };
  60155. /**
  60156. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60157. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60158. */
  60159. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60160. private _scene;
  60161. private _multiRenderTarget;
  60162. private _ratio;
  60163. private _enablePosition;
  60164. private _enableVelocity;
  60165. private _positionIndex;
  60166. private _velocityIndex;
  60167. protected _effect: Effect;
  60168. protected _cachedDefines: string;
  60169. /**
  60170. * Set the render list (meshes to be rendered) used in the G buffer.
  60171. */
  60172. renderList: Mesh[];
  60173. /**
  60174. * Gets wether or not G buffer are supported by the running hardware.
  60175. * This requires draw buffer supports
  60176. */
  60177. readonly isSupported: boolean;
  60178. /**
  60179. * Returns the index of the given texture type in the G-Buffer textures array
  60180. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60181. * @returns the index of the given texture type in the G-Buffer textures array
  60182. */
  60183. getTextureIndex(textureType: number): number;
  60184. /**
  60185. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60186. */
  60187. /**
  60188. * Sets whether or not objects positions are enabled for the G buffer.
  60189. */
  60190. enablePosition: boolean;
  60191. /**
  60192. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60193. */
  60194. /**
  60195. * Sets wether or not objects velocities are enabled for the G buffer.
  60196. */
  60197. enableVelocity: boolean;
  60198. /**
  60199. * Gets the scene associated with the buffer.
  60200. */
  60201. readonly scene: Scene;
  60202. /**
  60203. * Gets the ratio used by the buffer during its creation.
  60204. * How big is the buffer related to the main canvas.
  60205. */
  60206. readonly ratio: number;
  60207. /** @hidden */
  60208. static _SceneComponentInitialization: (scene: Scene) => void;
  60209. /**
  60210. * Creates a new G Buffer for the scene
  60211. * @param scene The scene the buffer belongs to
  60212. * @param ratio How big is the buffer related to the main canvas.
  60213. */
  60214. constructor(scene: Scene, ratio?: number);
  60215. /**
  60216. * Checks wether everything is ready to render a submesh to the G buffer.
  60217. * @param subMesh the submesh to check readiness for
  60218. * @param useInstances is the mesh drawn using instance or not
  60219. * @returns true if ready otherwise false
  60220. */
  60221. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60222. /**
  60223. * Gets the current underlying G Buffer.
  60224. * @returns the buffer
  60225. */
  60226. getGBuffer(): MultiRenderTarget;
  60227. /**
  60228. * Gets the number of samples used to render the buffer (anti aliasing).
  60229. */
  60230. /**
  60231. * Sets the number of samples used to render the buffer (anti aliasing).
  60232. */
  60233. samples: number;
  60234. /**
  60235. * Disposes the renderer and frees up associated resources.
  60236. */
  60237. dispose(): void;
  60238. protected _createRenderTargets(): void;
  60239. private _copyBonesTransformationMatrices;
  60240. }
  60241. }
  60242. declare module BABYLON {
  60243. interface Scene {
  60244. /** @hidden (Backing field) */
  60245. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60246. /**
  60247. * Gets or Sets the current geometry buffer associated to the scene.
  60248. */
  60249. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60250. /**
  60251. * Enables a GeometryBufferRender and associates it with the scene
  60252. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60253. * @returns the GeometryBufferRenderer
  60254. */
  60255. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60256. /**
  60257. * Disables the GeometryBufferRender associated with the scene
  60258. */
  60259. disableGeometryBufferRenderer(): void;
  60260. }
  60261. /**
  60262. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60263. * in several rendering techniques.
  60264. */
  60265. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60266. /**
  60267. * The component name helpful to identify the component in the list of scene components.
  60268. */
  60269. readonly name: string;
  60270. /**
  60271. * The scene the component belongs to.
  60272. */
  60273. scene: Scene;
  60274. /**
  60275. * Creates a new instance of the component for the given scene
  60276. * @param scene Defines the scene to register the component in
  60277. */
  60278. constructor(scene: Scene);
  60279. /**
  60280. * Registers the component in a given scene
  60281. */
  60282. register(): void;
  60283. /**
  60284. * Rebuilds the elements related to this component in case of
  60285. * context lost for instance.
  60286. */
  60287. rebuild(): void;
  60288. /**
  60289. * Disposes the component and the associated ressources
  60290. */
  60291. dispose(): void;
  60292. private _gatherRenderTargets;
  60293. }
  60294. }
  60295. declare module BABYLON {
  60296. /** @hidden */
  60297. export var motionBlurPixelShader: {
  60298. name: string;
  60299. shader: string;
  60300. };
  60301. }
  60302. declare module BABYLON {
  60303. /**
  60304. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60305. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60306. * As an example, all you have to do is to create the post-process:
  60307. * var mb = new BABYLON.MotionBlurPostProcess(
  60308. * 'mb', // The name of the effect.
  60309. * scene, // The scene containing the objects to blur according to their velocity.
  60310. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60311. * camera // The camera to apply the render pass to.
  60312. * );
  60313. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60314. */
  60315. export class MotionBlurPostProcess extends PostProcess {
  60316. /**
  60317. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60318. */
  60319. motionStrength: number;
  60320. /**
  60321. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60322. */
  60323. /**
  60324. * Sets the number of iterations to be used for motion blur quality
  60325. */
  60326. motionBlurSamples: number;
  60327. private _motionBlurSamples;
  60328. private _geometryBufferRenderer;
  60329. /**
  60330. * Creates a new instance MotionBlurPostProcess
  60331. * @param name The name of the effect.
  60332. * @param scene The scene containing the objects to blur according to their velocity.
  60333. * @param options The required width/height ratio to downsize to before computing the render pass.
  60334. * @param camera The camera to apply the render pass to.
  60335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60336. * @param engine The engine which the post process will be applied. (default: current engine)
  60337. * @param reusable If the post process can be reused on the same frame. (default: false)
  60338. * @param textureType Type of textures used when performing the post process. (default: 0)
  60339. * @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)
  60340. */
  60341. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60342. /**
  60343. * Excludes the given skinned mesh from computing bones velocities.
  60344. * 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.
  60345. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60346. */
  60347. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60348. /**
  60349. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60350. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60351. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60352. */
  60353. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60354. /**
  60355. * Disposes the post process.
  60356. * @param camera The camera to dispose the post process on.
  60357. */
  60358. dispose(camera?: Camera): void;
  60359. }
  60360. }
  60361. declare module BABYLON {
  60362. /** @hidden */
  60363. export var refractionPixelShader: {
  60364. name: string;
  60365. shader: string;
  60366. };
  60367. }
  60368. declare module BABYLON {
  60369. /**
  60370. * Post process which applies a refractin texture
  60371. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60372. */
  60373. export class RefractionPostProcess extends PostProcess {
  60374. /** the base color of the refraction (used to taint the rendering) */
  60375. color: Color3;
  60376. /** simulated refraction depth */
  60377. depth: number;
  60378. /** the coefficient of the base color (0 to remove base color tainting) */
  60379. colorLevel: number;
  60380. private _refTexture;
  60381. private _ownRefractionTexture;
  60382. /**
  60383. * Gets or sets the refraction texture
  60384. * Please note that you are responsible for disposing the texture if you set it manually
  60385. */
  60386. refractionTexture: Texture;
  60387. /**
  60388. * Initializes the RefractionPostProcess
  60389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60390. * @param name The name of the effect.
  60391. * @param refractionTextureUrl Url of the refraction texture to use
  60392. * @param color the base color of the refraction (used to taint the rendering)
  60393. * @param depth simulated refraction depth
  60394. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60395. * @param camera The camera to apply the render pass to.
  60396. * @param options The required width/height ratio to downsize to before computing the render pass.
  60397. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60398. * @param engine The engine which the post process will be applied. (default: current engine)
  60399. * @param reusable If the post process can be reused on the same frame. (default: false)
  60400. */
  60401. constructor(name: string, refractionTextureUrl: string,
  60402. /** the base color of the refraction (used to taint the rendering) */
  60403. color: Color3,
  60404. /** simulated refraction depth */
  60405. depth: number,
  60406. /** the coefficient of the base color (0 to remove base color tainting) */
  60407. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60408. /**
  60409. * Disposes of the post process
  60410. * @param camera Camera to dispose post process on
  60411. */
  60412. dispose(camera: Camera): void;
  60413. }
  60414. }
  60415. declare module BABYLON {
  60416. /** @hidden */
  60417. export var sharpenPixelShader: {
  60418. name: string;
  60419. shader: string;
  60420. };
  60421. }
  60422. declare module BABYLON {
  60423. /**
  60424. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60425. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60426. */
  60427. export class SharpenPostProcess extends PostProcess {
  60428. /**
  60429. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60430. */
  60431. colorAmount: number;
  60432. /**
  60433. * How much sharpness should be applied (default: 0.3)
  60434. */
  60435. edgeAmount: number;
  60436. /**
  60437. * Creates a new instance ConvolutionPostProcess
  60438. * @param name The name of the effect.
  60439. * @param options The required width/height ratio to downsize to before computing the render pass.
  60440. * @param camera The camera to apply the render pass to.
  60441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60442. * @param engine The engine which the post process will be applied. (default: current engine)
  60443. * @param reusable If the post process can be reused on the same frame. (default: false)
  60444. * @param textureType Type of textures used when performing the post process. (default: 0)
  60445. * @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)
  60446. */
  60447. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60448. }
  60449. }
  60450. declare module BABYLON {
  60451. /**
  60452. * PostProcessRenderPipeline
  60453. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60454. */
  60455. export class PostProcessRenderPipeline {
  60456. private engine;
  60457. private _renderEffects;
  60458. private _renderEffectsForIsolatedPass;
  60459. /**
  60460. * List of inspectable custom properties (used by the Inspector)
  60461. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60462. */
  60463. inspectableCustomProperties: IInspectable[];
  60464. /**
  60465. * @hidden
  60466. */
  60467. protected _cameras: Camera[];
  60468. /** @hidden */
  60469. _name: string;
  60470. /**
  60471. * Gets pipeline name
  60472. */
  60473. readonly name: string;
  60474. /**
  60475. * Initializes a PostProcessRenderPipeline
  60476. * @param engine engine to add the pipeline to
  60477. * @param name name of the pipeline
  60478. */
  60479. constructor(engine: Engine, name: string);
  60480. /**
  60481. * Gets the class name
  60482. * @returns "PostProcessRenderPipeline"
  60483. */
  60484. getClassName(): string;
  60485. /**
  60486. * If all the render effects in the pipeline are supported
  60487. */
  60488. readonly isSupported: boolean;
  60489. /**
  60490. * Adds an effect to the pipeline
  60491. * @param renderEffect the effect to add
  60492. */
  60493. addEffect(renderEffect: PostProcessRenderEffect): void;
  60494. /** @hidden */
  60495. _rebuild(): void;
  60496. /** @hidden */
  60497. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60498. /** @hidden */
  60499. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60500. /** @hidden */
  60501. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60502. /** @hidden */
  60503. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60504. /** @hidden */
  60505. _attachCameras(cameras: Camera, unique: boolean): void;
  60506. /** @hidden */
  60507. _attachCameras(cameras: Camera[], unique: boolean): void;
  60508. /** @hidden */
  60509. _detachCameras(cameras: Camera): void;
  60510. /** @hidden */
  60511. _detachCameras(cameras: Nullable<Camera[]>): void;
  60512. /** @hidden */
  60513. _update(): void;
  60514. /** @hidden */
  60515. _reset(): void;
  60516. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60517. /**
  60518. * Disposes of the pipeline
  60519. */
  60520. dispose(): void;
  60521. }
  60522. }
  60523. declare module BABYLON {
  60524. /**
  60525. * PostProcessRenderPipelineManager class
  60526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60527. */
  60528. export class PostProcessRenderPipelineManager {
  60529. private _renderPipelines;
  60530. /**
  60531. * Initializes a PostProcessRenderPipelineManager
  60532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60533. */
  60534. constructor();
  60535. /**
  60536. * Gets the list of supported render pipelines
  60537. */
  60538. readonly supportedPipelines: PostProcessRenderPipeline[];
  60539. /**
  60540. * Adds a pipeline to the manager
  60541. * @param renderPipeline The pipeline to add
  60542. */
  60543. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60544. /**
  60545. * Attaches a camera to the pipeline
  60546. * @param renderPipelineName The name of the pipeline to attach to
  60547. * @param cameras the camera to attach
  60548. * @param unique if the camera can be attached multiple times to the pipeline
  60549. */
  60550. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60551. /**
  60552. * Detaches a camera from the pipeline
  60553. * @param renderPipelineName The name of the pipeline to detach from
  60554. * @param cameras the camera to detach
  60555. */
  60556. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60557. /**
  60558. * Enables an effect by name on a pipeline
  60559. * @param renderPipelineName the name of the pipeline to enable the effect in
  60560. * @param renderEffectName the name of the effect to enable
  60561. * @param cameras the cameras that the effect should be enabled on
  60562. */
  60563. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60564. /**
  60565. * Disables an effect by name on a pipeline
  60566. * @param renderPipelineName the name of the pipeline to disable the effect in
  60567. * @param renderEffectName the name of the effect to disable
  60568. * @param cameras the cameras that the effect should be disabled on
  60569. */
  60570. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60571. /**
  60572. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60573. */
  60574. update(): void;
  60575. /** @hidden */
  60576. _rebuild(): void;
  60577. /**
  60578. * Disposes of the manager and pipelines
  60579. */
  60580. dispose(): void;
  60581. }
  60582. }
  60583. declare module BABYLON {
  60584. interface Scene {
  60585. /** @hidden (Backing field) */
  60586. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60587. /**
  60588. * Gets the postprocess render pipeline manager
  60589. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60590. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60591. */
  60592. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60593. }
  60594. /**
  60595. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60596. */
  60597. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60598. /**
  60599. * The component name helpfull to identify the component in the list of scene components.
  60600. */
  60601. readonly name: string;
  60602. /**
  60603. * The scene the component belongs to.
  60604. */
  60605. scene: Scene;
  60606. /**
  60607. * Creates a new instance of the component for the given scene
  60608. * @param scene Defines the scene to register the component in
  60609. */
  60610. constructor(scene: Scene);
  60611. /**
  60612. * Registers the component in a given scene
  60613. */
  60614. register(): void;
  60615. /**
  60616. * Rebuilds the elements related to this component in case of
  60617. * context lost for instance.
  60618. */
  60619. rebuild(): void;
  60620. /**
  60621. * Disposes the component and the associated ressources
  60622. */
  60623. dispose(): void;
  60624. private _gatherRenderTargets;
  60625. }
  60626. }
  60627. declare module BABYLON {
  60628. /**
  60629. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60630. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60631. */
  60632. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60633. private _scene;
  60634. private _camerasToBeAttached;
  60635. /**
  60636. * ID of the sharpen post process,
  60637. */
  60638. private readonly SharpenPostProcessId;
  60639. /**
  60640. * @ignore
  60641. * ID of the image processing post process;
  60642. */
  60643. readonly ImageProcessingPostProcessId: string;
  60644. /**
  60645. * @ignore
  60646. * ID of the Fast Approximate Anti-Aliasing post process;
  60647. */
  60648. readonly FxaaPostProcessId: string;
  60649. /**
  60650. * ID of the chromatic aberration post process,
  60651. */
  60652. private readonly ChromaticAberrationPostProcessId;
  60653. /**
  60654. * ID of the grain post process
  60655. */
  60656. private readonly GrainPostProcessId;
  60657. /**
  60658. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60659. */
  60660. sharpen: SharpenPostProcess;
  60661. private _sharpenEffect;
  60662. private bloom;
  60663. /**
  60664. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60665. */
  60666. depthOfField: DepthOfFieldEffect;
  60667. /**
  60668. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60669. */
  60670. fxaa: FxaaPostProcess;
  60671. /**
  60672. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60673. */
  60674. imageProcessing: ImageProcessingPostProcess;
  60675. /**
  60676. * Chromatic aberration post process which will shift rgb colors in the image
  60677. */
  60678. chromaticAberration: ChromaticAberrationPostProcess;
  60679. private _chromaticAberrationEffect;
  60680. /**
  60681. * Grain post process which add noise to the image
  60682. */
  60683. grain: GrainPostProcess;
  60684. private _grainEffect;
  60685. /**
  60686. * Glow post process which adds a glow to emissive areas of the image
  60687. */
  60688. private _glowLayer;
  60689. /**
  60690. * Animations which can be used to tweak settings over a period of time
  60691. */
  60692. animations: Animation[];
  60693. private _imageProcessingConfigurationObserver;
  60694. private _sharpenEnabled;
  60695. private _bloomEnabled;
  60696. private _depthOfFieldEnabled;
  60697. private _depthOfFieldBlurLevel;
  60698. private _fxaaEnabled;
  60699. private _imageProcessingEnabled;
  60700. private _defaultPipelineTextureType;
  60701. private _bloomScale;
  60702. private _chromaticAberrationEnabled;
  60703. private _grainEnabled;
  60704. private _buildAllowed;
  60705. /**
  60706. * Gets active scene
  60707. */
  60708. readonly scene: Scene;
  60709. /**
  60710. * Enable or disable the sharpen process from the pipeline
  60711. */
  60712. sharpenEnabled: boolean;
  60713. private _resizeObserver;
  60714. private _hardwareScaleLevel;
  60715. private _bloomKernel;
  60716. /**
  60717. * Specifies the size of the bloom blur kernel, relative to the final output size
  60718. */
  60719. bloomKernel: number;
  60720. /**
  60721. * Specifies the weight of the bloom in the final rendering
  60722. */
  60723. private _bloomWeight;
  60724. /**
  60725. * Specifies the luma threshold for the area that will be blurred by the bloom
  60726. */
  60727. private _bloomThreshold;
  60728. private _hdr;
  60729. /**
  60730. * The strength of the bloom.
  60731. */
  60732. bloomWeight: number;
  60733. /**
  60734. * The strength of the bloom.
  60735. */
  60736. bloomThreshold: number;
  60737. /**
  60738. * The scale of the bloom, lower value will provide better performance.
  60739. */
  60740. bloomScale: number;
  60741. /**
  60742. * Enable or disable the bloom from the pipeline
  60743. */
  60744. bloomEnabled: boolean;
  60745. private _rebuildBloom;
  60746. /**
  60747. * If the depth of field is enabled.
  60748. */
  60749. depthOfFieldEnabled: boolean;
  60750. /**
  60751. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60752. */
  60753. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60754. /**
  60755. * If the anti aliasing is enabled.
  60756. */
  60757. fxaaEnabled: boolean;
  60758. private _samples;
  60759. /**
  60760. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60761. */
  60762. samples: number;
  60763. /**
  60764. * If image processing is enabled.
  60765. */
  60766. imageProcessingEnabled: boolean;
  60767. /**
  60768. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60769. */
  60770. glowLayerEnabled: boolean;
  60771. /**
  60772. * Gets the glow layer (or null if not defined)
  60773. */
  60774. readonly glowLayer: Nullable<GlowLayer>;
  60775. /**
  60776. * Enable or disable the chromaticAberration process from the pipeline
  60777. */
  60778. chromaticAberrationEnabled: boolean;
  60779. /**
  60780. * Enable or disable the grain process from the pipeline
  60781. */
  60782. grainEnabled: boolean;
  60783. /**
  60784. * @constructor
  60785. * @param name - The rendering pipeline name (default: "")
  60786. * @param hdr - If high dynamic range textures should be used (default: true)
  60787. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60788. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60789. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60790. */
  60791. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60792. /**
  60793. * Get the class name
  60794. * @returns "DefaultRenderingPipeline"
  60795. */
  60796. getClassName(): string;
  60797. /**
  60798. * Force the compilation of the entire pipeline.
  60799. */
  60800. prepare(): void;
  60801. private _hasCleared;
  60802. private _prevPostProcess;
  60803. private _prevPrevPostProcess;
  60804. private _setAutoClearAndTextureSharing;
  60805. private _depthOfFieldSceneObserver;
  60806. private _buildPipeline;
  60807. private _disposePostProcesses;
  60808. /**
  60809. * Adds a camera to the pipeline
  60810. * @param camera the camera to be added
  60811. */
  60812. addCamera(camera: Camera): void;
  60813. /**
  60814. * Removes a camera from the pipeline
  60815. * @param camera the camera to remove
  60816. */
  60817. removeCamera(camera: Camera): void;
  60818. /**
  60819. * Dispose of the pipeline and stop all post processes
  60820. */
  60821. dispose(): void;
  60822. /**
  60823. * Serialize the rendering pipeline (Used when exporting)
  60824. * @returns the serialized object
  60825. */
  60826. serialize(): any;
  60827. /**
  60828. * Parse the serialized pipeline
  60829. * @param source Source pipeline.
  60830. * @param scene The scene to load the pipeline to.
  60831. * @param rootUrl The URL of the serialized pipeline.
  60832. * @returns An instantiated pipeline from the serialized object.
  60833. */
  60834. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60835. }
  60836. }
  60837. declare module BABYLON {
  60838. /** @hidden */
  60839. export var lensHighlightsPixelShader: {
  60840. name: string;
  60841. shader: string;
  60842. };
  60843. }
  60844. declare module BABYLON {
  60845. /** @hidden */
  60846. export var depthOfFieldPixelShader: {
  60847. name: string;
  60848. shader: string;
  60849. };
  60850. }
  60851. declare module BABYLON {
  60852. /**
  60853. * BABYLON.JS Chromatic Aberration GLSL Shader
  60854. * Author: Olivier Guyot
  60855. * Separates very slightly R, G and B colors on the edges of the screen
  60856. * Inspired by Francois Tarlier & Martins Upitis
  60857. */
  60858. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60859. /**
  60860. * @ignore
  60861. * The chromatic aberration PostProcess id in the pipeline
  60862. */
  60863. LensChromaticAberrationEffect: string;
  60864. /**
  60865. * @ignore
  60866. * The highlights enhancing PostProcess id in the pipeline
  60867. */
  60868. HighlightsEnhancingEffect: string;
  60869. /**
  60870. * @ignore
  60871. * The depth-of-field PostProcess id in the pipeline
  60872. */
  60873. LensDepthOfFieldEffect: string;
  60874. private _scene;
  60875. private _depthTexture;
  60876. private _grainTexture;
  60877. private _chromaticAberrationPostProcess;
  60878. private _highlightsPostProcess;
  60879. private _depthOfFieldPostProcess;
  60880. private _edgeBlur;
  60881. private _grainAmount;
  60882. private _chromaticAberration;
  60883. private _distortion;
  60884. private _highlightsGain;
  60885. private _highlightsThreshold;
  60886. private _dofDistance;
  60887. private _dofAperture;
  60888. private _dofDarken;
  60889. private _dofPentagon;
  60890. private _blurNoise;
  60891. /**
  60892. * @constructor
  60893. *
  60894. * Effect parameters are as follow:
  60895. * {
  60896. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60897. * edge_blur: number; // from 0 to x (1 for realism)
  60898. * distortion: number; // from 0 to x (1 for realism)
  60899. * grain_amount: number; // from 0 to 1
  60900. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60901. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60902. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60903. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60904. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60905. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60906. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60907. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60908. * }
  60909. * Note: if an effect parameter is unset, effect is disabled
  60910. *
  60911. * @param name The rendering pipeline name
  60912. * @param parameters - An object containing all parameters (see above)
  60913. * @param scene The scene linked to this pipeline
  60914. * @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)
  60915. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60916. */
  60917. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60918. /**
  60919. * Get the class name
  60920. * @returns "LensRenderingPipeline"
  60921. */
  60922. getClassName(): string;
  60923. /**
  60924. * Gets associated scene
  60925. */
  60926. readonly scene: Scene;
  60927. /**
  60928. * Gets or sets the edge blur
  60929. */
  60930. edgeBlur: number;
  60931. /**
  60932. * Gets or sets the grain amount
  60933. */
  60934. grainAmount: number;
  60935. /**
  60936. * Gets or sets the chromatic aberration amount
  60937. */
  60938. chromaticAberration: number;
  60939. /**
  60940. * Gets or sets the depth of field aperture
  60941. */
  60942. dofAperture: number;
  60943. /**
  60944. * Gets or sets the edge distortion
  60945. */
  60946. edgeDistortion: number;
  60947. /**
  60948. * Gets or sets the depth of field distortion
  60949. */
  60950. dofDistortion: number;
  60951. /**
  60952. * Gets or sets the darken out of focus amount
  60953. */
  60954. darkenOutOfFocus: number;
  60955. /**
  60956. * Gets or sets a boolean indicating if blur noise is enabled
  60957. */
  60958. blurNoise: boolean;
  60959. /**
  60960. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60961. */
  60962. pentagonBokeh: boolean;
  60963. /**
  60964. * Gets or sets the highlight grain amount
  60965. */
  60966. highlightsGain: number;
  60967. /**
  60968. * Gets or sets the highlight threshold
  60969. */
  60970. highlightsThreshold: number;
  60971. /**
  60972. * Sets the amount of blur at the edges
  60973. * @param amount blur amount
  60974. */
  60975. setEdgeBlur(amount: number): void;
  60976. /**
  60977. * Sets edge blur to 0
  60978. */
  60979. disableEdgeBlur(): void;
  60980. /**
  60981. * Sets the amout of grain
  60982. * @param amount Amount of grain
  60983. */
  60984. setGrainAmount(amount: number): void;
  60985. /**
  60986. * Set grain amount to 0
  60987. */
  60988. disableGrain(): void;
  60989. /**
  60990. * Sets the chromatic aberration amount
  60991. * @param amount amount of chromatic aberration
  60992. */
  60993. setChromaticAberration(amount: number): void;
  60994. /**
  60995. * Sets chromatic aberration amount to 0
  60996. */
  60997. disableChromaticAberration(): void;
  60998. /**
  60999. * Sets the EdgeDistortion amount
  61000. * @param amount amount of EdgeDistortion
  61001. */
  61002. setEdgeDistortion(amount: number): void;
  61003. /**
  61004. * Sets edge distortion to 0
  61005. */
  61006. disableEdgeDistortion(): void;
  61007. /**
  61008. * Sets the FocusDistance amount
  61009. * @param amount amount of FocusDistance
  61010. */
  61011. setFocusDistance(amount: number): void;
  61012. /**
  61013. * Disables depth of field
  61014. */
  61015. disableDepthOfField(): void;
  61016. /**
  61017. * Sets the Aperture amount
  61018. * @param amount amount of Aperture
  61019. */
  61020. setAperture(amount: number): void;
  61021. /**
  61022. * Sets the DarkenOutOfFocus amount
  61023. * @param amount amount of DarkenOutOfFocus
  61024. */
  61025. setDarkenOutOfFocus(amount: number): void;
  61026. private _pentagonBokehIsEnabled;
  61027. /**
  61028. * Creates a pentagon bokeh effect
  61029. */
  61030. enablePentagonBokeh(): void;
  61031. /**
  61032. * Disables the pentagon bokeh effect
  61033. */
  61034. disablePentagonBokeh(): void;
  61035. /**
  61036. * Enables noise blur
  61037. */
  61038. enableNoiseBlur(): void;
  61039. /**
  61040. * Disables noise blur
  61041. */
  61042. disableNoiseBlur(): void;
  61043. /**
  61044. * Sets the HighlightsGain amount
  61045. * @param amount amount of HighlightsGain
  61046. */
  61047. setHighlightsGain(amount: number): void;
  61048. /**
  61049. * Sets the HighlightsThreshold amount
  61050. * @param amount amount of HighlightsThreshold
  61051. */
  61052. setHighlightsThreshold(amount: number): void;
  61053. /**
  61054. * Disables highlights
  61055. */
  61056. disableHighlights(): void;
  61057. /**
  61058. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61059. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61060. */
  61061. dispose(disableDepthRender?: boolean): void;
  61062. private _createChromaticAberrationPostProcess;
  61063. private _createHighlightsPostProcess;
  61064. private _createDepthOfFieldPostProcess;
  61065. private _createGrainTexture;
  61066. }
  61067. }
  61068. declare module BABYLON {
  61069. /** @hidden */
  61070. export var ssao2PixelShader: {
  61071. name: string;
  61072. shader: string;
  61073. };
  61074. }
  61075. declare module BABYLON {
  61076. /** @hidden */
  61077. export var ssaoCombinePixelShader: {
  61078. name: string;
  61079. shader: string;
  61080. };
  61081. }
  61082. declare module BABYLON {
  61083. /**
  61084. * Render pipeline to produce ssao effect
  61085. */
  61086. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61087. /**
  61088. * @ignore
  61089. * The PassPostProcess id in the pipeline that contains the original scene color
  61090. */
  61091. SSAOOriginalSceneColorEffect: string;
  61092. /**
  61093. * @ignore
  61094. * The SSAO PostProcess id in the pipeline
  61095. */
  61096. SSAORenderEffect: string;
  61097. /**
  61098. * @ignore
  61099. * The horizontal blur PostProcess id in the pipeline
  61100. */
  61101. SSAOBlurHRenderEffect: string;
  61102. /**
  61103. * @ignore
  61104. * The vertical blur PostProcess id in the pipeline
  61105. */
  61106. SSAOBlurVRenderEffect: string;
  61107. /**
  61108. * @ignore
  61109. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61110. */
  61111. SSAOCombineRenderEffect: string;
  61112. /**
  61113. * The output strength of the SSAO post-process. Default value is 1.0.
  61114. */
  61115. totalStrength: number;
  61116. /**
  61117. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61118. */
  61119. maxZ: number;
  61120. /**
  61121. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61122. */
  61123. minZAspect: number;
  61124. private _samples;
  61125. /**
  61126. * Number of samples used for the SSAO calculations. Default value is 8
  61127. */
  61128. samples: number;
  61129. private _textureSamples;
  61130. /**
  61131. * Number of samples to use for antialiasing
  61132. */
  61133. textureSamples: number;
  61134. /**
  61135. * Ratio object used for SSAO ratio and blur ratio
  61136. */
  61137. private _ratio;
  61138. /**
  61139. * Dynamically generated sphere sampler.
  61140. */
  61141. private _sampleSphere;
  61142. /**
  61143. * Blur filter offsets
  61144. */
  61145. private _samplerOffsets;
  61146. private _expensiveBlur;
  61147. /**
  61148. * If bilateral blur should be used
  61149. */
  61150. expensiveBlur: boolean;
  61151. /**
  61152. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61153. */
  61154. radius: number;
  61155. /**
  61156. * The base color of the SSAO post-process
  61157. * The final result is "base + ssao" between [0, 1]
  61158. */
  61159. base: number;
  61160. /**
  61161. * Support test.
  61162. */
  61163. static readonly IsSupported: boolean;
  61164. private _scene;
  61165. private _depthTexture;
  61166. private _normalTexture;
  61167. private _randomTexture;
  61168. private _originalColorPostProcess;
  61169. private _ssaoPostProcess;
  61170. private _blurHPostProcess;
  61171. private _blurVPostProcess;
  61172. private _ssaoCombinePostProcess;
  61173. private _firstUpdate;
  61174. /**
  61175. * Gets active scene
  61176. */
  61177. readonly scene: Scene;
  61178. /**
  61179. * @constructor
  61180. * @param name The rendering pipeline name
  61181. * @param scene The scene linked to this pipeline
  61182. * @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 }
  61183. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61184. */
  61185. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61186. /**
  61187. * Get the class name
  61188. * @returns "SSAO2RenderingPipeline"
  61189. */
  61190. getClassName(): string;
  61191. /**
  61192. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61193. */
  61194. dispose(disableGeometryBufferRenderer?: boolean): void;
  61195. private _createBlurPostProcess;
  61196. /** @hidden */
  61197. _rebuild(): void;
  61198. private _bits;
  61199. private _radicalInverse_VdC;
  61200. private _hammersley;
  61201. private _hemisphereSample_uniform;
  61202. private _generateHemisphere;
  61203. private _createSSAOPostProcess;
  61204. private _createSSAOCombinePostProcess;
  61205. private _createRandomTexture;
  61206. /**
  61207. * Serialize the rendering pipeline (Used when exporting)
  61208. * @returns the serialized object
  61209. */
  61210. serialize(): any;
  61211. /**
  61212. * Parse the serialized pipeline
  61213. * @param source Source pipeline.
  61214. * @param scene The scene to load the pipeline to.
  61215. * @param rootUrl The URL of the serialized pipeline.
  61216. * @returns An instantiated pipeline from the serialized object.
  61217. */
  61218. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61219. }
  61220. }
  61221. declare module BABYLON {
  61222. /** @hidden */
  61223. export var ssaoPixelShader: {
  61224. name: string;
  61225. shader: string;
  61226. };
  61227. }
  61228. declare module BABYLON {
  61229. /**
  61230. * Render pipeline to produce ssao effect
  61231. */
  61232. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61233. /**
  61234. * @ignore
  61235. * The PassPostProcess id in the pipeline that contains the original scene color
  61236. */
  61237. SSAOOriginalSceneColorEffect: string;
  61238. /**
  61239. * @ignore
  61240. * The SSAO PostProcess id in the pipeline
  61241. */
  61242. SSAORenderEffect: string;
  61243. /**
  61244. * @ignore
  61245. * The horizontal blur PostProcess id in the pipeline
  61246. */
  61247. SSAOBlurHRenderEffect: string;
  61248. /**
  61249. * @ignore
  61250. * The vertical blur PostProcess id in the pipeline
  61251. */
  61252. SSAOBlurVRenderEffect: string;
  61253. /**
  61254. * @ignore
  61255. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61256. */
  61257. SSAOCombineRenderEffect: string;
  61258. /**
  61259. * The output strength of the SSAO post-process. Default value is 1.0.
  61260. */
  61261. totalStrength: number;
  61262. /**
  61263. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61264. */
  61265. radius: number;
  61266. /**
  61267. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61268. * Must not be equal to fallOff and superior to fallOff.
  61269. * Default value is 0.0075
  61270. */
  61271. area: number;
  61272. /**
  61273. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61274. * Must not be equal to area and inferior to area.
  61275. * Default value is 0.000001
  61276. */
  61277. fallOff: number;
  61278. /**
  61279. * The base color of the SSAO post-process
  61280. * The final result is "base + ssao" between [0, 1]
  61281. */
  61282. base: number;
  61283. private _scene;
  61284. private _depthTexture;
  61285. private _randomTexture;
  61286. private _originalColorPostProcess;
  61287. private _ssaoPostProcess;
  61288. private _blurHPostProcess;
  61289. private _blurVPostProcess;
  61290. private _ssaoCombinePostProcess;
  61291. private _firstUpdate;
  61292. /**
  61293. * Gets active scene
  61294. */
  61295. readonly scene: Scene;
  61296. /**
  61297. * @constructor
  61298. * @param name - The rendering pipeline name
  61299. * @param scene - The scene linked to this pipeline
  61300. * @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 }
  61301. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61302. */
  61303. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61304. /**
  61305. * Get the class name
  61306. * @returns "SSAORenderingPipeline"
  61307. */
  61308. getClassName(): string;
  61309. /**
  61310. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61311. */
  61312. dispose(disableDepthRender?: boolean): void;
  61313. private _createBlurPostProcess;
  61314. /** @hidden */
  61315. _rebuild(): void;
  61316. private _createSSAOPostProcess;
  61317. private _createSSAOCombinePostProcess;
  61318. private _createRandomTexture;
  61319. }
  61320. }
  61321. declare module BABYLON {
  61322. /** @hidden */
  61323. export var standardPixelShader: {
  61324. name: string;
  61325. shader: string;
  61326. };
  61327. }
  61328. declare module BABYLON {
  61329. /**
  61330. * Standard rendering pipeline
  61331. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61332. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61333. */
  61334. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61335. /**
  61336. * Public members
  61337. */
  61338. /**
  61339. * Post-process which contains the original scene color before the pipeline applies all the effects
  61340. */
  61341. originalPostProcess: Nullable<PostProcess>;
  61342. /**
  61343. * Post-process used to down scale an image x4
  61344. */
  61345. downSampleX4PostProcess: Nullable<PostProcess>;
  61346. /**
  61347. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61348. */
  61349. brightPassPostProcess: Nullable<PostProcess>;
  61350. /**
  61351. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61352. */
  61353. blurHPostProcesses: PostProcess[];
  61354. /**
  61355. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61356. */
  61357. blurVPostProcesses: PostProcess[];
  61358. /**
  61359. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61360. */
  61361. textureAdderPostProcess: Nullable<PostProcess>;
  61362. /**
  61363. * Post-process used to create volumetric lighting effect
  61364. */
  61365. volumetricLightPostProcess: Nullable<PostProcess>;
  61366. /**
  61367. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61368. */
  61369. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61370. /**
  61371. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61372. */
  61373. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61374. /**
  61375. * Post-process used to merge the volumetric light effect and the real scene color
  61376. */
  61377. volumetricLightMergePostProces: Nullable<PostProcess>;
  61378. /**
  61379. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61380. */
  61381. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61382. /**
  61383. * Base post-process used to calculate the average luminance of the final image for HDR
  61384. */
  61385. luminancePostProcess: Nullable<PostProcess>;
  61386. /**
  61387. * Post-processes used to create down sample post-processes in order to get
  61388. * the average luminance of the final image for HDR
  61389. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61390. */
  61391. luminanceDownSamplePostProcesses: PostProcess[];
  61392. /**
  61393. * Post-process used to create a HDR effect (light adaptation)
  61394. */
  61395. hdrPostProcess: Nullable<PostProcess>;
  61396. /**
  61397. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61398. */
  61399. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61400. /**
  61401. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61402. */
  61403. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61404. /**
  61405. * Post-process used to merge the final HDR post-process and the real scene color
  61406. */
  61407. hdrFinalPostProcess: Nullable<PostProcess>;
  61408. /**
  61409. * Post-process used to create a lens flare effect
  61410. */
  61411. lensFlarePostProcess: Nullable<PostProcess>;
  61412. /**
  61413. * Post-process that merges the result of the lens flare post-process and the real scene color
  61414. */
  61415. lensFlareComposePostProcess: Nullable<PostProcess>;
  61416. /**
  61417. * Post-process used to create a motion blur effect
  61418. */
  61419. motionBlurPostProcess: Nullable<PostProcess>;
  61420. /**
  61421. * Post-process used to create a depth of field effect
  61422. */
  61423. depthOfFieldPostProcess: Nullable<PostProcess>;
  61424. /**
  61425. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61426. */
  61427. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61428. /**
  61429. * Represents the brightness threshold in order to configure the illuminated surfaces
  61430. */
  61431. brightThreshold: number;
  61432. /**
  61433. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61434. */
  61435. blurWidth: number;
  61436. /**
  61437. * Sets if the blur for highlighted surfaces must be only horizontal
  61438. */
  61439. horizontalBlur: boolean;
  61440. /**
  61441. * Gets the overall exposure used by the pipeline
  61442. */
  61443. /**
  61444. * Sets the overall exposure used by the pipeline
  61445. */
  61446. exposure: number;
  61447. /**
  61448. * Texture used typically to simulate "dirty" on camera lens
  61449. */
  61450. lensTexture: Nullable<Texture>;
  61451. /**
  61452. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61453. */
  61454. volumetricLightCoefficient: number;
  61455. /**
  61456. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61457. */
  61458. volumetricLightPower: number;
  61459. /**
  61460. * Used the set the blur intensity to smooth the volumetric lights
  61461. */
  61462. volumetricLightBlurScale: number;
  61463. /**
  61464. * Light (spot or directional) used to generate the volumetric lights rays
  61465. * The source light must have a shadow generate so the pipeline can get its
  61466. * depth map
  61467. */
  61468. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61469. /**
  61470. * For eye adaptation, represents the minimum luminance the eye can see
  61471. */
  61472. hdrMinimumLuminance: number;
  61473. /**
  61474. * For eye adaptation, represents the decrease luminance speed
  61475. */
  61476. hdrDecreaseRate: number;
  61477. /**
  61478. * For eye adaptation, represents the increase luminance speed
  61479. */
  61480. hdrIncreaseRate: number;
  61481. /**
  61482. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61483. */
  61484. /**
  61485. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61486. */
  61487. hdrAutoExposure: boolean;
  61488. /**
  61489. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61490. */
  61491. lensColorTexture: Nullable<Texture>;
  61492. /**
  61493. * The overall strengh for the lens flare effect
  61494. */
  61495. lensFlareStrength: number;
  61496. /**
  61497. * Dispersion coefficient for lens flare ghosts
  61498. */
  61499. lensFlareGhostDispersal: number;
  61500. /**
  61501. * Main lens flare halo width
  61502. */
  61503. lensFlareHaloWidth: number;
  61504. /**
  61505. * Based on the lens distortion effect, defines how much the lens flare result
  61506. * is distorted
  61507. */
  61508. lensFlareDistortionStrength: number;
  61509. /**
  61510. * Configures the blur intensity used for for lens flare (halo)
  61511. */
  61512. lensFlareBlurWidth: number;
  61513. /**
  61514. * Lens star texture must be used to simulate rays on the flares and is available
  61515. * in the documentation
  61516. */
  61517. lensStarTexture: Nullable<Texture>;
  61518. /**
  61519. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61520. * flare effect by taking account of the dirt texture
  61521. */
  61522. lensFlareDirtTexture: Nullable<Texture>;
  61523. /**
  61524. * Represents the focal length for the depth of field effect
  61525. */
  61526. depthOfFieldDistance: number;
  61527. /**
  61528. * Represents the blur intensity for the blurred part of the depth of field effect
  61529. */
  61530. depthOfFieldBlurWidth: number;
  61531. /**
  61532. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61533. */
  61534. /**
  61535. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61536. */
  61537. motionStrength: number;
  61538. /**
  61539. * Gets wether or not the motion blur post-process is object based or screen based.
  61540. */
  61541. /**
  61542. * Sets wether or not the motion blur post-process should be object based or screen based
  61543. */
  61544. objectBasedMotionBlur: boolean;
  61545. /**
  61546. * List of animations for the pipeline (IAnimatable implementation)
  61547. */
  61548. animations: Animation[];
  61549. /**
  61550. * Private members
  61551. */
  61552. private _scene;
  61553. private _currentDepthOfFieldSource;
  61554. private _basePostProcess;
  61555. private _fixedExposure;
  61556. private _currentExposure;
  61557. private _hdrAutoExposure;
  61558. private _hdrCurrentLuminance;
  61559. private _motionStrength;
  61560. private _isObjectBasedMotionBlur;
  61561. private _floatTextureType;
  61562. private _camerasToBeAttached;
  61563. private _ratio;
  61564. private _bloomEnabled;
  61565. private _depthOfFieldEnabled;
  61566. private _vlsEnabled;
  61567. private _lensFlareEnabled;
  61568. private _hdrEnabled;
  61569. private _motionBlurEnabled;
  61570. private _fxaaEnabled;
  61571. private _motionBlurSamples;
  61572. private _volumetricLightStepsCount;
  61573. private _samples;
  61574. /**
  61575. * @ignore
  61576. * Specifies if the bloom pipeline is enabled
  61577. */
  61578. BloomEnabled: boolean;
  61579. /**
  61580. * @ignore
  61581. * Specifies if the depth of field pipeline is enabed
  61582. */
  61583. DepthOfFieldEnabled: boolean;
  61584. /**
  61585. * @ignore
  61586. * Specifies if the lens flare pipeline is enabed
  61587. */
  61588. LensFlareEnabled: boolean;
  61589. /**
  61590. * @ignore
  61591. * Specifies if the HDR pipeline is enabled
  61592. */
  61593. HDREnabled: boolean;
  61594. /**
  61595. * @ignore
  61596. * Specifies if the volumetric lights scattering effect is enabled
  61597. */
  61598. VLSEnabled: boolean;
  61599. /**
  61600. * @ignore
  61601. * Specifies if the motion blur effect is enabled
  61602. */
  61603. MotionBlurEnabled: boolean;
  61604. /**
  61605. * Specifies if anti-aliasing is enabled
  61606. */
  61607. fxaaEnabled: boolean;
  61608. /**
  61609. * Specifies the number of steps used to calculate the volumetric lights
  61610. * Typically in interval [50, 200]
  61611. */
  61612. volumetricLightStepsCount: number;
  61613. /**
  61614. * Specifies the number of samples used for the motion blur effect
  61615. * Typically in interval [16, 64]
  61616. */
  61617. motionBlurSamples: number;
  61618. /**
  61619. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61620. */
  61621. samples: number;
  61622. /**
  61623. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61624. * @constructor
  61625. * @param name The rendering pipeline name
  61626. * @param scene The scene linked to this pipeline
  61627. * @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)
  61628. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61629. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61630. */
  61631. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61632. private _buildPipeline;
  61633. private _createDownSampleX4PostProcess;
  61634. private _createBrightPassPostProcess;
  61635. private _createBlurPostProcesses;
  61636. private _createTextureAdderPostProcess;
  61637. private _createVolumetricLightPostProcess;
  61638. private _createLuminancePostProcesses;
  61639. private _createHdrPostProcess;
  61640. private _createLensFlarePostProcess;
  61641. private _createDepthOfFieldPostProcess;
  61642. private _createMotionBlurPostProcess;
  61643. private _getDepthTexture;
  61644. private _disposePostProcesses;
  61645. /**
  61646. * Dispose of the pipeline and stop all post processes
  61647. */
  61648. dispose(): void;
  61649. /**
  61650. * Serialize the rendering pipeline (Used when exporting)
  61651. * @returns the serialized object
  61652. */
  61653. serialize(): any;
  61654. /**
  61655. * Parse the serialized pipeline
  61656. * @param source Source pipeline.
  61657. * @param scene The scene to load the pipeline to.
  61658. * @param rootUrl The URL of the serialized pipeline.
  61659. * @returns An instantiated pipeline from the serialized object.
  61660. */
  61661. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61662. /**
  61663. * Luminance steps
  61664. */
  61665. static LuminanceSteps: number;
  61666. }
  61667. }
  61668. declare module BABYLON {
  61669. /** @hidden */
  61670. export var tonemapPixelShader: {
  61671. name: string;
  61672. shader: string;
  61673. };
  61674. }
  61675. declare module BABYLON {
  61676. /** Defines operator used for tonemapping */
  61677. export enum TonemappingOperator {
  61678. /** Hable */
  61679. Hable = 0,
  61680. /** Reinhard */
  61681. Reinhard = 1,
  61682. /** HejiDawson */
  61683. HejiDawson = 2,
  61684. /** Photographic */
  61685. Photographic = 3
  61686. }
  61687. /**
  61688. * Defines a post process to apply tone mapping
  61689. */
  61690. export class TonemapPostProcess extends PostProcess {
  61691. private _operator;
  61692. /** Defines the required exposure adjustement */
  61693. exposureAdjustment: number;
  61694. /**
  61695. * Creates a new TonemapPostProcess
  61696. * @param name defines the name of the postprocess
  61697. * @param _operator defines the operator to use
  61698. * @param exposureAdjustment defines the required exposure adjustement
  61699. * @param camera defines the camera to use (can be null)
  61700. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61701. * @param engine defines the hosting engine (can be ignore if camera is set)
  61702. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61703. */
  61704. constructor(name: string, _operator: TonemappingOperator,
  61705. /** Defines the required exposure adjustement */
  61706. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61707. }
  61708. }
  61709. declare module BABYLON {
  61710. /** @hidden */
  61711. export var depthVertexShader: {
  61712. name: string;
  61713. shader: string;
  61714. };
  61715. }
  61716. declare module BABYLON {
  61717. /** @hidden */
  61718. export var volumetricLightScatteringPixelShader: {
  61719. name: string;
  61720. shader: string;
  61721. };
  61722. }
  61723. declare module BABYLON {
  61724. /** @hidden */
  61725. export var volumetricLightScatteringPassVertexShader: {
  61726. name: string;
  61727. shader: string;
  61728. };
  61729. }
  61730. declare module BABYLON {
  61731. /** @hidden */
  61732. export var volumetricLightScatteringPassPixelShader: {
  61733. name: string;
  61734. shader: string;
  61735. };
  61736. }
  61737. declare module BABYLON {
  61738. /**
  61739. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61740. */
  61741. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61742. private _volumetricLightScatteringPass;
  61743. private _volumetricLightScatteringRTT;
  61744. private _viewPort;
  61745. private _screenCoordinates;
  61746. private _cachedDefines;
  61747. /**
  61748. * If not undefined, the mesh position is computed from the attached node position
  61749. */
  61750. attachedNode: {
  61751. position: Vector3;
  61752. };
  61753. /**
  61754. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61755. */
  61756. customMeshPosition: Vector3;
  61757. /**
  61758. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61759. */
  61760. useCustomMeshPosition: boolean;
  61761. /**
  61762. * If the post-process should inverse the light scattering direction
  61763. */
  61764. invert: boolean;
  61765. /**
  61766. * The internal mesh used by the post-process
  61767. */
  61768. mesh: Mesh;
  61769. /**
  61770. * @hidden
  61771. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61772. */
  61773. useDiffuseColor: boolean;
  61774. /**
  61775. * Array containing the excluded meshes not rendered in the internal pass
  61776. */
  61777. excludedMeshes: AbstractMesh[];
  61778. /**
  61779. * Controls the overall intensity of the post-process
  61780. */
  61781. exposure: number;
  61782. /**
  61783. * Dissipates each sample's contribution in range [0, 1]
  61784. */
  61785. decay: number;
  61786. /**
  61787. * Controls the overall intensity of each sample
  61788. */
  61789. weight: number;
  61790. /**
  61791. * Controls the density of each sample
  61792. */
  61793. density: number;
  61794. /**
  61795. * @constructor
  61796. * @param name The post-process name
  61797. * @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)
  61798. * @param camera The camera that the post-process will be attached to
  61799. * @param mesh The mesh used to create the light scattering
  61800. * @param samples The post-process quality, default 100
  61801. * @param samplingModeThe post-process filtering mode
  61802. * @param engine The babylon engine
  61803. * @param reusable If the post-process is reusable
  61804. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61805. */
  61806. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61807. /**
  61808. * Returns the string "VolumetricLightScatteringPostProcess"
  61809. * @returns "VolumetricLightScatteringPostProcess"
  61810. */
  61811. getClassName(): string;
  61812. private _isReady;
  61813. /**
  61814. * Sets the new light position for light scattering effect
  61815. * @param position The new custom light position
  61816. */
  61817. setCustomMeshPosition(position: Vector3): void;
  61818. /**
  61819. * Returns the light position for light scattering effect
  61820. * @return Vector3 The custom light position
  61821. */
  61822. getCustomMeshPosition(): Vector3;
  61823. /**
  61824. * Disposes the internal assets and detaches the post-process from the camera
  61825. */
  61826. dispose(camera: Camera): void;
  61827. /**
  61828. * Returns the render target texture used by the post-process
  61829. * @return the render target texture used by the post-process
  61830. */
  61831. getPass(): RenderTargetTexture;
  61832. private _meshExcluded;
  61833. private _createPass;
  61834. private _updateMeshScreenCoordinates;
  61835. /**
  61836. * Creates a default mesh for the Volumeric Light Scattering post-process
  61837. * @param name The mesh name
  61838. * @param scene The scene where to create the mesh
  61839. * @return the default mesh
  61840. */
  61841. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61842. }
  61843. }
  61844. declare module BABYLON {
  61845. interface Scene {
  61846. /** @hidden (Backing field) */
  61847. _boundingBoxRenderer: BoundingBoxRenderer;
  61848. /** @hidden (Backing field) */
  61849. _forceShowBoundingBoxes: boolean;
  61850. /**
  61851. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61852. */
  61853. forceShowBoundingBoxes: boolean;
  61854. /**
  61855. * Gets the bounding box renderer associated with the scene
  61856. * @returns a BoundingBoxRenderer
  61857. */
  61858. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61859. }
  61860. interface AbstractMesh {
  61861. /** @hidden (Backing field) */
  61862. _showBoundingBox: boolean;
  61863. /**
  61864. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61865. */
  61866. showBoundingBox: boolean;
  61867. }
  61868. /**
  61869. * Component responsible of rendering the bounding box of the meshes in a scene.
  61870. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61871. */
  61872. export class BoundingBoxRenderer implements ISceneComponent {
  61873. /**
  61874. * The component name helpfull to identify the component in the list of scene components.
  61875. */
  61876. readonly name: string;
  61877. /**
  61878. * The scene the component belongs to.
  61879. */
  61880. scene: Scene;
  61881. /**
  61882. * Color of the bounding box lines placed in front of an object
  61883. */
  61884. frontColor: Color3;
  61885. /**
  61886. * Color of the bounding box lines placed behind an object
  61887. */
  61888. backColor: Color3;
  61889. /**
  61890. * Defines if the renderer should show the back lines or not
  61891. */
  61892. showBackLines: boolean;
  61893. /**
  61894. * @hidden
  61895. */
  61896. renderList: SmartArray<BoundingBox>;
  61897. private _colorShader;
  61898. private _vertexBuffers;
  61899. private _indexBuffer;
  61900. private _fillIndexBuffer;
  61901. private _fillIndexData;
  61902. /**
  61903. * Instantiates a new bounding box renderer in a scene.
  61904. * @param scene the scene the renderer renders in
  61905. */
  61906. constructor(scene: Scene);
  61907. /**
  61908. * Registers the component in a given scene
  61909. */
  61910. register(): void;
  61911. private _evaluateSubMesh;
  61912. private _activeMesh;
  61913. private _prepareRessources;
  61914. private _createIndexBuffer;
  61915. /**
  61916. * Rebuilds the elements related to this component in case of
  61917. * context lost for instance.
  61918. */
  61919. rebuild(): void;
  61920. /**
  61921. * @hidden
  61922. */
  61923. reset(): void;
  61924. /**
  61925. * Render the bounding boxes of a specific rendering group
  61926. * @param renderingGroupId defines the rendering group to render
  61927. */
  61928. render(renderingGroupId: number): void;
  61929. /**
  61930. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61931. * @param mesh Define the mesh to render the occlusion bounding box for
  61932. */
  61933. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61934. /**
  61935. * Dispose and release the resources attached to this renderer.
  61936. */
  61937. dispose(): void;
  61938. }
  61939. }
  61940. declare module BABYLON {
  61941. /** @hidden */
  61942. export var depthPixelShader: {
  61943. name: string;
  61944. shader: string;
  61945. };
  61946. }
  61947. declare module BABYLON {
  61948. /**
  61949. * This represents a depth renderer in Babylon.
  61950. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61951. */
  61952. export class DepthRenderer {
  61953. private _scene;
  61954. private _depthMap;
  61955. private _effect;
  61956. private readonly _storeNonLinearDepth;
  61957. private readonly _clearColor;
  61958. /** Get if the depth renderer is using packed depth or not */
  61959. readonly isPacked: boolean;
  61960. private _cachedDefines;
  61961. private _camera;
  61962. /**
  61963. * Specifiess that the depth renderer will only be used within
  61964. * the camera it is created for.
  61965. * This can help forcing its rendering during the camera processing.
  61966. */
  61967. useOnlyInActiveCamera: boolean;
  61968. /** @hidden */
  61969. static _SceneComponentInitialization: (scene: Scene) => void;
  61970. /**
  61971. * Instantiates a depth renderer
  61972. * @param scene The scene the renderer belongs to
  61973. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61974. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61975. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61976. */
  61977. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61978. /**
  61979. * Creates the depth rendering effect and checks if the effect is ready.
  61980. * @param subMesh The submesh to be used to render the depth map of
  61981. * @param useInstances If multiple world instances should be used
  61982. * @returns if the depth renderer is ready to render the depth map
  61983. */
  61984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61985. /**
  61986. * Gets the texture which the depth map will be written to.
  61987. * @returns The depth map texture
  61988. */
  61989. getDepthMap(): RenderTargetTexture;
  61990. /**
  61991. * Disposes of the depth renderer.
  61992. */
  61993. dispose(): void;
  61994. }
  61995. }
  61996. declare module BABYLON {
  61997. interface Scene {
  61998. /** @hidden (Backing field) */
  61999. _depthRenderer: {
  62000. [id: string]: DepthRenderer;
  62001. };
  62002. /**
  62003. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62004. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62005. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62006. * @returns the created depth renderer
  62007. */
  62008. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62009. /**
  62010. * Disables a depth renderer for a given camera
  62011. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62012. */
  62013. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62014. }
  62015. /**
  62016. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62017. * in several rendering techniques.
  62018. */
  62019. export class DepthRendererSceneComponent implements ISceneComponent {
  62020. /**
  62021. * The component name helpfull to identify the component in the list of scene components.
  62022. */
  62023. readonly name: string;
  62024. /**
  62025. * The scene the component belongs to.
  62026. */
  62027. scene: Scene;
  62028. /**
  62029. * Creates a new instance of the component for the given scene
  62030. * @param scene Defines the scene to register the component in
  62031. */
  62032. constructor(scene: Scene);
  62033. /**
  62034. * Registers the component in a given scene
  62035. */
  62036. register(): void;
  62037. /**
  62038. * Rebuilds the elements related to this component in case of
  62039. * context lost for instance.
  62040. */
  62041. rebuild(): void;
  62042. /**
  62043. * Disposes the component and the associated ressources
  62044. */
  62045. dispose(): void;
  62046. private _gatherRenderTargets;
  62047. private _gatherActiveCameraRenderTargets;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /** @hidden */
  62052. export var outlinePixelShader: {
  62053. name: string;
  62054. shader: string;
  62055. };
  62056. }
  62057. declare module BABYLON {
  62058. /** @hidden */
  62059. export var outlineVertexShader: {
  62060. name: string;
  62061. shader: string;
  62062. };
  62063. }
  62064. declare module BABYLON {
  62065. interface Scene {
  62066. /** @hidden */
  62067. _outlineRenderer: OutlineRenderer;
  62068. /**
  62069. * Gets the outline renderer associated with the scene
  62070. * @returns a OutlineRenderer
  62071. */
  62072. getOutlineRenderer(): OutlineRenderer;
  62073. }
  62074. interface AbstractMesh {
  62075. /** @hidden (Backing field) */
  62076. _renderOutline: boolean;
  62077. /**
  62078. * Gets or sets a boolean indicating if the outline must be rendered as well
  62079. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62080. */
  62081. renderOutline: boolean;
  62082. /** @hidden (Backing field) */
  62083. _renderOverlay: boolean;
  62084. /**
  62085. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62086. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62087. */
  62088. renderOverlay: boolean;
  62089. }
  62090. /**
  62091. * This class is responsible to draw bothe outline/overlay of meshes.
  62092. * It should not be used directly but through the available method on mesh.
  62093. */
  62094. export class OutlineRenderer implements ISceneComponent {
  62095. /**
  62096. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62097. */
  62098. private static _StencilReference;
  62099. /**
  62100. * The name of the component. Each component must have a unique name.
  62101. */
  62102. name: string;
  62103. /**
  62104. * The scene the component belongs to.
  62105. */
  62106. scene: Scene;
  62107. /**
  62108. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62109. */
  62110. zOffset: number;
  62111. private _engine;
  62112. private _effect;
  62113. private _cachedDefines;
  62114. private _savedDepthWrite;
  62115. /**
  62116. * Instantiates a new outline renderer. (There could be only one per scene).
  62117. * @param scene Defines the scene it belongs to
  62118. */
  62119. constructor(scene: Scene);
  62120. /**
  62121. * Register the component to one instance of a scene.
  62122. */
  62123. register(): void;
  62124. /**
  62125. * Rebuilds the elements related to this component in case of
  62126. * context lost for instance.
  62127. */
  62128. rebuild(): void;
  62129. /**
  62130. * Disposes the component and the associated ressources.
  62131. */
  62132. dispose(): void;
  62133. /**
  62134. * Renders the outline in the canvas.
  62135. * @param subMesh Defines the sumesh to render
  62136. * @param batch Defines the batch of meshes in case of instances
  62137. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62138. */
  62139. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62140. /**
  62141. * Returns whether or not the outline renderer is ready for a given submesh.
  62142. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62143. * @param subMesh Defines the submesh to check readyness for
  62144. * @param useInstances Defines wheter wee are trying to render instances or not
  62145. * @returns true if ready otherwise false
  62146. */
  62147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62148. private _beforeRenderingMesh;
  62149. private _afterRenderingMesh;
  62150. }
  62151. }
  62152. declare module BABYLON {
  62153. /**
  62154. * Class used to manage multiple sprites of different sizes on the same spritesheet
  62155. * @see http://doc.babylonjs.com/babylon101/sprites
  62156. */
  62157. export class SpritePackedManager extends SpriteManager {
  62158. /** defines the packed manager's name */
  62159. name: string;
  62160. /**
  62161. * Creates a new sprite manager from a packed sprite sheet
  62162. * @param name defines the manager's name
  62163. * @param imgUrl defines the sprite sheet url
  62164. * @param capacity defines the maximum allowed number of sprites
  62165. * @param scene defines the hosting scene
  62166. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  62167. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  62168. * @param samplingMode defines the smapling mode to use with spritesheet
  62169. * @param fromPacked set to true; do not alter
  62170. */
  62171. constructor(
  62172. /** defines the packed manager's name */
  62173. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  62174. }
  62175. }
  62176. declare module BABYLON {
  62177. /**
  62178. * Defines the list of states available for a task inside a AssetsManager
  62179. */
  62180. export enum AssetTaskState {
  62181. /**
  62182. * Initialization
  62183. */
  62184. INIT = 0,
  62185. /**
  62186. * Running
  62187. */
  62188. RUNNING = 1,
  62189. /**
  62190. * Done
  62191. */
  62192. DONE = 2,
  62193. /**
  62194. * Error
  62195. */
  62196. ERROR = 3
  62197. }
  62198. /**
  62199. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62200. */
  62201. export abstract class AbstractAssetTask {
  62202. /**
  62203. * Task name
  62204. */ name: string;
  62205. /**
  62206. * Callback called when the task is successful
  62207. */
  62208. onSuccess: (task: any) => void;
  62209. /**
  62210. * Callback called when the task is not successful
  62211. */
  62212. onError: (task: any, message?: string, exception?: any) => void;
  62213. /**
  62214. * Creates a new AssetsManager
  62215. * @param name defines the name of the task
  62216. */
  62217. constructor(
  62218. /**
  62219. * Task name
  62220. */ name: string);
  62221. private _isCompleted;
  62222. private _taskState;
  62223. private _errorObject;
  62224. /**
  62225. * Get if the task is completed
  62226. */
  62227. readonly isCompleted: boolean;
  62228. /**
  62229. * Gets the current state of the task
  62230. */
  62231. readonly taskState: AssetTaskState;
  62232. /**
  62233. * Gets the current error object (if task is in error)
  62234. */
  62235. readonly errorObject: {
  62236. message?: string;
  62237. exception?: any;
  62238. };
  62239. /**
  62240. * Internal only
  62241. * @hidden
  62242. */
  62243. _setErrorObject(message?: string, exception?: any): void;
  62244. /**
  62245. * Execute the current task
  62246. * @param scene defines the scene where you want your assets to be loaded
  62247. * @param onSuccess is a callback called when the task is successfully executed
  62248. * @param onError is a callback called if an error occurs
  62249. */
  62250. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62251. /**
  62252. * Execute the current task
  62253. * @param scene defines the scene where you want your assets to be loaded
  62254. * @param onSuccess is a callback called when the task is successfully executed
  62255. * @param onError is a callback called if an error occurs
  62256. */
  62257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62258. /**
  62259. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62260. * This can be used with failed tasks that have the reason for failure fixed.
  62261. */
  62262. reset(): void;
  62263. private onErrorCallback;
  62264. private onDoneCallback;
  62265. }
  62266. /**
  62267. * Define the interface used by progress events raised during assets loading
  62268. */
  62269. export interface IAssetsProgressEvent {
  62270. /**
  62271. * Defines the number of remaining tasks to process
  62272. */
  62273. remainingCount: number;
  62274. /**
  62275. * Defines the total number of tasks
  62276. */
  62277. totalCount: number;
  62278. /**
  62279. * Defines the task that was just processed
  62280. */
  62281. task: AbstractAssetTask;
  62282. }
  62283. /**
  62284. * Class used to share progress information about assets loading
  62285. */
  62286. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62287. /**
  62288. * Defines the number of remaining tasks to process
  62289. */
  62290. remainingCount: number;
  62291. /**
  62292. * Defines the total number of tasks
  62293. */
  62294. totalCount: number;
  62295. /**
  62296. * Defines the task that was just processed
  62297. */
  62298. task: AbstractAssetTask;
  62299. /**
  62300. * Creates a AssetsProgressEvent
  62301. * @param remainingCount defines the number of remaining tasks to process
  62302. * @param totalCount defines the total number of tasks
  62303. * @param task defines the task that was just processed
  62304. */
  62305. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62306. }
  62307. /**
  62308. * Define a task used by AssetsManager to load meshes
  62309. */
  62310. export class MeshAssetTask extends AbstractAssetTask {
  62311. /**
  62312. * Defines the name of the task
  62313. */
  62314. name: string;
  62315. /**
  62316. * Defines the list of mesh's names you want to load
  62317. */
  62318. meshesNames: any;
  62319. /**
  62320. * Defines the root url to use as a base to load your meshes and associated resources
  62321. */
  62322. rootUrl: string;
  62323. /**
  62324. * Defines the filename of the scene to load from
  62325. */
  62326. sceneFilename: string;
  62327. /**
  62328. * Gets the list of loaded meshes
  62329. */
  62330. loadedMeshes: Array<AbstractMesh>;
  62331. /**
  62332. * Gets the list of loaded particle systems
  62333. */
  62334. loadedParticleSystems: Array<IParticleSystem>;
  62335. /**
  62336. * Gets the list of loaded skeletons
  62337. */
  62338. loadedSkeletons: Array<Skeleton>;
  62339. /**
  62340. * Gets the list of loaded animation groups
  62341. */
  62342. loadedAnimationGroups: Array<AnimationGroup>;
  62343. /**
  62344. * Callback called when the task is successful
  62345. */
  62346. onSuccess: (task: MeshAssetTask) => void;
  62347. /**
  62348. * Callback called when the task is successful
  62349. */
  62350. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62351. /**
  62352. * Creates a new MeshAssetTask
  62353. * @param name defines the name of the task
  62354. * @param meshesNames defines the list of mesh's names you want to load
  62355. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62356. * @param sceneFilename defines the filename of the scene to load from
  62357. */
  62358. constructor(
  62359. /**
  62360. * Defines the name of the task
  62361. */
  62362. name: string,
  62363. /**
  62364. * Defines the list of mesh's names you want to load
  62365. */
  62366. meshesNames: any,
  62367. /**
  62368. * Defines the root url to use as a base to load your meshes and associated resources
  62369. */
  62370. rootUrl: string,
  62371. /**
  62372. * Defines the filename of the scene to load from
  62373. */
  62374. sceneFilename: string);
  62375. /**
  62376. * Execute the current task
  62377. * @param scene defines the scene where you want your assets to be loaded
  62378. * @param onSuccess is a callback called when the task is successfully executed
  62379. * @param onError is a callback called if an error occurs
  62380. */
  62381. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62382. }
  62383. /**
  62384. * Define a task used by AssetsManager to load text content
  62385. */
  62386. export class TextFileAssetTask extends AbstractAssetTask {
  62387. /**
  62388. * Defines the name of the task
  62389. */
  62390. name: string;
  62391. /**
  62392. * Defines the location of the file to load
  62393. */
  62394. url: string;
  62395. /**
  62396. * Gets the loaded text string
  62397. */
  62398. text: string;
  62399. /**
  62400. * Callback called when the task is successful
  62401. */
  62402. onSuccess: (task: TextFileAssetTask) => void;
  62403. /**
  62404. * Callback called when the task is successful
  62405. */
  62406. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62407. /**
  62408. * Creates a new TextFileAssetTask object
  62409. * @param name defines the name of the task
  62410. * @param url defines the location of the file to load
  62411. */
  62412. constructor(
  62413. /**
  62414. * Defines the name of the task
  62415. */
  62416. name: string,
  62417. /**
  62418. * Defines the location of the file to load
  62419. */
  62420. url: string);
  62421. /**
  62422. * Execute the current task
  62423. * @param scene defines the scene where you want your assets to be loaded
  62424. * @param onSuccess is a callback called when the task is successfully executed
  62425. * @param onError is a callback called if an error occurs
  62426. */
  62427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62428. }
  62429. /**
  62430. * Define a task used by AssetsManager to load binary data
  62431. */
  62432. export class BinaryFileAssetTask extends AbstractAssetTask {
  62433. /**
  62434. * Defines the name of the task
  62435. */
  62436. name: string;
  62437. /**
  62438. * Defines the location of the file to load
  62439. */
  62440. url: string;
  62441. /**
  62442. * Gets the lodaded data (as an array buffer)
  62443. */
  62444. data: ArrayBuffer;
  62445. /**
  62446. * Callback called when the task is successful
  62447. */
  62448. onSuccess: (task: BinaryFileAssetTask) => void;
  62449. /**
  62450. * Callback called when the task is successful
  62451. */
  62452. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62453. /**
  62454. * Creates a new BinaryFileAssetTask object
  62455. * @param name defines the name of the new task
  62456. * @param url defines the location of the file to load
  62457. */
  62458. constructor(
  62459. /**
  62460. * Defines the name of the task
  62461. */
  62462. name: string,
  62463. /**
  62464. * Defines the location of the file to load
  62465. */
  62466. url: string);
  62467. /**
  62468. * Execute the current task
  62469. * @param scene defines the scene where you want your assets to be loaded
  62470. * @param onSuccess is a callback called when the task is successfully executed
  62471. * @param onError is a callback called if an error occurs
  62472. */
  62473. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62474. }
  62475. /**
  62476. * Define a task used by AssetsManager to load images
  62477. */
  62478. export class ImageAssetTask extends AbstractAssetTask {
  62479. /**
  62480. * Defines the name of the task
  62481. */
  62482. name: string;
  62483. /**
  62484. * Defines the location of the image to load
  62485. */
  62486. url: string;
  62487. /**
  62488. * Gets the loaded images
  62489. */
  62490. image: HTMLImageElement;
  62491. /**
  62492. * Callback called when the task is successful
  62493. */
  62494. onSuccess: (task: ImageAssetTask) => void;
  62495. /**
  62496. * Callback called when the task is successful
  62497. */
  62498. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62499. /**
  62500. * Creates a new ImageAssetTask
  62501. * @param name defines the name of the task
  62502. * @param url defines the location of the image to load
  62503. */
  62504. constructor(
  62505. /**
  62506. * Defines the name of the task
  62507. */
  62508. name: string,
  62509. /**
  62510. * Defines the location of the image to load
  62511. */
  62512. url: string);
  62513. /**
  62514. * Execute the current task
  62515. * @param scene defines the scene where you want your assets to be loaded
  62516. * @param onSuccess is a callback called when the task is successfully executed
  62517. * @param onError is a callback called if an error occurs
  62518. */
  62519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62520. }
  62521. /**
  62522. * Defines the interface used by texture loading tasks
  62523. */
  62524. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62525. /**
  62526. * Gets the loaded texture
  62527. */
  62528. texture: TEX;
  62529. }
  62530. /**
  62531. * Define a task used by AssetsManager to load 2D textures
  62532. */
  62533. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62534. /**
  62535. * Defines the name of the task
  62536. */
  62537. name: string;
  62538. /**
  62539. * Defines the location of the file to load
  62540. */
  62541. url: string;
  62542. /**
  62543. * Defines if mipmap should not be generated (default is false)
  62544. */
  62545. noMipmap?: boolean | undefined;
  62546. /**
  62547. * Defines if texture must be inverted on Y axis (default is false)
  62548. */
  62549. invertY?: boolean | undefined;
  62550. /**
  62551. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62552. */
  62553. samplingMode: number;
  62554. /**
  62555. * Gets the loaded texture
  62556. */
  62557. texture: Texture;
  62558. /**
  62559. * Callback called when the task is successful
  62560. */
  62561. onSuccess: (task: TextureAssetTask) => void;
  62562. /**
  62563. * Callback called when the task is successful
  62564. */
  62565. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62566. /**
  62567. * Creates a new TextureAssetTask object
  62568. * @param name defines the name of the task
  62569. * @param url defines the location of the file to load
  62570. * @param noMipmap defines if mipmap should not be generated (default is false)
  62571. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62572. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62573. */
  62574. constructor(
  62575. /**
  62576. * Defines the name of the task
  62577. */
  62578. name: string,
  62579. /**
  62580. * Defines the location of the file to load
  62581. */
  62582. url: string,
  62583. /**
  62584. * Defines if mipmap should not be generated (default is false)
  62585. */
  62586. noMipmap?: boolean | undefined,
  62587. /**
  62588. * Defines if texture must be inverted on Y axis (default is false)
  62589. */
  62590. invertY?: boolean | undefined,
  62591. /**
  62592. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62593. */
  62594. samplingMode?: number);
  62595. /**
  62596. * Execute the current task
  62597. * @param scene defines the scene where you want your assets to be loaded
  62598. * @param onSuccess is a callback called when the task is successfully executed
  62599. * @param onError is a callback called if an error occurs
  62600. */
  62601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62602. }
  62603. /**
  62604. * Define a task used by AssetsManager to load cube textures
  62605. */
  62606. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62607. /**
  62608. * Defines the name of the task
  62609. */
  62610. name: string;
  62611. /**
  62612. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62613. */
  62614. url: string;
  62615. /**
  62616. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62617. */
  62618. extensions?: string[] | undefined;
  62619. /**
  62620. * Defines if mipmaps should not be generated (default is false)
  62621. */
  62622. noMipmap?: boolean | undefined;
  62623. /**
  62624. * Defines the explicit list of files (undefined by default)
  62625. */
  62626. files?: string[] | undefined;
  62627. /**
  62628. * Gets the loaded texture
  62629. */
  62630. texture: CubeTexture;
  62631. /**
  62632. * Callback called when the task is successful
  62633. */
  62634. onSuccess: (task: CubeTextureAssetTask) => void;
  62635. /**
  62636. * Callback called when the task is successful
  62637. */
  62638. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62639. /**
  62640. * Creates a new CubeTextureAssetTask
  62641. * @param name defines the name of the task
  62642. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62643. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62644. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62645. * @param files defines the explicit list of files (undefined by default)
  62646. */
  62647. constructor(
  62648. /**
  62649. * Defines the name of the task
  62650. */
  62651. name: string,
  62652. /**
  62653. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62654. */
  62655. url: string,
  62656. /**
  62657. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62658. */
  62659. extensions?: string[] | undefined,
  62660. /**
  62661. * Defines if mipmaps should not be generated (default is false)
  62662. */
  62663. noMipmap?: boolean | undefined,
  62664. /**
  62665. * Defines the explicit list of files (undefined by default)
  62666. */
  62667. files?: string[] | undefined);
  62668. /**
  62669. * Execute the current task
  62670. * @param scene defines the scene where you want your assets to be loaded
  62671. * @param onSuccess is a callback called when the task is successfully executed
  62672. * @param onError is a callback called if an error occurs
  62673. */
  62674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62675. }
  62676. /**
  62677. * Define a task used by AssetsManager to load HDR cube textures
  62678. */
  62679. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62680. /**
  62681. * Defines the name of the task
  62682. */
  62683. name: string;
  62684. /**
  62685. * Defines the location of the file to load
  62686. */
  62687. url: string;
  62688. /**
  62689. * Defines the desired size (the more it increases the longer the generation will be)
  62690. */
  62691. size: number;
  62692. /**
  62693. * Defines if mipmaps should not be generated (default is false)
  62694. */
  62695. noMipmap: boolean;
  62696. /**
  62697. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62698. */
  62699. generateHarmonics: boolean;
  62700. /**
  62701. * 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)
  62702. */
  62703. gammaSpace: boolean;
  62704. /**
  62705. * Internal Use Only
  62706. */
  62707. reserved: boolean;
  62708. /**
  62709. * Gets the loaded texture
  62710. */
  62711. texture: HDRCubeTexture;
  62712. /**
  62713. * Callback called when the task is successful
  62714. */
  62715. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62716. /**
  62717. * Callback called when the task is successful
  62718. */
  62719. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62720. /**
  62721. * Creates a new HDRCubeTextureAssetTask object
  62722. * @param name defines the name of the task
  62723. * @param url defines the location of the file to load
  62724. * @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.
  62725. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62726. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62727. * @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)
  62728. * @param reserved Internal use only
  62729. */
  62730. constructor(
  62731. /**
  62732. * Defines the name of the task
  62733. */
  62734. name: string,
  62735. /**
  62736. * Defines the location of the file to load
  62737. */
  62738. url: string,
  62739. /**
  62740. * Defines the desired size (the more it increases the longer the generation will be)
  62741. */
  62742. size: number,
  62743. /**
  62744. * Defines if mipmaps should not be generated (default is false)
  62745. */
  62746. noMipmap?: boolean,
  62747. /**
  62748. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62749. */
  62750. generateHarmonics?: boolean,
  62751. /**
  62752. * 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)
  62753. */
  62754. gammaSpace?: boolean,
  62755. /**
  62756. * Internal Use Only
  62757. */
  62758. reserved?: boolean);
  62759. /**
  62760. * Execute the current task
  62761. * @param scene defines the scene where you want your assets to be loaded
  62762. * @param onSuccess is a callback called when the task is successfully executed
  62763. * @param onError is a callback called if an error occurs
  62764. */
  62765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62766. }
  62767. /**
  62768. * Define a task used by AssetsManager to load Equirectangular cube textures
  62769. */
  62770. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62771. /**
  62772. * Defines the name of the task
  62773. */
  62774. name: string;
  62775. /**
  62776. * Defines the location of the file to load
  62777. */
  62778. url: string;
  62779. /**
  62780. * Defines the desired size (the more it increases the longer the generation will be)
  62781. */
  62782. size: number;
  62783. /**
  62784. * Defines if mipmaps should not be generated (default is false)
  62785. */
  62786. noMipmap: boolean;
  62787. /**
  62788. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62789. * but the standard material would require them in Gamma space) (default is true)
  62790. */
  62791. gammaSpace: boolean;
  62792. /**
  62793. * Gets the loaded texture
  62794. */
  62795. texture: EquiRectangularCubeTexture;
  62796. /**
  62797. * Callback called when the task is successful
  62798. */
  62799. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62800. /**
  62801. * Callback called when the task is successful
  62802. */
  62803. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62804. /**
  62805. * Creates a new EquiRectangularCubeTextureAssetTask object
  62806. * @param name defines the name of the task
  62807. * @param url defines the location of the file to load
  62808. * @param size defines the desired size (the more it increases the longer the generation will be)
  62809. * If the size is omitted this implies you are using a preprocessed cubemap.
  62810. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62811. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62812. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62813. * (default is true)
  62814. */
  62815. constructor(
  62816. /**
  62817. * Defines the name of the task
  62818. */
  62819. name: string,
  62820. /**
  62821. * Defines the location of the file to load
  62822. */
  62823. url: string,
  62824. /**
  62825. * Defines the desired size (the more it increases the longer the generation will be)
  62826. */
  62827. size: number,
  62828. /**
  62829. * Defines if mipmaps should not be generated (default is false)
  62830. */
  62831. noMipmap?: boolean,
  62832. /**
  62833. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62834. * but the standard material would require them in Gamma space) (default is true)
  62835. */
  62836. gammaSpace?: boolean);
  62837. /**
  62838. * Execute the current task
  62839. * @param scene defines the scene where you want your assets to be loaded
  62840. * @param onSuccess is a callback called when the task is successfully executed
  62841. * @param onError is a callback called if an error occurs
  62842. */
  62843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62844. }
  62845. /**
  62846. * This class can be used to easily import assets into a scene
  62847. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62848. */
  62849. export class AssetsManager {
  62850. private _scene;
  62851. private _isLoading;
  62852. protected _tasks: AbstractAssetTask[];
  62853. protected _waitingTasksCount: number;
  62854. protected _totalTasksCount: number;
  62855. /**
  62856. * Callback called when all tasks are processed
  62857. */
  62858. onFinish: (tasks: AbstractAssetTask[]) => void;
  62859. /**
  62860. * Callback called when a task is successful
  62861. */
  62862. onTaskSuccess: (task: AbstractAssetTask) => void;
  62863. /**
  62864. * Callback called when a task had an error
  62865. */
  62866. onTaskError: (task: AbstractAssetTask) => void;
  62867. /**
  62868. * Callback called when a task is done (whatever the result is)
  62869. */
  62870. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62871. /**
  62872. * Observable called when all tasks are processed
  62873. */
  62874. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62875. /**
  62876. * Observable called when a task had an error
  62877. */
  62878. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62879. /**
  62880. * Observable called when all tasks were executed
  62881. */
  62882. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62883. /**
  62884. * Observable called when a task is done (whatever the result is)
  62885. */
  62886. onProgressObservable: Observable<IAssetsProgressEvent>;
  62887. /**
  62888. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62890. */
  62891. useDefaultLoadingScreen: boolean;
  62892. /**
  62893. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62894. * when all assets have been downloaded.
  62895. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62896. */
  62897. autoHideLoadingUI: boolean;
  62898. /**
  62899. * Creates a new AssetsManager
  62900. * @param scene defines the scene to work on
  62901. */
  62902. constructor(scene: Scene);
  62903. /**
  62904. * Add a MeshAssetTask to the list of active tasks
  62905. * @param taskName defines the name of the new task
  62906. * @param meshesNames defines the name of meshes to load
  62907. * @param rootUrl defines the root url to use to locate files
  62908. * @param sceneFilename defines the filename of the scene file
  62909. * @returns a new MeshAssetTask object
  62910. */
  62911. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62912. /**
  62913. * Add a TextFileAssetTask to the list of active tasks
  62914. * @param taskName defines the name of the new task
  62915. * @param url defines the url of the file to load
  62916. * @returns a new TextFileAssetTask object
  62917. */
  62918. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62919. /**
  62920. * Add a BinaryFileAssetTask to the list of active tasks
  62921. * @param taskName defines the name of the new task
  62922. * @param url defines the url of the file to load
  62923. * @returns a new BinaryFileAssetTask object
  62924. */
  62925. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62926. /**
  62927. * Add a ImageAssetTask to the list of active tasks
  62928. * @param taskName defines the name of the new task
  62929. * @param url defines the url of the file to load
  62930. * @returns a new ImageAssetTask object
  62931. */
  62932. addImageTask(taskName: string, url: string): ImageAssetTask;
  62933. /**
  62934. * Add a TextureAssetTask to the list of active tasks
  62935. * @param taskName defines the name of the new task
  62936. * @param url defines the url of the file to load
  62937. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62938. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62939. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62940. * @returns a new TextureAssetTask object
  62941. */
  62942. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62943. /**
  62944. * Add a CubeTextureAssetTask to the list of active tasks
  62945. * @param taskName defines the name of the new task
  62946. * @param url defines the url of the file to load
  62947. * @param extensions defines the extension to use to load the cube map (can be null)
  62948. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62949. * @param files defines the list of files to load (can be null)
  62950. * @returns a new CubeTextureAssetTask object
  62951. */
  62952. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62953. /**
  62954. *
  62955. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62956. * @param taskName defines the name of the new task
  62957. * @param url defines the url of the file to load
  62958. * @param size defines the size you want for the cubemap (can be null)
  62959. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62960. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62961. * @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)
  62962. * @param reserved Internal use only
  62963. * @returns a new HDRCubeTextureAssetTask object
  62964. */
  62965. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62966. /**
  62967. *
  62968. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62969. * @param taskName defines the name of the new task
  62970. * @param url defines the url of the file to load
  62971. * @param size defines the size you want for the cubemap (can be null)
  62972. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62973. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62974. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62975. * @returns a new EquiRectangularCubeTextureAssetTask object
  62976. */
  62977. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62978. /**
  62979. * Remove a task from the assets manager.
  62980. * @param task the task to remove
  62981. */
  62982. removeTask(task: AbstractAssetTask): void;
  62983. private _decreaseWaitingTasksCount;
  62984. private _runTask;
  62985. /**
  62986. * Reset the AssetsManager and remove all tasks
  62987. * @return the current instance of the AssetsManager
  62988. */
  62989. reset(): AssetsManager;
  62990. /**
  62991. * Start the loading process
  62992. * @return the current instance of the AssetsManager
  62993. */
  62994. load(): AssetsManager;
  62995. /**
  62996. * Start the loading process as an async operation
  62997. * @return a promise returning the list of failed tasks
  62998. */
  62999. loadAsync(): Promise<void>;
  63000. }
  63001. }
  63002. declare module BABYLON {
  63003. /**
  63004. * Wrapper class for promise with external resolve and reject.
  63005. */
  63006. export class Deferred<T> {
  63007. /**
  63008. * The promise associated with this deferred object.
  63009. */
  63010. readonly promise: Promise<T>;
  63011. private _resolve;
  63012. private _reject;
  63013. /**
  63014. * The resolve method of the promise associated with this deferred object.
  63015. */
  63016. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63017. /**
  63018. * The reject method of the promise associated with this deferred object.
  63019. */
  63020. readonly reject: (reason?: any) => void;
  63021. /**
  63022. * Constructor for this deferred object.
  63023. */
  63024. constructor();
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63030. */
  63031. export class MeshExploder {
  63032. private _centerMesh;
  63033. private _meshes;
  63034. private _meshesOrigins;
  63035. private _toCenterVectors;
  63036. private _scaledDirection;
  63037. private _newPosition;
  63038. private _centerPosition;
  63039. /**
  63040. * Explodes meshes from a center mesh.
  63041. * @param meshes The meshes to explode.
  63042. * @param centerMesh The mesh to be center of explosion.
  63043. */
  63044. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63045. private _setCenterMesh;
  63046. /**
  63047. * Get class name
  63048. * @returns "MeshExploder"
  63049. */
  63050. getClassName(): string;
  63051. /**
  63052. * "Exploded meshes"
  63053. * @returns Array of meshes with the centerMesh at index 0.
  63054. */
  63055. getMeshes(): Array<Mesh>;
  63056. /**
  63057. * Explodes meshes giving a specific direction
  63058. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63059. */
  63060. explode(direction?: number): void;
  63061. }
  63062. }
  63063. declare module BABYLON {
  63064. /**
  63065. * Class used to help managing file picking and drag'n'drop
  63066. */
  63067. export class FilesInput {
  63068. /**
  63069. * List of files ready to be loaded
  63070. */
  63071. static readonly FilesToLoad: {
  63072. [key: string]: File;
  63073. };
  63074. /**
  63075. * Callback called when a file is processed
  63076. */
  63077. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63078. private _engine;
  63079. private _currentScene;
  63080. private _sceneLoadedCallback;
  63081. private _progressCallback;
  63082. private _additionalRenderLoopLogicCallback;
  63083. private _textureLoadingCallback;
  63084. private _startingProcessingFilesCallback;
  63085. private _onReloadCallback;
  63086. private _errorCallback;
  63087. private _elementToMonitor;
  63088. private _sceneFileToLoad;
  63089. private _filesToLoad;
  63090. /**
  63091. * Creates a new FilesInput
  63092. * @param engine defines the rendering engine
  63093. * @param scene defines the hosting scene
  63094. * @param sceneLoadedCallback callback called when scene is loaded
  63095. * @param progressCallback callback called to track progress
  63096. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63097. * @param textureLoadingCallback callback called when a texture is loading
  63098. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63099. * @param onReloadCallback callback called when a reload is requested
  63100. * @param errorCallback callback call if an error occurs
  63101. */
  63102. 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);
  63103. private _dragEnterHandler;
  63104. private _dragOverHandler;
  63105. private _dropHandler;
  63106. /**
  63107. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63108. * @param elementToMonitor defines the DOM element to track
  63109. */
  63110. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63111. /**
  63112. * Release all associated resources
  63113. */
  63114. dispose(): void;
  63115. private renderFunction;
  63116. private drag;
  63117. private drop;
  63118. private _traverseFolder;
  63119. private _processFiles;
  63120. /**
  63121. * Load files from a drop event
  63122. * @param event defines the drop event to use as source
  63123. */
  63124. loadFiles(event: any): void;
  63125. private _processReload;
  63126. /**
  63127. * Reload the current scene from the loaded files
  63128. */
  63129. reload(): void;
  63130. }
  63131. }
  63132. declare module BABYLON {
  63133. /**
  63134. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63136. */
  63137. export class SceneOptimization {
  63138. /**
  63139. * Defines the priority of this optimization (0 by default which means first in the list)
  63140. */
  63141. priority: number;
  63142. /**
  63143. * Gets a string describing the action executed by the current optimization
  63144. * @returns description string
  63145. */
  63146. getDescription(): string;
  63147. /**
  63148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63149. * @param scene defines the current scene where to apply this optimization
  63150. * @param optimizer defines the current optimizer
  63151. * @returns true if everything that can be done was applied
  63152. */
  63153. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63154. /**
  63155. * Creates the SceneOptimization object
  63156. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63157. * @param desc defines the description associated with the optimization
  63158. */
  63159. constructor(
  63160. /**
  63161. * Defines the priority of this optimization (0 by default which means first in the list)
  63162. */
  63163. priority?: number);
  63164. }
  63165. /**
  63166. * Defines an optimization used to reduce the size of render target textures
  63167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63168. */
  63169. export class TextureOptimization extends SceneOptimization {
  63170. /**
  63171. * Defines the priority of this optimization (0 by default which means first in the list)
  63172. */
  63173. priority: number;
  63174. /**
  63175. * 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
  63176. */
  63177. maximumSize: number;
  63178. /**
  63179. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63180. */
  63181. step: number;
  63182. /**
  63183. * Gets a string describing the action executed by the current optimization
  63184. * @returns description string
  63185. */
  63186. getDescription(): string;
  63187. /**
  63188. * Creates the TextureOptimization object
  63189. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63190. * @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
  63191. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63192. */
  63193. constructor(
  63194. /**
  63195. * Defines the priority of this optimization (0 by default which means first in the list)
  63196. */
  63197. priority?: number,
  63198. /**
  63199. * 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
  63200. */
  63201. maximumSize?: number,
  63202. /**
  63203. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63204. */
  63205. step?: number);
  63206. /**
  63207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63208. * @param scene defines the current scene where to apply this optimization
  63209. * @param optimizer defines the current optimizer
  63210. * @returns true if everything that can be done was applied
  63211. */
  63212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63213. }
  63214. /**
  63215. * Defines an optimization used to increase or decrease the rendering resolution
  63216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63217. */
  63218. export class HardwareScalingOptimization extends SceneOptimization {
  63219. /**
  63220. * Defines the priority of this optimization (0 by default which means first in the list)
  63221. */
  63222. priority: number;
  63223. /**
  63224. * Defines the maximum scale to use (2 by default)
  63225. */
  63226. maximumScale: number;
  63227. /**
  63228. * Defines the step to use between two passes (0.5 by default)
  63229. */
  63230. step: number;
  63231. private _currentScale;
  63232. private _directionOffset;
  63233. /**
  63234. * Gets a string describing the action executed by the current optimization
  63235. * @return description string
  63236. */
  63237. getDescription(): string;
  63238. /**
  63239. * Creates the HardwareScalingOptimization object
  63240. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63241. * @param maximumScale defines the maximum scale to use (2 by default)
  63242. * @param step defines the step to use between two passes (0.5 by default)
  63243. */
  63244. constructor(
  63245. /**
  63246. * Defines the priority of this optimization (0 by default which means first in the list)
  63247. */
  63248. priority?: number,
  63249. /**
  63250. * Defines the maximum scale to use (2 by default)
  63251. */
  63252. maximumScale?: number,
  63253. /**
  63254. * Defines the step to use between two passes (0.5 by default)
  63255. */
  63256. step?: number);
  63257. /**
  63258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63259. * @param scene defines the current scene where to apply this optimization
  63260. * @param optimizer defines the current optimizer
  63261. * @returns true if everything that can be done was applied
  63262. */
  63263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63264. }
  63265. /**
  63266. * Defines an optimization used to remove shadows
  63267. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63268. */
  63269. export class ShadowsOptimization extends SceneOptimization {
  63270. /**
  63271. * Gets a string describing the action executed by the current optimization
  63272. * @return description string
  63273. */
  63274. getDescription(): string;
  63275. /**
  63276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63277. * @param scene defines the current scene where to apply this optimization
  63278. * @param optimizer defines the current optimizer
  63279. * @returns true if everything that can be done was applied
  63280. */
  63281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63282. }
  63283. /**
  63284. * Defines an optimization used to turn post-processes off
  63285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63286. */
  63287. export class PostProcessesOptimization extends SceneOptimization {
  63288. /**
  63289. * Gets a string describing the action executed by the current optimization
  63290. * @return description string
  63291. */
  63292. getDescription(): string;
  63293. /**
  63294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63295. * @param scene defines the current scene where to apply this optimization
  63296. * @param optimizer defines the current optimizer
  63297. * @returns true if everything that can be done was applied
  63298. */
  63299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63300. }
  63301. /**
  63302. * Defines an optimization used to turn lens flares off
  63303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63304. */
  63305. export class LensFlaresOptimization extends SceneOptimization {
  63306. /**
  63307. * Gets a string describing the action executed by the current optimization
  63308. * @return description string
  63309. */
  63310. getDescription(): string;
  63311. /**
  63312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63313. * @param scene defines the current scene where to apply this optimization
  63314. * @param optimizer defines the current optimizer
  63315. * @returns true if everything that can be done was applied
  63316. */
  63317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63318. }
  63319. /**
  63320. * Defines an optimization based on user defined callback.
  63321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63322. */
  63323. export class CustomOptimization extends SceneOptimization {
  63324. /**
  63325. * Callback called to apply the custom optimization.
  63326. */
  63327. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63328. /**
  63329. * Callback called to get custom description
  63330. */
  63331. onGetDescription: () => string;
  63332. /**
  63333. * Gets a string describing the action executed by the current optimization
  63334. * @returns description string
  63335. */
  63336. getDescription(): string;
  63337. /**
  63338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63339. * @param scene defines the current scene where to apply this optimization
  63340. * @param optimizer defines the current optimizer
  63341. * @returns true if everything that can be done was applied
  63342. */
  63343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63344. }
  63345. /**
  63346. * Defines an optimization used to turn particles off
  63347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63348. */
  63349. export class ParticlesOptimization extends SceneOptimization {
  63350. /**
  63351. * Gets a string describing the action executed by the current optimization
  63352. * @return description string
  63353. */
  63354. getDescription(): string;
  63355. /**
  63356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63357. * @param scene defines the current scene where to apply this optimization
  63358. * @param optimizer defines the current optimizer
  63359. * @returns true if everything that can be done was applied
  63360. */
  63361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63362. }
  63363. /**
  63364. * Defines an optimization used to turn render targets off
  63365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63366. */
  63367. export class RenderTargetsOptimization extends SceneOptimization {
  63368. /**
  63369. * Gets a string describing the action executed by the current optimization
  63370. * @return description string
  63371. */
  63372. getDescription(): string;
  63373. /**
  63374. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63375. * @param scene defines the current scene where to apply this optimization
  63376. * @param optimizer defines the current optimizer
  63377. * @returns true if everything that can be done was applied
  63378. */
  63379. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63380. }
  63381. /**
  63382. * Defines an optimization used to merge meshes with compatible materials
  63383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63384. */
  63385. export class MergeMeshesOptimization extends SceneOptimization {
  63386. private static _UpdateSelectionTree;
  63387. /**
  63388. * Gets or sets a boolean which defines if optimization octree has to be updated
  63389. */
  63390. /**
  63391. * Gets or sets a boolean which defines if optimization octree has to be updated
  63392. */
  63393. static UpdateSelectionTree: boolean;
  63394. /**
  63395. * Gets a string describing the action executed by the current optimization
  63396. * @return description string
  63397. */
  63398. getDescription(): string;
  63399. private _canBeMerged;
  63400. /**
  63401. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63402. * @param scene defines the current scene where to apply this optimization
  63403. * @param optimizer defines the current optimizer
  63404. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63405. * @returns true if everything that can be done was applied
  63406. */
  63407. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63408. }
  63409. /**
  63410. * Defines a list of options used by SceneOptimizer
  63411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63412. */
  63413. export class SceneOptimizerOptions {
  63414. /**
  63415. * Defines the target frame rate to reach (60 by default)
  63416. */
  63417. targetFrameRate: number;
  63418. /**
  63419. * Defines the interval between two checkes (2000ms by default)
  63420. */
  63421. trackerDuration: number;
  63422. /**
  63423. * Gets the list of optimizations to apply
  63424. */
  63425. optimizations: SceneOptimization[];
  63426. /**
  63427. * Creates a new list of options used by SceneOptimizer
  63428. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63429. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63430. */
  63431. constructor(
  63432. /**
  63433. * Defines the target frame rate to reach (60 by default)
  63434. */
  63435. targetFrameRate?: number,
  63436. /**
  63437. * Defines the interval between two checkes (2000ms by default)
  63438. */
  63439. trackerDuration?: number);
  63440. /**
  63441. * Add a new optimization
  63442. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63443. * @returns the current SceneOptimizerOptions
  63444. */
  63445. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63446. /**
  63447. * Add a new custom optimization
  63448. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63449. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63450. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63451. * @returns the current SceneOptimizerOptions
  63452. */
  63453. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63454. /**
  63455. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63456. * @param targetFrameRate defines the target frame rate (60 by default)
  63457. * @returns a SceneOptimizerOptions object
  63458. */
  63459. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63460. /**
  63461. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63462. * @param targetFrameRate defines the target frame rate (60 by default)
  63463. * @returns a SceneOptimizerOptions object
  63464. */
  63465. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63466. /**
  63467. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63468. * @param targetFrameRate defines the target frame rate (60 by default)
  63469. * @returns a SceneOptimizerOptions object
  63470. */
  63471. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63472. }
  63473. /**
  63474. * Class used to run optimizations in order to reach a target frame rate
  63475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63476. */
  63477. export class SceneOptimizer implements IDisposable {
  63478. private _isRunning;
  63479. private _options;
  63480. private _scene;
  63481. private _currentPriorityLevel;
  63482. private _targetFrameRate;
  63483. private _trackerDuration;
  63484. private _currentFrameRate;
  63485. private _sceneDisposeObserver;
  63486. private _improvementMode;
  63487. /**
  63488. * Defines an observable called when the optimizer reaches the target frame rate
  63489. */
  63490. onSuccessObservable: Observable<SceneOptimizer>;
  63491. /**
  63492. * Defines an observable called when the optimizer enables an optimization
  63493. */
  63494. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63495. /**
  63496. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63497. */
  63498. onFailureObservable: Observable<SceneOptimizer>;
  63499. /**
  63500. * Gets a boolean indicating if the optimizer is in improvement mode
  63501. */
  63502. readonly isInImprovementMode: boolean;
  63503. /**
  63504. * Gets the current priority level (0 at start)
  63505. */
  63506. readonly currentPriorityLevel: number;
  63507. /**
  63508. * Gets the current frame rate checked by the SceneOptimizer
  63509. */
  63510. readonly currentFrameRate: number;
  63511. /**
  63512. * Gets or sets the current target frame rate (60 by default)
  63513. */
  63514. /**
  63515. * Gets or sets the current target frame rate (60 by default)
  63516. */
  63517. targetFrameRate: number;
  63518. /**
  63519. * Gets or sets the current interval between two checks (every 2000ms by default)
  63520. */
  63521. /**
  63522. * Gets or sets the current interval between two checks (every 2000ms by default)
  63523. */
  63524. trackerDuration: number;
  63525. /**
  63526. * Gets the list of active optimizations
  63527. */
  63528. readonly optimizations: SceneOptimization[];
  63529. /**
  63530. * Creates a new SceneOptimizer
  63531. * @param scene defines the scene to work on
  63532. * @param options defines the options to use with the SceneOptimizer
  63533. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63534. * @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)
  63535. */
  63536. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63537. /**
  63538. * Stops the current optimizer
  63539. */
  63540. stop(): void;
  63541. /**
  63542. * Reset the optimizer to initial step (current priority level = 0)
  63543. */
  63544. reset(): void;
  63545. /**
  63546. * Start the optimizer. By default it will try to reach a specific framerate
  63547. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63548. */
  63549. start(): void;
  63550. private _checkCurrentState;
  63551. /**
  63552. * Release all resources
  63553. */
  63554. dispose(): void;
  63555. /**
  63556. * Helper function to create a SceneOptimizer with one single line of code
  63557. * @param scene defines the scene to work on
  63558. * @param options defines the options to use with the SceneOptimizer
  63559. * @param onSuccess defines a callback to call on success
  63560. * @param onFailure defines a callback to call on failure
  63561. * @returns the new SceneOptimizer object
  63562. */
  63563. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63564. }
  63565. }
  63566. declare module BABYLON {
  63567. /**
  63568. * Class used to serialize a scene into a string
  63569. */
  63570. export class SceneSerializer {
  63571. /**
  63572. * Clear cache used by a previous serialization
  63573. */
  63574. static ClearCache(): void;
  63575. /**
  63576. * Serialize a scene into a JSON compatible object
  63577. * @param scene defines the scene to serialize
  63578. * @returns a JSON compatible object
  63579. */
  63580. static Serialize(scene: Scene): any;
  63581. /**
  63582. * Serialize a mesh into a JSON compatible object
  63583. * @param toSerialize defines the mesh to serialize
  63584. * @param withParents defines if parents must be serialized as well
  63585. * @param withChildren defines if children must be serialized as well
  63586. * @returns a JSON compatible object
  63587. */
  63588. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63589. }
  63590. }
  63591. declare module BABYLON {
  63592. /**
  63593. * Class used to host texture specific utilities
  63594. */
  63595. export class TextureTools {
  63596. /**
  63597. * Uses the GPU to create a copy texture rescaled at a given size
  63598. * @param texture Texture to copy from
  63599. * @param width defines the desired width
  63600. * @param height defines the desired height
  63601. * @param useBilinearMode defines if bilinear mode has to be used
  63602. * @return the generated texture
  63603. */
  63604. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63605. }
  63606. }
  63607. declare module BABYLON {
  63608. /**
  63609. * This represents the different options available for the video capture.
  63610. */
  63611. export interface VideoRecorderOptions {
  63612. /** Defines the mime type of the video. */
  63613. mimeType: string;
  63614. /** Defines the FPS the video should be recorded at. */
  63615. fps: number;
  63616. /** Defines the chunk size for the recording data. */
  63617. recordChunckSize: number;
  63618. /** The audio tracks to attach to the recording. */
  63619. audioTracks?: MediaStreamTrack[];
  63620. }
  63621. /**
  63622. * This can help with recording videos from BabylonJS.
  63623. * This is based on the available WebRTC functionalities of the browser.
  63624. *
  63625. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63626. */
  63627. export class VideoRecorder {
  63628. private static readonly _defaultOptions;
  63629. /**
  63630. * Returns whether or not the VideoRecorder is available in your browser.
  63631. * @param engine Defines the Babylon Engine.
  63632. * @returns true if supported otherwise false.
  63633. */
  63634. static IsSupported(engine: Engine): boolean;
  63635. private readonly _options;
  63636. private _canvas;
  63637. private _mediaRecorder;
  63638. private _recordedChunks;
  63639. private _fileName;
  63640. private _resolve;
  63641. private _reject;
  63642. /**
  63643. * True when a recording is already in progress.
  63644. */
  63645. readonly isRecording: boolean;
  63646. /**
  63647. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63648. * @param engine Defines the BabylonJS Engine you wish to record.
  63649. * @param options Defines options that can be used to customize the capture.
  63650. */
  63651. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63652. /**
  63653. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63654. */
  63655. stopRecording(): void;
  63656. /**
  63657. * Starts recording the canvas for a max duration specified in parameters.
  63658. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63659. * If null no automatic download will start and you can rely on the promise to get the data back.
  63660. * @param maxDuration Defines the maximum recording time in seconds.
  63661. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63662. * @return A promise callback at the end of the recording with the video data in Blob.
  63663. */
  63664. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63665. /**
  63666. * Releases internal resources used during the recording.
  63667. */
  63668. dispose(): void;
  63669. private _handleDataAvailable;
  63670. private _handleError;
  63671. private _handleStop;
  63672. }
  63673. }
  63674. declare module BABYLON {
  63675. /**
  63676. * Class containing a set of static utilities functions for screenshots
  63677. */
  63678. export class ScreenshotTools {
  63679. /**
  63680. * Captures a screenshot of the current rendering
  63681. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63682. * @param engine defines the rendering engine
  63683. * @param camera defines the source camera
  63684. * @param size This parameter can be set to a single number or to an object with the
  63685. * following (optional) properties: precision, width, height. If a single number is passed,
  63686. * it will be used for both width and height. If an object is passed, the screenshot size
  63687. * will be derived from the parameters. The precision property is a multiplier allowing
  63688. * rendering at a higher or lower resolution
  63689. * @param successCallback defines the callback receives a single parameter which contains the
  63690. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63691. * src parameter of an <img> to display it
  63692. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63693. * Check your browser for supported MIME types
  63694. */
  63695. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63696. /**
  63697. * Captures a screenshot of the current rendering
  63698. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63699. * @param engine defines the rendering engine
  63700. * @param camera defines the source camera
  63701. * @param size This parameter can be set to a single number or to an object with the
  63702. * following (optional) properties: precision, width, height. If a single number is passed,
  63703. * it will be used for both width and height. If an object is passed, the screenshot size
  63704. * will be derived from the parameters. The precision property is a multiplier allowing
  63705. * rendering at a higher or lower resolution
  63706. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63707. * Check your browser for supported MIME types
  63708. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63709. * to the src parameter of an <img> to display it
  63710. */
  63711. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63712. /**
  63713. * Generates an image screenshot from the specified camera.
  63714. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63715. * @param engine The engine to use for rendering
  63716. * @param camera The camera to use for rendering
  63717. * @param size This parameter can be set to a single number or to an object with the
  63718. * following (optional) properties: precision, width, height. If a single number is passed,
  63719. * it will be used for both width and height. If an object is passed, the screenshot size
  63720. * will be derived from the parameters. The precision property is a multiplier allowing
  63721. * rendering at a higher or lower resolution
  63722. * @param successCallback The callback receives a single parameter which contains the
  63723. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63724. * src parameter of an <img> to display it
  63725. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63726. * Check your browser for supported MIME types
  63727. * @param samples Texture samples (default: 1)
  63728. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63729. * @param fileName A name for for the downloaded file.
  63730. */
  63731. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63732. /**
  63733. * Generates an image screenshot from the specified camera.
  63734. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63735. * @param engine The engine to use for rendering
  63736. * @param camera The camera to use for rendering
  63737. * @param size This parameter can be set to a single number or to an object with the
  63738. * following (optional) properties: precision, width, height. If a single number is passed,
  63739. * it will be used for both width and height. If an object is passed, the screenshot size
  63740. * will be derived from the parameters. The precision property is a multiplier allowing
  63741. * rendering at a higher or lower resolution
  63742. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63743. * Check your browser for supported MIME types
  63744. * @param samples Texture samples (default: 1)
  63745. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63746. * @param fileName A name for for the downloaded file.
  63747. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63748. * to the src parameter of an <img> to display it
  63749. */
  63750. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63751. /**
  63752. * Gets height and width for screenshot size
  63753. * @private
  63754. */
  63755. private static _getScreenshotSize;
  63756. }
  63757. }
  63758. declare module BABYLON {
  63759. /**
  63760. * A cursor which tracks a point on a path
  63761. */
  63762. export class PathCursor {
  63763. private path;
  63764. /**
  63765. * Stores path cursor callbacks for when an onchange event is triggered
  63766. */
  63767. private _onchange;
  63768. /**
  63769. * The value of the path cursor
  63770. */
  63771. value: number;
  63772. /**
  63773. * The animation array of the path cursor
  63774. */
  63775. animations: Animation[];
  63776. /**
  63777. * Initializes the path cursor
  63778. * @param path The path to track
  63779. */
  63780. constructor(path: Path2);
  63781. /**
  63782. * Gets the cursor point on the path
  63783. * @returns A point on the path cursor at the cursor location
  63784. */
  63785. getPoint(): Vector3;
  63786. /**
  63787. * Moves the cursor ahead by the step amount
  63788. * @param step The amount to move the cursor forward
  63789. * @returns This path cursor
  63790. */
  63791. moveAhead(step?: number): PathCursor;
  63792. /**
  63793. * Moves the cursor behind by the step amount
  63794. * @param step The amount to move the cursor back
  63795. * @returns This path cursor
  63796. */
  63797. moveBack(step?: number): PathCursor;
  63798. /**
  63799. * Moves the cursor by the step amount
  63800. * If the step amount is greater than one, an exception is thrown
  63801. * @param step The amount to move the cursor
  63802. * @returns This path cursor
  63803. */
  63804. move(step: number): PathCursor;
  63805. /**
  63806. * Ensures that the value is limited between zero and one
  63807. * @returns This path cursor
  63808. */
  63809. private ensureLimits;
  63810. /**
  63811. * Runs onchange callbacks on change (used by the animation engine)
  63812. * @returns This path cursor
  63813. */
  63814. private raiseOnChange;
  63815. /**
  63816. * Executes a function on change
  63817. * @param f A path cursor onchange callback
  63818. * @returns This path cursor
  63819. */
  63820. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63821. }
  63822. }
  63823. declare module BABYLON {
  63824. /** @hidden */
  63825. export var blurPixelShader: {
  63826. name: string;
  63827. shader: string;
  63828. };
  63829. }
  63830. declare module BABYLON {
  63831. /** @hidden */
  63832. export var pointCloudVertexDeclaration: {
  63833. name: string;
  63834. shader: string;
  63835. };
  63836. }
  63837. // Mixins
  63838. interface Window {
  63839. mozIndexedDB: IDBFactory;
  63840. webkitIndexedDB: IDBFactory;
  63841. msIndexedDB: IDBFactory;
  63842. webkitURL: typeof URL;
  63843. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  63844. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  63845. WebGLRenderingContext: WebGLRenderingContext;
  63846. MSGesture: MSGesture;
  63847. CANNON: any;
  63848. AudioContext: AudioContext;
  63849. webkitAudioContext: AudioContext;
  63850. PointerEvent: any;
  63851. Math: Math;
  63852. Uint8Array: Uint8ArrayConstructor;
  63853. Float32Array: Float32ArrayConstructor;
  63854. mozURL: typeof URL;
  63855. msURL: typeof URL;
  63856. VRFrameData: any; // WebVR, from specs 1.1
  63857. DracoDecoderModule: any;
  63858. setImmediate(handler: (...args: any[]) => void): number;
  63859. }
  63860. interface HTMLCanvasElement {
  63861. requestPointerLock(): void;
  63862. msRequestPointerLock?(): void;
  63863. mozRequestPointerLock?(): void;
  63864. webkitRequestPointerLock?(): void;
  63865. /** Track wether a record is in progress */
  63866. isRecording: boolean;
  63867. /** Capture Stream method defined by some browsers */
  63868. captureStream(fps?: number): MediaStream;
  63869. }
  63870. interface CanvasRenderingContext2D {
  63871. msImageSmoothingEnabled: boolean;
  63872. }
  63873. interface MouseEvent {
  63874. mozMovementX: number;
  63875. mozMovementY: number;
  63876. webkitMovementX: number;
  63877. webkitMovementY: number;
  63878. msMovementX: number;
  63879. msMovementY: number;
  63880. }
  63881. interface Navigator {
  63882. mozGetVRDevices: (any: any) => any;
  63883. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63884. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63885. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  63886. webkitGetGamepads(): Gamepad[];
  63887. msGetGamepads(): Gamepad[];
  63888. webkitGamepads(): Gamepad[];
  63889. }
  63890. interface HTMLVideoElement {
  63891. mozSrcObject: any;
  63892. }
  63893. interface Math {
  63894. fround(x: number): number;
  63895. imul(a: number, b: number): number;
  63896. }
  63897. interface WebGLRenderingContext {
  63898. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  63899. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  63900. vertexAttribDivisor(index: number, divisor: number): void;
  63901. createVertexArray(): any;
  63902. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  63903. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  63904. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  63905. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  63906. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  63907. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  63908. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  63909. // Queries
  63910. createQuery(): WebGLQuery;
  63911. deleteQuery(query: WebGLQuery): void;
  63912. beginQuery(target: number, query: WebGLQuery): void;
  63913. endQuery(target: number): void;
  63914. getQueryParameter(query: WebGLQuery, pname: number): any;
  63915. getQuery(target: number, pname: number): any;
  63916. MAX_SAMPLES: number;
  63917. RGBA8: number;
  63918. READ_FRAMEBUFFER: number;
  63919. DRAW_FRAMEBUFFER: number;
  63920. UNIFORM_BUFFER: number;
  63921. HALF_FLOAT_OES: number;
  63922. RGBA16F: number;
  63923. RGBA32F: number;
  63924. R32F: number;
  63925. RG32F: number;
  63926. RGB32F: number;
  63927. R16F: number;
  63928. RG16F: number;
  63929. RGB16F: number;
  63930. RED: number;
  63931. RG: number;
  63932. R8: number;
  63933. RG8: number;
  63934. UNSIGNED_INT_24_8: number;
  63935. DEPTH24_STENCIL8: number;
  63936. MIN: number;
  63937. MAX: number;
  63938. /* Multiple Render Targets */
  63939. drawBuffers(buffers: number[]): void;
  63940. readBuffer(src: number): void;
  63941. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  63942. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  63943. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  63944. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  63945. // Occlusion Query
  63946. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  63947. ANY_SAMPLES_PASSED: number;
  63948. QUERY_RESULT_AVAILABLE: number;
  63949. QUERY_RESULT: number;
  63950. }
  63951. interface WebGLProgram {
  63952. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  63953. }
  63954. interface EXT_disjoint_timer_query {
  63955. QUERY_COUNTER_BITS_EXT: number;
  63956. TIME_ELAPSED_EXT: number;
  63957. TIMESTAMP_EXT: number;
  63958. GPU_DISJOINT_EXT: number;
  63959. QUERY_RESULT_EXT: number;
  63960. QUERY_RESULT_AVAILABLE_EXT: number;
  63961. queryCounterEXT(query: WebGLQuery, target: number): void;
  63962. createQueryEXT(): WebGLQuery;
  63963. beginQueryEXT(target: number, query: WebGLQuery): void;
  63964. endQueryEXT(target: number): void;
  63965. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  63966. deleteQueryEXT(query: WebGLQuery): void;
  63967. }
  63968. interface WebGLUniformLocation {
  63969. _currentState: any;
  63970. }
  63971. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  63972. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  63973. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  63974. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63975. interface WebGLRenderingContext {
  63976. readonly RASTERIZER_DISCARD: number;
  63977. readonly DEPTH_COMPONENT24: number;
  63978. readonly TEXTURE_3D: number;
  63979. readonly TEXTURE_2D_ARRAY: number;
  63980. readonly TEXTURE_COMPARE_FUNC: number;
  63981. readonly TEXTURE_COMPARE_MODE: number;
  63982. readonly COMPARE_REF_TO_TEXTURE: number;
  63983. readonly TEXTURE_WRAP_R: number;
  63984. readonly HALF_FLOAT: number;
  63985. readonly RGB8: number;
  63986. readonly RED_INTEGER: number;
  63987. readonly RG_INTEGER: number;
  63988. readonly RGB_INTEGER: number;
  63989. readonly RGBA_INTEGER: number;
  63990. readonly R8_SNORM: number;
  63991. readonly RG8_SNORM: number;
  63992. readonly RGB8_SNORM: number;
  63993. readonly RGBA8_SNORM: number;
  63994. readonly R8I: number;
  63995. readonly RG8I: number;
  63996. readonly RGB8I: number;
  63997. readonly RGBA8I: number;
  63998. readonly R8UI: number;
  63999. readonly RG8UI: number;
  64000. readonly RGB8UI: number;
  64001. readonly RGBA8UI: number;
  64002. readonly R16I: number;
  64003. readonly RG16I: number;
  64004. readonly RGB16I: number;
  64005. readonly RGBA16I: number;
  64006. readonly R16UI: number;
  64007. readonly RG16UI: number;
  64008. readonly RGB16UI: number;
  64009. readonly RGBA16UI: number;
  64010. readonly R32I: number;
  64011. readonly RG32I: number;
  64012. readonly RGB32I: number;
  64013. readonly RGBA32I: number;
  64014. readonly R32UI: number;
  64015. readonly RG32UI: number;
  64016. readonly RGB32UI: number;
  64017. readonly RGBA32UI: number;
  64018. readonly RGB10_A2UI: number;
  64019. readonly R11F_G11F_B10F: number;
  64020. readonly RGB9_E5: number;
  64021. readonly RGB10_A2: number;
  64022. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  64023. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  64024. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  64025. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64026. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  64027. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  64028. 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;
  64029. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  64030. readonly TRANSFORM_FEEDBACK: number;
  64031. readonly INTERLEAVED_ATTRIBS: number;
  64032. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  64033. createTransformFeedback(): WebGLTransformFeedback;
  64034. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  64035. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  64036. beginTransformFeedback(primitiveMode: number): void;
  64037. endTransformFeedback(): void;
  64038. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  64039. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64040. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64041. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  64042. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  64043. }
  64044. interface ImageBitmap {
  64045. readonly width: number;
  64046. readonly height: number;
  64047. close(): void;
  64048. }
  64049. interface WebGLQuery extends WebGLObject {
  64050. }
  64051. declare var WebGLQuery: {
  64052. prototype: WebGLQuery;
  64053. new(): WebGLQuery;
  64054. };
  64055. interface WebGLSampler extends WebGLObject {
  64056. }
  64057. declare var WebGLSampler: {
  64058. prototype: WebGLSampler;
  64059. new(): WebGLSampler;
  64060. };
  64061. interface WebGLSync extends WebGLObject {
  64062. }
  64063. declare var WebGLSync: {
  64064. prototype: WebGLSync;
  64065. new(): WebGLSync;
  64066. };
  64067. interface WebGLTransformFeedback extends WebGLObject {
  64068. }
  64069. declare var WebGLTransformFeedback: {
  64070. prototype: WebGLTransformFeedback;
  64071. new(): WebGLTransformFeedback;
  64072. };
  64073. interface WebGLVertexArrayObject extends WebGLObject {
  64074. }
  64075. declare var WebGLVertexArrayObject: {
  64076. prototype: WebGLVertexArrayObject;
  64077. new(): WebGLVertexArrayObject;
  64078. };
  64079. // Type definitions for WebVR API
  64080. // Project: https://w3c.github.io/webvr/
  64081. // Definitions by: six a <https://github.com/lostfictions>
  64082. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  64083. interface VRDisplay extends EventTarget {
  64084. /**
  64085. * Dictionary of capabilities describing the VRDisplay.
  64086. */
  64087. readonly capabilities: VRDisplayCapabilities;
  64088. /**
  64089. * z-depth defining the far plane of the eye view frustum
  64090. * enables mapping of values in the render target depth
  64091. * attachment to scene coordinates. Initially set to 10000.0.
  64092. */
  64093. depthFar: number;
  64094. /**
  64095. * z-depth defining the near plane of the eye view frustum
  64096. * enables mapping of values in the render target depth
  64097. * attachment to scene coordinates. Initially set to 0.01.
  64098. */
  64099. depthNear: number;
  64100. /**
  64101. * An identifier for this distinct VRDisplay. Used as an
  64102. * association point in the Gamepad API.
  64103. */
  64104. readonly displayId: number;
  64105. /**
  64106. * A display name, a user-readable name identifying it.
  64107. */
  64108. readonly displayName: string;
  64109. readonly isConnected: boolean;
  64110. readonly isPresenting: boolean;
  64111. /**
  64112. * If this VRDisplay supports room-scale experiences, the optional
  64113. * stage attribute contains details on the room-scale parameters.
  64114. */
  64115. readonly stageParameters: VRStageParameters | null;
  64116. /**
  64117. * Passing the value returned by `requestAnimationFrame` to
  64118. * `cancelAnimationFrame` will unregister the callback.
  64119. * @param handle Define the hanle of the request to cancel
  64120. */
  64121. cancelAnimationFrame(handle: number): void;
  64122. /**
  64123. * Stops presenting to the VRDisplay.
  64124. * @returns a promise to know when it stopped
  64125. */
  64126. exitPresent(): Promise<void>;
  64127. /**
  64128. * Return the current VREyeParameters for the given eye.
  64129. * @param whichEye Define the eye we want the parameter for
  64130. * @returns the eye parameters
  64131. */
  64132. getEyeParameters(whichEye: string): VREyeParameters;
  64133. /**
  64134. * Populates the passed VRFrameData with the information required to render
  64135. * the current frame.
  64136. * @param frameData Define the data structure to populate
  64137. * @returns true if ok otherwise false
  64138. */
  64139. getFrameData(frameData: VRFrameData): boolean;
  64140. /**
  64141. * Get the layers currently being presented.
  64142. * @returns the list of VR layers
  64143. */
  64144. getLayers(): VRLayer[];
  64145. /**
  64146. * Return a VRPose containing the future predicted pose of the VRDisplay
  64147. * when the current frame will be presented. The value returned will not
  64148. * change until JavaScript has returned control to the browser.
  64149. *
  64150. * The VRPose will contain the position, orientation, velocity,
  64151. * and acceleration of each of these properties.
  64152. * @returns the pose object
  64153. */
  64154. getPose(): VRPose;
  64155. /**
  64156. * Return the current instantaneous pose of the VRDisplay, with no
  64157. * prediction applied.
  64158. * @returns the current instantaneous pose
  64159. */
  64160. getImmediatePose(): VRPose;
  64161. /**
  64162. * The callback passed to `requestAnimationFrame` will be called
  64163. * any time a new frame should be rendered. When the VRDisplay is
  64164. * presenting the callback will be called at the native refresh
  64165. * rate of the HMD. When not presenting this function acts
  64166. * identically to how window.requestAnimationFrame acts. Content should
  64167. * make no assumptions of frame rate or vsync behavior as the HMD runs
  64168. * asynchronously from other displays and at differing refresh rates.
  64169. * @param callback Define the eaction to run next frame
  64170. * @returns the request handle it
  64171. */
  64172. requestAnimationFrame(callback: FrameRequestCallback): number;
  64173. /**
  64174. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  64175. * Repeat calls while already presenting will update the VRLayers being displayed.
  64176. * @param layers Define the list of layer to present
  64177. * @returns a promise to know when the request has been fulfilled
  64178. */
  64179. requestPresent(layers: VRLayer[]): Promise<void>;
  64180. /**
  64181. * Reset the pose for this display, treating its current position and
  64182. * orientation as the "origin/zero" values. VRPose.position,
  64183. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  64184. * updated when calling resetPose(). This should be called in only
  64185. * sitting-space experiences.
  64186. */
  64187. resetPose(): void;
  64188. /**
  64189. * The VRLayer provided to the VRDisplay will be captured and presented
  64190. * in the HMD. Calling this function has the same effect on the source
  64191. * canvas as any other operation that uses its source image, and canvases
  64192. * created without preserveDrawingBuffer set to true will be cleared.
  64193. * @param pose Define the pose to submit
  64194. */
  64195. submitFrame(pose?: VRPose): void;
  64196. }
  64197. declare var VRDisplay: {
  64198. prototype: VRDisplay;
  64199. new(): VRDisplay;
  64200. };
  64201. interface VRLayer {
  64202. leftBounds?: number[] | Float32Array | null;
  64203. rightBounds?: number[] | Float32Array | null;
  64204. source?: HTMLCanvasElement | null;
  64205. }
  64206. interface VRDisplayCapabilities {
  64207. readonly canPresent: boolean;
  64208. readonly hasExternalDisplay: boolean;
  64209. readonly hasOrientation: boolean;
  64210. readonly hasPosition: boolean;
  64211. readonly maxLayers: number;
  64212. }
  64213. interface VREyeParameters {
  64214. /** @deprecated */
  64215. readonly fieldOfView: VRFieldOfView;
  64216. readonly offset: Float32Array;
  64217. readonly renderHeight: number;
  64218. readonly renderWidth: number;
  64219. }
  64220. interface VRFieldOfView {
  64221. readonly downDegrees: number;
  64222. readonly leftDegrees: number;
  64223. readonly rightDegrees: number;
  64224. readonly upDegrees: number;
  64225. }
  64226. interface VRFrameData {
  64227. readonly leftProjectionMatrix: Float32Array;
  64228. readonly leftViewMatrix: Float32Array;
  64229. readonly pose: VRPose;
  64230. readonly rightProjectionMatrix: Float32Array;
  64231. readonly rightViewMatrix: Float32Array;
  64232. readonly timestamp: number;
  64233. }
  64234. interface VRPose {
  64235. readonly angularAcceleration: Float32Array | null;
  64236. readonly angularVelocity: Float32Array | null;
  64237. readonly linearAcceleration: Float32Array | null;
  64238. readonly linearVelocity: Float32Array | null;
  64239. readonly orientation: Float32Array | null;
  64240. readonly position: Float32Array | null;
  64241. readonly timestamp: number;
  64242. }
  64243. interface VRStageParameters {
  64244. sittingToStandingTransform?: Float32Array;
  64245. sizeX?: number;
  64246. sizeY?: number;
  64247. }
  64248. interface Navigator {
  64249. getVRDisplays(): Promise<VRDisplay[]>;
  64250. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  64251. }
  64252. interface Window {
  64253. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  64254. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  64255. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  64256. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64257. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  64258. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  64259. }
  64260. interface Gamepad {
  64261. readonly displayId: number;
  64262. }
  64263. type XRSessionMode =
  64264. | "inline"
  64265. | "immersive-vr"
  64266. | "immersive-ar";
  64267. type XRReferenceSpaceType =
  64268. | "viewer"
  64269. | "local"
  64270. | "local-floor"
  64271. | "bounded-floor"
  64272. | "unbounded";
  64273. type XREnvironmentBlendMode =
  64274. | "opaque"
  64275. | "additive"
  64276. | "alpha-blend";
  64277. type XRVisibilityState =
  64278. | "visible"
  64279. | "visible-blurred"
  64280. | "hidden";
  64281. type XRHandedness =
  64282. | "none"
  64283. | "left"
  64284. | "right";
  64285. type XRTargetRayMode =
  64286. | "gaze"
  64287. | "tracked-pointer"
  64288. | "screen";
  64289. type XREye =
  64290. | "none"
  64291. | "left"
  64292. | "right";
  64293. interface XRSpace extends EventTarget {
  64294. }
  64295. interface XRRenderState {
  64296. depthNear?: number;
  64297. depthFar?: number;
  64298. inlineVerticalFieldOfView?: number;
  64299. baseLayer?: XRWebGLLayer;
  64300. }
  64301. interface XRInputSource {
  64302. handedness: XRHandedness;
  64303. targetRayMode: XRTargetRayMode;
  64304. targetRaySpace: XRSpace;
  64305. gripSpace: XRSpace | undefined;
  64306. gamepad: Gamepad | undefined;
  64307. profiles: Array<string>;
  64308. }
  64309. interface XRSession {
  64310. addEventListener: Function;
  64311. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  64312. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  64313. requestAnimationFrame: Function;
  64314. end(): Promise<void>;
  64315. renderState: XRRenderState;
  64316. inputSources: Array<XRInputSource>;
  64317. }
  64318. interface XRReferenceSpace extends XRSpace {
  64319. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  64320. onreset: any;
  64321. }
  64322. interface XRFrame {
  64323. session: XRSession;
  64324. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  64325. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  64326. }
  64327. interface XRViewerPose extends XRPose {
  64328. views: Array<XRView>;
  64329. }
  64330. interface XRPose {
  64331. transform: XRRigidTransform;
  64332. emulatedPosition: boolean;
  64333. }
  64334. declare var XRWebGLLayer: {
  64335. prototype: XRWebGLLayer;
  64336. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  64337. };
  64338. interface XRWebGLLayer {
  64339. framebuffer: WebGLFramebuffer;
  64340. framebufferWidth: number;
  64341. framebufferHeight: number;
  64342. getViewport: Function;
  64343. }
  64344. interface XRRigidTransform {
  64345. position: DOMPointReadOnly;
  64346. orientation: DOMPointReadOnly;
  64347. matrix: Float32Array;
  64348. inverse: XRRigidTransform;
  64349. }
  64350. interface XRView {
  64351. eye: XREye;
  64352. projectionMatrix: Float32Array;
  64353. transform: XRRigidTransform;
  64354. }
  64355. interface XRInputSourceChangeEvent {
  64356. session: XRSession;
  64357. removed: Array<XRInputSource>;
  64358. added: Array<XRInputSource>;
  64359. }
  64360. /**
  64361. * @ignore
  64362. */
  64363. declare module BABYLON.GLTF2.Exporter {
  64364. }
  64365. /**
  64366. * @ignore
  64367. */
  64368. declare module BABYLON.GLTF1 {
  64369. }
  64370. declare module BABYLON.GUI {
  64371. /**
  64372. * Class used to specific a value and its associated unit
  64373. */
  64374. export class ValueAndUnit {
  64375. /** defines the unit to store */
  64376. unit: number;
  64377. /** defines a boolean indicating if the value can be negative */
  64378. negativeValueAllowed: boolean;
  64379. private _value;
  64380. private _originalUnit;
  64381. /**
  64382. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  64383. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64384. */
  64385. ignoreAdaptiveScaling: boolean;
  64386. /**
  64387. * Creates a new ValueAndUnit
  64388. * @param value defines the value to store
  64389. * @param unit defines the unit to store
  64390. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  64391. */
  64392. constructor(value: number,
  64393. /** defines the unit to store */
  64394. unit?: number,
  64395. /** defines a boolean indicating if the value can be negative */
  64396. negativeValueAllowed?: boolean);
  64397. /** Gets a boolean indicating if the value is a percentage */
  64398. readonly isPercentage: boolean;
  64399. /** Gets a boolean indicating if the value is store as pixel */
  64400. readonly isPixel: boolean;
  64401. /** Gets direct internal value */
  64402. readonly internalValue: number;
  64403. /**
  64404. * Gets value as pixel
  64405. * @param host defines the root host
  64406. * @param refValue defines the reference value for percentages
  64407. * @returns the value as pixel
  64408. */
  64409. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  64410. /**
  64411. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  64412. * @param value defines the value to store
  64413. * @param unit defines the unit to store
  64414. * @returns the current ValueAndUnit
  64415. */
  64416. updateInPlace(value: number, unit?: number): ValueAndUnit;
  64417. /**
  64418. * Gets the value accordingly to its unit
  64419. * @param host defines the root host
  64420. * @returns the value
  64421. */
  64422. getValue(host: AdvancedDynamicTexture): number;
  64423. /**
  64424. * Gets a string representation of the value
  64425. * @param host defines the root host
  64426. * @param decimals defines an optional number of decimals to display
  64427. * @returns a string
  64428. */
  64429. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  64430. /**
  64431. * Store a value parsed from a string
  64432. * @param source defines the source string
  64433. * @returns true if the value was successfully parsed
  64434. */
  64435. fromString(source: string | number): boolean;
  64436. private static _Regex;
  64437. private static _UNITMODE_PERCENTAGE;
  64438. private static _UNITMODE_PIXEL;
  64439. /** UNITMODE_PERCENTAGE */
  64440. static readonly UNITMODE_PERCENTAGE: number;
  64441. /** UNITMODE_PIXEL */
  64442. static readonly UNITMODE_PIXEL: number;
  64443. }
  64444. }
  64445. declare module BABYLON.GUI {
  64446. /**
  64447. * Define a style used by control to automatically setup properties based on a template.
  64448. * Only support font related properties so far
  64449. */
  64450. export class Style implements BABYLON.IDisposable {
  64451. private _fontFamily;
  64452. private _fontStyle;
  64453. private _fontWeight;
  64454. /** @hidden */
  64455. _host: AdvancedDynamicTexture;
  64456. /** @hidden */
  64457. _fontSize: ValueAndUnit;
  64458. /**
  64459. * BABYLON.Observable raised when the style values are changed
  64460. */
  64461. onChangedObservable: BABYLON.Observable<Style>;
  64462. /**
  64463. * Creates a new style object
  64464. * @param host defines the AdvancedDynamicTexture which hosts this style
  64465. */
  64466. constructor(host: AdvancedDynamicTexture);
  64467. /**
  64468. * Gets or sets the font size
  64469. */
  64470. fontSize: string | number;
  64471. /**
  64472. * Gets or sets the font family
  64473. */
  64474. fontFamily: string;
  64475. /**
  64476. * Gets or sets the font style
  64477. */
  64478. fontStyle: string;
  64479. /** Gets or sets font weight */
  64480. fontWeight: string;
  64481. /** Dispose all associated resources */
  64482. dispose(): void;
  64483. }
  64484. }
  64485. declare module BABYLON.GUI {
  64486. /**
  64487. * Class used to transport BABYLON.Vector2 information for pointer events
  64488. */
  64489. export class Vector2WithInfo extends BABYLON.Vector2 {
  64490. /** defines the current mouse button index */
  64491. buttonIndex: number;
  64492. /**
  64493. * Creates a new Vector2WithInfo
  64494. * @param source defines the vector2 data to transport
  64495. * @param buttonIndex defines the current mouse button index
  64496. */
  64497. constructor(source: BABYLON.Vector2,
  64498. /** defines the current mouse button index */
  64499. buttonIndex?: number);
  64500. }
  64501. /** Class used to provide 2D matrix features */
  64502. export class Matrix2D {
  64503. /** Gets the internal array of 6 floats used to store matrix data */
  64504. m: Float32Array;
  64505. /**
  64506. * Creates a new matrix
  64507. * @param m00 defines value for (0, 0)
  64508. * @param m01 defines value for (0, 1)
  64509. * @param m10 defines value for (1, 0)
  64510. * @param m11 defines value for (1, 1)
  64511. * @param m20 defines value for (2, 0)
  64512. * @param m21 defines value for (2, 1)
  64513. */
  64514. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  64515. /**
  64516. * Fills the matrix from direct values
  64517. * @param m00 defines value for (0, 0)
  64518. * @param m01 defines value for (0, 1)
  64519. * @param m10 defines value for (1, 0)
  64520. * @param m11 defines value for (1, 1)
  64521. * @param m20 defines value for (2, 0)
  64522. * @param m21 defines value for (2, 1)
  64523. * @returns the current modified matrix
  64524. */
  64525. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  64526. /**
  64527. * Gets matrix determinant
  64528. * @returns the determinant
  64529. */
  64530. determinant(): number;
  64531. /**
  64532. * Inverses the matrix and stores it in a target matrix
  64533. * @param result defines the target matrix
  64534. * @returns the current matrix
  64535. */
  64536. invertToRef(result: Matrix2D): Matrix2D;
  64537. /**
  64538. * Multiplies the current matrix with another one
  64539. * @param other defines the second operand
  64540. * @param result defines the target matrix
  64541. * @returns the current matrix
  64542. */
  64543. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  64544. /**
  64545. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  64546. * @param x defines the x coordinate to transform
  64547. * @param y defines the x coordinate to transform
  64548. * @param result defines the target vector2
  64549. * @returns the current matrix
  64550. */
  64551. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  64552. /**
  64553. * Creates an identity matrix
  64554. * @returns a new matrix
  64555. */
  64556. static Identity(): Matrix2D;
  64557. /**
  64558. * Creates a translation matrix and stores it in a target matrix
  64559. * @param x defines the x coordinate of the translation
  64560. * @param y defines the y coordinate of the translation
  64561. * @param result defines the target matrix
  64562. */
  64563. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  64564. /**
  64565. * Creates a scaling matrix and stores it in a target matrix
  64566. * @param x defines the x coordinate of the scaling
  64567. * @param y defines the y coordinate of the scaling
  64568. * @param result defines the target matrix
  64569. */
  64570. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  64571. /**
  64572. * Creates a rotation matrix and stores it in a target matrix
  64573. * @param angle defines the rotation angle
  64574. * @param result defines the target matrix
  64575. */
  64576. static RotationToRef(angle: number, result: Matrix2D): void;
  64577. private static _TempPreTranslationMatrix;
  64578. private static _TempPostTranslationMatrix;
  64579. private static _TempRotationMatrix;
  64580. private static _TempScalingMatrix;
  64581. private static _TempCompose0;
  64582. private static _TempCompose1;
  64583. private static _TempCompose2;
  64584. /**
  64585. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  64586. * @param tx defines the x coordinate of the translation
  64587. * @param ty defines the y coordinate of the translation
  64588. * @param angle defines the rotation angle
  64589. * @param scaleX defines the x coordinate of the scaling
  64590. * @param scaleY defines the y coordinate of the scaling
  64591. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  64592. * @param result defines the target matrix
  64593. */
  64594. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  64595. }
  64596. }
  64597. declare module BABYLON.GUI {
  64598. /**
  64599. * Class used to store 2D control sizes
  64600. */
  64601. export class Measure {
  64602. /** defines left coordinate */
  64603. left: number;
  64604. /** defines top coordinate */
  64605. top: number;
  64606. /** defines width dimension */
  64607. width: number;
  64608. /** defines height dimension */
  64609. height: number;
  64610. /**
  64611. * Creates a new measure
  64612. * @param left defines left coordinate
  64613. * @param top defines top coordinate
  64614. * @param width defines width dimension
  64615. * @param height defines height dimension
  64616. */
  64617. constructor(
  64618. /** defines left coordinate */
  64619. left: number,
  64620. /** defines top coordinate */
  64621. top: number,
  64622. /** defines width dimension */
  64623. width: number,
  64624. /** defines height dimension */
  64625. height: number);
  64626. /**
  64627. * Copy from another measure
  64628. * @param other defines the other measure to copy from
  64629. */
  64630. copyFrom(other: Measure): void;
  64631. /**
  64632. * Copy from a group of 4 floats
  64633. * @param left defines left coordinate
  64634. * @param top defines top coordinate
  64635. * @param width defines width dimension
  64636. * @param height defines height dimension
  64637. */
  64638. copyFromFloats(left: number, top: number, width: number, height: number): void;
  64639. /**
  64640. * Computes the axis aligned bounding box measure for two given measures
  64641. * @param a Input measure
  64642. * @param b Input measure
  64643. * @param result the resulting bounding measure
  64644. */
  64645. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  64646. /**
  64647. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  64648. * @param transform the matrix to transform the measure before computing the AABB
  64649. * @param result the resulting AABB
  64650. */
  64651. transformToRef(transform: Matrix2D, result: Measure): void;
  64652. /**
  64653. * Check equality between this measure and another one
  64654. * @param other defines the other measures
  64655. * @returns true if both measures are equals
  64656. */
  64657. isEqualsTo(other: Measure): boolean;
  64658. /**
  64659. * Creates an empty measure
  64660. * @returns a new measure
  64661. */
  64662. static Empty(): Measure;
  64663. }
  64664. }
  64665. declare module BABYLON.GUI {
  64666. /**
  64667. * Interface used to define a control that can receive focus
  64668. */
  64669. export interface IFocusableControl {
  64670. /**
  64671. * Function called when the control receives the focus
  64672. */
  64673. onFocus(): void;
  64674. /**
  64675. * Function called when the control loses the focus
  64676. */
  64677. onBlur(): void;
  64678. /**
  64679. * Function called to let the control handle keyboard events
  64680. * @param evt defines the current keyboard event
  64681. */
  64682. processKeyboard(evt: KeyboardEvent): void;
  64683. /**
  64684. * Function called to get the list of controls that should not steal the focus from this control
  64685. * @returns an array of controls
  64686. */
  64687. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64688. }
  64689. /**
  64690. * Class used to create texture to support 2D GUI elements
  64691. * @see http://doc.babylonjs.com/how_to/gui
  64692. */
  64693. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  64694. private _isDirty;
  64695. private _renderObserver;
  64696. private _resizeObserver;
  64697. private _preKeyboardObserver;
  64698. private _pointerMoveObserver;
  64699. private _pointerObserver;
  64700. private _canvasPointerOutObserver;
  64701. private _background;
  64702. /** @hidden */
  64703. _rootContainer: Container;
  64704. /** @hidden */
  64705. _lastPickedControl: Control;
  64706. /** @hidden */
  64707. _lastControlOver: {
  64708. [pointerId: number]: Control;
  64709. };
  64710. /** @hidden */
  64711. _lastControlDown: {
  64712. [pointerId: number]: Control;
  64713. };
  64714. /** @hidden */
  64715. _capturingControl: {
  64716. [pointerId: number]: Control;
  64717. };
  64718. /** @hidden */
  64719. _shouldBlockPointer: boolean;
  64720. /** @hidden */
  64721. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64722. /** @hidden */
  64723. _linkedControls: Control[];
  64724. private _isFullscreen;
  64725. private _fullscreenViewport;
  64726. private _idealWidth;
  64727. private _idealHeight;
  64728. private _useSmallestIdeal;
  64729. private _renderAtIdealSize;
  64730. private _focusedControl;
  64731. private _blockNextFocusCheck;
  64732. private _renderScale;
  64733. private _rootCanvas;
  64734. private _cursorChanged;
  64735. /**
  64736. * Define type to string to ensure compatibility across browsers
  64737. * Safari doesn't support DataTransfer constructor
  64738. */
  64739. private _clipboardData;
  64740. /**
  64741. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64742. */
  64743. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64744. /**
  64745. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64746. */
  64747. onControlPickedObservable: BABYLON.Observable<Control>;
  64748. /**
  64749. * BABYLON.Observable event triggered before layout is evaluated
  64750. */
  64751. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64752. /**
  64753. * BABYLON.Observable event triggered after the layout was evaluated
  64754. */
  64755. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64756. /**
  64757. * BABYLON.Observable event triggered before the texture is rendered
  64758. */
  64759. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64760. /**
  64761. * BABYLON.Observable event triggered after the texture was rendered
  64762. */
  64763. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64764. /**
  64765. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64766. */
  64767. premulAlpha: boolean;
  64768. /**
  64769. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64770. * Useful when you want more antialiasing
  64771. */
  64772. renderScale: number;
  64773. /** Gets or sets the background color */
  64774. background: string;
  64775. /**
  64776. * Gets or sets the ideal width used to design controls.
  64777. * The GUI will then rescale everything accordingly
  64778. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64779. */
  64780. idealWidth: number;
  64781. /**
  64782. * Gets or sets the ideal height used to design controls.
  64783. * The GUI will then rescale everything accordingly
  64784. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64785. */
  64786. idealHeight: number;
  64787. /**
  64788. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64789. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64790. */
  64791. useSmallestIdeal: boolean;
  64792. /**
  64793. * Gets or sets a boolean indicating if adaptive scaling must be used
  64794. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64795. */
  64796. renderAtIdealSize: boolean;
  64797. /**
  64798. * Gets the underlying layer used to render the texture when in fullscreen mode
  64799. */
  64800. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64801. /**
  64802. * Gets the root container control
  64803. */
  64804. readonly rootContainer: Container;
  64805. /**
  64806. * Returns an array containing the root container.
  64807. * This is mostly used to let the Inspector introspects the ADT
  64808. * @returns an array containing the rootContainer
  64809. */
  64810. getChildren(): Array<Container>;
  64811. /**
  64812. * Will return all controls that are inside this texture
  64813. * @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
  64814. * @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
  64815. * @return all child controls
  64816. */
  64817. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64818. /**
  64819. * Gets or sets the current focused control
  64820. */
  64821. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64822. /**
  64823. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64824. */
  64825. isForeground: boolean;
  64826. /**
  64827. * Gets or set information about clipboardData
  64828. */
  64829. clipboardData: string;
  64830. /**
  64831. * Creates a new AdvancedDynamicTexture
  64832. * @param name defines the name of the texture
  64833. * @param width defines the width of the texture
  64834. * @param height defines the height of the texture
  64835. * @param scene defines the hosting scene
  64836. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64837. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64838. */
  64839. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64840. /**
  64841. * Get the current class name of the texture useful for serialization or dynamic coding.
  64842. * @returns "AdvancedDynamicTexture"
  64843. */
  64844. getClassName(): string;
  64845. /**
  64846. * Function used to execute a function on all controls
  64847. * @param func defines the function to execute
  64848. * @param container defines the container where controls belong. If null the root container will be used
  64849. */
  64850. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64851. private _useInvalidateRectOptimization;
  64852. /**
  64853. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64854. */
  64855. useInvalidateRectOptimization: boolean;
  64856. private _invalidatedRectangle;
  64857. /**
  64858. * Invalidates a rectangle area on the gui texture
  64859. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64860. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64861. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64862. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64863. */
  64864. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64865. /**
  64866. * Marks the texture as dirty forcing a complete update
  64867. */
  64868. markAsDirty(): void;
  64869. /**
  64870. * Helper function used to create a new style
  64871. * @returns a new style
  64872. * @see http://doc.babylonjs.com/how_to/gui#styles
  64873. */
  64874. createStyle(): Style;
  64875. /**
  64876. * Adds a new control to the root container
  64877. * @param control defines the control to add
  64878. * @returns the current texture
  64879. */
  64880. addControl(control: Control): AdvancedDynamicTexture;
  64881. /**
  64882. * Removes a control from the root container
  64883. * @param control defines the control to remove
  64884. * @returns the current texture
  64885. */
  64886. removeControl(control: Control): AdvancedDynamicTexture;
  64887. /**
  64888. * Release all resources
  64889. */
  64890. dispose(): void;
  64891. private _onResize;
  64892. /** @hidden */
  64893. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64894. /**
  64895. * Get screen coordinates for a vector3
  64896. * @param position defines the position to project
  64897. * @param worldMatrix defines the world matrix to use
  64898. * @returns the projected position
  64899. */
  64900. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64901. private _checkUpdate;
  64902. private _clearMeasure;
  64903. private _render;
  64904. /** @hidden */
  64905. _changeCursor(cursor: string): void;
  64906. /** @hidden */
  64907. _registerLastControlDown(control: Control, pointerId: number): void;
  64908. private _doPicking;
  64909. /** @hidden */
  64910. _cleanControlAfterRemovalFromList(list: {
  64911. [pointerId: number]: Control;
  64912. }, control: Control): void;
  64913. /** @hidden */
  64914. _cleanControlAfterRemoval(control: Control): void;
  64915. /** Attach to all scene events required to support pointer events */
  64916. attach(): void;
  64917. /** @hidden */
  64918. private onClipboardCopy;
  64919. /** @hidden */
  64920. private onClipboardCut;
  64921. /** @hidden */
  64922. private onClipboardPaste;
  64923. /**
  64924. * Register the clipboard Events onto the canvas
  64925. */
  64926. registerClipboardEvents(): void;
  64927. /**
  64928. * Unregister the clipboard Events from the canvas
  64929. */
  64930. unRegisterClipboardEvents(): void;
  64931. /**
  64932. * Connect the texture to a hosting mesh to enable interactions
  64933. * @param mesh defines the mesh to attach to
  64934. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64935. */
  64936. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64937. /**
  64938. * Move the focus to a specific control
  64939. * @param control defines the control which will receive the focus
  64940. */
  64941. moveFocusToControl(control: IFocusableControl): void;
  64942. private _manageFocus;
  64943. private _attachToOnPointerOut;
  64944. /**
  64945. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64946. * @param mesh defines the mesh which will receive the texture
  64947. * @param width defines the texture width (1024 by default)
  64948. * @param height defines the texture height (1024 by default)
  64949. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64950. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64951. * @returns a new AdvancedDynamicTexture
  64952. */
  64953. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64954. /**
  64955. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64956. * In this mode the texture will rely on a layer for its rendering.
  64957. * This allows it to be treated like any other layer.
  64958. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64959. * LayerMask is set through advancedTexture.layer.layerMask
  64960. * @param name defines name for the texture
  64961. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64962. * @param scene defines the hsoting scene
  64963. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64964. * @returns a new AdvancedDynamicTexture
  64965. */
  64966. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64967. }
  64968. }
  64969. declare module BABYLON.GUI {
  64970. /**
  64971. * Root class used for all 2D controls
  64972. * @see http://doc.babylonjs.com/how_to/gui#controls
  64973. */
  64974. export class Control {
  64975. /** defines the name of the control */
  64976. name?: string | undefined;
  64977. /**
  64978. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64979. */
  64980. static AllowAlphaInheritance: boolean;
  64981. private _alpha;
  64982. private _alphaSet;
  64983. private _zIndex;
  64984. /** @hidden */
  64985. _host: AdvancedDynamicTexture;
  64986. /** Gets or sets the control parent */
  64987. parent: BABYLON.Nullable<Container>;
  64988. /** @hidden */
  64989. _currentMeasure: Measure;
  64990. private _fontFamily;
  64991. private _fontStyle;
  64992. private _fontWeight;
  64993. private _fontSize;
  64994. private _font;
  64995. /** @hidden */
  64996. _width: ValueAndUnit;
  64997. /** @hidden */
  64998. _height: ValueAndUnit;
  64999. /** @hidden */
  65000. protected _fontOffset: {
  65001. ascent: number;
  65002. height: number;
  65003. descent: number;
  65004. };
  65005. private _color;
  65006. private _style;
  65007. private _styleObserver;
  65008. /** @hidden */
  65009. protected _horizontalAlignment: number;
  65010. /** @hidden */
  65011. protected _verticalAlignment: number;
  65012. /** @hidden */
  65013. protected _isDirty: boolean;
  65014. /** @hidden */
  65015. protected _wasDirty: boolean;
  65016. /** @hidden */
  65017. _tempParentMeasure: Measure;
  65018. /** @hidden */
  65019. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  65020. /** @hidden */
  65021. protected _cachedParentMeasure: Measure;
  65022. private _paddingLeft;
  65023. private _paddingRight;
  65024. private _paddingTop;
  65025. private _paddingBottom;
  65026. /** @hidden */
  65027. _left: ValueAndUnit;
  65028. /** @hidden */
  65029. _top: ValueAndUnit;
  65030. private _scaleX;
  65031. private _scaleY;
  65032. private _rotation;
  65033. private _transformCenterX;
  65034. private _transformCenterY;
  65035. /** @hidden */
  65036. _transformMatrix: Matrix2D;
  65037. /** @hidden */
  65038. protected _invertTransformMatrix: Matrix2D;
  65039. /** @hidden */
  65040. protected _transformedPosition: BABYLON.Vector2;
  65041. private _isMatrixDirty;
  65042. private _cachedOffsetX;
  65043. private _cachedOffsetY;
  65044. private _isVisible;
  65045. private _isHighlighted;
  65046. /** @hidden */
  65047. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65048. private _fontSet;
  65049. private _dummyVector2;
  65050. private _downCount;
  65051. private _enterCount;
  65052. private _doNotRender;
  65053. private _downPointerIds;
  65054. protected _isEnabled: boolean;
  65055. protected _disabledColor: string;
  65056. /** @hidden */
  65057. protected _rebuildLayout: boolean;
  65058. /** @hidden */
  65059. _isClipped: boolean;
  65060. /** @hidden */
  65061. _tag: any;
  65062. /**
  65063. * 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
  65064. */
  65065. uniqueId: number;
  65066. /**
  65067. * Gets or sets an object used to store user defined information for the node
  65068. */
  65069. metadata: any;
  65070. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  65071. isHitTestVisible: boolean;
  65072. /** Gets or sets a boolean indicating if the control can block pointer events */
  65073. isPointerBlocker: boolean;
  65074. /** Gets or sets a boolean indicating if the control can be focusable */
  65075. isFocusInvisible: boolean;
  65076. /**
  65077. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  65078. * 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
  65079. */
  65080. clipChildren: boolean;
  65081. /**
  65082. * Gets or sets a boolean indicating that control content must be clipped
  65083. * 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
  65084. */
  65085. clipContent: boolean;
  65086. /**
  65087. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  65088. */
  65089. useBitmapCache: boolean;
  65090. private _cacheData;
  65091. private _shadowOffsetX;
  65092. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  65093. shadowOffsetX: number;
  65094. private _shadowOffsetY;
  65095. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  65096. shadowOffsetY: number;
  65097. private _shadowBlur;
  65098. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  65099. shadowBlur: number;
  65100. private _shadowColor;
  65101. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  65102. shadowColor: string;
  65103. /** Gets or sets the cursor to use when the control is hovered */
  65104. hoverCursor: string;
  65105. /** @hidden */
  65106. protected _linkOffsetX: ValueAndUnit;
  65107. /** @hidden */
  65108. protected _linkOffsetY: ValueAndUnit;
  65109. /** Gets the control type name */
  65110. readonly typeName: string;
  65111. /**
  65112. * Get the current class name of the control.
  65113. * @returns current class name
  65114. */
  65115. getClassName(): string;
  65116. /**
  65117. * An event triggered when the pointer move over the control.
  65118. */
  65119. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  65120. /**
  65121. * An event triggered when the pointer move out of the control.
  65122. */
  65123. onPointerOutObservable: BABYLON.Observable<Control>;
  65124. /**
  65125. * An event triggered when the pointer taps the control
  65126. */
  65127. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  65128. /**
  65129. * An event triggered when pointer up
  65130. */
  65131. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  65132. /**
  65133. * An event triggered when a control is clicked on
  65134. */
  65135. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  65136. /**
  65137. * An event triggered when pointer enters the control
  65138. */
  65139. onPointerEnterObservable: BABYLON.Observable<Control>;
  65140. /**
  65141. * An event triggered when the control is marked as dirty
  65142. */
  65143. onDirtyObservable: BABYLON.Observable<Control>;
  65144. /**
  65145. * An event triggered before drawing the control
  65146. */
  65147. onBeforeDrawObservable: BABYLON.Observable<Control>;
  65148. /**
  65149. * An event triggered after the control was drawn
  65150. */
  65151. onAfterDrawObservable: BABYLON.Observable<Control>;
  65152. /**
  65153. * Get the hosting AdvancedDynamicTexture
  65154. */
  65155. readonly host: AdvancedDynamicTexture;
  65156. /** Gets or set information about font offsets (used to render and align text) */
  65157. fontOffset: {
  65158. ascent: number;
  65159. height: number;
  65160. descent: number;
  65161. };
  65162. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  65163. alpha: number;
  65164. /**
  65165. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  65166. */
  65167. isHighlighted: boolean;
  65168. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  65169. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65170. */
  65171. scaleX: number;
  65172. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  65173. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65174. */
  65175. scaleY: number;
  65176. /** Gets or sets the rotation angle (0 by default)
  65177. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65178. */
  65179. rotation: number;
  65180. /** Gets or sets the transformation center on Y axis (0 by default)
  65181. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65182. */
  65183. transformCenterY: number;
  65184. /** Gets or sets the transformation center on X axis (0 by default)
  65185. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  65186. */
  65187. transformCenterX: number;
  65188. /**
  65189. * Gets or sets the horizontal alignment
  65190. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65191. */
  65192. horizontalAlignment: number;
  65193. /**
  65194. * Gets or sets the vertical alignment
  65195. * @see http://doc.babylonjs.com/how_to/gui#alignments
  65196. */
  65197. verticalAlignment: number;
  65198. /**
  65199. * Gets or sets control width
  65200. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65201. */
  65202. width: string | number;
  65203. /**
  65204. * Gets or sets the control width in pixel
  65205. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65206. */
  65207. widthInPixels: number;
  65208. /**
  65209. * Gets or sets control height
  65210. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65211. */
  65212. height: string | number;
  65213. /**
  65214. * Gets or sets control height in pixel
  65215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65216. */
  65217. heightInPixels: number;
  65218. /** Gets or set font family */
  65219. fontFamily: string;
  65220. /** Gets or sets font style */
  65221. fontStyle: string;
  65222. /** Gets or sets font weight */
  65223. fontWeight: string;
  65224. /**
  65225. * Gets or sets style
  65226. * @see http://doc.babylonjs.com/how_to/gui#styles
  65227. */
  65228. style: BABYLON.Nullable<Style>;
  65229. /** @hidden */
  65230. readonly _isFontSizeInPercentage: boolean;
  65231. /** Gets or sets font size in pixels */
  65232. fontSizeInPixels: number;
  65233. /** Gets or sets font size */
  65234. fontSize: string | number;
  65235. /** Gets or sets foreground color */
  65236. color: string;
  65237. /** Gets or sets z index which is used to reorder controls on the z axis */
  65238. zIndex: number;
  65239. /** Gets or sets a boolean indicating if the control can be rendered */
  65240. notRenderable: boolean;
  65241. /** Gets or sets a boolean indicating if the control is visible */
  65242. isVisible: boolean;
  65243. /** Gets a boolean indicating that the control needs to update its rendering */
  65244. readonly isDirty: boolean;
  65245. /**
  65246. * Gets the current linked mesh (or null if none)
  65247. */
  65248. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65249. /**
  65250. * Gets or sets a value indicating the padding to use on the left of the control
  65251. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65252. */
  65253. paddingLeft: string | number;
  65254. /**
  65255. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  65256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65257. */
  65258. paddingLeftInPixels: number;
  65259. /**
  65260. * Gets or sets a value indicating the padding to use on the right of the control
  65261. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65262. */
  65263. paddingRight: string | number;
  65264. /**
  65265. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  65266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65267. */
  65268. paddingRightInPixels: number;
  65269. /**
  65270. * Gets or sets a value indicating the padding to use on the top of the control
  65271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65272. */
  65273. paddingTop: string | number;
  65274. /**
  65275. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  65276. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65277. */
  65278. paddingTopInPixels: number;
  65279. /**
  65280. * Gets or sets a value indicating the padding to use on the bottom of the control
  65281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65282. */
  65283. paddingBottom: string | number;
  65284. /**
  65285. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  65286. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65287. */
  65288. paddingBottomInPixels: number;
  65289. /**
  65290. * Gets or sets a value indicating the left coordinate of the control
  65291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65292. */
  65293. left: string | number;
  65294. /**
  65295. * Gets or sets a value indicating the left coordinate in pixels of the control
  65296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65297. */
  65298. leftInPixels: number;
  65299. /**
  65300. * Gets or sets a value indicating the top coordinate of the control
  65301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65302. */
  65303. top: string | number;
  65304. /**
  65305. * Gets or sets a value indicating the top coordinate in pixels of the control
  65306. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65307. */
  65308. topInPixels: number;
  65309. /**
  65310. * Gets or sets a value indicating the offset on X axis to the linked mesh
  65311. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65312. */
  65313. linkOffsetX: string | number;
  65314. /**
  65315. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  65316. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65317. */
  65318. linkOffsetXInPixels: number;
  65319. /**
  65320. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  65321. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65322. */
  65323. linkOffsetY: string | number;
  65324. /**
  65325. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  65326. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65327. */
  65328. linkOffsetYInPixels: number;
  65329. /** Gets the center coordinate on X axis */
  65330. readonly centerX: number;
  65331. /** Gets the center coordinate on Y axis */
  65332. readonly centerY: number;
  65333. /** Gets or sets if control is Enabled*/
  65334. isEnabled: boolean;
  65335. /** Gets or sets background color of control if it's disabled*/
  65336. disabledColor: string;
  65337. /**
  65338. * Creates a new control
  65339. * @param name defines the name of the control
  65340. */
  65341. constructor(
  65342. /** defines the name of the control */
  65343. name?: string | undefined);
  65344. /** @hidden */
  65345. protected _getTypeName(): string;
  65346. /**
  65347. * Gets the first ascendant in the hierarchy of the given type
  65348. * @param className defines the required type
  65349. * @returns the ascendant or null if not found
  65350. */
  65351. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  65352. /** @hidden */
  65353. _resetFontCache(): void;
  65354. /**
  65355. * Determines if a container is an ascendant of the current control
  65356. * @param container defines the container to look for
  65357. * @returns true if the container is one of the ascendant of the control
  65358. */
  65359. isAscendant(container: Control): boolean;
  65360. /**
  65361. * Gets coordinates in local control space
  65362. * @param globalCoordinates defines the coordinates to transform
  65363. * @returns the new coordinates in local space
  65364. */
  65365. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65366. /**
  65367. * Gets coordinates in local control space
  65368. * @param globalCoordinates defines the coordinates to transform
  65369. * @param result defines the target vector2 where to store the result
  65370. * @returns the current control
  65371. */
  65372. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  65373. /**
  65374. * Gets coordinates in parent local control space
  65375. * @param globalCoordinates defines the coordinates to transform
  65376. * @returns the new coordinates in parent local space
  65377. */
  65378. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  65379. /**
  65380. * Move the current control to a vector3 position projected onto the screen.
  65381. * @param position defines the target position
  65382. * @param scene defines the hosting scene
  65383. */
  65384. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  65385. /** @hidden */
  65386. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65387. /**
  65388. * Will return all controls that have this control as ascendant
  65389. * @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
  65390. * @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
  65391. * @return all child controls
  65392. */
  65393. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  65394. /**
  65395. * Link current control with a target mesh
  65396. * @param mesh defines the mesh to link with
  65397. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  65398. */
  65399. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  65400. /** @hidden */
  65401. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  65402. /** @hidden */
  65403. _offsetLeft(offset: number): void;
  65404. /** @hidden */
  65405. _offsetTop(offset: number): void;
  65406. /** @hidden */
  65407. _markMatrixAsDirty(): void;
  65408. /** @hidden */
  65409. _flagDescendantsAsMatrixDirty(): void;
  65410. /** @hidden */
  65411. _intersectsRect(rect: Measure): boolean;
  65412. /** @hidden */
  65413. protected invalidateRect(): void;
  65414. /** @hidden */
  65415. _markAsDirty(force?: boolean): void;
  65416. /** @hidden */
  65417. _markAllAsDirty(): void;
  65418. /** @hidden */
  65419. _link(host: AdvancedDynamicTexture): void;
  65420. /** @hidden */
  65421. protected _transform(context?: CanvasRenderingContext2D): void;
  65422. /** @hidden */
  65423. _renderHighlight(context: CanvasRenderingContext2D): void;
  65424. /** @hidden */
  65425. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65426. /** @hidden */
  65427. protected _applyStates(context: CanvasRenderingContext2D): void;
  65428. /** @hidden */
  65429. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65430. /** @hidden */
  65431. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65432. protected _evaluateClippingState(parentMeasure: Measure): void;
  65433. /** @hidden */
  65434. _measure(): void;
  65435. /** @hidden */
  65436. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65437. /** @hidden */
  65438. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65439. /** @hidden */
  65440. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65441. /** @hidden */
  65442. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65443. private static _ClipMeasure;
  65444. private _tmpMeasureA;
  65445. private _clip;
  65446. /** @hidden */
  65447. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  65448. /** @hidden */
  65449. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  65450. /**
  65451. * Tests if a given coordinates belong to the current control
  65452. * @param x defines x coordinate to test
  65453. * @param y defines y coordinate to test
  65454. * @returns true if the coordinates are inside the control
  65455. */
  65456. contains(x: number, y: number): boolean;
  65457. /** @hidden */
  65458. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65459. /** @hidden */
  65460. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65461. /** @hidden */
  65462. _onPointerEnter(target: Control): boolean;
  65463. /** @hidden */
  65464. _onPointerOut(target: Control, force?: boolean): void;
  65465. /** @hidden */
  65466. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65467. /** @hidden */
  65468. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65469. /** @hidden */
  65470. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  65471. /** @hidden */
  65472. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  65473. private _prepareFont;
  65474. /** Releases associated resources */
  65475. dispose(): void;
  65476. private static _HORIZONTAL_ALIGNMENT_LEFT;
  65477. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  65478. private static _HORIZONTAL_ALIGNMENT_CENTER;
  65479. private static _VERTICAL_ALIGNMENT_TOP;
  65480. private static _VERTICAL_ALIGNMENT_BOTTOM;
  65481. private static _VERTICAL_ALIGNMENT_CENTER;
  65482. /** HORIZONTAL_ALIGNMENT_LEFT */
  65483. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  65484. /** HORIZONTAL_ALIGNMENT_RIGHT */
  65485. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  65486. /** HORIZONTAL_ALIGNMENT_CENTER */
  65487. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  65488. /** VERTICAL_ALIGNMENT_TOP */
  65489. static readonly VERTICAL_ALIGNMENT_TOP: number;
  65490. /** VERTICAL_ALIGNMENT_BOTTOM */
  65491. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  65492. /** VERTICAL_ALIGNMENT_CENTER */
  65493. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  65494. private static _FontHeightSizes;
  65495. /** @hidden */
  65496. static _GetFontOffset(font: string): {
  65497. ascent: number;
  65498. height: number;
  65499. descent: number;
  65500. };
  65501. /**
  65502. * Creates a stack panel that can be used to render headers
  65503. * @param control defines the control to associate with the header
  65504. * @param text defines the text of the header
  65505. * @param size defines the size of the header
  65506. * @param options defines options used to configure the header
  65507. * @returns a new StackPanel
  65508. * @ignore
  65509. * @hidden
  65510. */
  65511. static AddHeader: (control: Control, text: string, size: string | number, options: {
  65512. isHorizontal: boolean;
  65513. controlFirst: boolean;
  65514. }) => any;
  65515. /** @hidden */
  65516. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  65517. }
  65518. }
  65519. declare module BABYLON.GUI {
  65520. /**
  65521. * Root class for 2D containers
  65522. * @see http://doc.babylonjs.com/how_to/gui#containers
  65523. */
  65524. export class Container extends Control {
  65525. name?: string | undefined;
  65526. /** @hidden */
  65527. protected _children: Control[];
  65528. /** @hidden */
  65529. protected _measureForChildren: Measure;
  65530. /** @hidden */
  65531. protected _background: string;
  65532. /** @hidden */
  65533. protected _adaptWidthToChildren: boolean;
  65534. /** @hidden */
  65535. protected _adaptHeightToChildren: boolean;
  65536. /**
  65537. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  65538. */
  65539. logLayoutCycleErrors: boolean;
  65540. /**
  65541. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  65542. */
  65543. maxLayoutCycle: number;
  65544. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  65545. adaptHeightToChildren: boolean;
  65546. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  65547. adaptWidthToChildren: boolean;
  65548. /** Gets or sets background color */
  65549. background: string;
  65550. /** Gets the list of children */
  65551. readonly children: Control[];
  65552. /**
  65553. * Creates a new Container
  65554. * @param name defines the name of the container
  65555. */
  65556. constructor(name?: string | undefined);
  65557. protected _getTypeName(): string;
  65558. _flagDescendantsAsMatrixDirty(): void;
  65559. /**
  65560. * Gets a child using its name
  65561. * @param name defines the child name to look for
  65562. * @returns the child control if found
  65563. */
  65564. getChildByName(name: string): BABYLON.Nullable<Control>;
  65565. /**
  65566. * Gets a child using its type and its name
  65567. * @param name defines the child name to look for
  65568. * @param type defines the child type to look for
  65569. * @returns the child control if found
  65570. */
  65571. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  65572. /**
  65573. * Search for a specific control in children
  65574. * @param control defines the control to look for
  65575. * @returns true if the control is in child list
  65576. */
  65577. containsControl(control: Control): boolean;
  65578. /**
  65579. * Adds a new control to the current container
  65580. * @param control defines the control to add
  65581. * @returns the current container
  65582. */
  65583. addControl(control: BABYLON.Nullable<Control>): Container;
  65584. /**
  65585. * Removes all controls from the current container
  65586. * @returns the current container
  65587. */
  65588. clearControls(): Container;
  65589. /**
  65590. * Removes a control from the current container
  65591. * @param control defines the control to remove
  65592. * @returns the current container
  65593. */
  65594. removeControl(control: Control): Container;
  65595. /** @hidden */
  65596. _reOrderControl(control: Control): void;
  65597. /** @hidden */
  65598. _offsetLeft(offset: number): void;
  65599. /** @hidden */
  65600. _offsetTop(offset: number): void;
  65601. /** @hidden */
  65602. _markAllAsDirty(): void;
  65603. /** @hidden */
  65604. protected _localDraw(context: CanvasRenderingContext2D): void;
  65605. /** @hidden */
  65606. _link(host: AdvancedDynamicTexture): void;
  65607. /** @hidden */
  65608. protected _beforeLayout(): void;
  65609. /** @hidden */
  65610. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65611. /** @hidden */
  65612. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  65613. protected _postMeasure(): void;
  65614. /** @hidden */
  65615. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  65616. /** @hidden */
  65617. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  65618. /** @hidden */
  65619. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65620. /** @hidden */
  65621. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65622. /** Releases associated resources */
  65623. dispose(): void;
  65624. }
  65625. }
  65626. declare module BABYLON.GUI {
  65627. /** Class used to create rectangle container */
  65628. export class Rectangle extends Container {
  65629. name?: string | undefined;
  65630. private _thickness;
  65631. private _cornerRadius;
  65632. /** Gets or sets border thickness */
  65633. thickness: number;
  65634. /** Gets or sets the corner radius angle */
  65635. cornerRadius: number;
  65636. /**
  65637. * Creates a new Rectangle
  65638. * @param name defines the control name
  65639. */
  65640. constructor(name?: string | undefined);
  65641. protected _getTypeName(): string;
  65642. protected _localDraw(context: CanvasRenderingContext2D): void;
  65643. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65644. private _drawRoundedRect;
  65645. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65646. }
  65647. }
  65648. declare module BABYLON.GUI {
  65649. /**
  65650. * Enum that determines the text-wrapping mode to use.
  65651. */
  65652. export enum TextWrapping {
  65653. /**
  65654. * Clip the text when it's larger than Control.width; this is the default mode.
  65655. */
  65656. Clip = 0,
  65657. /**
  65658. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  65659. */
  65660. WordWrap = 1,
  65661. /**
  65662. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  65663. */
  65664. Ellipsis = 2
  65665. }
  65666. /**
  65667. * Class used to create text block control
  65668. */
  65669. export class TextBlock extends Control {
  65670. /**
  65671. * Defines the name of the control
  65672. */
  65673. name?: string | undefined;
  65674. private _text;
  65675. private _textWrapping;
  65676. private _textHorizontalAlignment;
  65677. private _textVerticalAlignment;
  65678. private _lines;
  65679. private _resizeToFit;
  65680. private _lineSpacing;
  65681. private _outlineWidth;
  65682. private _outlineColor;
  65683. /**
  65684. * An event triggered after the text is changed
  65685. */
  65686. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  65687. /**
  65688. * An event triggered after the text was broken up into lines
  65689. */
  65690. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  65691. /**
  65692. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  65693. */
  65694. readonly lines: any[];
  65695. /**
  65696. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65697. */
  65698. /**
  65699. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  65700. */
  65701. resizeToFit: boolean;
  65702. /**
  65703. * Gets or sets a boolean indicating if text must be wrapped
  65704. */
  65705. /**
  65706. * Gets or sets a boolean indicating if text must be wrapped
  65707. */
  65708. textWrapping: TextWrapping | boolean;
  65709. /**
  65710. * Gets or sets text to display
  65711. */
  65712. /**
  65713. * Gets or sets text to display
  65714. */
  65715. text: string;
  65716. /**
  65717. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65718. */
  65719. /**
  65720. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  65721. */
  65722. textHorizontalAlignment: number;
  65723. /**
  65724. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65725. */
  65726. /**
  65727. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  65728. */
  65729. textVerticalAlignment: number;
  65730. /**
  65731. * Gets or sets line spacing value
  65732. */
  65733. /**
  65734. * Gets or sets line spacing value
  65735. */
  65736. lineSpacing: string | number;
  65737. /**
  65738. * Gets or sets outlineWidth of the text to display
  65739. */
  65740. /**
  65741. * Gets or sets outlineWidth of the text to display
  65742. */
  65743. outlineWidth: number;
  65744. /**
  65745. * Gets or sets outlineColor of the text to display
  65746. */
  65747. /**
  65748. * Gets or sets outlineColor of the text to display
  65749. */
  65750. outlineColor: string;
  65751. /**
  65752. * Creates a new TextBlock object
  65753. * @param name defines the name of the control
  65754. * @param text defines the text to display (emptry string by default)
  65755. */
  65756. constructor(
  65757. /**
  65758. * Defines the name of the control
  65759. */
  65760. name?: string | undefined, text?: string);
  65761. protected _getTypeName(): string;
  65762. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65763. private _drawText;
  65764. /** @hidden */
  65765. _draw(context: CanvasRenderingContext2D): void;
  65766. protected _applyStates(context: CanvasRenderingContext2D): void;
  65767. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  65768. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  65769. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  65770. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  65771. protected _renderLines(context: CanvasRenderingContext2D): void;
  65772. /**
  65773. * Given a width constraint applied on the text block, find the expected height
  65774. * @returns expected height
  65775. */
  65776. computeExpectedHeight(): number;
  65777. dispose(): void;
  65778. }
  65779. }
  65780. declare module BABYLON.GUI {
  65781. /**
  65782. * Class used to create 2D images
  65783. */
  65784. export class Image extends Control {
  65785. name?: string | undefined;
  65786. private static _WorkingCanvas;
  65787. private _domImage;
  65788. private _imageWidth;
  65789. private _imageHeight;
  65790. private _loaded;
  65791. private _stretch;
  65792. private _source;
  65793. private _autoScale;
  65794. private _sourceLeft;
  65795. private _sourceTop;
  65796. private _sourceWidth;
  65797. private _sourceHeight;
  65798. private _cellWidth;
  65799. private _cellHeight;
  65800. private _cellId;
  65801. private _populateNinePatchSlicesFromImage;
  65802. private _sliceLeft;
  65803. private _sliceRight;
  65804. private _sliceTop;
  65805. private _sliceBottom;
  65806. private _detectPointerOnOpaqueOnly;
  65807. /**
  65808. * BABYLON.Observable notified when the content is loaded
  65809. */
  65810. onImageLoadedObservable: BABYLON.Observable<Image>;
  65811. /**
  65812. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  65813. */
  65814. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  65815. /**
  65816. * Gets a boolean indicating that the content is loaded
  65817. */
  65818. readonly isLoaded: boolean;
  65819. /**
  65820. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65821. */
  65822. populateNinePatchSlicesFromImage: boolean;
  65823. /**
  65824. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65825. * Beware using this as this will comsume more memory as the image has to be stored twice
  65826. */
  65827. detectPointerOnOpaqueOnly: boolean;
  65828. /**
  65829. * Gets or sets the left value for slicing (9-patch)
  65830. */
  65831. sliceLeft: number;
  65832. /**
  65833. * Gets or sets the right value for slicing (9-patch)
  65834. */
  65835. sliceRight: number;
  65836. /**
  65837. * Gets or sets the top value for slicing (9-patch)
  65838. */
  65839. sliceTop: number;
  65840. /**
  65841. * Gets or sets the bottom value for slicing (9-patch)
  65842. */
  65843. sliceBottom: number;
  65844. /**
  65845. * Gets or sets the left coordinate in the source image
  65846. */
  65847. sourceLeft: number;
  65848. /**
  65849. * Gets or sets the top coordinate in the source image
  65850. */
  65851. sourceTop: number;
  65852. /**
  65853. * Gets or sets the width to capture in the source image
  65854. */
  65855. sourceWidth: number;
  65856. /**
  65857. * Gets or sets the height to capture in the source image
  65858. */
  65859. sourceHeight: number;
  65860. /**
  65861. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65862. * @see http://doc.babylonjs.com/how_to/gui#image
  65863. */
  65864. autoScale: boolean;
  65865. /** Gets or sets the streching mode used by the image */
  65866. stretch: number;
  65867. /**
  65868. * Gets or sets the internal DOM image used to render the control
  65869. */
  65870. domImage: HTMLImageElement;
  65871. private _onImageLoaded;
  65872. private _extractNinePatchSliceDataFromImage;
  65873. /**
  65874. * Gets or sets image source url
  65875. */
  65876. source: BABYLON.Nullable<string>;
  65877. /**
  65878. * Checks for svg document with icon id present
  65879. */
  65880. private _svgCheck;
  65881. /**
  65882. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  65883. * given external svg file and icon id
  65884. */
  65885. private _getSVGAttribs;
  65886. /**
  65887. * Gets or sets the cell width to use when animation sheet is enabled
  65888. * @see http://doc.babylonjs.com/how_to/gui#image
  65889. */
  65890. cellWidth: number;
  65891. /**
  65892. * Gets or sets the cell height to use when animation sheet is enabled
  65893. * @see http://doc.babylonjs.com/how_to/gui#image
  65894. */
  65895. cellHeight: number;
  65896. /**
  65897. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65898. * @see http://doc.babylonjs.com/how_to/gui#image
  65899. */
  65900. cellId: number;
  65901. /**
  65902. * Creates a new Image
  65903. * @param name defines the control name
  65904. * @param url defines the image url
  65905. */
  65906. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65907. /**
  65908. * Tests if a given coordinates belong to the current control
  65909. * @param x defines x coordinate to test
  65910. * @param y defines y coordinate to test
  65911. * @returns true if the coordinates are inside the control
  65912. */
  65913. contains(x: number, y: number): boolean;
  65914. protected _getTypeName(): string;
  65915. /** Force the control to synchronize with its content */
  65916. synchronizeSizeWithContent(): void;
  65917. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65918. private _prepareWorkingCanvasForOpaqueDetection;
  65919. private _drawImage;
  65920. _draw(context: CanvasRenderingContext2D): void;
  65921. private _renderCornerPatch;
  65922. private _renderNinePatch;
  65923. dispose(): void;
  65924. /** STRETCH_NONE */
  65925. static readonly STRETCH_NONE: number;
  65926. /** STRETCH_FILL */
  65927. static readonly STRETCH_FILL: number;
  65928. /** STRETCH_UNIFORM */
  65929. static readonly STRETCH_UNIFORM: number;
  65930. /** STRETCH_EXTEND */
  65931. static readonly STRETCH_EXTEND: number;
  65932. /** NINE_PATCH */
  65933. static readonly STRETCH_NINE_PATCH: number;
  65934. }
  65935. }
  65936. declare module BABYLON.GUI {
  65937. /**
  65938. * Class used to create 2D buttons
  65939. */
  65940. export class Button extends Rectangle {
  65941. name?: string | undefined;
  65942. /**
  65943. * Function called to generate a pointer enter animation
  65944. */
  65945. pointerEnterAnimation: () => void;
  65946. /**
  65947. * Function called to generate a pointer out animation
  65948. */
  65949. pointerOutAnimation: () => void;
  65950. /**
  65951. * Function called to generate a pointer down animation
  65952. */
  65953. pointerDownAnimation: () => void;
  65954. /**
  65955. * Function called to generate a pointer up animation
  65956. */
  65957. pointerUpAnimation: () => void;
  65958. /**
  65959. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65960. */
  65961. delegatePickingToChildren: boolean;
  65962. private _image;
  65963. /**
  65964. * Returns the image part of the button (if any)
  65965. */
  65966. readonly image: BABYLON.Nullable<Image>;
  65967. private _textBlock;
  65968. /**
  65969. * Returns the image part of the button (if any)
  65970. */
  65971. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65972. /**
  65973. * Creates a new Button
  65974. * @param name defines the name of the button
  65975. */
  65976. constructor(name?: string | undefined);
  65977. protected _getTypeName(): string;
  65978. /** @hidden */
  65979. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65980. /** @hidden */
  65981. _onPointerEnter(target: Control): boolean;
  65982. /** @hidden */
  65983. _onPointerOut(target: Control, force?: boolean): void;
  65984. /** @hidden */
  65985. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65986. /** @hidden */
  65987. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65988. /**
  65989. * Creates a new button made with an image and a text
  65990. * @param name defines the name of the button
  65991. * @param text defines the text of the button
  65992. * @param imageUrl defines the url of the image
  65993. * @returns a new Button
  65994. */
  65995. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65996. /**
  65997. * Creates a new button made with an image
  65998. * @param name defines the name of the button
  65999. * @param imageUrl defines the url of the image
  66000. * @returns a new Button
  66001. */
  66002. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  66003. /**
  66004. * Creates a new button made with a text
  66005. * @param name defines the name of the button
  66006. * @param text defines the text of the button
  66007. * @returns a new Button
  66008. */
  66009. static CreateSimpleButton(name: string, text: string): Button;
  66010. /**
  66011. * Creates a new button made with an image and a centered text
  66012. * @param name defines the name of the button
  66013. * @param text defines the text of the button
  66014. * @param imageUrl defines the url of the image
  66015. * @returns a new Button
  66016. */
  66017. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  66018. }
  66019. }
  66020. declare module BABYLON.GUI {
  66021. /**
  66022. * Class used to create a 2D stack panel container
  66023. */
  66024. export class StackPanel extends Container {
  66025. name?: string | undefined;
  66026. private _isVertical;
  66027. private _manualWidth;
  66028. private _manualHeight;
  66029. private _doNotTrackManualChanges;
  66030. /**
  66031. * Gets or sets a boolean indicating that layou warnings should be ignored
  66032. */
  66033. ignoreLayoutWarnings: boolean;
  66034. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  66035. isVertical: boolean;
  66036. /**
  66037. * Gets or sets panel width.
  66038. * This value should not be set when in horizontal mode as it will be computed automatically
  66039. */
  66040. width: string | number;
  66041. /**
  66042. * Gets or sets panel height.
  66043. * This value should not be set when in vertical mode as it will be computed automatically
  66044. */
  66045. height: string | number;
  66046. /**
  66047. * Creates a new StackPanel
  66048. * @param name defines control name
  66049. */
  66050. constructor(name?: string | undefined);
  66051. protected _getTypeName(): string;
  66052. /** @hidden */
  66053. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66054. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66055. protected _postMeasure(): void;
  66056. }
  66057. }
  66058. declare module BABYLON.GUI {
  66059. /**
  66060. * Class used to represent a 2D checkbox
  66061. */
  66062. export class Checkbox extends Control {
  66063. name?: string | undefined;
  66064. private _isChecked;
  66065. private _background;
  66066. private _checkSizeRatio;
  66067. private _thickness;
  66068. /** Gets or sets border thickness */
  66069. thickness: number;
  66070. /**
  66071. * BABYLON.Observable raised when isChecked property changes
  66072. */
  66073. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66074. /** Gets or sets a value indicating the ratio between overall size and check size */
  66075. checkSizeRatio: number;
  66076. /** Gets or sets background color */
  66077. background: string;
  66078. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66079. isChecked: boolean;
  66080. /**
  66081. * Creates a new CheckBox
  66082. * @param name defines the control name
  66083. */
  66084. constructor(name?: string | undefined);
  66085. protected _getTypeName(): string;
  66086. /** @hidden */
  66087. _draw(context: CanvasRenderingContext2D): void;
  66088. /** @hidden */
  66089. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66090. /**
  66091. * Utility function to easily create a checkbox with a header
  66092. * @param title defines the label to use for the header
  66093. * @param onValueChanged defines the callback to call when value changes
  66094. * @returns a StackPanel containing the checkbox and a textBlock
  66095. */
  66096. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  66097. }
  66098. }
  66099. declare module BABYLON.GUI {
  66100. /**
  66101. * Class used to store key control properties
  66102. */
  66103. export class KeyPropertySet {
  66104. /** Width */
  66105. width?: string;
  66106. /** Height */
  66107. height?: string;
  66108. /** Left padding */
  66109. paddingLeft?: string;
  66110. /** Right padding */
  66111. paddingRight?: string;
  66112. /** Top padding */
  66113. paddingTop?: string;
  66114. /** Bottom padding */
  66115. paddingBottom?: string;
  66116. /** Foreground color */
  66117. color?: string;
  66118. /** Background color */
  66119. background?: string;
  66120. }
  66121. /**
  66122. * Class used to create virtual keyboard
  66123. */
  66124. export class VirtualKeyboard extends StackPanel {
  66125. /** BABYLON.Observable raised when a key is pressed */
  66126. onKeyPressObservable: BABYLON.Observable<string>;
  66127. /** Gets or sets default key button width */
  66128. defaultButtonWidth: string;
  66129. /** Gets or sets default key button height */
  66130. defaultButtonHeight: string;
  66131. /** Gets or sets default key button left padding */
  66132. defaultButtonPaddingLeft: string;
  66133. /** Gets or sets default key button right padding */
  66134. defaultButtonPaddingRight: string;
  66135. /** Gets or sets default key button top padding */
  66136. defaultButtonPaddingTop: string;
  66137. /** Gets or sets default key button bottom padding */
  66138. defaultButtonPaddingBottom: string;
  66139. /** Gets or sets default key button foreground color */
  66140. defaultButtonColor: string;
  66141. /** Gets or sets default key button background color */
  66142. defaultButtonBackground: string;
  66143. /** Gets or sets shift button foreground color */
  66144. shiftButtonColor: string;
  66145. /** Gets or sets shift button thickness*/
  66146. selectedShiftThickness: number;
  66147. /** Gets shift key state */
  66148. shiftState: number;
  66149. protected _getTypeName(): string;
  66150. private _createKey;
  66151. /**
  66152. * Adds a new row of keys
  66153. * @param keys defines the list of keys to add
  66154. * @param propertySets defines the associated property sets
  66155. */
  66156. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  66157. /**
  66158. * Set the shift key to a specific state
  66159. * @param shiftState defines the new shift state
  66160. */
  66161. applyShiftState(shiftState: number): void;
  66162. private _currentlyConnectedInputText;
  66163. private _connectedInputTexts;
  66164. private _onKeyPressObserver;
  66165. /** Gets the input text control currently attached to the keyboard */
  66166. readonly connectedInputText: BABYLON.Nullable<InputText>;
  66167. /**
  66168. * Connects the keyboard with an input text control
  66169. *
  66170. * @param input defines the target control
  66171. */
  66172. connect(input: InputText): void;
  66173. /**
  66174. * Disconnects the keyboard from connected InputText controls
  66175. *
  66176. * @param input optionally defines a target control, otherwise all are disconnected
  66177. */
  66178. disconnect(input?: InputText): void;
  66179. private _removeConnectedInputObservables;
  66180. /**
  66181. * Release all resources
  66182. */
  66183. dispose(): void;
  66184. /**
  66185. * Creates a new keyboard using a default layout
  66186. *
  66187. * @param name defines control name
  66188. * @returns a new VirtualKeyboard
  66189. */
  66190. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  66191. }
  66192. }
  66193. declare module BABYLON.GUI {
  66194. /**
  66195. * Class used to create input text control
  66196. */
  66197. export class InputText extends Control implements IFocusableControl {
  66198. name?: string | undefined;
  66199. private _text;
  66200. private _placeholderText;
  66201. private _background;
  66202. private _focusedBackground;
  66203. private _focusedColor;
  66204. private _placeholderColor;
  66205. private _thickness;
  66206. private _margin;
  66207. private _autoStretchWidth;
  66208. private _maxWidth;
  66209. private _isFocused;
  66210. private _blinkTimeout;
  66211. private _blinkIsEven;
  66212. private _cursorOffset;
  66213. private _scrollLeft;
  66214. private _textWidth;
  66215. private _clickedCoordinate;
  66216. private _deadKey;
  66217. private _addKey;
  66218. private _currentKey;
  66219. private _isTextHighlightOn;
  66220. private _textHighlightColor;
  66221. private _highligherOpacity;
  66222. private _highlightedText;
  66223. private _startHighlightIndex;
  66224. private _endHighlightIndex;
  66225. private _cursorIndex;
  66226. private _onFocusSelectAll;
  66227. private _isPointerDown;
  66228. private _onClipboardObserver;
  66229. private _onPointerDblTapObserver;
  66230. /** @hidden */
  66231. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  66232. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  66233. promptMessage: string;
  66234. /** Force disable prompt on mobile device */
  66235. disableMobilePrompt: boolean;
  66236. /** BABYLON.Observable raised when the text changes */
  66237. onTextChangedObservable: BABYLON.Observable<InputText>;
  66238. /** BABYLON.Observable raised just before an entered character is to be added */
  66239. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  66240. /** BABYLON.Observable raised when the control gets the focus */
  66241. onFocusObservable: BABYLON.Observable<InputText>;
  66242. /** BABYLON.Observable raised when the control loses the focus */
  66243. onBlurObservable: BABYLON.Observable<InputText>;
  66244. /**Observable raised when the text is highlighted */
  66245. onTextHighlightObservable: BABYLON.Observable<InputText>;
  66246. /**Observable raised when copy event is triggered */
  66247. onTextCopyObservable: BABYLON.Observable<InputText>;
  66248. /** BABYLON.Observable raised when cut event is triggered */
  66249. onTextCutObservable: BABYLON.Observable<InputText>;
  66250. /** BABYLON.Observable raised when paste event is triggered */
  66251. onTextPasteObservable: BABYLON.Observable<InputText>;
  66252. /** BABYLON.Observable raised when a key event was processed */
  66253. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  66254. /** Gets or sets the maximum width allowed by the control */
  66255. maxWidth: string | number;
  66256. /** Gets the maximum width allowed by the control in pixels */
  66257. readonly maxWidthInPixels: number;
  66258. /** Gets or sets the text highlighter transparency; default: 0.4 */
  66259. highligherOpacity: number;
  66260. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  66261. onFocusSelectAll: boolean;
  66262. /** Gets or sets the text hightlight color */
  66263. textHighlightColor: string;
  66264. /** Gets or sets control margin */
  66265. margin: string;
  66266. /** Gets control margin in pixels */
  66267. readonly marginInPixels: number;
  66268. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  66269. autoStretchWidth: boolean;
  66270. /** Gets or sets border thickness */
  66271. thickness: number;
  66272. /** Gets or sets the background color when focused */
  66273. focusedBackground: string;
  66274. /** Gets or sets the background color when focused */
  66275. focusedColor: string;
  66276. /** Gets or sets the background color */
  66277. background: string;
  66278. /** Gets or sets the placeholder color */
  66279. placeholderColor: string;
  66280. /** Gets or sets the text displayed when the control is empty */
  66281. placeholderText: string;
  66282. /** Gets or sets the dead key flag */
  66283. deadKey: boolean;
  66284. /** Gets or sets the highlight text */
  66285. highlightedText: string;
  66286. /** Gets or sets if the current key should be added */
  66287. addKey: boolean;
  66288. /** Gets or sets the value of the current key being entered */
  66289. currentKey: string;
  66290. /** Gets or sets the text displayed in the control */
  66291. text: string;
  66292. /** Gets or sets control width */
  66293. width: string | number;
  66294. /**
  66295. * Creates a new InputText
  66296. * @param name defines the control name
  66297. * @param text defines the text of the control
  66298. */
  66299. constructor(name?: string | undefined, text?: string);
  66300. /** @hidden */
  66301. onBlur(): void;
  66302. /** @hidden */
  66303. onFocus(): void;
  66304. protected _getTypeName(): string;
  66305. /**
  66306. * Function called to get the list of controls that should not steal the focus from this control
  66307. * @returns an array of controls
  66308. */
  66309. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  66310. /** @hidden */
  66311. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  66312. /** @hidden */
  66313. private _updateValueFromCursorIndex;
  66314. /** @hidden */
  66315. private _processDblClick;
  66316. /** @hidden */
  66317. private _selectAllText;
  66318. /**
  66319. * Handles the keyboard event
  66320. * @param evt Defines the KeyboardEvent
  66321. */
  66322. processKeyboard(evt: KeyboardEvent): void;
  66323. /** @hidden */
  66324. private _onCopyText;
  66325. /** @hidden */
  66326. private _onCutText;
  66327. /** @hidden */
  66328. private _onPasteText;
  66329. _draw(context: CanvasRenderingContext2D): void;
  66330. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66331. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66332. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66333. protected _beforeRenderText(text: string): string;
  66334. dispose(): void;
  66335. }
  66336. }
  66337. declare module BABYLON.GUI {
  66338. /**
  66339. * Class used to create a 2D grid container
  66340. */
  66341. export class Grid extends Container {
  66342. name?: string | undefined;
  66343. private _rowDefinitions;
  66344. private _columnDefinitions;
  66345. private _cells;
  66346. private _childControls;
  66347. /**
  66348. * Gets the number of columns
  66349. */
  66350. readonly columnCount: number;
  66351. /**
  66352. * Gets the number of rows
  66353. */
  66354. readonly rowCount: number;
  66355. /** Gets the list of children */
  66356. readonly children: Control[];
  66357. /** Gets the list of cells (e.g. the containers) */
  66358. readonly cells: {
  66359. [key: string]: Container;
  66360. };
  66361. /**
  66362. * Gets the definition of a specific row
  66363. * @param index defines the index of the row
  66364. * @returns the row definition
  66365. */
  66366. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66367. /**
  66368. * Gets the definition of a specific column
  66369. * @param index defines the index of the column
  66370. * @returns the column definition
  66371. */
  66372. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  66373. /**
  66374. * Adds a new row to the grid
  66375. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66376. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  66377. * @returns the current grid
  66378. */
  66379. addRowDefinition(height: number, isPixel?: boolean): Grid;
  66380. /**
  66381. * Adds a new column to the grid
  66382. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66383. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66384. * @returns the current grid
  66385. */
  66386. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  66387. /**
  66388. * Update a row definition
  66389. * @param index defines the index of the row to update
  66390. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  66391. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  66392. * @returns the current grid
  66393. */
  66394. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  66395. /**
  66396. * Update a column definition
  66397. * @param index defines the index of the column to update
  66398. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  66399. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  66400. * @returns the current grid
  66401. */
  66402. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  66403. /**
  66404. * Gets the list of children stored in a specific cell
  66405. * @param row defines the row to check
  66406. * @param column defines the column to check
  66407. * @returns the list of controls
  66408. */
  66409. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  66410. /**
  66411. * Gets a string representing the child cell info (row x column)
  66412. * @param child defines the control to get info from
  66413. * @returns a string containing the child cell info (row x column)
  66414. */
  66415. getChildCellInfo(child: Control): string;
  66416. private _removeCell;
  66417. private _offsetCell;
  66418. /**
  66419. * Remove a column definition at specified index
  66420. * @param index defines the index of the column to remove
  66421. * @returns the current grid
  66422. */
  66423. removeColumnDefinition(index: number): Grid;
  66424. /**
  66425. * Remove a row definition at specified index
  66426. * @param index defines the index of the row to remove
  66427. * @returns the current grid
  66428. */
  66429. removeRowDefinition(index: number): Grid;
  66430. /**
  66431. * Adds a new control to the current grid
  66432. * @param control defines the control to add
  66433. * @param row defines the row where to add the control (0 by default)
  66434. * @param column defines the column where to add the control (0 by default)
  66435. * @returns the current grid
  66436. */
  66437. addControl(control: Control, row?: number, column?: number): Grid;
  66438. /**
  66439. * Removes a control from the current container
  66440. * @param control defines the control to remove
  66441. * @returns the current container
  66442. */
  66443. removeControl(control: Control): Container;
  66444. /**
  66445. * Creates a new Grid
  66446. * @param name defines control name
  66447. */
  66448. constructor(name?: string | undefined);
  66449. protected _getTypeName(): string;
  66450. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  66451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66452. _flagDescendantsAsMatrixDirty(): void;
  66453. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66454. /** Releases associated resources */
  66455. dispose(): void;
  66456. }
  66457. }
  66458. declare module BABYLON.GUI {
  66459. /** Class used to create color pickers */
  66460. export class ColorPicker extends Control {
  66461. name?: string | undefined;
  66462. private static _Epsilon;
  66463. private _colorWheelCanvas;
  66464. private _value;
  66465. private _tmpColor;
  66466. private _pointerStartedOnSquare;
  66467. private _pointerStartedOnWheel;
  66468. private _squareLeft;
  66469. private _squareTop;
  66470. private _squareSize;
  66471. private _h;
  66472. private _s;
  66473. private _v;
  66474. private _lastPointerDownID;
  66475. /**
  66476. * BABYLON.Observable raised when the value changes
  66477. */
  66478. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  66479. /** Gets or sets the color of the color picker */
  66480. value: BABYLON.Color3;
  66481. /**
  66482. * Gets or sets control width
  66483. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66484. */
  66485. width: string | number;
  66486. /**
  66487. * Gets or sets control height
  66488. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  66489. */
  66490. /** Gets or sets control height */
  66491. height: string | number;
  66492. /** Gets or sets control size */
  66493. size: string | number;
  66494. /**
  66495. * Creates a new ColorPicker
  66496. * @param name defines the control name
  66497. */
  66498. constructor(name?: string | undefined);
  66499. protected _getTypeName(): string;
  66500. /** @hidden */
  66501. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66502. private _updateSquareProps;
  66503. private _drawGradientSquare;
  66504. private _drawCircle;
  66505. private _createColorWheelCanvas;
  66506. /** @hidden */
  66507. _draw(context: CanvasRenderingContext2D): void;
  66508. private _pointerIsDown;
  66509. private _updateValueFromPointer;
  66510. private _isPointOnSquare;
  66511. private _isPointOnWheel;
  66512. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66513. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66514. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66515. /**
  66516. * This function expands the color picker by creating a color picker dialog with manual
  66517. * color value input and the ability to save colors into an array to be used later in
  66518. * subsequent launches of the dialogue.
  66519. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  66520. * @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.
  66521. * @returns picked color as a hex string and the saved colors array as hex strings.
  66522. */
  66523. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  66524. pickerWidth?: string;
  66525. pickerHeight?: string;
  66526. headerHeight?: string;
  66527. lastColor?: string;
  66528. swatchLimit?: number;
  66529. numSwatchesPerLine?: number;
  66530. savedColors?: Array<string>;
  66531. }): Promise<{
  66532. savedColors?: string[];
  66533. pickedColor: string;
  66534. }>;
  66535. }
  66536. }
  66537. declare module BABYLON.GUI {
  66538. /** Class used to create 2D ellipse containers */
  66539. export class Ellipse extends Container {
  66540. name?: string | undefined;
  66541. private _thickness;
  66542. /** Gets or sets border thickness */
  66543. thickness: number;
  66544. /**
  66545. * Creates a new Ellipse
  66546. * @param name defines the control name
  66547. */
  66548. constructor(name?: string | undefined);
  66549. protected _getTypeName(): string;
  66550. protected _localDraw(context: CanvasRenderingContext2D): void;
  66551. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66552. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  66553. }
  66554. }
  66555. declare module BABYLON.GUI {
  66556. /**
  66557. * Class used to create a password control
  66558. */
  66559. export class InputPassword extends InputText {
  66560. protected _beforeRenderText(text: string): string;
  66561. }
  66562. }
  66563. declare module BABYLON.GUI {
  66564. /** Class used to render 2D lines */
  66565. export class Line extends Control {
  66566. name?: string | undefined;
  66567. private _lineWidth;
  66568. private _x1;
  66569. private _y1;
  66570. private _x2;
  66571. private _y2;
  66572. private _dash;
  66573. private _connectedControl;
  66574. private _connectedControlDirtyObserver;
  66575. /** Gets or sets the dash pattern */
  66576. dash: Array<number>;
  66577. /** Gets or sets the control connected with the line end */
  66578. connectedControl: Control;
  66579. /** Gets or sets start coordinates on X axis */
  66580. x1: string | number;
  66581. /** Gets or sets start coordinates on Y axis */
  66582. y1: string | number;
  66583. /** Gets or sets end coordinates on X axis */
  66584. x2: string | number;
  66585. /** Gets or sets end coordinates on Y axis */
  66586. y2: string | number;
  66587. /** Gets or sets line width */
  66588. lineWidth: number;
  66589. /** Gets or sets horizontal alignment */
  66590. horizontalAlignment: number;
  66591. /** Gets or sets vertical alignment */
  66592. verticalAlignment: number;
  66593. private readonly _effectiveX2;
  66594. private readonly _effectiveY2;
  66595. /**
  66596. * Creates a new Line
  66597. * @param name defines the control name
  66598. */
  66599. constructor(name?: string | undefined);
  66600. protected _getTypeName(): string;
  66601. _draw(context: CanvasRenderingContext2D): void;
  66602. _measure(): void;
  66603. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66604. /**
  66605. * Move one end of the line given 3D cartesian coordinates.
  66606. * @param position Targeted world position
  66607. * @param scene BABYLON.Scene
  66608. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66609. */
  66610. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  66611. /**
  66612. * Move one end of the line to a position in screen absolute space.
  66613. * @param projectedPosition Position in screen absolute space (X, Y)
  66614. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  66615. */
  66616. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  66617. }
  66618. }
  66619. declare module BABYLON.GUI {
  66620. /**
  66621. * Class used to store a point for a MultiLine object.
  66622. * The point can be pure 2D coordinates, a mesh or a control
  66623. */
  66624. export class MultiLinePoint {
  66625. private _multiLine;
  66626. private _x;
  66627. private _y;
  66628. private _control;
  66629. private _mesh;
  66630. private _controlObserver;
  66631. private _meshObserver;
  66632. /** @hidden */
  66633. _point: BABYLON.Vector2;
  66634. /**
  66635. * Creates a new MultiLinePoint
  66636. * @param multiLine defines the source MultiLine object
  66637. */
  66638. constructor(multiLine: MultiLine);
  66639. /** Gets or sets x coordinate */
  66640. x: string | number;
  66641. /** Gets or sets y coordinate */
  66642. y: string | number;
  66643. /** Gets or sets the control associated with this point */
  66644. control: BABYLON.Nullable<Control>;
  66645. /** Gets or sets the mesh associated with this point */
  66646. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66647. /** Resets links */
  66648. resetLinks(): void;
  66649. /**
  66650. * Gets a translation vector
  66651. * @returns the translation vector
  66652. */
  66653. translate(): BABYLON.Vector2;
  66654. private _translatePoint;
  66655. /** Release associated resources */
  66656. dispose(): void;
  66657. }
  66658. }
  66659. declare module BABYLON.GUI {
  66660. /**
  66661. * Class used to create multi line control
  66662. */
  66663. export class MultiLine extends Control {
  66664. name?: string | undefined;
  66665. private _lineWidth;
  66666. private _dash;
  66667. private _points;
  66668. private _minX;
  66669. private _minY;
  66670. private _maxX;
  66671. private _maxY;
  66672. /**
  66673. * Creates a new MultiLine
  66674. * @param name defines the control name
  66675. */
  66676. constructor(name?: string | undefined);
  66677. /** Gets or sets dash pattern */
  66678. dash: Array<number>;
  66679. /**
  66680. * Gets point stored at specified index
  66681. * @param index defines the index to look for
  66682. * @returns the requested point if found
  66683. */
  66684. getAt(index: number): MultiLinePoint;
  66685. /** Function called when a point is updated */
  66686. onPointUpdate: () => void;
  66687. /**
  66688. * Adds new points to the point collection
  66689. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  66690. * @returns the list of created MultiLinePoint
  66691. */
  66692. add(...items: (AbstractMesh | Control | {
  66693. x: string | number;
  66694. y: string | number;
  66695. })[]): MultiLinePoint[];
  66696. /**
  66697. * Adds a new point to the point collection
  66698. * @param item defines the item (mesh, control or 2d coordiantes) to add
  66699. * @returns the created MultiLinePoint
  66700. */
  66701. push(item?: (AbstractMesh | Control | {
  66702. x: string | number;
  66703. y: string | number;
  66704. })): MultiLinePoint;
  66705. /**
  66706. * Remove a specific value or point from the active point collection
  66707. * @param value defines the value or point to remove
  66708. */
  66709. remove(value: number | MultiLinePoint): void;
  66710. /**
  66711. * Resets this object to initial state (no point)
  66712. */
  66713. reset(): void;
  66714. /**
  66715. * Resets all links
  66716. */
  66717. resetLinks(): void;
  66718. /** Gets or sets line width */
  66719. lineWidth: number;
  66720. horizontalAlignment: number;
  66721. verticalAlignment: number;
  66722. protected _getTypeName(): string;
  66723. _draw(context: CanvasRenderingContext2D): void;
  66724. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66725. _measure(): void;
  66726. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66727. dispose(): void;
  66728. }
  66729. }
  66730. declare module BABYLON.GUI {
  66731. /**
  66732. * Class used to create radio button controls
  66733. */
  66734. export class RadioButton extends Control {
  66735. name?: string | undefined;
  66736. private _isChecked;
  66737. private _background;
  66738. private _checkSizeRatio;
  66739. private _thickness;
  66740. /** Gets or sets border thickness */
  66741. thickness: number;
  66742. /** Gets or sets group name */
  66743. group: string;
  66744. /** BABYLON.Observable raised when isChecked is changed */
  66745. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  66746. /** Gets or sets a value indicating the ratio between overall size and check size */
  66747. checkSizeRatio: number;
  66748. /** Gets or sets background color */
  66749. background: string;
  66750. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  66751. isChecked: boolean;
  66752. /**
  66753. * Creates a new RadioButton
  66754. * @param name defines the control name
  66755. */
  66756. constructor(name?: string | undefined);
  66757. protected _getTypeName(): string;
  66758. _draw(context: CanvasRenderingContext2D): void;
  66759. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66760. /**
  66761. * Utility function to easily create a radio button with a header
  66762. * @param title defines the label to use for the header
  66763. * @param group defines the group to use for the radio button
  66764. * @param isChecked defines the initial state of the radio button
  66765. * @param onValueChanged defines the callback to call when value changes
  66766. * @returns a StackPanel containing the radio button and a textBlock
  66767. */
  66768. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  66769. }
  66770. }
  66771. declare module BABYLON.GUI {
  66772. /**
  66773. * Class used to create slider controls
  66774. */
  66775. export class BaseSlider extends Control {
  66776. name?: string | undefined;
  66777. protected _thumbWidth: ValueAndUnit;
  66778. private _minimum;
  66779. private _maximum;
  66780. private _value;
  66781. private _isVertical;
  66782. protected _barOffset: ValueAndUnit;
  66783. private _isThumbClamped;
  66784. protected _displayThumb: boolean;
  66785. private _step;
  66786. private _lastPointerDownID;
  66787. protected _effectiveBarOffset: number;
  66788. protected _renderLeft: number;
  66789. protected _renderTop: number;
  66790. protected _renderWidth: number;
  66791. protected _renderHeight: number;
  66792. protected _backgroundBoxLength: number;
  66793. protected _backgroundBoxThickness: number;
  66794. protected _effectiveThumbThickness: number;
  66795. /** BABYLON.Observable raised when the sldier value changes */
  66796. onValueChangedObservable: BABYLON.Observable<number>;
  66797. /** Gets or sets a boolean indicating if the thumb must be rendered */
  66798. displayThumb: boolean;
  66799. /** Gets or sets a step to apply to values (0 by default) */
  66800. step: number;
  66801. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  66802. barOffset: string | number;
  66803. /** Gets main bar offset in pixels*/
  66804. readonly barOffsetInPixels: number;
  66805. /** Gets or sets thumb width */
  66806. thumbWidth: string | number;
  66807. /** Gets thumb width in pixels */
  66808. readonly thumbWidthInPixels: number;
  66809. /** Gets or sets minimum value */
  66810. minimum: number;
  66811. /** Gets or sets maximum value */
  66812. maximum: number;
  66813. /** Gets or sets current value */
  66814. value: number;
  66815. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66816. isVertical: boolean;
  66817. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66818. isThumbClamped: boolean;
  66819. /**
  66820. * Creates a new BaseSlider
  66821. * @param name defines the control name
  66822. */
  66823. constructor(name?: string | undefined);
  66824. protected _getTypeName(): string;
  66825. protected _getThumbPosition(): number;
  66826. protected _getThumbThickness(type: string): number;
  66827. protected _prepareRenderingData(type: string): void;
  66828. private _pointerIsDown;
  66829. /** @hidden */
  66830. protected _updateValueFromPointer(x: number, y: number): void;
  66831. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66832. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  66833. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66834. }
  66835. }
  66836. declare module BABYLON.GUI {
  66837. /**
  66838. * Class used to create slider controls
  66839. */
  66840. export class Slider extends BaseSlider {
  66841. name?: string | undefined;
  66842. private _background;
  66843. private _borderColor;
  66844. private _isThumbCircle;
  66845. protected _displayValueBar: boolean;
  66846. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66847. displayValueBar: boolean;
  66848. /** Gets or sets border color */
  66849. borderColor: string;
  66850. /** Gets or sets background color */
  66851. background: string;
  66852. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66853. isThumbCircle: boolean;
  66854. /**
  66855. * Creates a new Slider
  66856. * @param name defines the control name
  66857. */
  66858. constructor(name?: string | undefined);
  66859. protected _getTypeName(): string;
  66860. _draw(context: CanvasRenderingContext2D): void;
  66861. }
  66862. }
  66863. declare module BABYLON.GUI {
  66864. /** Class used to create a RadioGroup
  66865. * which contains groups of radio buttons
  66866. */
  66867. export class SelectorGroup {
  66868. /** name of SelectorGroup */
  66869. name: string;
  66870. private _groupPanel;
  66871. private _selectors;
  66872. private _groupHeader;
  66873. /**
  66874. * Creates a new SelectorGroup
  66875. * @param name of group, used as a group heading
  66876. */
  66877. constructor(
  66878. /** name of SelectorGroup */
  66879. name: string);
  66880. /** Gets the groupPanel of the SelectorGroup */
  66881. readonly groupPanel: StackPanel;
  66882. /** Gets the selectors array */
  66883. readonly selectors: StackPanel[];
  66884. /** Gets and sets the group header */
  66885. header: string;
  66886. /** @hidden */
  66887. private _addGroupHeader;
  66888. /** @hidden*/
  66889. _getSelector(selectorNb: number): StackPanel | undefined;
  66890. /** Removes the selector at the given position
  66891. * @param selectorNb the position of the selector within the group
  66892. */
  66893. removeSelector(selectorNb: number): void;
  66894. }
  66895. /** Class used to create a CheckboxGroup
  66896. * which contains groups of checkbox buttons
  66897. */
  66898. export class CheckboxGroup extends SelectorGroup {
  66899. /** Adds a checkbox as a control
  66900. * @param text is the label for the selector
  66901. * @param func is the function called when the Selector is checked
  66902. * @param checked is true when Selector is checked
  66903. */
  66904. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66905. /** @hidden */
  66906. _setSelectorLabel(selectorNb: number, label: string): void;
  66907. /** @hidden */
  66908. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66909. /** @hidden */
  66910. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66911. /** @hidden */
  66912. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66913. }
  66914. /** Class used to create a RadioGroup
  66915. * which contains groups of radio buttons
  66916. */
  66917. export class RadioGroup extends SelectorGroup {
  66918. private _selectNb;
  66919. /** Adds a radio button as a control
  66920. * @param label is the label for the selector
  66921. * @param func is the function called when the Selector is checked
  66922. * @param checked is true when Selector is checked
  66923. */
  66924. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66925. /** @hidden */
  66926. _setSelectorLabel(selectorNb: number, label: string): void;
  66927. /** @hidden */
  66928. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66929. /** @hidden */
  66930. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66931. /** @hidden */
  66932. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66933. }
  66934. /** Class used to create a SliderGroup
  66935. * which contains groups of slider buttons
  66936. */
  66937. export class SliderGroup extends SelectorGroup {
  66938. /**
  66939. * Adds a slider to the SelectorGroup
  66940. * @param label is the label for the SliderBar
  66941. * @param func is the function called when the Slider moves
  66942. * @param unit is a string describing the units used, eg degrees or metres
  66943. * @param min is the minimum value for the Slider
  66944. * @param max is the maximum value for the Slider
  66945. * @param value is the start value for the Slider between min and max
  66946. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66947. */
  66948. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66949. /** @hidden */
  66950. _setSelectorLabel(selectorNb: number, label: string): void;
  66951. /** @hidden */
  66952. _setSelectorLabelColor(selectorNb: number, color: string): void;
  66953. /** @hidden */
  66954. _setSelectorButtonColor(selectorNb: number, color: string): void;
  66955. /** @hidden */
  66956. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66957. }
  66958. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66959. * @see http://doc.babylonjs.com/how_to/selector
  66960. */
  66961. export class SelectionPanel extends Rectangle {
  66962. /** name of SelectionPanel */
  66963. name: string;
  66964. /** an array of SelectionGroups */
  66965. groups: SelectorGroup[];
  66966. private _panel;
  66967. private _buttonColor;
  66968. private _buttonBackground;
  66969. private _headerColor;
  66970. private _barColor;
  66971. private _barHeight;
  66972. private _spacerHeight;
  66973. private _labelColor;
  66974. private _groups;
  66975. private _bars;
  66976. /**
  66977. * Creates a new SelectionPanel
  66978. * @param name of SelectionPanel
  66979. * @param groups is an array of SelectionGroups
  66980. */
  66981. constructor(
  66982. /** name of SelectionPanel */
  66983. name: string,
  66984. /** an array of SelectionGroups */
  66985. groups?: SelectorGroup[]);
  66986. protected _getTypeName(): string;
  66987. /** Gets or sets the headerColor */
  66988. headerColor: string;
  66989. private _setHeaderColor;
  66990. /** Gets or sets the button color */
  66991. buttonColor: string;
  66992. private _setbuttonColor;
  66993. /** Gets or sets the label color */
  66994. labelColor: string;
  66995. private _setLabelColor;
  66996. /** Gets or sets the button background */
  66997. buttonBackground: string;
  66998. private _setButtonBackground;
  66999. /** Gets or sets the color of separator bar */
  67000. barColor: string;
  67001. private _setBarColor;
  67002. /** Gets or sets the height of separator bar */
  67003. barHeight: string;
  67004. private _setBarHeight;
  67005. /** Gets or sets the height of spacers*/
  67006. spacerHeight: string;
  67007. private _setSpacerHeight;
  67008. /** Adds a bar between groups */
  67009. private _addSpacer;
  67010. /** Add a group to the selection panel
  67011. * @param group is the selector group to add
  67012. */
  67013. addGroup(group: SelectorGroup): void;
  67014. /** Remove the group from the given position
  67015. * @param groupNb is the position of the group in the list
  67016. */
  67017. removeGroup(groupNb: number): void;
  67018. /** Change a group header label
  67019. * @param label is the new group header label
  67020. * @param groupNb is the number of the group to relabel
  67021. * */
  67022. setHeaderName(label: string, groupNb: number): void;
  67023. /** Change selector label to the one given
  67024. * @param label is the new selector label
  67025. * @param groupNb is the number of the groupcontaining the selector
  67026. * @param selectorNb is the number of the selector within a group to relabel
  67027. * */
  67028. relabel(label: string, groupNb: number, selectorNb: number): void;
  67029. /** For a given group position remove the selector at the given position
  67030. * @param groupNb is the number of the group to remove the selector from
  67031. * @param selectorNb is the number of the selector within the group
  67032. */
  67033. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  67034. /** For a given group position of correct type add a checkbox button
  67035. * @param groupNb is the number of the group to remove the selector from
  67036. * @param label is the label for the selector
  67037. * @param func is the function called when the Selector is checked
  67038. * @param checked is true when Selector is checked
  67039. */
  67040. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67041. /** For a given group position of correct type add a radio button
  67042. * @param groupNb is the number of the group to remove the selector from
  67043. * @param label is the label for the selector
  67044. * @param func is the function called when the Selector is checked
  67045. * @param checked is true when Selector is checked
  67046. */
  67047. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  67048. /**
  67049. * For a given slider group add a slider
  67050. * @param groupNb is the number of the group to add the slider to
  67051. * @param label is the label for the Slider
  67052. * @param func is the function called when the Slider moves
  67053. * @param unit is a string describing the units used, eg degrees or metres
  67054. * @param min is the minimum value for the Slider
  67055. * @param max is the maximum value for the Slider
  67056. * @param value is the start value for the Slider between min and max
  67057. * @param onVal is the function used to format the value displayed, eg radians to degrees
  67058. */
  67059. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  67060. }
  67061. }
  67062. declare module BABYLON.GUI {
  67063. /**
  67064. * Class used to hold a the container for ScrollViewer
  67065. * @hidden
  67066. */
  67067. export class _ScrollViewerWindow extends Container {
  67068. parentClientWidth: number;
  67069. parentClientHeight: number;
  67070. /**
  67071. * Creates a new ScrollViewerWindow
  67072. * @param name of ScrollViewerWindow
  67073. */
  67074. constructor(name?: string);
  67075. protected _getTypeName(): string;
  67076. /** @hidden */
  67077. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67078. protected _postMeasure(): void;
  67079. }
  67080. }
  67081. declare module BABYLON.GUI {
  67082. /**
  67083. * Class used to create slider controls
  67084. */
  67085. export class ScrollBar extends BaseSlider {
  67086. name?: string | undefined;
  67087. private _background;
  67088. private _borderColor;
  67089. private _thumbMeasure;
  67090. /** Gets or sets border color */
  67091. borderColor: string;
  67092. /** Gets or sets background color */
  67093. background: string;
  67094. /**
  67095. * Creates a new Slider
  67096. * @param name defines the control name
  67097. */
  67098. constructor(name?: string | undefined);
  67099. protected _getTypeName(): string;
  67100. protected _getThumbThickness(): number;
  67101. _draw(context: CanvasRenderingContext2D): void;
  67102. private _first;
  67103. private _originX;
  67104. private _originY;
  67105. /** @hidden */
  67106. protected _updateValueFromPointer(x: number, y: number): void;
  67107. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  67108. }
  67109. }
  67110. declare module BABYLON.GUI {
  67111. /**
  67112. * Class used to hold a viewer window and sliders in a grid
  67113. */
  67114. export class ScrollViewer extends Rectangle {
  67115. private _grid;
  67116. private _horizontalBarSpace;
  67117. private _verticalBarSpace;
  67118. private _dragSpace;
  67119. private _horizontalBar;
  67120. private _verticalBar;
  67121. private _barColor;
  67122. private _barBackground;
  67123. private _barSize;
  67124. private _endLeft;
  67125. private _endTop;
  67126. private _window;
  67127. private _pointerIsOver;
  67128. private _wheelPrecision;
  67129. private _onPointerObserver;
  67130. private _clientWidth;
  67131. private _clientHeight;
  67132. /**
  67133. * Gets the horizontal scrollbar
  67134. */
  67135. readonly horizontalBar: ScrollBar;
  67136. /**
  67137. * Gets the vertical scrollbar
  67138. */
  67139. readonly verticalBar: ScrollBar;
  67140. /**
  67141. * Adds a new control to the current container
  67142. * @param control defines the control to add
  67143. * @returns the current container
  67144. */
  67145. addControl(control: BABYLON.Nullable<Control>): Container;
  67146. /**
  67147. * Removes a control from the current container
  67148. * @param control defines the control to remove
  67149. * @returns the current container
  67150. */
  67151. removeControl(control: Control): Container;
  67152. /** Gets the list of children */
  67153. readonly children: Control[];
  67154. _flagDescendantsAsMatrixDirty(): void;
  67155. /**
  67156. * Creates a new ScrollViewer
  67157. * @param name of ScrollViewer
  67158. */
  67159. constructor(name?: string);
  67160. /** Reset the scroll viewer window to initial size */
  67161. resetWindow(): void;
  67162. protected _getTypeName(): string;
  67163. private _buildClientSizes;
  67164. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  67165. protected _postMeasure(): void;
  67166. /**
  67167. * Gets or sets the mouse wheel precision
  67168. * from 0 to 1 with a default value of 0.05
  67169. * */
  67170. wheelPrecision: number;
  67171. /** Gets or sets the bar color */
  67172. barColor: string;
  67173. /** Gets or sets the size of the bar */
  67174. barSize: number;
  67175. /** Gets or sets the bar background */
  67176. barBackground: string;
  67177. /** @hidden */
  67178. private _updateScroller;
  67179. _link(host: AdvancedDynamicTexture): void;
  67180. /** @hidden */
  67181. private _attachWheel;
  67182. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  67183. /** Releases associated resources */
  67184. dispose(): void;
  67185. }
  67186. }
  67187. declare module BABYLON.GUI {
  67188. /** Class used to render a grid */
  67189. export class DisplayGrid extends Control {
  67190. name?: string | undefined;
  67191. private _cellWidth;
  67192. private _cellHeight;
  67193. private _minorLineTickness;
  67194. private _minorLineColor;
  67195. private _majorLineTickness;
  67196. private _majorLineColor;
  67197. private _majorLineFrequency;
  67198. private _background;
  67199. private _displayMajorLines;
  67200. private _displayMinorLines;
  67201. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  67202. displayMinorLines: boolean;
  67203. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  67204. displayMajorLines: boolean;
  67205. /** Gets or sets background color (Black by default) */
  67206. background: string;
  67207. /** Gets or sets the width of each cell (20 by default) */
  67208. cellWidth: number;
  67209. /** Gets or sets the height of each cell (20 by default) */
  67210. cellHeight: number;
  67211. /** Gets or sets the tickness of minor lines (1 by default) */
  67212. minorLineTickness: number;
  67213. /** Gets or sets the color of minor lines (DarkGray by default) */
  67214. minorLineColor: string;
  67215. /** Gets or sets the tickness of major lines (2 by default) */
  67216. majorLineTickness: number;
  67217. /** Gets or sets the color of major lines (White by default) */
  67218. majorLineColor: string;
  67219. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  67220. majorLineFrequency: number;
  67221. /**
  67222. * Creates a new GridDisplayRectangle
  67223. * @param name defines the control name
  67224. */
  67225. constructor(name?: string | undefined);
  67226. _draw(context: CanvasRenderingContext2D): void;
  67227. protected _getTypeName(): string;
  67228. }
  67229. }
  67230. declare module BABYLON.GUI {
  67231. /**
  67232. * Class used to create slider controls based on images
  67233. */
  67234. export class ImageBasedSlider extends BaseSlider {
  67235. name?: string | undefined;
  67236. private _backgroundImage;
  67237. private _thumbImage;
  67238. private _valueBarImage;
  67239. private _tempMeasure;
  67240. displayThumb: boolean;
  67241. /**
  67242. * Gets or sets the image used to render the background
  67243. */
  67244. backgroundImage: Image;
  67245. /**
  67246. * Gets or sets the image used to render the value bar
  67247. */
  67248. valueBarImage: Image;
  67249. /**
  67250. * Gets or sets the image used to render the thumb
  67251. */
  67252. thumbImage: Image;
  67253. /**
  67254. * Creates a new ImageBasedSlider
  67255. * @param name defines the control name
  67256. */
  67257. constructor(name?: string | undefined);
  67258. protected _getTypeName(): string;
  67259. _draw(context: CanvasRenderingContext2D): void;
  67260. }
  67261. }
  67262. declare module BABYLON.GUI {
  67263. /**
  67264. * Forcing an export so that this code will execute
  67265. * @hidden
  67266. */
  67267. const name = "Statics";
  67268. }
  67269. declare module BABYLON.GUI {
  67270. /**
  67271. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  67272. */
  67273. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  67274. /**
  67275. * Define the instrumented AdvancedDynamicTexture.
  67276. */
  67277. texture: AdvancedDynamicTexture;
  67278. private _captureRenderTime;
  67279. private _renderTime;
  67280. private _captureLayoutTime;
  67281. private _layoutTime;
  67282. private _onBeginRenderObserver;
  67283. private _onEndRenderObserver;
  67284. private _onBeginLayoutObserver;
  67285. private _onEndLayoutObserver;
  67286. /**
  67287. * Gets the perf counter used to capture render time
  67288. */
  67289. readonly renderTimeCounter: BABYLON.PerfCounter;
  67290. /**
  67291. * Gets the perf counter used to capture layout time
  67292. */
  67293. readonly layoutTimeCounter: BABYLON.PerfCounter;
  67294. /**
  67295. * Enable or disable the render time capture
  67296. */
  67297. captureRenderTime: boolean;
  67298. /**
  67299. * Enable or disable the layout time capture
  67300. */
  67301. captureLayoutTime: boolean;
  67302. /**
  67303. * Instantiates a new advanced dynamic texture instrumentation.
  67304. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  67305. * @param texture Defines the AdvancedDynamicTexture to instrument
  67306. */
  67307. constructor(
  67308. /**
  67309. * Define the instrumented AdvancedDynamicTexture.
  67310. */
  67311. texture: AdvancedDynamicTexture);
  67312. /**
  67313. * Dispose and release associated resources.
  67314. */
  67315. dispose(): void;
  67316. }
  67317. }
  67318. declare module BABYLON.GUI {
  67319. /**
  67320. * Class used to load GUI via XML.
  67321. */
  67322. export class XmlLoader {
  67323. private _nodes;
  67324. private _nodeTypes;
  67325. private _isLoaded;
  67326. private _objectAttributes;
  67327. private _parentClass;
  67328. /**
  67329. * Create a new xml loader
  67330. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  67331. */
  67332. constructor(parentClass?: null);
  67333. private _getChainElement;
  67334. private _getClassAttribute;
  67335. private _createGuiElement;
  67336. private _parseGrid;
  67337. private _parseElement;
  67338. private _prepareSourceElement;
  67339. private _parseElementsFromSource;
  67340. private _parseXml;
  67341. /**
  67342. * Gets if the loading has finished.
  67343. * @returns whether the loading has finished or not
  67344. */
  67345. isLoaded(): boolean;
  67346. /**
  67347. * Gets a loaded node / control by id.
  67348. * @param id the Controls id set in the xml
  67349. * @returns element of type Control
  67350. */
  67351. getNodeById(id: string): any;
  67352. /**
  67353. * Gets all loaded nodes / controls
  67354. * @returns Array of controls
  67355. */
  67356. getNodes(): any;
  67357. /**
  67358. * Initiates the xml layout loading
  67359. * @param xmlFile defines the xml layout to load
  67360. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  67361. * @param callback defines the callback called on layout load.
  67362. */
  67363. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  67364. }
  67365. }
  67366. declare module BABYLON.GUI {
  67367. /**
  67368. * Class used to create containers for controls
  67369. */
  67370. export class Container3D extends Control3D {
  67371. private _blockLayout;
  67372. /**
  67373. * Gets the list of child controls
  67374. */
  67375. protected _children: Control3D[];
  67376. /**
  67377. * Gets the list of child controls
  67378. */
  67379. readonly children: Array<Control3D>;
  67380. /**
  67381. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  67382. * This is helpful to optimize layout operation when adding multiple children in a row
  67383. */
  67384. blockLayout: boolean;
  67385. /**
  67386. * Creates a new container
  67387. * @param name defines the container name
  67388. */
  67389. constructor(name?: string);
  67390. /**
  67391. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  67392. * @returns the current container
  67393. */
  67394. updateLayout(): Container3D;
  67395. /**
  67396. * Gets a boolean indicating if the given control is in the children of this control
  67397. * @param control defines the control to check
  67398. * @returns true if the control is in the child list
  67399. */
  67400. containsControl(control: Control3D): boolean;
  67401. /**
  67402. * Adds a control to the children of this control
  67403. * @param control defines the control to add
  67404. * @returns the current container
  67405. */
  67406. addControl(control: Control3D): Container3D;
  67407. /**
  67408. * This function will be called everytime a new control is added
  67409. */
  67410. protected _arrangeChildren(): void;
  67411. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67412. /**
  67413. * Removes a control from the children of this control
  67414. * @param control defines the control to remove
  67415. * @returns the current container
  67416. */
  67417. removeControl(control: Control3D): Container3D;
  67418. protected _getTypeName(): string;
  67419. /**
  67420. * Releases all associated resources
  67421. */
  67422. dispose(): void;
  67423. /** Control rotation will remain unchanged */
  67424. static readonly UNSET_ORIENTATION: number;
  67425. /** Control will rotate to make it look at sphere central axis */
  67426. static readonly FACEORIGIN_ORIENTATION: number;
  67427. /** Control will rotate to make it look back at sphere central axis */
  67428. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  67429. /** Control will rotate to look at z axis (0, 0, 1) */
  67430. static readonly FACEFORWARD_ORIENTATION: number;
  67431. /** Control will rotate to look at negative z axis (0, 0, -1) */
  67432. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  67433. }
  67434. }
  67435. declare module BABYLON.GUI {
  67436. /**
  67437. * Class used to manage 3D user interface
  67438. * @see http://doc.babylonjs.com/how_to/gui3d
  67439. */
  67440. export class GUI3DManager implements BABYLON.IDisposable {
  67441. private _scene;
  67442. private _sceneDisposeObserver;
  67443. private _utilityLayer;
  67444. private _rootContainer;
  67445. private _pointerObserver;
  67446. private _pointerOutObserver;
  67447. /** @hidden */
  67448. _lastPickedControl: Control3D;
  67449. /** @hidden */
  67450. _lastControlOver: {
  67451. [pointerId: number]: Control3D;
  67452. };
  67453. /** @hidden */
  67454. _lastControlDown: {
  67455. [pointerId: number]: Control3D;
  67456. };
  67457. /**
  67458. * BABYLON.Observable raised when the point picked by the pointer events changed
  67459. */
  67460. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  67461. /** @hidden */
  67462. _sharedMaterials: {
  67463. [key: string]: BABYLON.Material;
  67464. };
  67465. /** Gets the hosting scene */
  67466. readonly scene: BABYLON.Scene;
  67467. /** Gets associated utility layer */
  67468. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  67469. /**
  67470. * Creates a new GUI3DManager
  67471. * @param scene
  67472. */
  67473. constructor(scene?: BABYLON.Scene);
  67474. private _handlePointerOut;
  67475. private _doPicking;
  67476. /**
  67477. * Gets the root container
  67478. */
  67479. readonly rootContainer: Container3D;
  67480. /**
  67481. * Gets a boolean indicating if the given control is in the root child list
  67482. * @param control defines the control to check
  67483. * @returns true if the control is in the root child list
  67484. */
  67485. containsControl(control: Control3D): boolean;
  67486. /**
  67487. * Adds a control to the root child list
  67488. * @param control defines the control to add
  67489. * @returns the current manager
  67490. */
  67491. addControl(control: Control3D): GUI3DManager;
  67492. /**
  67493. * Removes a control from the root child list
  67494. * @param control defines the control to remove
  67495. * @returns the current container
  67496. */
  67497. removeControl(control: Control3D): GUI3DManager;
  67498. /**
  67499. * Releases all associated resources
  67500. */
  67501. dispose(): void;
  67502. }
  67503. }
  67504. declare module BABYLON.GUI {
  67505. /**
  67506. * Class used to transport BABYLON.Vector3 information for pointer events
  67507. */
  67508. export class Vector3WithInfo extends BABYLON.Vector3 {
  67509. /** defines the current mouse button index */
  67510. buttonIndex: number;
  67511. /**
  67512. * Creates a new Vector3WithInfo
  67513. * @param source defines the vector3 data to transport
  67514. * @param buttonIndex defines the current mouse button index
  67515. */
  67516. constructor(source: BABYLON.Vector3,
  67517. /** defines the current mouse button index */
  67518. buttonIndex?: number);
  67519. }
  67520. }
  67521. declare module BABYLON.GUI {
  67522. /**
  67523. * Class used as base class for controls
  67524. */
  67525. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  67526. /** Defines the control name */
  67527. name?: string | undefined;
  67528. /** @hidden */
  67529. _host: GUI3DManager;
  67530. private _node;
  67531. private _downCount;
  67532. private _enterCount;
  67533. private _downPointerIds;
  67534. private _isVisible;
  67535. /** Gets or sets the control position in world space */
  67536. position: BABYLON.Vector3;
  67537. /** Gets or sets the control scaling in world space */
  67538. scaling: BABYLON.Vector3;
  67539. /** Callback used to start pointer enter animation */
  67540. pointerEnterAnimation: () => void;
  67541. /** Callback used to start pointer out animation */
  67542. pointerOutAnimation: () => void;
  67543. /** Callback used to start pointer down animation */
  67544. pointerDownAnimation: () => void;
  67545. /** Callback used to start pointer up animation */
  67546. pointerUpAnimation: () => void;
  67547. /**
  67548. * An event triggered when the pointer move over the control
  67549. */
  67550. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  67551. /**
  67552. * An event triggered when the pointer move out of the control
  67553. */
  67554. onPointerOutObservable: BABYLON.Observable<Control3D>;
  67555. /**
  67556. * An event triggered when the pointer taps the control
  67557. */
  67558. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  67559. /**
  67560. * An event triggered when pointer is up
  67561. */
  67562. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  67563. /**
  67564. * An event triggered when a control is clicked on (with a mouse)
  67565. */
  67566. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  67567. /**
  67568. * An event triggered when pointer enters the control
  67569. */
  67570. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  67571. /**
  67572. * Gets or sets the parent container
  67573. */
  67574. parent: BABYLON.Nullable<Container3D>;
  67575. private _behaviors;
  67576. /**
  67577. * Gets the list of attached behaviors
  67578. * @see http://doc.babylonjs.com/features/behaviour
  67579. */
  67580. readonly behaviors: BABYLON.Behavior<Control3D>[];
  67581. /**
  67582. * Attach a behavior to the control
  67583. * @see http://doc.babylonjs.com/features/behaviour
  67584. * @param behavior defines the behavior to attach
  67585. * @returns the current control
  67586. */
  67587. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67588. /**
  67589. * Remove an attached behavior
  67590. * @see http://doc.babylonjs.com/features/behaviour
  67591. * @param behavior defines the behavior to attach
  67592. * @returns the current control
  67593. */
  67594. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  67595. /**
  67596. * Gets an attached behavior by name
  67597. * @param name defines the name of the behavior to look for
  67598. * @see http://doc.babylonjs.com/features/behaviour
  67599. * @returns null if behavior was not found else the requested behavior
  67600. */
  67601. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  67602. /** Gets or sets a boolean indicating if the control is visible */
  67603. isVisible: boolean;
  67604. /**
  67605. * Creates a new control
  67606. * @param name defines the control name
  67607. */
  67608. constructor(
  67609. /** Defines the control name */
  67610. name?: string | undefined);
  67611. /**
  67612. * Gets a string representing the class name
  67613. */
  67614. readonly typeName: string;
  67615. /**
  67616. * Get the current class name of the control.
  67617. * @returns current class name
  67618. */
  67619. getClassName(): string;
  67620. protected _getTypeName(): string;
  67621. /**
  67622. * Gets the transform node used by this control
  67623. */
  67624. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  67625. /**
  67626. * Gets the mesh used to render this control
  67627. */
  67628. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  67629. /**
  67630. * Link the control as child of the given node
  67631. * @param node defines the node to link to. Use null to unlink the control
  67632. * @returns the current control
  67633. */
  67634. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  67635. /** @hidden **/
  67636. _prepareNode(scene: BABYLON.Scene): void;
  67637. /**
  67638. * Node creation.
  67639. * Can be overriden by children
  67640. * @param scene defines the scene where the node must be attached
  67641. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  67642. */
  67643. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  67644. /**
  67645. * Affect a material to the given mesh
  67646. * @param mesh defines the mesh which will represent the control
  67647. */
  67648. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67649. /** @hidden */
  67650. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  67651. /** @hidden */
  67652. _onPointerEnter(target: Control3D): boolean;
  67653. /** @hidden */
  67654. _onPointerOut(target: Control3D): void;
  67655. /** @hidden */
  67656. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67657. /** @hidden */
  67658. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  67659. /** @hidden */
  67660. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  67661. /** @hidden */
  67662. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  67663. /** @hidden */
  67664. _disposeNode(): void;
  67665. /**
  67666. * Releases all associated resources
  67667. */
  67668. dispose(): void;
  67669. }
  67670. }
  67671. declare module BABYLON.GUI {
  67672. /**
  67673. * Class used as a root to all buttons
  67674. */
  67675. export class AbstractButton3D extends Control3D {
  67676. /**
  67677. * Creates a new button
  67678. * @param name defines the control name
  67679. */
  67680. constructor(name?: string);
  67681. protected _getTypeName(): string;
  67682. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67683. }
  67684. }
  67685. declare module BABYLON.GUI {
  67686. /**
  67687. * Class used to create a button in 3D
  67688. */
  67689. export class Button3D extends AbstractButton3D {
  67690. /** @hidden */
  67691. protected _currentMaterial: BABYLON.Material;
  67692. private _facadeTexture;
  67693. private _content;
  67694. private _contentResolution;
  67695. private _contentScaleRatio;
  67696. /**
  67697. * Gets or sets the texture resolution used to render content (512 by default)
  67698. */
  67699. contentResolution: BABYLON.int;
  67700. /**
  67701. * Gets or sets the texture scale ratio used to render content (2 by default)
  67702. */
  67703. contentScaleRatio: number;
  67704. protected _disposeFacadeTexture(): void;
  67705. protected _resetContent(): void;
  67706. /**
  67707. * Creates a new button
  67708. * @param name defines the control name
  67709. */
  67710. constructor(name?: string);
  67711. /**
  67712. * Gets or sets the GUI 2D content used to display the button's facade
  67713. */
  67714. content: Control;
  67715. /**
  67716. * Apply the facade texture (created from the content property).
  67717. * This function can be overloaded by child classes
  67718. * @param facadeTexture defines the AdvancedDynamicTexture to use
  67719. */
  67720. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67721. protected _getTypeName(): string;
  67722. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67723. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67724. /**
  67725. * Releases all associated resources
  67726. */
  67727. dispose(): void;
  67728. }
  67729. }
  67730. declare module BABYLON.GUI {
  67731. /**
  67732. * Abstract class used to create a container panel deployed on the surface of a volume
  67733. */
  67734. export abstract class VolumeBasedPanel extends Container3D {
  67735. private _columns;
  67736. private _rows;
  67737. private _rowThenColum;
  67738. private _orientation;
  67739. protected _cellWidth: number;
  67740. protected _cellHeight: number;
  67741. /**
  67742. * Gets or sets the distance between elements
  67743. */
  67744. margin: number;
  67745. /**
  67746. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  67747. * | Value | Type | Description |
  67748. * | ----- | ----------------------------------- | ----------- |
  67749. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  67750. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  67751. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  67752. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  67753. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  67754. */
  67755. orientation: number;
  67756. /**
  67757. * Gets or sets the number of columns requested (10 by default).
  67758. * The panel will automatically compute the number of rows based on number of child controls.
  67759. */
  67760. columns: BABYLON.int;
  67761. /**
  67762. * Gets or sets a the number of rows requested.
  67763. * The panel will automatically compute the number of columns based on number of child controls.
  67764. */
  67765. rows: BABYLON.int;
  67766. /**
  67767. * Creates new VolumeBasedPanel
  67768. */
  67769. constructor();
  67770. protected _arrangeChildren(): void;
  67771. /** Child classes must implement this function to provide correct control positioning */
  67772. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67773. /** Child classes can implement this function to provide additional processing */
  67774. protected _finalProcessing(): void;
  67775. }
  67776. }
  67777. declare module BABYLON.GUI {
  67778. /**
  67779. * Class used to create a container panel deployed on the surface of a cylinder
  67780. */
  67781. export class CylinderPanel extends VolumeBasedPanel {
  67782. private _radius;
  67783. /**
  67784. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  67785. */
  67786. radius: BABYLON.float;
  67787. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67788. private _cylindricalMapping;
  67789. }
  67790. }
  67791. declare module BABYLON.GUI {
  67792. /** @hidden */
  67793. export var fluentVertexShader: {
  67794. name: string;
  67795. shader: string;
  67796. };
  67797. }
  67798. declare module BABYLON.GUI {
  67799. /** @hidden */
  67800. export var fluentPixelShader: {
  67801. name: string;
  67802. shader: string;
  67803. };
  67804. }
  67805. declare module BABYLON.GUI {
  67806. /** @hidden */
  67807. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  67808. INNERGLOW: boolean;
  67809. BORDER: boolean;
  67810. HOVERLIGHT: boolean;
  67811. TEXTURE: boolean;
  67812. constructor();
  67813. }
  67814. /**
  67815. * Class used to render controls with fluent desgin
  67816. */
  67817. export class FluentMaterial extends BABYLON.PushMaterial {
  67818. /**
  67819. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  67820. */
  67821. innerGlowColorIntensity: number;
  67822. /**
  67823. * Gets or sets the inner glow color (white by default)
  67824. */
  67825. innerGlowColor: BABYLON.Color3;
  67826. /**
  67827. * Gets or sets alpha value (default is 1.0)
  67828. */
  67829. alpha: number;
  67830. /**
  67831. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  67832. */
  67833. albedoColor: BABYLON.Color3;
  67834. /**
  67835. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  67836. */
  67837. renderBorders: boolean;
  67838. /**
  67839. * Gets or sets border width (default is 0.5)
  67840. */
  67841. borderWidth: number;
  67842. /**
  67843. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  67844. */
  67845. edgeSmoothingValue: number;
  67846. /**
  67847. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  67848. */
  67849. borderMinValue: number;
  67850. /**
  67851. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  67852. */
  67853. renderHoverLight: boolean;
  67854. /**
  67855. * Gets or sets the radius used to render the hover light (default is 1.0)
  67856. */
  67857. hoverRadius: number;
  67858. /**
  67859. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  67860. */
  67861. hoverColor: BABYLON.Color4;
  67862. /**
  67863. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  67864. */
  67865. hoverPosition: BABYLON.Vector3;
  67866. private _albedoTexture;
  67867. /** Gets or sets the texture to use for albedo color */
  67868. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67869. /**
  67870. * Creates a new Fluent material
  67871. * @param name defines the name of the material
  67872. * @param scene defines the hosting scene
  67873. */
  67874. constructor(name: string, scene: BABYLON.Scene);
  67875. needAlphaBlending(): boolean;
  67876. needAlphaTesting(): boolean;
  67877. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67878. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67879. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67880. getActiveTextures(): BABYLON.BaseTexture[];
  67881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67882. dispose(forceDisposeEffect?: boolean): void;
  67883. clone(name: string): FluentMaterial;
  67884. serialize(): any;
  67885. getClassName(): string;
  67886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  67887. }
  67888. }
  67889. declare module BABYLON.GUI {
  67890. /**
  67891. * Class used to create a holographic button in 3D
  67892. */
  67893. export class HolographicButton extends Button3D {
  67894. private _backPlate;
  67895. private _textPlate;
  67896. private _frontPlate;
  67897. private _text;
  67898. private _imageUrl;
  67899. private _shareMaterials;
  67900. private _frontMaterial;
  67901. private _backMaterial;
  67902. private _plateMaterial;
  67903. private _pickedPointObserver;
  67904. private _tooltipFade;
  67905. private _tooltipTextBlock;
  67906. private _tooltipTexture;
  67907. private _tooltipMesh;
  67908. private _tooltipHoverObserver;
  67909. private _tooltipOutObserver;
  67910. private _disposeTooltip;
  67911. /**
  67912. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67913. */
  67914. tooltipText: BABYLON.Nullable<string>;
  67915. /**
  67916. * Gets or sets text for the button
  67917. */
  67918. text: string;
  67919. /**
  67920. * Gets or sets the image url for the button
  67921. */
  67922. imageUrl: string;
  67923. /**
  67924. * Gets the back material used by this button
  67925. */
  67926. readonly backMaterial: FluentMaterial;
  67927. /**
  67928. * Gets the front material used by this button
  67929. */
  67930. readonly frontMaterial: FluentMaterial;
  67931. /**
  67932. * Gets the plate material used by this button
  67933. */
  67934. readonly plateMaterial: BABYLON.StandardMaterial;
  67935. /**
  67936. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67937. */
  67938. readonly shareMaterials: boolean;
  67939. /**
  67940. * Creates a new button
  67941. * @param name defines the control name
  67942. */
  67943. constructor(name?: string, shareMaterials?: boolean);
  67944. protected _getTypeName(): string;
  67945. private _rebuildContent;
  67946. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67947. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67948. private _createBackMaterial;
  67949. private _createFrontMaterial;
  67950. private _createPlateMaterial;
  67951. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67952. /**
  67953. * Releases all associated resources
  67954. */
  67955. dispose(): void;
  67956. }
  67957. }
  67958. declare module BABYLON.GUI {
  67959. /**
  67960. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67961. */
  67962. export class MeshButton3D extends Button3D {
  67963. /** @hidden */
  67964. protected _currentMesh: BABYLON.Mesh;
  67965. /**
  67966. * Creates a new 3D button based on a mesh
  67967. * @param mesh mesh to become a 3D button
  67968. * @param name defines the control name
  67969. */
  67970. constructor(mesh: BABYLON.Mesh, name?: string);
  67971. protected _getTypeName(): string;
  67972. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67973. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67974. }
  67975. }
  67976. declare module BABYLON.GUI {
  67977. /**
  67978. * Class used to create a container panel deployed on the surface of a plane
  67979. */
  67980. export class PlanePanel extends VolumeBasedPanel {
  67981. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67982. }
  67983. }
  67984. declare module BABYLON.GUI {
  67985. /**
  67986. * Class used to create a container panel where items get randomized planar mapping
  67987. */
  67988. export class ScatterPanel extends VolumeBasedPanel {
  67989. private _iteration;
  67990. /**
  67991. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67992. */
  67993. iteration: BABYLON.float;
  67994. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67995. private _scatterMapping;
  67996. protected _finalProcessing(): void;
  67997. }
  67998. }
  67999. declare module BABYLON.GUI {
  68000. /**
  68001. * Class used to create a container panel deployed on the surface of a sphere
  68002. */
  68003. export class SpherePanel extends VolumeBasedPanel {
  68004. private _radius;
  68005. /**
  68006. * Gets or sets the radius of the sphere where to project controls (5 by default)
  68007. */
  68008. radius: BABYLON.float;
  68009. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  68010. private _sphericalMapping;
  68011. }
  68012. }
  68013. declare module BABYLON.GUI {
  68014. /**
  68015. * Class used to create a stack panel in 3D on XY plane
  68016. */
  68017. export class StackPanel3D extends Container3D {
  68018. private _isVertical;
  68019. /**
  68020. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  68021. */
  68022. isVertical: boolean;
  68023. /**
  68024. * Gets or sets the distance between elements
  68025. */
  68026. margin: number;
  68027. /**
  68028. * Creates new StackPanel
  68029. * @param isVertical
  68030. */
  68031. constructor(isVertical?: boolean);
  68032. protected _arrangeChildren(): void;
  68033. }
  68034. }
  68035. declare module BABYLON {
  68036. /**
  68037. * Interface for a data buffer
  68038. */
  68039. export interface IDataBuffer {
  68040. /**
  68041. * Reads bytes from the data buffer.
  68042. * @param byteOffset The byte offset to read
  68043. * @param byteLength The byte length to read
  68044. * @returns A promise that resolves when the bytes are read
  68045. */
  68046. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68047. /**
  68048. * The byte length of the buffer.
  68049. */
  68050. readonly byteLength: number;
  68051. }
  68052. /**
  68053. * Utility class for reading from a data buffer
  68054. */
  68055. export class DataReader {
  68056. /**
  68057. * The data buffer associated with this data reader.
  68058. */
  68059. readonly buffer: IDataBuffer;
  68060. /**
  68061. * The current byte offset from the beginning of the data buffer.
  68062. */
  68063. byteOffset: number;
  68064. private _dataView;
  68065. private _dataByteOffset;
  68066. /**
  68067. * Constructor
  68068. * @param buffer The buffer to read
  68069. */
  68070. constructor(buffer: IDataBuffer);
  68071. /**
  68072. * Loads the given byte length.
  68073. * @param byteLength The byte length to load
  68074. * @returns A promise that resolves when the load is complete
  68075. */
  68076. loadAsync(byteLength: number): Promise<void>;
  68077. /**
  68078. * Read a unsigned 32-bit integer from the currently loaded data range.
  68079. * @returns The 32-bit integer read
  68080. */
  68081. readUint32(): number;
  68082. /**
  68083. * Read a byte array from the currently loaded data range.
  68084. * @param byteLength The byte length to read
  68085. * @returns The byte array read
  68086. */
  68087. readUint8Array(byteLength: number): Uint8Array;
  68088. /**
  68089. * Read a string from the currently loaded data range.
  68090. * @param byteLength The byte length to read
  68091. * @returns The string read
  68092. */
  68093. readString(byteLength: number): string;
  68094. /**
  68095. * Skips the given byte length the currently loaded data range.
  68096. * @param byteLength The byte length to skip
  68097. */
  68098. skipBytes(byteLength: number): void;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /**
  68103. * Mode that determines the coordinate system to use.
  68104. */
  68105. export enum GLTFLoaderCoordinateSystemMode {
  68106. /**
  68107. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  68108. */
  68109. AUTO = 0,
  68110. /**
  68111. * Sets the useRightHandedSystem flag on the scene.
  68112. */
  68113. FORCE_RIGHT_HANDED = 1
  68114. }
  68115. /**
  68116. * Mode that determines what animations will start.
  68117. */
  68118. export enum GLTFLoaderAnimationStartMode {
  68119. /**
  68120. * No animation will start.
  68121. */
  68122. NONE = 0,
  68123. /**
  68124. * The first animation will start.
  68125. */
  68126. FIRST = 1,
  68127. /**
  68128. * All animations will start.
  68129. */
  68130. ALL = 2
  68131. }
  68132. /**
  68133. * Interface that contains the data for the glTF asset.
  68134. */
  68135. export interface IGLTFLoaderData {
  68136. /**
  68137. * The object that represents the glTF JSON.
  68138. */
  68139. json: Object;
  68140. /**
  68141. * The BIN chunk of a binary glTF.
  68142. */
  68143. bin: Nullable<IDataBuffer>;
  68144. }
  68145. /**
  68146. * Interface for extending the loader.
  68147. */
  68148. export interface IGLTFLoaderExtension {
  68149. /**
  68150. * The name of this extension.
  68151. */
  68152. readonly name: string;
  68153. /**
  68154. * Defines whether this extension is enabled.
  68155. */
  68156. enabled: boolean;
  68157. }
  68158. /**
  68159. * Loader state.
  68160. */
  68161. export enum GLTFLoaderState {
  68162. /**
  68163. * The asset is loading.
  68164. */
  68165. LOADING = 0,
  68166. /**
  68167. * The asset is ready for rendering.
  68168. */
  68169. READY = 1,
  68170. /**
  68171. * The asset is completely loaded.
  68172. */
  68173. COMPLETE = 2
  68174. }
  68175. /** @hidden */
  68176. export interface IGLTFLoader extends IDisposable {
  68177. readonly state: Nullable<GLTFLoaderState>;
  68178. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  68179. meshes: AbstractMesh[];
  68180. particleSystems: IParticleSystem[];
  68181. skeletons: Skeleton[];
  68182. animationGroups: AnimationGroup[];
  68183. }>;
  68184. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  68185. }
  68186. /**
  68187. * File loader for loading glTF files into a scene.
  68188. */
  68189. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68190. /** @hidden */
  68191. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68192. /** @hidden */
  68193. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  68194. /**
  68195. * Raised when the asset has been parsed
  68196. */
  68197. onParsedObservable: Observable<IGLTFLoaderData>;
  68198. private _onParsedObserver;
  68199. /**
  68200. * Raised when the asset has been parsed
  68201. */
  68202. onParsed: (loaderData: IGLTFLoaderData) => void;
  68203. /**
  68204. * 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.
  68205. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  68206. * Defaults to true.
  68207. * @hidden
  68208. */
  68209. static IncrementalLoading: boolean;
  68210. /**
  68211. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  68212. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  68213. * @hidden
  68214. */
  68215. static HomogeneousCoordinates: boolean;
  68216. /**
  68217. * The coordinate system mode. Defaults to AUTO.
  68218. */
  68219. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  68220. /**
  68221. * The animation start mode. Defaults to FIRST.
  68222. */
  68223. animationStartMode: GLTFLoaderAnimationStartMode;
  68224. /**
  68225. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  68226. */
  68227. compileMaterials: boolean;
  68228. /**
  68229. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  68230. */
  68231. useClipPlane: boolean;
  68232. /**
  68233. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  68234. */
  68235. compileShadowGenerators: boolean;
  68236. /**
  68237. * Defines if the Alpha blended materials are only applied as coverage.
  68238. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  68239. * If true, no extra effects are applied to transparent pixels.
  68240. */
  68241. transparencyAsCoverage: boolean;
  68242. /**
  68243. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  68244. * Enabling will disable offline support and glTF validator.
  68245. * Defaults to false.
  68246. */
  68247. useRangeRequests: boolean;
  68248. /**
  68249. * Function called before loading a url referenced by the asset.
  68250. */
  68251. preprocessUrlAsync: (url: string) => Promise<string>;
  68252. /**
  68253. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68254. */
  68255. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  68256. private _onMeshLoadedObserver;
  68257. /**
  68258. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  68259. */
  68260. onMeshLoaded: (mesh: AbstractMesh) => void;
  68261. /**
  68262. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  68263. */
  68264. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  68265. private _onTextureLoadedObserver;
  68266. /**
  68267. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  68268. */
  68269. onTextureLoaded: (texture: BaseTexture) => void;
  68270. /**
  68271. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  68272. */
  68273. readonly onMaterialLoadedObservable: Observable<Material>;
  68274. private _onMaterialLoadedObserver;
  68275. /**
  68276. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  68277. */
  68278. onMaterialLoaded: (material: Material) => void;
  68279. /**
  68280. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  68281. */
  68282. readonly onCameraLoadedObservable: Observable<Camera>;
  68283. private _onCameraLoadedObserver;
  68284. /**
  68285. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  68286. */
  68287. onCameraLoaded: (camera: Camera) => void;
  68288. /**
  68289. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  68290. * For assets with LODs, raised when all of the LODs are complete.
  68291. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68292. */
  68293. readonly onCompleteObservable: Observable<void>;
  68294. private _onCompleteObserver;
  68295. /**
  68296. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  68297. * For assets with LODs, raised when all of the LODs are complete.
  68298. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  68299. */
  68300. onComplete: () => void;
  68301. /**
  68302. * Observable raised when an error occurs.
  68303. */
  68304. readonly onErrorObservable: Observable<any>;
  68305. private _onErrorObserver;
  68306. /**
  68307. * Callback raised when an error occurs.
  68308. */
  68309. onError: (reason: any) => void;
  68310. /**
  68311. * Observable raised after the loader is disposed.
  68312. */
  68313. readonly onDisposeObservable: Observable<void>;
  68314. private _onDisposeObserver;
  68315. /**
  68316. * Callback raised after the loader is disposed.
  68317. */
  68318. onDispose: () => void;
  68319. /**
  68320. * Observable raised after a loader extension is created.
  68321. * Set additional options for a loader extension in this event.
  68322. */
  68323. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  68324. private _onExtensionLoadedObserver;
  68325. /**
  68326. * Callback raised after a loader extension is created.
  68327. */
  68328. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  68329. /**
  68330. * Defines if the loader logging is enabled.
  68331. */
  68332. loggingEnabled: boolean;
  68333. /**
  68334. * Defines if the loader should capture performance counters.
  68335. */
  68336. capturePerformanceCounters: boolean;
  68337. /**
  68338. * Defines if the loader should validate the asset.
  68339. */
  68340. validate: boolean;
  68341. /**
  68342. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  68343. */
  68344. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  68345. private _onValidatedObserver;
  68346. /**
  68347. * Callback raised after a loader extension is created.
  68348. */
  68349. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  68350. private _loader;
  68351. /**
  68352. * Name of the loader ("gltf")
  68353. */
  68354. name: string;
  68355. /**
  68356. * Supported file extensions of the loader (.gltf, .glb)
  68357. */
  68358. extensions: ISceneLoaderPluginExtensions;
  68359. /**
  68360. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  68361. */
  68362. dispose(): void;
  68363. /** @hidden */
  68364. _clear(): void;
  68365. /**
  68366. * The callback called when loading from a url.
  68367. * @param scene scene loading this url
  68368. * @param url url to load
  68369. * @param onSuccess callback called when the file successfully loads
  68370. * @param onProgress callback called while file is loading (if the server supports this mode)
  68371. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68372. * @param onError callback called when the file fails to load
  68373. * @returns a file request object
  68374. */
  68375. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68376. /**
  68377. * The callback called when loading from a file object.
  68378. * @param scene scene loading this file
  68379. * @param file defines the file to load
  68380. * @param onSuccess defines the callback to call when data is loaded
  68381. * @param onProgress defines the callback to call during loading process
  68382. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68383. * @param onError defines the callback to call when an error occurs
  68384. * @returns a file request object
  68385. */
  68386. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  68387. /**
  68388. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  68389. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68390. * @param scene the scene the meshes should be added to
  68391. * @param data the glTF data to load
  68392. * @param rootUrl root url to load from
  68393. * @param onProgress event that fires when loading progress has occured
  68394. * @param fileName Defines the name of the file to load
  68395. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68396. */
  68397. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68398. meshes: AbstractMesh[];
  68399. particleSystems: IParticleSystem[];
  68400. skeletons: Skeleton[];
  68401. animationGroups: AnimationGroup[];
  68402. }>;
  68403. /**
  68404. * Imports all objects from the loaded glTF data and adds them to the scene
  68405. * @param scene the scene the objects should be added to
  68406. * @param data the glTF data to load
  68407. * @param rootUrl root url to load from
  68408. * @param onProgress event that fires when loading progress has occured
  68409. * @param fileName Defines the name of the file to load
  68410. * @returns a promise which completes when objects have been loaded to the scene
  68411. */
  68412. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68413. /**
  68414. * Load into an asset container.
  68415. * @param scene The scene to load into
  68416. * @param data The data to import
  68417. * @param rootUrl The root url for scene and resources
  68418. * @param onProgress The callback when the load progresses
  68419. * @param fileName Defines the name of the file to load
  68420. * @returns The loaded asset container
  68421. */
  68422. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68423. /**
  68424. * The callback that returns true if the data can be directly loaded.
  68425. * @param data string containing the file data
  68426. * @returns if the data can be loaded directly
  68427. */
  68428. canDirectLoad(data: string): boolean;
  68429. /**
  68430. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  68431. * @param scene scene loading this data
  68432. * @param data string containing the data
  68433. * @returns data to pass to the plugin
  68434. */
  68435. directLoad(scene: Scene, data: string): any;
  68436. /**
  68437. * The callback that allows custom handling of the root url based on the response url.
  68438. * @param rootUrl the original root url
  68439. * @param responseURL the response url if available
  68440. * @returns the new root url
  68441. */
  68442. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  68443. /**
  68444. * Instantiates a glTF file loader plugin.
  68445. * @returns the created plugin
  68446. */
  68447. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  68448. /**
  68449. * The loader state or null if the loader is not active.
  68450. */
  68451. readonly loaderState: Nullable<GLTFLoaderState>;
  68452. /**
  68453. * Returns a promise that resolves when the asset is completely loaded.
  68454. * @returns a promise that resolves when the asset is completely loaded.
  68455. */
  68456. whenCompleteAsync(): Promise<void>;
  68457. private _validateAsync;
  68458. private _getLoader;
  68459. private _parseJson;
  68460. private _unpackBinaryAsync;
  68461. private _unpackBinaryV1Async;
  68462. private _unpackBinaryV2Async;
  68463. private static _parseVersion;
  68464. private static _compareVersion;
  68465. private static readonly _logSpaces;
  68466. private _logIndentLevel;
  68467. private _loggingEnabled;
  68468. /** @hidden */
  68469. _log: (message: string) => void;
  68470. /** @hidden */
  68471. _logOpen(message: string): void;
  68472. /** @hidden */
  68473. _logClose(): void;
  68474. private _logEnabled;
  68475. private _logDisabled;
  68476. private _capturePerformanceCounters;
  68477. /** @hidden */
  68478. _startPerformanceCounter: (counterName: string) => void;
  68479. /** @hidden */
  68480. _endPerformanceCounter: (counterName: string) => void;
  68481. private _startPerformanceCounterEnabled;
  68482. private _startPerformanceCounterDisabled;
  68483. private _endPerformanceCounterEnabled;
  68484. private _endPerformanceCounterDisabled;
  68485. }
  68486. }
  68487. declare module BABYLON.GLTF1 {
  68488. /**
  68489. * Enums
  68490. * @hidden
  68491. */
  68492. export enum EComponentType {
  68493. BYTE = 5120,
  68494. UNSIGNED_BYTE = 5121,
  68495. SHORT = 5122,
  68496. UNSIGNED_SHORT = 5123,
  68497. FLOAT = 5126
  68498. }
  68499. /** @hidden */
  68500. export enum EShaderType {
  68501. FRAGMENT = 35632,
  68502. VERTEX = 35633
  68503. }
  68504. /** @hidden */
  68505. export enum EParameterType {
  68506. BYTE = 5120,
  68507. UNSIGNED_BYTE = 5121,
  68508. SHORT = 5122,
  68509. UNSIGNED_SHORT = 5123,
  68510. INT = 5124,
  68511. UNSIGNED_INT = 5125,
  68512. FLOAT = 5126,
  68513. FLOAT_VEC2 = 35664,
  68514. FLOAT_VEC3 = 35665,
  68515. FLOAT_VEC4 = 35666,
  68516. INT_VEC2 = 35667,
  68517. INT_VEC3 = 35668,
  68518. INT_VEC4 = 35669,
  68519. BOOL = 35670,
  68520. BOOL_VEC2 = 35671,
  68521. BOOL_VEC3 = 35672,
  68522. BOOL_VEC4 = 35673,
  68523. FLOAT_MAT2 = 35674,
  68524. FLOAT_MAT3 = 35675,
  68525. FLOAT_MAT4 = 35676,
  68526. SAMPLER_2D = 35678
  68527. }
  68528. /** @hidden */
  68529. export enum ETextureWrapMode {
  68530. CLAMP_TO_EDGE = 33071,
  68531. MIRRORED_REPEAT = 33648,
  68532. REPEAT = 10497
  68533. }
  68534. /** @hidden */
  68535. export enum ETextureFilterType {
  68536. NEAREST = 9728,
  68537. LINEAR = 9728,
  68538. NEAREST_MIPMAP_NEAREST = 9984,
  68539. LINEAR_MIPMAP_NEAREST = 9985,
  68540. NEAREST_MIPMAP_LINEAR = 9986,
  68541. LINEAR_MIPMAP_LINEAR = 9987
  68542. }
  68543. /** @hidden */
  68544. export enum ETextureFormat {
  68545. ALPHA = 6406,
  68546. RGB = 6407,
  68547. RGBA = 6408,
  68548. LUMINANCE = 6409,
  68549. LUMINANCE_ALPHA = 6410
  68550. }
  68551. /** @hidden */
  68552. export enum ECullingType {
  68553. FRONT = 1028,
  68554. BACK = 1029,
  68555. FRONT_AND_BACK = 1032
  68556. }
  68557. /** @hidden */
  68558. export enum EBlendingFunction {
  68559. ZERO = 0,
  68560. ONE = 1,
  68561. SRC_COLOR = 768,
  68562. ONE_MINUS_SRC_COLOR = 769,
  68563. DST_COLOR = 774,
  68564. ONE_MINUS_DST_COLOR = 775,
  68565. SRC_ALPHA = 770,
  68566. ONE_MINUS_SRC_ALPHA = 771,
  68567. DST_ALPHA = 772,
  68568. ONE_MINUS_DST_ALPHA = 773,
  68569. CONSTANT_COLOR = 32769,
  68570. ONE_MINUS_CONSTANT_COLOR = 32770,
  68571. CONSTANT_ALPHA = 32771,
  68572. ONE_MINUS_CONSTANT_ALPHA = 32772,
  68573. SRC_ALPHA_SATURATE = 776
  68574. }
  68575. /** @hidden */
  68576. export interface IGLTFProperty {
  68577. extensions?: {
  68578. [key: string]: any;
  68579. };
  68580. extras?: Object;
  68581. }
  68582. /** @hidden */
  68583. export interface IGLTFChildRootProperty extends IGLTFProperty {
  68584. name?: string;
  68585. }
  68586. /** @hidden */
  68587. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  68588. bufferView: string;
  68589. byteOffset: number;
  68590. byteStride: number;
  68591. count: number;
  68592. type: string;
  68593. componentType: EComponentType;
  68594. max?: number[];
  68595. min?: number[];
  68596. name?: string;
  68597. }
  68598. /** @hidden */
  68599. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  68600. buffer: string;
  68601. byteOffset: number;
  68602. byteLength: number;
  68603. byteStride: number;
  68604. target?: number;
  68605. }
  68606. /** @hidden */
  68607. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  68608. uri: string;
  68609. byteLength?: number;
  68610. type?: string;
  68611. }
  68612. /** @hidden */
  68613. export interface IGLTFShader extends IGLTFChildRootProperty {
  68614. uri: string;
  68615. type: EShaderType;
  68616. }
  68617. /** @hidden */
  68618. export interface IGLTFProgram extends IGLTFChildRootProperty {
  68619. attributes: string[];
  68620. fragmentShader: string;
  68621. vertexShader: string;
  68622. }
  68623. /** @hidden */
  68624. export interface IGLTFTechniqueParameter {
  68625. type: number;
  68626. count?: number;
  68627. semantic?: string;
  68628. node?: string;
  68629. value?: number | boolean | string | Array<any>;
  68630. source?: string;
  68631. babylonValue?: any;
  68632. }
  68633. /** @hidden */
  68634. export interface IGLTFTechniqueCommonProfile {
  68635. lightingModel: string;
  68636. texcoordBindings: Object;
  68637. parameters?: Array<any>;
  68638. }
  68639. /** @hidden */
  68640. export interface IGLTFTechniqueStatesFunctions {
  68641. blendColor?: number[];
  68642. blendEquationSeparate?: number[];
  68643. blendFuncSeparate?: number[];
  68644. colorMask: boolean[];
  68645. cullFace: number[];
  68646. }
  68647. /** @hidden */
  68648. export interface IGLTFTechniqueStates {
  68649. enable: number[];
  68650. functions: IGLTFTechniqueStatesFunctions;
  68651. }
  68652. /** @hidden */
  68653. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  68654. parameters: {
  68655. [key: string]: IGLTFTechniqueParameter;
  68656. };
  68657. program: string;
  68658. attributes: {
  68659. [key: string]: string;
  68660. };
  68661. uniforms: {
  68662. [key: string]: string;
  68663. };
  68664. states: IGLTFTechniqueStates;
  68665. }
  68666. /** @hidden */
  68667. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  68668. technique?: string;
  68669. values: string[];
  68670. }
  68671. /** @hidden */
  68672. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  68673. attributes: {
  68674. [key: string]: string;
  68675. };
  68676. indices: string;
  68677. material: string;
  68678. mode?: number;
  68679. }
  68680. /** @hidden */
  68681. export interface IGLTFMesh extends IGLTFChildRootProperty {
  68682. primitives: IGLTFMeshPrimitive[];
  68683. }
  68684. /** @hidden */
  68685. export interface IGLTFImage extends IGLTFChildRootProperty {
  68686. uri: string;
  68687. }
  68688. /** @hidden */
  68689. export interface IGLTFSampler extends IGLTFChildRootProperty {
  68690. magFilter?: number;
  68691. minFilter?: number;
  68692. wrapS?: number;
  68693. wrapT?: number;
  68694. }
  68695. /** @hidden */
  68696. export interface IGLTFTexture extends IGLTFChildRootProperty {
  68697. sampler: string;
  68698. source: string;
  68699. format?: ETextureFormat;
  68700. internalFormat?: ETextureFormat;
  68701. target?: number;
  68702. type?: number;
  68703. babylonTexture?: Texture;
  68704. }
  68705. /** @hidden */
  68706. export interface IGLTFAmbienLight {
  68707. color?: number[];
  68708. }
  68709. /** @hidden */
  68710. export interface IGLTFDirectionalLight {
  68711. color?: number[];
  68712. }
  68713. /** @hidden */
  68714. export interface IGLTFPointLight {
  68715. color?: number[];
  68716. constantAttenuation?: number;
  68717. linearAttenuation?: number;
  68718. quadraticAttenuation?: number;
  68719. }
  68720. /** @hidden */
  68721. export interface IGLTFSpotLight {
  68722. color?: number[];
  68723. constantAttenuation?: number;
  68724. fallOfAngle?: number;
  68725. fallOffExponent?: number;
  68726. linearAttenuation?: number;
  68727. quadraticAttenuation?: number;
  68728. }
  68729. /** @hidden */
  68730. export interface IGLTFLight extends IGLTFChildRootProperty {
  68731. type: string;
  68732. }
  68733. /** @hidden */
  68734. export interface IGLTFCameraOrthographic {
  68735. xmag: number;
  68736. ymag: number;
  68737. zfar: number;
  68738. znear: number;
  68739. }
  68740. /** @hidden */
  68741. export interface IGLTFCameraPerspective {
  68742. aspectRatio: number;
  68743. yfov: number;
  68744. zfar: number;
  68745. znear: number;
  68746. }
  68747. /** @hidden */
  68748. export interface IGLTFCamera extends IGLTFChildRootProperty {
  68749. type: string;
  68750. }
  68751. /** @hidden */
  68752. export interface IGLTFAnimationChannelTarget {
  68753. id: string;
  68754. path: string;
  68755. }
  68756. /** @hidden */
  68757. export interface IGLTFAnimationChannel {
  68758. sampler: string;
  68759. target: IGLTFAnimationChannelTarget;
  68760. }
  68761. /** @hidden */
  68762. export interface IGLTFAnimationSampler {
  68763. input: string;
  68764. output: string;
  68765. interpolation?: string;
  68766. }
  68767. /** @hidden */
  68768. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  68769. channels?: IGLTFAnimationChannel[];
  68770. parameters?: {
  68771. [key: string]: string;
  68772. };
  68773. samplers?: {
  68774. [key: string]: IGLTFAnimationSampler;
  68775. };
  68776. }
  68777. /** @hidden */
  68778. export interface IGLTFNodeInstanceSkin {
  68779. skeletons: string[];
  68780. skin: string;
  68781. meshes: string[];
  68782. }
  68783. /** @hidden */
  68784. export interface IGLTFSkins extends IGLTFChildRootProperty {
  68785. bindShapeMatrix: number[];
  68786. inverseBindMatrices: string;
  68787. jointNames: string[];
  68788. babylonSkeleton?: Skeleton;
  68789. }
  68790. /** @hidden */
  68791. export interface IGLTFNode extends IGLTFChildRootProperty {
  68792. camera?: string;
  68793. children: string[];
  68794. skin?: string;
  68795. jointName?: string;
  68796. light?: string;
  68797. matrix: number[];
  68798. mesh?: string;
  68799. meshes?: string[];
  68800. rotation?: number[];
  68801. scale?: number[];
  68802. translation?: number[];
  68803. babylonNode?: Node;
  68804. }
  68805. /** @hidden */
  68806. export interface IGLTFScene extends IGLTFChildRootProperty {
  68807. nodes: string[];
  68808. }
  68809. /** @hidden */
  68810. export interface IGLTFRuntime {
  68811. extensions: {
  68812. [key: string]: any;
  68813. };
  68814. accessors: {
  68815. [key: string]: IGLTFAccessor;
  68816. };
  68817. buffers: {
  68818. [key: string]: IGLTFBuffer;
  68819. };
  68820. bufferViews: {
  68821. [key: string]: IGLTFBufferView;
  68822. };
  68823. meshes: {
  68824. [key: string]: IGLTFMesh;
  68825. };
  68826. lights: {
  68827. [key: string]: IGLTFLight;
  68828. };
  68829. cameras: {
  68830. [key: string]: IGLTFCamera;
  68831. };
  68832. nodes: {
  68833. [key: string]: IGLTFNode;
  68834. };
  68835. images: {
  68836. [key: string]: IGLTFImage;
  68837. };
  68838. textures: {
  68839. [key: string]: IGLTFTexture;
  68840. };
  68841. shaders: {
  68842. [key: string]: IGLTFShader;
  68843. };
  68844. programs: {
  68845. [key: string]: IGLTFProgram;
  68846. };
  68847. samplers: {
  68848. [key: string]: IGLTFSampler;
  68849. };
  68850. techniques: {
  68851. [key: string]: IGLTFTechnique;
  68852. };
  68853. materials: {
  68854. [key: string]: IGLTFMaterial;
  68855. };
  68856. animations: {
  68857. [key: string]: IGLTFAnimation;
  68858. };
  68859. skins: {
  68860. [key: string]: IGLTFSkins;
  68861. };
  68862. currentScene?: Object;
  68863. scenes: {
  68864. [key: string]: IGLTFScene;
  68865. };
  68866. extensionsUsed: string[];
  68867. extensionsRequired?: string[];
  68868. buffersCount: number;
  68869. shaderscount: number;
  68870. scene: Scene;
  68871. rootUrl: string;
  68872. loadedBufferCount: number;
  68873. loadedBufferViews: {
  68874. [name: string]: ArrayBufferView;
  68875. };
  68876. loadedShaderCount: number;
  68877. importOnlyMeshes: boolean;
  68878. importMeshesNames?: string[];
  68879. dummyNodes: Node[];
  68880. }
  68881. /** @hidden */
  68882. export interface INodeToRoot {
  68883. bone: Bone;
  68884. node: IGLTFNode;
  68885. id: string;
  68886. }
  68887. /** @hidden */
  68888. export interface IJointNode {
  68889. node: IGLTFNode;
  68890. id: string;
  68891. }
  68892. }
  68893. declare module BABYLON.GLTF1 {
  68894. /**
  68895. * Utils functions for GLTF
  68896. * @hidden
  68897. */
  68898. export class GLTFUtils {
  68899. /**
  68900. * Sets the given "parameter" matrix
  68901. * @param scene: the Scene object
  68902. * @param source: the source node where to pick the matrix
  68903. * @param parameter: the GLTF technique parameter
  68904. * @param uniformName: the name of the shader's uniform
  68905. * @param shaderMaterial: the shader material
  68906. */
  68907. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  68908. /**
  68909. * Sets the given "parameter" matrix
  68910. * @param shaderMaterial: the shader material
  68911. * @param uniform: the name of the shader's uniform
  68912. * @param value: the value of the uniform
  68913. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  68914. */
  68915. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  68916. /**
  68917. * Returns the wrap mode of the texture
  68918. * @param mode: the mode value
  68919. */
  68920. static GetWrapMode(mode: number): number;
  68921. /**
  68922. * Returns the byte stride giving an accessor
  68923. * @param accessor: the GLTF accessor objet
  68924. */
  68925. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  68926. /**
  68927. * Returns the texture filter mode giving a mode value
  68928. * @param mode: the filter mode value
  68929. */
  68930. static GetTextureFilterMode(mode: number): ETextureFilterType;
  68931. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  68932. /**
  68933. * Returns a buffer from its accessor
  68934. * @param gltfRuntime: the GLTF runtime
  68935. * @param accessor: the GLTF accessor
  68936. */
  68937. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  68938. /**
  68939. * Decodes a buffer view into a string
  68940. * @param view: the buffer view
  68941. */
  68942. static DecodeBufferToText(view: ArrayBufferView): string;
  68943. /**
  68944. * Returns the default material of gltf. Related to
  68945. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  68946. * @param scene: the Babylon.js scene
  68947. */
  68948. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  68949. private static _DefaultMaterial;
  68950. }
  68951. }
  68952. declare module BABYLON.GLTF1 {
  68953. /**
  68954. * Implementation of the base glTF spec
  68955. * @hidden
  68956. */
  68957. export class GLTFLoaderBase {
  68958. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  68959. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68960. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  68961. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68962. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  68963. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68964. }
  68965. /**
  68966. * glTF V1 Loader
  68967. * @hidden
  68968. */
  68969. export class GLTFLoader implements IGLTFLoader {
  68970. static Extensions: {
  68971. [name: string]: GLTFLoaderExtension;
  68972. };
  68973. static RegisterExtension(extension: GLTFLoaderExtension): void;
  68974. state: Nullable<GLTFLoaderState>;
  68975. dispose(): void;
  68976. private _importMeshAsync;
  68977. /**
  68978. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  68979. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68980. * @param scene the scene the meshes should be added to
  68981. * @param data gltf data containing information of the meshes in a loaded file
  68982. * @param rootUrl root url to load from
  68983. * @param onProgress event that fires when loading progress has occured
  68984. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68985. */
  68986. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  68987. meshes: AbstractMesh[];
  68988. particleSystems: IParticleSystem[];
  68989. skeletons: Skeleton[];
  68990. animationGroups: AnimationGroup[];
  68991. }>;
  68992. private _loadAsync;
  68993. /**
  68994. * Imports all objects from a loaded gltf file and adds them to the scene
  68995. * @param scene the scene the objects should be added to
  68996. * @param data gltf data containing information of the meshes in a loaded file
  68997. * @param rootUrl root url to load from
  68998. * @param onProgress event that fires when loading progress has occured
  68999. * @returns a promise which completes when objects have been loaded to the scene
  69000. */
  69001. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  69002. private _loadShadersAsync;
  69003. private _loadBuffersAsync;
  69004. private _createNodes;
  69005. }
  69006. /** @hidden */
  69007. export abstract class GLTFLoaderExtension {
  69008. private _name;
  69009. constructor(name: string);
  69010. readonly name: string;
  69011. /**
  69012. * Defines an override for loading the runtime
  69013. * Return true to stop further extensions from loading the runtime
  69014. */
  69015. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  69016. /**
  69017. * Defines an onverride for creating gltf runtime
  69018. * Return true to stop further extensions from creating the runtime
  69019. */
  69020. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  69021. /**
  69022. * Defines an override for loading buffers
  69023. * Return true to stop further extensions from loading this buffer
  69024. */
  69025. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  69026. /**
  69027. * Defines an override for loading texture buffers
  69028. * Return true to stop further extensions from loading this texture data
  69029. */
  69030. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69031. /**
  69032. * Defines an override for creating textures
  69033. * Return true to stop further extensions from loading this texture
  69034. */
  69035. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  69036. /**
  69037. * Defines an override for loading shader strings
  69038. * Return true to stop further extensions from loading this shader data
  69039. */
  69040. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69041. /**
  69042. * Defines an override for loading materials
  69043. * Return true to stop further extensions from loading this material
  69044. */
  69045. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69046. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  69047. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  69048. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  69049. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  69050. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  69051. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  69052. private static LoadTextureBufferAsync;
  69053. private static CreateTextureAsync;
  69054. private static ApplyExtensions;
  69055. }
  69056. }
  69057. declare module BABYLON.GLTF1 {
  69058. /** @hidden */
  69059. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  69060. private _bin;
  69061. constructor();
  69062. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  69063. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69064. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  69065. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  69066. }
  69067. }
  69068. declare module BABYLON.GLTF1 {
  69069. /** @hidden */
  69070. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  69071. constructor();
  69072. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  69073. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  69074. private _loadTexture;
  69075. }
  69076. }
  69077. declare module BABYLON.GLTF2.Loader {
  69078. /**
  69079. * Loader interface with an index field.
  69080. */
  69081. export interface IArrayItem {
  69082. /**
  69083. * The index of this item in the array.
  69084. */
  69085. index: number;
  69086. }
  69087. /**
  69088. * Loader interface with additional members.
  69089. */
  69090. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  69091. /** @hidden */
  69092. _data?: Promise<ArrayBufferView>;
  69093. /** @hidden */
  69094. _babylonVertexBuffer?: Promise<VertexBuffer>;
  69095. }
  69096. /**
  69097. * Loader interface with additional members.
  69098. */
  69099. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  69100. }
  69101. /** @hidden */
  69102. export interface _IAnimationSamplerData {
  69103. input: Float32Array;
  69104. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  69105. output: Float32Array;
  69106. }
  69107. /**
  69108. * Loader interface with additional members.
  69109. */
  69110. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  69111. /** @hidden */
  69112. _data?: Promise<_IAnimationSamplerData>;
  69113. }
  69114. /**
  69115. * Loader interface with additional members.
  69116. */
  69117. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  69118. channels: IAnimationChannel[];
  69119. samplers: IAnimationSampler[];
  69120. /** @hidden */
  69121. _babylonAnimationGroup?: AnimationGroup;
  69122. }
  69123. /**
  69124. * Loader interface with additional members.
  69125. */
  69126. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  69127. /** @hidden */
  69128. _data?: Promise<ArrayBufferView>;
  69129. }
  69130. /**
  69131. * Loader interface with additional members.
  69132. */
  69133. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  69134. /** @hidden */
  69135. _data?: Promise<ArrayBufferView>;
  69136. /** @hidden */
  69137. _babylonBuffer?: Promise<Buffer>;
  69138. }
  69139. /**
  69140. * Loader interface with additional members.
  69141. */
  69142. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  69143. }
  69144. /**
  69145. * Loader interface with additional members.
  69146. */
  69147. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  69148. /** @hidden */
  69149. _data?: Promise<ArrayBufferView>;
  69150. }
  69151. /**
  69152. * Loader interface with additional members.
  69153. */
  69154. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  69155. }
  69156. /**
  69157. * Loader interface with additional members.
  69158. */
  69159. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  69160. }
  69161. /**
  69162. * Loader interface with additional members.
  69163. */
  69164. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  69165. baseColorTexture?: ITextureInfo;
  69166. metallicRoughnessTexture?: ITextureInfo;
  69167. }
  69168. /**
  69169. * Loader interface with additional members.
  69170. */
  69171. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  69172. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  69173. normalTexture?: IMaterialNormalTextureInfo;
  69174. occlusionTexture?: IMaterialOcclusionTextureInfo;
  69175. emissiveTexture?: ITextureInfo;
  69176. /** @hidden */
  69177. _data?: {
  69178. [babylonDrawMode: number]: {
  69179. babylonMaterial: Material;
  69180. babylonMeshes: AbstractMesh[];
  69181. promise: Promise<void>;
  69182. };
  69183. };
  69184. }
  69185. /**
  69186. * Loader interface with additional members.
  69187. */
  69188. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  69189. primitives: IMeshPrimitive[];
  69190. }
  69191. /**
  69192. * Loader interface with additional members.
  69193. */
  69194. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  69195. /** @hidden */
  69196. _instanceData?: {
  69197. babylonSourceMesh: Mesh;
  69198. promise: Promise<any>;
  69199. };
  69200. }
  69201. /**
  69202. * Loader interface with additional members.
  69203. */
  69204. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  69205. /**
  69206. * The parent glTF node.
  69207. */
  69208. parent?: INode;
  69209. /** @hidden */
  69210. _babylonTransformNode?: TransformNode;
  69211. /** @hidden */
  69212. _primitiveBabylonMeshes?: AbstractMesh[];
  69213. /** @hidden */
  69214. _babylonBones?: Bone[];
  69215. /** @hidden */
  69216. _numMorphTargets?: number;
  69217. }
  69218. /** @hidden */
  69219. export interface _ISamplerData {
  69220. noMipMaps: boolean;
  69221. samplingMode: number;
  69222. wrapU: number;
  69223. wrapV: number;
  69224. }
  69225. /**
  69226. * Loader interface with additional members.
  69227. */
  69228. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  69229. /** @hidden */
  69230. _data?: _ISamplerData;
  69231. }
  69232. /**
  69233. * Loader interface with additional members.
  69234. */
  69235. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  69236. }
  69237. /**
  69238. * Loader interface with additional members.
  69239. */
  69240. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  69241. /** @hidden */
  69242. _data?: {
  69243. babylonSkeleton: Skeleton;
  69244. promise: Promise<void>;
  69245. };
  69246. }
  69247. /**
  69248. * Loader interface with additional members.
  69249. */
  69250. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  69251. }
  69252. /**
  69253. * Loader interface with additional members.
  69254. */
  69255. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  69256. }
  69257. /**
  69258. * Loader interface with additional members.
  69259. */
  69260. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  69261. accessors?: IAccessor[];
  69262. animations?: IAnimation[];
  69263. buffers?: IBuffer[];
  69264. bufferViews?: IBufferView[];
  69265. cameras?: ICamera[];
  69266. images?: IImage[];
  69267. materials?: IMaterial[];
  69268. meshes?: IMesh[];
  69269. nodes?: INode[];
  69270. samplers?: ISampler[];
  69271. scenes?: IScene[];
  69272. skins?: ISkin[];
  69273. textures?: ITexture[];
  69274. }
  69275. }
  69276. declare module BABYLON.GLTF2 {
  69277. /**
  69278. * Interface for a glTF loader extension.
  69279. */
  69280. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  69281. /**
  69282. * Called after the loader state changes to LOADING.
  69283. */
  69284. onLoading?(): void;
  69285. /**
  69286. * Called after the loader state changes to READY.
  69287. */
  69288. onReady?(): void;
  69289. /**
  69290. * Define this method to modify the default behavior when loading scenes.
  69291. * @param context The context when loading the asset
  69292. * @param scene The glTF scene property
  69293. * @returns A promise that resolves when the load is complete or null if not handled
  69294. */
  69295. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  69296. /**
  69297. * Define this method to modify the default behavior when loading nodes.
  69298. * @param context The context when loading the asset
  69299. * @param node The glTF node property
  69300. * @param assign A function called synchronously after parsing the glTF properties
  69301. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  69302. */
  69303. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69304. /**
  69305. * Define this method to modify the default behavior when loading cameras.
  69306. * @param context The context when loading the asset
  69307. * @param camera The glTF camera property
  69308. * @param assign A function called synchronously after parsing the glTF properties
  69309. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  69310. */
  69311. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69312. /**
  69313. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  69314. * @param context The context when loading the asset
  69315. * @param primitive The glTF mesh primitive property
  69316. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  69317. */
  69318. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69319. /**
  69320. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69321. * @param context The context when loading the asset
  69322. * @param name The mesh name when loading the asset
  69323. * @param node The glTF node when loading the asset
  69324. * @param mesh The glTF mesh when loading the asset
  69325. * @param primitive The glTF mesh primitive property
  69326. * @param assign A function called synchronously after parsing the glTF properties
  69327. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69328. */
  69329. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69330. /**
  69331. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  69332. * @param context The context when loading the asset
  69333. * @param material The glTF material property
  69334. * @param assign A function called synchronously after parsing the glTF properties
  69335. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  69336. */
  69337. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69338. /**
  69339. * Define this method to modify the default behavior when creating materials.
  69340. * @param context The context when loading the asset
  69341. * @param material The glTF material property
  69342. * @param babylonDrawMode The draw mode for the Babylon material
  69343. * @returns The Babylon material or null if not handled
  69344. */
  69345. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69346. /**
  69347. * Define this method to modify the default behavior when loading material properties.
  69348. * @param context The context when loading the asset
  69349. * @param material The glTF material property
  69350. * @param babylonMaterial The Babylon material
  69351. * @returns A promise that resolves when the load is complete or null if not handled
  69352. */
  69353. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69354. /**
  69355. * Define this method to modify the default behavior when loading texture infos.
  69356. * @param context The context when loading the asset
  69357. * @param textureInfo The glTF texture info property
  69358. * @param assign A function called synchronously after parsing the glTF properties
  69359. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  69360. */
  69361. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69362. /**
  69363. * Define this method to modify the default behavior when loading animations.
  69364. * @param context The context when loading the asset
  69365. * @param animation The glTF animation property
  69366. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  69367. */
  69368. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69369. /**
  69370. * @hidden Define this method to modify the default behavior when loading skins.
  69371. * @param context The context when loading the asset
  69372. * @param node The glTF node property
  69373. * @param skin The glTF skin property
  69374. * @returns A promise that resolves when the load is complete or null if not handled
  69375. */
  69376. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  69377. /**
  69378. * @hidden Define this method to modify the default behavior when loading uris.
  69379. * @param context The context when loading the asset
  69380. * @param property The glTF property associated with the uri
  69381. * @param uri The uri to load
  69382. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69383. */
  69384. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69385. /**
  69386. * Define this method to modify the default behavior when loading buffer views.
  69387. * @param context The context when loading the asset
  69388. * @param bufferView The glTF buffer view property
  69389. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69390. */
  69391. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  69392. /**
  69393. * Define this method to modify the default behavior when loading buffers.
  69394. * @param context The context when loading the asset
  69395. * @param buffer The glTF buffer property
  69396. * @param byteOffset The byte offset to load
  69397. * @param byteLength The byte length to load
  69398. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  69399. */
  69400. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69401. }
  69402. }
  69403. declare module BABYLON.GLTF2 {
  69404. /**
  69405. * Helper class for working with arrays when loading the glTF asset
  69406. */
  69407. export class ArrayItem {
  69408. /**
  69409. * Gets an item from the given array.
  69410. * @param context The context when loading the asset
  69411. * @param array The array to get the item from
  69412. * @param index The index to the array
  69413. * @returns The array item
  69414. */
  69415. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  69416. /**
  69417. * Assign an `index` field to each item of the given array.
  69418. * @param array The array of items
  69419. */
  69420. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  69421. }
  69422. /**
  69423. * The glTF 2.0 loader
  69424. */
  69425. export class GLTFLoader implements IGLTFLoader {
  69426. /** @hidden */
  69427. _completePromises: Promise<any>[];
  69428. private _disposed;
  69429. private _parent;
  69430. private _state;
  69431. private _extensions;
  69432. private _rootUrl;
  69433. private _fileName;
  69434. private _uniqueRootUrl;
  69435. private _gltf;
  69436. private _bin;
  69437. private _babylonScene;
  69438. private _rootBabylonMesh;
  69439. private _defaultBabylonMaterialData;
  69440. private _progressCallback?;
  69441. private _requests;
  69442. private static readonly _DefaultSampler;
  69443. private static _ExtensionNames;
  69444. private static _ExtensionFactories;
  69445. /**
  69446. * Registers a loader extension.
  69447. * @param name The name of the loader extension.
  69448. * @param factory The factory function that creates the loader extension.
  69449. */
  69450. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  69451. /**
  69452. * Unregisters a loader extension.
  69453. * @param name The name of the loader extenion.
  69454. * @returns A boolean indicating whether the extension has been unregistered
  69455. */
  69456. static UnregisterExtension(name: string): boolean;
  69457. /**
  69458. * Gets the loader state.
  69459. */
  69460. readonly state: Nullable<GLTFLoaderState>;
  69461. /**
  69462. * The object that represents the glTF JSON.
  69463. */
  69464. readonly gltf: IGLTF;
  69465. /**
  69466. * The BIN chunk of a binary glTF.
  69467. */
  69468. readonly bin: Nullable<IDataBuffer>;
  69469. /**
  69470. * The parent file loader.
  69471. */
  69472. readonly parent: GLTFFileLoader;
  69473. /**
  69474. * The Babylon scene when loading the asset.
  69475. */
  69476. readonly babylonScene: Scene;
  69477. /**
  69478. * The root Babylon mesh when loading the asset.
  69479. */
  69480. readonly rootBabylonMesh: Mesh;
  69481. /** @hidden */
  69482. constructor(parent: GLTFFileLoader);
  69483. /** @hidden */
  69484. dispose(): void;
  69485. /** @hidden */
  69486. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69487. meshes: AbstractMesh[];
  69488. particleSystems: IParticleSystem[];
  69489. skeletons: Skeleton[];
  69490. animationGroups: AnimationGroup[];
  69491. }>;
  69492. /** @hidden */
  69493. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69494. private _loadAsync;
  69495. private _loadData;
  69496. private _setupData;
  69497. private _loadExtensions;
  69498. private _checkExtensions;
  69499. private _setState;
  69500. private _createRootNode;
  69501. /**
  69502. * Loads a glTF scene.
  69503. * @param context The context when loading the asset
  69504. * @param scene The glTF scene property
  69505. * @returns A promise that resolves when the load is complete
  69506. */
  69507. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  69508. private _forEachPrimitive;
  69509. private _getMeshes;
  69510. private _getSkeletons;
  69511. private _getAnimationGroups;
  69512. private _startAnimations;
  69513. /**
  69514. * Loads a glTF node.
  69515. * @param context The context when loading the asset
  69516. * @param node The glTF node property
  69517. * @param assign A function called synchronously after parsing the glTF properties
  69518. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  69519. */
  69520. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  69521. private _loadMeshAsync;
  69522. /**
  69523. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  69524. * @param context The context when loading the asset
  69525. * @param name The mesh name when loading the asset
  69526. * @param node The glTF node when loading the asset
  69527. * @param mesh The glTF mesh when loading the asset
  69528. * @param primitive The glTF mesh primitive property
  69529. * @param assign A function called synchronously after parsing the glTF properties
  69530. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  69531. */
  69532. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  69533. private _loadVertexDataAsync;
  69534. private _createMorphTargets;
  69535. private _loadMorphTargetsAsync;
  69536. private _loadMorphTargetVertexDataAsync;
  69537. private static _LoadTransform;
  69538. private _loadSkinAsync;
  69539. private _loadBones;
  69540. private _loadBone;
  69541. private _loadSkinInverseBindMatricesDataAsync;
  69542. private _updateBoneMatrices;
  69543. private _getNodeMatrix;
  69544. /**
  69545. * Loads a glTF camera.
  69546. * @param context The context when loading the asset
  69547. * @param camera The glTF camera property
  69548. * @param assign A function called synchronously after parsing the glTF properties
  69549. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  69550. */
  69551. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  69552. private _loadAnimationsAsync;
  69553. /**
  69554. * Loads a glTF animation.
  69555. * @param context The context when loading the asset
  69556. * @param animation The glTF animation property
  69557. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  69558. */
  69559. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  69560. /**
  69561. * @hidden Loads a glTF animation channel.
  69562. * @param context The context when loading the asset
  69563. * @param animationContext The context of the animation when loading the asset
  69564. * @param animation The glTF animation property
  69565. * @param channel The glTF animation channel property
  69566. * @param babylonAnimationGroup The babylon animation group property
  69567. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  69568. * @returns A void promise when the channel load is complete
  69569. */
  69570. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  69571. private _loadAnimationSamplerAsync;
  69572. private _loadBufferAsync;
  69573. /**
  69574. * Loads a glTF buffer view.
  69575. * @param context The context when loading the asset
  69576. * @param bufferView The glTF buffer view property
  69577. * @returns A promise that resolves with the loaded data when the load is complete
  69578. */
  69579. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  69580. private _loadAccessorAsync;
  69581. private _loadFloatAccessorAsync;
  69582. private _loadIndicesAccessorAsync;
  69583. private _loadVertexBufferViewAsync;
  69584. private _loadVertexAccessorAsync;
  69585. private _loadMaterialMetallicRoughnessPropertiesAsync;
  69586. /** @hidden */
  69587. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  69588. private _createDefaultMaterial;
  69589. /**
  69590. * Creates a Babylon material from a glTF material.
  69591. * @param context The context when loading the asset
  69592. * @param material The glTF material property
  69593. * @param babylonDrawMode The draw mode for the Babylon material
  69594. * @returns The Babylon material
  69595. */
  69596. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  69597. /**
  69598. * Loads properties from a glTF material into a Babylon material.
  69599. * @param context The context when loading the asset
  69600. * @param material The glTF material property
  69601. * @param babylonMaterial The Babylon material
  69602. * @returns A promise that resolves when the load is complete
  69603. */
  69604. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69605. /**
  69606. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  69607. * @param context The context when loading the asset
  69608. * @param material The glTF material property
  69609. * @param babylonMaterial The Babylon material
  69610. * @returns A promise that resolves when the load is complete
  69611. */
  69612. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  69613. /**
  69614. * Loads the alpha properties from a glTF material into a Babylon material.
  69615. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  69616. * @param context The context when loading the asset
  69617. * @param material The glTF material property
  69618. * @param babylonMaterial The Babylon material
  69619. */
  69620. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  69621. /**
  69622. * Loads a glTF texture info.
  69623. * @param context The context when loading the asset
  69624. * @param textureInfo The glTF texture info property
  69625. * @param assign A function called synchronously after parsing the glTF properties
  69626. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  69627. */
  69628. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  69629. private _loadTextureAsync;
  69630. private _loadSampler;
  69631. /**
  69632. * Loads a glTF image.
  69633. * @param context The context when loading the asset
  69634. * @param image The glTF image property
  69635. * @returns A promise that resolves with the loaded data when the load is complete
  69636. */
  69637. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  69638. /**
  69639. * Loads a glTF uri.
  69640. * @param context The context when loading the asset
  69641. * @param property The glTF property associated with the uri
  69642. * @param uri The base64 or relative uri
  69643. * @returns A promise that resolves with the loaded data when the load is complete
  69644. */
  69645. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  69646. private _onProgress;
  69647. /**
  69648. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  69649. * @param babylonObject the Babylon object with metadata
  69650. * @param pointer the JSON pointer
  69651. */
  69652. static AddPointerMetadata(babylonObject: {
  69653. metadata: any;
  69654. }, pointer: string): void;
  69655. private static _GetTextureWrapMode;
  69656. private static _GetTextureSamplingMode;
  69657. private static _GetTypedArrayConstructor;
  69658. private static _GetTypedArray;
  69659. private static _GetNumComponents;
  69660. private static _ValidateUri;
  69661. private static _GetDrawMode;
  69662. private _compileMaterialsAsync;
  69663. private _compileShadowGeneratorsAsync;
  69664. private _forEachExtensions;
  69665. private _applyExtensions;
  69666. private _extensionsOnLoading;
  69667. private _extensionsOnReady;
  69668. private _extensionsLoadSceneAsync;
  69669. private _extensionsLoadNodeAsync;
  69670. private _extensionsLoadCameraAsync;
  69671. private _extensionsLoadVertexDataAsync;
  69672. private _extensionsLoadMeshPrimitiveAsync;
  69673. private _extensionsLoadMaterialAsync;
  69674. private _extensionsCreateMaterial;
  69675. private _extensionsLoadMaterialPropertiesAsync;
  69676. private _extensionsLoadTextureInfoAsync;
  69677. private _extensionsLoadAnimationAsync;
  69678. private _extensionsLoadSkinAsync;
  69679. private _extensionsLoadUriAsync;
  69680. private _extensionsLoadBufferViewAsync;
  69681. private _extensionsLoadBufferAsync;
  69682. /**
  69683. * Helper method called by a loader extension to load an glTF extension.
  69684. * @param context The context when loading the asset
  69685. * @param property The glTF property to load the extension from
  69686. * @param extensionName The name of the extension to load
  69687. * @param actionAsync The action to run
  69688. * @returns The promise returned by actionAsync or null if the extension does not exist
  69689. */
  69690. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69691. /**
  69692. * Helper method called by a loader extension to load a glTF extra.
  69693. * @param context The context when loading the asset
  69694. * @param property The glTF property to load the extra from
  69695. * @param extensionName The name of the extension to load
  69696. * @param actionAsync The action to run
  69697. * @returns The promise returned by actionAsync or null if the extra does not exist
  69698. */
  69699. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  69700. /**
  69701. * Checks for presence of an extension.
  69702. * @param name The name of the extension to check
  69703. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  69704. */
  69705. isExtensionUsed(name: string): boolean;
  69706. /**
  69707. * Increments the indentation level and logs a message.
  69708. * @param message The message to log
  69709. */
  69710. logOpen(message: string): void;
  69711. /**
  69712. * Decrements the indentation level.
  69713. */
  69714. logClose(): void;
  69715. /**
  69716. * Logs a message
  69717. * @param message The message to log
  69718. */
  69719. log(message: string): void;
  69720. /**
  69721. * Starts a performance counter.
  69722. * @param counterName The name of the performance counter
  69723. */
  69724. startPerformanceCounter(counterName: string): void;
  69725. /**
  69726. * Ends a performance counter.
  69727. * @param counterName The name of the performance counter
  69728. */
  69729. endPerformanceCounter(counterName: string): void;
  69730. }
  69731. }
  69732. declare module BABYLON.GLTF2.Loader.Extensions {
  69733. /**
  69734. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  69735. */
  69736. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  69737. /** The name of this extension. */
  69738. readonly name: string;
  69739. /** Defines whether this extension is enabled. */
  69740. enabled: boolean;
  69741. private _loader;
  69742. private _lights?;
  69743. /** @hidden */
  69744. constructor(loader: GLTFLoader);
  69745. /** @hidden */
  69746. dispose(): void;
  69747. /** @hidden */
  69748. onLoading(): void;
  69749. /** @hidden */
  69750. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69751. private _loadLightAsync;
  69752. }
  69753. }
  69754. declare module BABYLON.GLTF2.Loader.Extensions {
  69755. /**
  69756. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  69757. */
  69758. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  69759. /** The name of this extension. */
  69760. readonly name: string;
  69761. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  69762. dracoCompression?: DracoCompression;
  69763. /** Defines whether this extension is enabled. */
  69764. enabled: boolean;
  69765. private _loader;
  69766. /** @hidden */
  69767. constructor(loader: GLTFLoader);
  69768. /** @hidden */
  69769. dispose(): void;
  69770. /** @hidden */
  69771. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  69772. }
  69773. }
  69774. declare module BABYLON.GLTF2.Loader.Extensions {
  69775. /**
  69776. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69777. */
  69778. export class KHR_lights implements IGLTFLoaderExtension {
  69779. /** The name of this extension. */
  69780. readonly name: string;
  69781. /** Defines whether this extension is enabled. */
  69782. enabled: boolean;
  69783. private _loader;
  69784. private _lights?;
  69785. /** @hidden */
  69786. constructor(loader: GLTFLoader);
  69787. /** @hidden */
  69788. dispose(): void;
  69789. /** @hidden */
  69790. onLoading(): void;
  69791. /** @hidden */
  69792. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69793. }
  69794. }
  69795. declare module BABYLON.GLTF2.Loader.Extensions {
  69796. /**
  69797. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  69798. */
  69799. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  69800. /** The name of this extension. */
  69801. readonly name: string;
  69802. /** Defines whether this extension is enabled. */
  69803. enabled: boolean;
  69804. private _loader;
  69805. /** @hidden */
  69806. constructor(loader: GLTFLoader);
  69807. /** @hidden */
  69808. dispose(): void;
  69809. /** @hidden */
  69810. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69811. private _loadSpecularGlossinessPropertiesAsync;
  69812. }
  69813. }
  69814. declare module BABYLON.GLTF2.Loader.Extensions {
  69815. /**
  69816. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  69817. */
  69818. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  69819. /** The name of this extension. */
  69820. readonly name: string;
  69821. /** Defines whether this extension is enabled. */
  69822. enabled: boolean;
  69823. private _loader;
  69824. /** @hidden */
  69825. constructor(loader: GLTFLoader);
  69826. /** @hidden */
  69827. dispose(): void;
  69828. /** @hidden */
  69829. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69830. private _loadUnlitPropertiesAsync;
  69831. }
  69832. }
  69833. declare module BABYLON.GLTF2.Loader.Extensions {
  69834. /**
  69835. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  69836. */
  69837. export class KHR_texture_transform implements IGLTFLoaderExtension {
  69838. /** The name of this extension. */
  69839. readonly name: string;
  69840. /** Defines whether this extension is enabled. */
  69841. enabled: boolean;
  69842. private _loader;
  69843. /** @hidden */
  69844. constructor(loader: GLTFLoader);
  69845. /** @hidden */
  69846. dispose(): void;
  69847. /** @hidden */
  69848. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  69849. }
  69850. }
  69851. declare module BABYLON.GLTF2.Loader.Extensions {
  69852. /**
  69853. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  69854. */
  69855. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  69856. /** The name of this extension. */
  69857. readonly name: string;
  69858. /** Defines whether this extension is enabled. */
  69859. enabled: boolean;
  69860. private _loader;
  69861. private _clips;
  69862. private _emitters;
  69863. /** @hidden */
  69864. constructor(loader: GLTFLoader);
  69865. /** @hidden */
  69866. dispose(): void;
  69867. /** @hidden */
  69868. onLoading(): void;
  69869. /** @hidden */
  69870. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  69871. /** @hidden */
  69872. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69873. /** @hidden */
  69874. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  69875. private _loadClipAsync;
  69876. private _loadEmitterAsync;
  69877. private _getEventAction;
  69878. private _loadAnimationEventAsync;
  69879. }
  69880. }
  69881. declare module BABYLON.GLTF2.Loader.Extensions {
  69882. /**
  69883. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  69884. */
  69885. export class MSFT_lod implements IGLTFLoaderExtension {
  69886. /** The name of this extension. */
  69887. readonly name: string;
  69888. /** Defines whether this extension is enabled. */
  69889. enabled: boolean;
  69890. /**
  69891. * Maximum number of LODs to load, starting from the lowest LOD.
  69892. */
  69893. maxLODsToLoad: number;
  69894. /**
  69895. * Observable raised when all node LODs of one level are loaded.
  69896. * The event data is the index of the loaded LOD starting from zero.
  69897. * Dispose the loader to cancel the loading of the next level of LODs.
  69898. */
  69899. onNodeLODsLoadedObservable: Observable<number>;
  69900. /**
  69901. * Observable raised when all material LODs of one level are loaded.
  69902. * The event data is the index of the loaded LOD starting from zero.
  69903. * Dispose the loader to cancel the loading of the next level of LODs.
  69904. */
  69905. onMaterialLODsLoadedObservable: Observable<number>;
  69906. private _loader;
  69907. private _nodeIndexLOD;
  69908. private _nodeSignalLODs;
  69909. private _nodePromiseLODs;
  69910. private _materialIndexLOD;
  69911. private _materialSignalLODs;
  69912. private _materialPromiseLODs;
  69913. private _indexLOD;
  69914. private _bufferLODs;
  69915. /** @hidden */
  69916. constructor(loader: GLTFLoader);
  69917. /** @hidden */
  69918. dispose(): void;
  69919. /** @hidden */
  69920. onReady(): void;
  69921. /** @hidden */
  69922. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69923. /** @hidden */
  69924. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  69925. /** @hidden */
  69926. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  69927. /** @hidden */
  69928. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  69929. private _loadBufferLOD;
  69930. /**
  69931. * Gets an array of LOD properties from lowest to highest.
  69932. */
  69933. private _getLODs;
  69934. private _disposeUnusedMaterials;
  69935. }
  69936. }
  69937. declare module BABYLON.GLTF2.Loader.Extensions {
  69938. /** @hidden */
  69939. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  69940. readonly name: string;
  69941. enabled: boolean;
  69942. private _loader;
  69943. constructor(loader: GLTFLoader);
  69944. dispose(): void;
  69945. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69946. }
  69947. }
  69948. declare module BABYLON.GLTF2.Loader.Extensions {
  69949. /** @hidden */
  69950. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  69951. readonly name: string;
  69952. enabled: boolean;
  69953. private _loader;
  69954. constructor(loader: GLTFLoader);
  69955. dispose(): void;
  69956. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  69957. }
  69958. }
  69959. declare module BABYLON.GLTF2.Loader.Extensions {
  69960. /**
  69961. * Store glTF extras (if present) in BJS objects' metadata
  69962. */
  69963. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  69964. /** The name of this extension. */
  69965. readonly name: string;
  69966. /** Defines whether this extension is enabled. */
  69967. enabled: boolean;
  69968. private _loader;
  69969. private _assignExtras;
  69970. /** @hidden */
  69971. constructor(loader: GLTFLoader);
  69972. /** @hidden */
  69973. dispose(): void;
  69974. /** @hidden */
  69975. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  69976. /** @hidden */
  69977. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  69978. /** @hidden */
  69979. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  69980. }
  69981. }
  69982. declare module BABYLON {
  69983. /**
  69984. * Class reading and parsing the MTL file bundled with the obj file.
  69985. */
  69986. export class MTLFileLoader {
  69987. /**
  69988. * All material loaded from the mtl will be set here
  69989. */
  69990. materials: StandardMaterial[];
  69991. /**
  69992. * This function will read the mtl file and create each material described inside
  69993. * This function could be improve by adding :
  69994. * -some component missing (Ni, Tf...)
  69995. * -including the specific options available
  69996. *
  69997. * @param scene defines the scene the material will be created in
  69998. * @param data defines the mtl data to parse
  69999. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  70000. */
  70001. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  70002. /**
  70003. * Gets the texture for the material.
  70004. *
  70005. * If the material is imported from input file,
  70006. * We sanitize the url to ensure it takes the textre from aside the material.
  70007. *
  70008. * @param rootUrl The root url to load from
  70009. * @param value The value stored in the mtl
  70010. * @return The Texture
  70011. */
  70012. private static _getTexture;
  70013. }
  70014. /**
  70015. * Options for loading OBJ/MTL files
  70016. */
  70017. type MeshLoadOptions = {
  70018. /**
  70019. * Defines if UVs are optimized by default during load.
  70020. */
  70021. OptimizeWithUV: boolean;
  70022. /**
  70023. * Defines custom scaling of UV coordinates of loaded meshes.
  70024. */
  70025. UVScaling: Vector2;
  70026. /**
  70027. * Invert model on y-axis (does a model scaling inversion)
  70028. */
  70029. InvertY: boolean;
  70030. /**
  70031. * Invert Y-Axis of referenced textures on load
  70032. */
  70033. InvertTextureY: boolean;
  70034. /**
  70035. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70036. */
  70037. ImportVertexColors: boolean;
  70038. /**
  70039. * Compute the normals for the model, even if normals are present in the file.
  70040. */
  70041. ComputeNormals: boolean;
  70042. /**
  70043. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70044. */
  70045. SkipMaterials: boolean;
  70046. /**
  70047. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70048. */
  70049. MaterialLoadingFailsSilently: boolean;
  70050. };
  70051. /**
  70052. * OBJ file type loader.
  70053. * This is a babylon scene loader plugin.
  70054. */
  70055. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  70056. /**
  70057. * Defines if UVs are optimized by default during load.
  70058. */
  70059. static OPTIMIZE_WITH_UV: boolean;
  70060. /**
  70061. * Invert model on y-axis (does a model scaling inversion)
  70062. */
  70063. static INVERT_Y: boolean;
  70064. /**
  70065. * Invert Y-Axis of referenced textures on load
  70066. */
  70067. static INVERT_TEXTURE_Y: boolean;
  70068. /**
  70069. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  70070. */
  70071. static IMPORT_VERTEX_COLORS: boolean;
  70072. /**
  70073. * Compute the normals for the model, even if normals are present in the file.
  70074. */
  70075. static COMPUTE_NORMALS: boolean;
  70076. /**
  70077. * Defines custom scaling of UV coordinates of loaded meshes.
  70078. */
  70079. static UV_SCALING: Vector2;
  70080. /**
  70081. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  70082. */
  70083. static SKIP_MATERIALS: boolean;
  70084. /**
  70085. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  70086. *
  70087. * Defaults to true for backwards compatibility.
  70088. */
  70089. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  70090. /**
  70091. * Defines the name of the plugin.
  70092. */
  70093. name: string;
  70094. /**
  70095. * Defines the extension the plugin is able to load.
  70096. */
  70097. extensions: string;
  70098. /** @hidden */
  70099. obj: RegExp;
  70100. /** @hidden */
  70101. group: RegExp;
  70102. /** @hidden */
  70103. mtllib: RegExp;
  70104. /** @hidden */
  70105. usemtl: RegExp;
  70106. /** @hidden */
  70107. smooth: RegExp;
  70108. /** @hidden */
  70109. vertexPattern: RegExp;
  70110. /** @hidden */
  70111. normalPattern: RegExp;
  70112. /** @hidden */
  70113. uvPattern: RegExp;
  70114. /** @hidden */
  70115. facePattern1: RegExp;
  70116. /** @hidden */
  70117. facePattern2: RegExp;
  70118. /** @hidden */
  70119. facePattern3: RegExp;
  70120. /** @hidden */
  70121. facePattern4: RegExp;
  70122. /** @hidden */
  70123. facePattern5: RegExp;
  70124. private _meshLoadOptions;
  70125. /**
  70126. * Creates loader for .OBJ files
  70127. *
  70128. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  70129. */
  70130. constructor(meshLoadOptions?: MeshLoadOptions);
  70131. private static readonly currentMeshLoadOptions;
  70132. /**
  70133. * Calls synchronously the MTL file attached to this obj.
  70134. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  70135. * Without this function materials are not displayed in the first frame (but displayed after).
  70136. * In consequence it is impossible to get material information in your HTML file
  70137. *
  70138. * @param url The URL of the MTL file
  70139. * @param rootUrl
  70140. * @param onSuccess Callback function to be called when the MTL file is loaded
  70141. * @private
  70142. */
  70143. private _loadMTL;
  70144. /**
  70145. * Instantiates a OBJ file loader plugin.
  70146. * @returns the created plugin
  70147. */
  70148. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  70149. /**
  70150. * If the data string can be loaded directly.
  70151. *
  70152. * @param data string containing the file data
  70153. * @returns if the data can be loaded directly
  70154. */
  70155. canDirectLoad(data: string): boolean;
  70156. /**
  70157. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  70158. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  70159. * @param scene the scene the meshes should be added to
  70160. * @param data the OBJ data to load
  70161. * @param rootUrl root url to load from
  70162. * @param onProgress event that fires when loading progress has occured
  70163. * @param fileName Defines the name of the file to load
  70164. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  70165. */
  70166. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  70167. meshes: AbstractMesh[];
  70168. particleSystems: IParticleSystem[];
  70169. skeletons: Skeleton[];
  70170. animationGroups: AnimationGroup[];
  70171. }>;
  70172. /**
  70173. * Imports all objects from the loaded OBJ data and adds them to the scene
  70174. * @param scene the scene the objects should be added to
  70175. * @param data the OBJ data to load
  70176. * @param rootUrl root url to load from
  70177. * @param onProgress event that fires when loading progress has occured
  70178. * @param fileName Defines the name of the file to load
  70179. * @returns a promise which completes when objects have been loaded to the scene
  70180. */
  70181. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  70182. /**
  70183. * Load into an asset container.
  70184. * @param scene The scene to load into
  70185. * @param data The data to import
  70186. * @param rootUrl The root url for scene and resources
  70187. * @param onProgress The callback when the load progresses
  70188. * @param fileName Defines the name of the file to load
  70189. * @returns The loaded asset container
  70190. */
  70191. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  70192. /**
  70193. * Read the OBJ file and create an Array of meshes.
  70194. * Each mesh contains all information given by the OBJ and the MTL file.
  70195. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  70196. *
  70197. * @param meshesNames
  70198. * @param scene Scene The scene where are displayed the data
  70199. * @param data String The content of the obj file
  70200. * @param rootUrl String The path to the folder
  70201. * @returns Array<AbstractMesh>
  70202. * @private
  70203. */
  70204. private _parseSolid;
  70205. }
  70206. }
  70207. declare module BABYLON {
  70208. /**
  70209. * STL file type loader.
  70210. * This is a babylon scene loader plugin.
  70211. */
  70212. export class STLFileLoader implements ISceneLoaderPlugin {
  70213. /** @hidden */
  70214. solidPattern: RegExp;
  70215. /** @hidden */
  70216. facetsPattern: RegExp;
  70217. /** @hidden */
  70218. normalPattern: RegExp;
  70219. /** @hidden */
  70220. vertexPattern: RegExp;
  70221. /**
  70222. * Defines the name of the plugin.
  70223. */
  70224. name: string;
  70225. /**
  70226. * Defines the extensions the stl loader is able to load.
  70227. * force data to come in as an ArrayBuffer
  70228. * we'll convert to string if it looks like it's an ASCII .stl
  70229. */
  70230. extensions: ISceneLoaderPluginExtensions;
  70231. /**
  70232. * Import meshes into a scene.
  70233. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  70234. * @param scene The scene to import into
  70235. * @param data The data to import
  70236. * @param rootUrl The root url for scene and resources
  70237. * @param meshes The meshes array to import into
  70238. * @param particleSystems The particle systems array to import into
  70239. * @param skeletons The skeletons array to import into
  70240. * @param onError The callback when import fails
  70241. * @returns True if successful or false otherwise
  70242. */
  70243. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  70244. /**
  70245. * Load into a scene.
  70246. * @param scene The scene to load into
  70247. * @param data The data to import
  70248. * @param rootUrl The root url for scene and resources
  70249. * @param onError The callback when import fails
  70250. * @returns true if successful or false otherwise
  70251. */
  70252. load(scene: Scene, data: any, rootUrl: string): boolean;
  70253. /**
  70254. * Load into an asset container.
  70255. * @param scene The scene to load into
  70256. * @param data The data to import
  70257. * @param rootUrl The root url for scene and resources
  70258. * @param onError The callback when import fails
  70259. * @returns The loaded asset container
  70260. */
  70261. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  70262. private _isBinary;
  70263. private _parseBinary;
  70264. private _parseASCII;
  70265. }
  70266. }
  70267. declare module BABYLON {
  70268. /**
  70269. * Class for generating OBJ data from a Babylon scene.
  70270. */
  70271. export class OBJExport {
  70272. /**
  70273. * Exports the geometry of a Mesh array in .OBJ file format (text)
  70274. * @param mesh defines the list of meshes to serialize
  70275. * @param materials defines if materials should be exported
  70276. * @param matlibname defines the name of the associated mtl file
  70277. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  70278. * @returns the OBJ content
  70279. */
  70280. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  70281. /**
  70282. * Exports the material(s) of a mesh in .MTL file format (text)
  70283. * @param mesh defines the mesh to extract the material from
  70284. * @returns the mtl content
  70285. */
  70286. static MTL(mesh: Mesh): string;
  70287. }
  70288. }
  70289. declare module BABYLON {
  70290. /** @hidden */
  70291. export var __IGLTFExporterExtension: number;
  70292. /**
  70293. * Interface for extending the exporter
  70294. * @hidden
  70295. */
  70296. export interface IGLTFExporterExtension {
  70297. /**
  70298. * The name of this extension
  70299. */
  70300. readonly name: string;
  70301. /**
  70302. * Defines whether this extension is enabled
  70303. */
  70304. enabled: boolean;
  70305. /**
  70306. * Defines whether this extension is required
  70307. */
  70308. required: boolean;
  70309. }
  70310. }
  70311. declare module BABYLON.GLTF2.Exporter {
  70312. /** @hidden */
  70313. export var __IGLTFExporterExtensionV2: number;
  70314. /**
  70315. * Interface for a glTF exporter extension
  70316. * @hidden
  70317. */
  70318. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  70319. /**
  70320. * Define this method to modify the default behavior before exporting a texture
  70321. * @param context The context when loading the asset
  70322. * @param babylonTexture The glTF texture info property
  70323. * @param mimeType The mime-type of the generated image
  70324. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  70325. */
  70326. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70327. /**
  70328. * Define this method to modify the default behavior when exporting texture info
  70329. * @param context The context when loading the asset
  70330. * @param meshPrimitive glTF mesh primitive
  70331. * @param babylonSubMesh Babylon submesh
  70332. * @param binaryWriter glTF serializer binary writer instance
  70333. * @returns nullable IMeshPrimitive promise
  70334. */
  70335. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70336. /**
  70337. * Define this method to modify the default behavior when exporting a node
  70338. * @param context The context when exporting the node
  70339. * @param node glTF node
  70340. * @param babylonNode BabylonJS node
  70341. * @returns nullable INode promise
  70342. */
  70343. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70344. /**
  70345. * Called after the exporter state changes to EXPORTING
  70346. */
  70347. onExporting?(): void;
  70348. }
  70349. }
  70350. declare module BABYLON.GLTF2.Exporter {
  70351. /**
  70352. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  70353. * @hidden
  70354. */
  70355. export class _GLTFMaterialExporter {
  70356. /**
  70357. * Represents the dielectric specular values for R, G and B
  70358. */
  70359. private static readonly _DielectricSpecular;
  70360. /**
  70361. * Allows the maximum specular power to be defined for material calculations
  70362. */
  70363. private static readonly _MaxSpecularPower;
  70364. /**
  70365. * Mapping to store textures
  70366. */
  70367. private _textureMap;
  70368. /**
  70369. * Numeric tolerance value
  70370. */
  70371. private static readonly _Epsilon;
  70372. /**
  70373. * Reference to the glTF Exporter
  70374. */
  70375. private _exporter;
  70376. constructor(exporter: _Exporter);
  70377. /**
  70378. * Specifies if two colors are approximately equal in value
  70379. * @param color1 first color to compare to
  70380. * @param color2 second color to compare to
  70381. * @param epsilon threshold value
  70382. */
  70383. private static FuzzyEquals;
  70384. /**
  70385. * Gets the materials from a Babylon scene and converts them to glTF materials
  70386. * @param scene babylonjs scene
  70387. * @param mimeType texture mime type
  70388. * @param images array of images
  70389. * @param textures array of textures
  70390. * @param materials array of materials
  70391. * @param imageData mapping of texture names to base64 textures
  70392. * @param hasTextureCoords specifies if texture coordinates are present on the material
  70393. */
  70394. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70395. /**
  70396. * Makes a copy of the glTF material without the texture parameters
  70397. * @param originalMaterial original glTF material
  70398. * @returns glTF material without texture parameters
  70399. */
  70400. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  70401. /**
  70402. * Specifies if the material has any texture parameters present
  70403. * @param material glTF Material
  70404. * @returns boolean specifying if texture parameters are present
  70405. */
  70406. _hasTexturesPresent(material: IMaterial): boolean;
  70407. /**
  70408. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  70409. * @param babylonStandardMaterial
  70410. * @returns glTF Metallic Roughness Material representation
  70411. */
  70412. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  70413. /**
  70414. * Computes the metallic factor
  70415. * @param diffuse diffused value
  70416. * @param specular specular value
  70417. * @param oneMinusSpecularStrength one minus the specular strength
  70418. * @returns metallic value
  70419. */
  70420. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  70421. /**
  70422. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  70423. * @param glTFMaterial glTF material
  70424. * @param babylonMaterial Babylon material
  70425. */
  70426. private static _SetAlphaMode;
  70427. /**
  70428. * Converts a Babylon Standard Material to a glTF Material
  70429. * @param babylonStandardMaterial BJS Standard Material
  70430. * @param mimeType mime type to use for the textures
  70431. * @param images array of glTF image interfaces
  70432. * @param textures array of glTF texture interfaces
  70433. * @param materials array of glTF material interfaces
  70434. * @param imageData map of image file name to data
  70435. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70436. */
  70437. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70438. /**
  70439. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70440. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  70441. * @param mimeType mime type to use for the textures
  70442. * @param images array of glTF image interfaces
  70443. * @param textures array of glTF texture interfaces
  70444. * @param materials array of glTF material interfaces
  70445. * @param imageData map of image file name to data
  70446. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70447. */
  70448. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70449. /**
  70450. * Converts an image typed array buffer to a base64 image
  70451. * @param buffer typed array buffer
  70452. * @param width width of the image
  70453. * @param height height of the image
  70454. * @param mimeType mimetype of the image
  70455. * @returns base64 image string
  70456. */
  70457. private _createBase64FromCanvasAsync;
  70458. /**
  70459. * Generates a white texture based on the specified width and height
  70460. * @param width width of the texture in pixels
  70461. * @param height height of the texture in pixels
  70462. * @param scene babylonjs scene
  70463. * @returns white texture
  70464. */
  70465. private _createWhiteTexture;
  70466. /**
  70467. * 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
  70468. * @param texture1 first texture to resize
  70469. * @param texture2 second texture to resize
  70470. * @param scene babylonjs scene
  70471. * @returns resized textures or null
  70472. */
  70473. private _resizeTexturesToSameDimensions;
  70474. /**
  70475. * Converts an array of pixels to a Float32Array
  70476. * Throws an error if the pixel format is not supported
  70477. * @param pixels - array buffer containing pixel values
  70478. * @returns Float32 of pixels
  70479. */
  70480. private _convertPixelArrayToFloat32;
  70481. /**
  70482. * Convert Specular Glossiness Textures to Metallic Roughness
  70483. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  70484. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  70485. * @param diffuseTexture texture used to store diffuse information
  70486. * @param specularGlossinessTexture texture used to store specular and glossiness information
  70487. * @param factors specular glossiness material factors
  70488. * @param mimeType the mime type to use for the texture
  70489. * @returns pbr metallic roughness interface or null
  70490. */
  70491. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  70492. /**
  70493. * Converts specular glossiness material properties to metallic roughness
  70494. * @param specularGlossiness interface with specular glossiness material properties
  70495. * @returns interface with metallic roughness material properties
  70496. */
  70497. private _convertSpecularGlossinessToMetallicRoughness;
  70498. /**
  70499. * Calculates the surface reflectance, independent of lighting conditions
  70500. * @param color Color source to calculate brightness from
  70501. * @returns number representing the perceived brightness, or zero if color is undefined
  70502. */
  70503. private _getPerceivedBrightness;
  70504. /**
  70505. * Returns the maximum color component value
  70506. * @param color
  70507. * @returns maximum color component value, or zero if color is null or undefined
  70508. */
  70509. private _getMaxComponent;
  70510. /**
  70511. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  70512. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70513. * @param mimeType mime type to use for the textures
  70514. * @param images array of glTF image interfaces
  70515. * @param textures array of glTF texture interfaces
  70516. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70517. * @param imageData map of image file name to data
  70518. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70519. * @returns glTF PBR Metallic Roughness factors
  70520. */
  70521. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  70522. private _getGLTFTextureSampler;
  70523. private _getGLTFTextureWrapMode;
  70524. private _getGLTFTextureWrapModesSampler;
  70525. /**
  70526. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  70527. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70528. * @param mimeType mime type to use for the textures
  70529. * @param images array of glTF image interfaces
  70530. * @param textures array of glTF texture interfaces
  70531. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  70532. * @param imageData map of image file name to data
  70533. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70534. * @returns glTF PBR Metallic Roughness factors
  70535. */
  70536. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  70537. /**
  70538. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  70539. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  70540. * @param mimeType mime type to use for the textures
  70541. * @param images array of glTF image interfaces
  70542. * @param textures array of glTF texture interfaces
  70543. * @param materials array of glTF material interfaces
  70544. * @param imageData map of image file name to data
  70545. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  70546. */
  70547. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  70548. private setMetallicRoughnessPbrMaterial;
  70549. private getPixelsFromTexture;
  70550. /**
  70551. * Extracts a texture from a Babylon texture into file data and glTF data
  70552. * @param babylonTexture Babylon texture to extract
  70553. * @param mimeType Mime Type of the babylonTexture
  70554. * @return glTF texture info, or null if the texture format is not supported
  70555. */
  70556. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70557. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  70558. /**
  70559. * Builds a texture from base64 string
  70560. * @param base64Texture base64 texture string
  70561. * @param baseTextureName Name to use for the texture
  70562. * @param mimeType image mime type for the texture
  70563. * @param images array of images
  70564. * @param textures array of textures
  70565. * @param imageData map of image data
  70566. * @returns glTF texture info, or null if the texture format is not supported
  70567. */
  70568. private _getTextureInfoFromBase64;
  70569. }
  70570. }
  70571. declare module BABYLON {
  70572. /**
  70573. * Class for holding and downloading glTF file data
  70574. */
  70575. export class GLTFData {
  70576. /**
  70577. * Object which contains the file name as the key and its data as the value
  70578. */
  70579. glTFFiles: {
  70580. [fileName: string]: string | Blob;
  70581. };
  70582. /**
  70583. * Initializes the glTF file object
  70584. */
  70585. constructor();
  70586. /**
  70587. * Downloads the glTF data as files based on their names and data
  70588. */
  70589. downloadFiles(): void;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /**
  70594. * Holds a collection of exporter options and parameters
  70595. */
  70596. export interface IExportOptions {
  70597. /**
  70598. * Function which indicates whether a babylon node should be exported or not
  70599. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  70600. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  70601. */
  70602. shouldExportNode?(node: Node): boolean;
  70603. /**
  70604. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  70605. * @param metadata source metadata to read from
  70606. * @returns the data to store to glTF node extras
  70607. */
  70608. metadataSelector?(metadata: any): any;
  70609. /**
  70610. * The sample rate to bake animation curves
  70611. */
  70612. animationSampleRate?: number;
  70613. /**
  70614. * Begin serialization without waiting for the scene to be ready
  70615. */
  70616. exportWithoutWaitingForScene?: boolean;
  70617. }
  70618. /**
  70619. * Class for generating glTF data from a Babylon scene.
  70620. */
  70621. export class GLTF2Export {
  70622. /**
  70623. * Exports the geometry of the scene to .gltf file format asynchronously
  70624. * @param scene Babylon scene with scene hierarchy information
  70625. * @param filePrefix File prefix to use when generating the glTF file
  70626. * @param options Exporter options
  70627. * @returns Returns an object with a .gltf file and associates texture names
  70628. * as keys and their data and paths as values
  70629. */
  70630. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70631. private static _PreExportAsync;
  70632. private static _PostExportAsync;
  70633. /**
  70634. * Exports the geometry of the scene to .glb file format asychronously
  70635. * @param scene Babylon scene with scene hierarchy information
  70636. * @param filePrefix File prefix to use when generating glb file
  70637. * @param options Exporter options
  70638. * @returns Returns an object with a .glb filename as key and data as value
  70639. */
  70640. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  70641. }
  70642. }
  70643. declare module BABYLON.GLTF2.Exporter {
  70644. /**
  70645. * @hidden
  70646. */
  70647. export class _GLTFUtilities {
  70648. /**
  70649. * Creates a buffer view based on the supplied arguments
  70650. * @param bufferIndex index value of the specified buffer
  70651. * @param byteOffset byte offset value
  70652. * @param byteLength byte length of the bufferView
  70653. * @param byteStride byte distance between conequential elements
  70654. * @param name name of the buffer view
  70655. * @returns bufferView for glTF
  70656. */
  70657. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  70658. /**
  70659. * Creates an accessor based on the supplied arguments
  70660. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  70661. * @param name The name of the accessor
  70662. * @param type The type of the accessor
  70663. * @param componentType The datatype of components in the attribute
  70664. * @param count The number of attributes referenced by this accessor
  70665. * @param byteOffset The offset relative to the start of the bufferView in bytes
  70666. * @param min Minimum value of each component in this attribute
  70667. * @param max Maximum value of each component in this attribute
  70668. * @returns accessor for glTF
  70669. */
  70670. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  70671. /**
  70672. * Calculates the minimum and maximum values of an array of position floats
  70673. * @param positions Positions array of a mesh
  70674. * @param vertexStart Starting vertex offset to calculate min and max values
  70675. * @param vertexCount Number of vertices to check for min and max values
  70676. * @returns min number array and max number array
  70677. */
  70678. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  70679. min: number[];
  70680. max: number[];
  70681. };
  70682. /**
  70683. * Converts a new right-handed Vector3
  70684. * @param vector vector3 array
  70685. * @returns right-handed Vector3
  70686. */
  70687. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  70688. /**
  70689. * Converts a Vector3 to right-handed
  70690. * @param vector Vector3 to convert to right-handed
  70691. */
  70692. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  70693. /**
  70694. * Converts a three element number array to right-handed
  70695. * @param vector number array to convert to right-handed
  70696. */
  70697. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  70698. /**
  70699. * Converts a new right-handed Vector3
  70700. * @param vector vector3 array
  70701. * @returns right-handed Vector3
  70702. */
  70703. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  70704. /**
  70705. * Converts a Vector3 to right-handed
  70706. * @param vector Vector3 to convert to right-handed
  70707. */
  70708. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  70709. /**
  70710. * Converts a three element number array to right-handed
  70711. * @param vector number array to convert to right-handed
  70712. */
  70713. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  70714. /**
  70715. * Converts a Vector4 to right-handed
  70716. * @param vector Vector4 to convert to right-handed
  70717. */
  70718. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  70719. /**
  70720. * Converts a Vector4 to right-handed
  70721. * @param vector Vector4 to convert to right-handed
  70722. */
  70723. static _GetRightHandedArray4FromRef(vector: number[]): void;
  70724. /**
  70725. * Converts a Quaternion to right-handed
  70726. * @param quaternion Source quaternion to convert to right-handed
  70727. */
  70728. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  70729. /**
  70730. * Converts a Quaternion to right-handed
  70731. * @param quaternion Source quaternion to convert to right-handed
  70732. */
  70733. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  70734. static _NormalizeTangentFromRef(tangent: Vector4): void;
  70735. }
  70736. }
  70737. declare module BABYLON.GLTF2.Exporter {
  70738. /**
  70739. * Converts Babylon Scene into glTF 2.0.
  70740. * @hidden
  70741. */
  70742. export class _Exporter {
  70743. /**
  70744. * Stores the glTF to export
  70745. */
  70746. _glTF: IGLTF;
  70747. /**
  70748. * Stores all generated buffer views, which represents views into the main glTF buffer data
  70749. */
  70750. _bufferViews: IBufferView[];
  70751. /**
  70752. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  70753. */
  70754. _accessors: IAccessor[];
  70755. /**
  70756. * Stores all the generated nodes, which contains transform and/or mesh information per node
  70757. */
  70758. private _nodes;
  70759. /**
  70760. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  70761. */
  70762. private _scenes;
  70763. /**
  70764. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  70765. */
  70766. private _meshes;
  70767. /**
  70768. * Stores all the generated material information, which represents the appearance of each primitive
  70769. */
  70770. _materials: IMaterial[];
  70771. _materialMap: {
  70772. [materialID: number]: number;
  70773. };
  70774. /**
  70775. * Stores all the generated texture information, which is referenced by glTF materials
  70776. */
  70777. _textures: ITexture[];
  70778. /**
  70779. * Stores all the generated image information, which is referenced by glTF textures
  70780. */
  70781. _images: IImage[];
  70782. /**
  70783. * Stores all the texture samplers
  70784. */
  70785. _samplers: ISampler[];
  70786. /**
  70787. * Stores all the generated animation samplers, which is referenced by glTF animations
  70788. */
  70789. /**
  70790. * Stores the animations for glTF models
  70791. */
  70792. private _animations;
  70793. /**
  70794. * Stores the total amount of bytes stored in the glTF buffer
  70795. */
  70796. private _totalByteLength;
  70797. /**
  70798. * Stores a reference to the Babylon scene containing the source geometry and material information
  70799. */
  70800. _babylonScene: Scene;
  70801. /**
  70802. * Stores a map of the image data, where the key is the file name and the value
  70803. * is the image data
  70804. */
  70805. _imageData: {
  70806. [fileName: string]: {
  70807. data: Uint8Array;
  70808. mimeType: ImageMimeType;
  70809. };
  70810. };
  70811. /**
  70812. * Stores a map of the unique id of a node to its index in the node array
  70813. */
  70814. private _nodeMap;
  70815. /**
  70816. * Specifies if the Babylon scene should be converted to right-handed on export
  70817. */
  70818. _convertToRightHandedSystem: boolean;
  70819. /**
  70820. * Baked animation sample rate
  70821. */
  70822. private _animationSampleRate;
  70823. private _options;
  70824. private _localEngine;
  70825. _glTFMaterialExporter: _GLTFMaterialExporter;
  70826. private _extensions;
  70827. private static _ExtensionNames;
  70828. private static _ExtensionFactories;
  70829. private _applyExtensions;
  70830. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  70831. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  70832. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70833. private _forEachExtensions;
  70834. private _extensionsOnExporting;
  70835. /**
  70836. * Load glTF serializer extensions
  70837. */
  70838. private _loadExtensions;
  70839. /**
  70840. * Creates a glTF Exporter instance, which can accept optional exporter options
  70841. * @param babylonScene Babylon scene object
  70842. * @param options Options to modify the behavior of the exporter
  70843. */
  70844. constructor(babylonScene: Scene, options?: IExportOptions);
  70845. /**
  70846. * Registers a glTF exporter extension
  70847. * @param name Name of the extension to export
  70848. * @param factory The factory function that creates the exporter extension
  70849. */
  70850. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  70851. /**
  70852. * Un-registers an exporter extension
  70853. * @param name The name fo the exporter extension
  70854. * @returns A boolean indicating whether the extension has been un-registered
  70855. */
  70856. static UnregisterExtension(name: string): boolean;
  70857. /**
  70858. * Lazy load a local engine with premultiplied alpha set to false
  70859. */
  70860. _getLocalEngine(): Engine;
  70861. private reorderIndicesBasedOnPrimitiveMode;
  70862. /**
  70863. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  70864. * clock-wise during export to glTF
  70865. * @param submesh BabylonJS submesh
  70866. * @param primitiveMode Primitive mode of the mesh
  70867. * @param sideOrientation the winding order of the submesh
  70868. * @param vertexBufferKind The type of vertex attribute
  70869. * @param meshAttributeArray The vertex attribute data
  70870. * @param byteOffset The offset to the binary data
  70871. * @param binaryWriter The binary data for the glTF file
  70872. */
  70873. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  70874. /**
  70875. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  70876. * clock-wise during export to glTF
  70877. * @param submesh BabylonJS submesh
  70878. * @param primitiveMode Primitive mode of the mesh
  70879. * @param sideOrientation the winding order of the submesh
  70880. * @param vertexBufferKind The type of vertex attribute
  70881. * @param meshAttributeArray The vertex attribute data
  70882. * @param byteOffset The offset to the binary data
  70883. * @param binaryWriter The binary data for the glTF file
  70884. */
  70885. private reorderTriangleFillMode;
  70886. /**
  70887. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  70888. * clock-wise during export to glTF
  70889. * @param submesh BabylonJS submesh
  70890. * @param primitiveMode Primitive mode of the mesh
  70891. * @param sideOrientation the winding order of the submesh
  70892. * @param vertexBufferKind The type of vertex attribute
  70893. * @param meshAttributeArray The vertex attribute data
  70894. * @param byteOffset The offset to the binary data
  70895. * @param binaryWriter The binary data for the glTF file
  70896. */
  70897. private reorderTriangleStripDrawMode;
  70898. /**
  70899. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  70900. * clock-wise during export to glTF
  70901. * @param submesh BabylonJS submesh
  70902. * @param primitiveMode Primitive mode of the mesh
  70903. * @param sideOrientation the winding order of the submesh
  70904. * @param vertexBufferKind The type of vertex attribute
  70905. * @param meshAttributeArray The vertex attribute data
  70906. * @param byteOffset The offset to the binary data
  70907. * @param binaryWriter The binary data for the glTF file
  70908. */
  70909. private reorderTriangleFanMode;
  70910. /**
  70911. * Writes the vertex attribute data to binary
  70912. * @param vertices The vertices to write to the binary writer
  70913. * @param byteOffset The offset into the binary writer to overwrite binary data
  70914. * @param vertexAttributeKind The vertex attribute type
  70915. * @param meshAttributeArray The vertex attribute data
  70916. * @param binaryWriter The writer containing the binary data
  70917. */
  70918. private writeVertexAttributeData;
  70919. /**
  70920. * Writes mesh attribute data to a data buffer
  70921. * Returns the bytelength of the data
  70922. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  70923. * @param meshAttributeArray Array containing the attribute data
  70924. * @param binaryWriter The buffer to write the binary data to
  70925. * @param indices Used to specify the order of the vertex data
  70926. */
  70927. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  70928. /**
  70929. * Generates glTF json data
  70930. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  70931. * @param glTFPrefix Text to use when prefixing a glTF file
  70932. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  70933. * @returns json data as string
  70934. */
  70935. private generateJSON;
  70936. /**
  70937. * Generates data for .gltf and .bin files based on the glTF prefix string
  70938. * @param glTFPrefix Text to use when prefixing a glTF file
  70939. * @returns GLTFData with glTF file data
  70940. */
  70941. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  70942. /**
  70943. * Creates a binary buffer for glTF
  70944. * @returns array buffer for binary data
  70945. */
  70946. private _generateBinaryAsync;
  70947. /**
  70948. * Pads the number to a multiple of 4
  70949. * @param num number to pad
  70950. * @returns padded number
  70951. */
  70952. private _getPadding;
  70953. /**
  70954. * Generates a glb file from the json and binary data
  70955. * Returns an object with the glb file name as the key and data as the value
  70956. * @param glTFPrefix
  70957. * @returns object with glb filename as key and data as value
  70958. */
  70959. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  70960. /**
  70961. * Sets the TRS for each node
  70962. * @param node glTF Node for storing the transformation data
  70963. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  70964. */
  70965. private setNodeTransformation;
  70966. private getVertexBufferFromMesh;
  70967. /**
  70968. * Creates a bufferview based on the vertices type for the Babylon mesh
  70969. * @param kind Indicates the type of vertices data
  70970. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  70971. * @param binaryWriter The buffer to write the bufferview data to
  70972. */
  70973. private createBufferViewKind;
  70974. /**
  70975. * The primitive mode of the Babylon mesh
  70976. * @param babylonMesh The BabylonJS mesh
  70977. */
  70978. private getMeshPrimitiveMode;
  70979. /**
  70980. * Sets the primitive mode of the glTF mesh primitive
  70981. * @param meshPrimitive glTF mesh primitive
  70982. * @param primitiveMode The primitive mode
  70983. */
  70984. private setPrimitiveMode;
  70985. /**
  70986. * Sets the vertex attribute accessor based of the glTF mesh primitive
  70987. * @param meshPrimitive glTF mesh primitive
  70988. * @param attributeKind vertex attribute
  70989. * @returns boolean specifying if uv coordinates are present
  70990. */
  70991. private setAttributeKind;
  70992. /**
  70993. * Sets data for the primitive attributes of each submesh
  70994. * @param mesh glTF Mesh object to store the primitive attribute information
  70995. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  70996. * @param binaryWriter Buffer to write the attribute data to
  70997. */
  70998. private setPrimitiveAttributesAsync;
  70999. /**
  71000. * Creates a glTF scene based on the array of meshes
  71001. * Returns the the total byte offset
  71002. * @param babylonScene Babylon scene to get the mesh data from
  71003. * @param binaryWriter Buffer to write binary data to
  71004. */
  71005. private createSceneAsync;
  71006. /**
  71007. * Creates a mapping of Node unique id to node index and handles animations
  71008. * @param babylonScene Babylon Scene
  71009. * @param nodes Babylon transform nodes
  71010. * @param binaryWriter Buffer to write binary data to
  71011. * @returns Node mapping of unique id to index
  71012. */
  71013. private createNodeMapAndAnimationsAsync;
  71014. /**
  71015. * Creates a glTF node from a Babylon mesh
  71016. * @param babylonMesh Source Babylon mesh
  71017. * @param binaryWriter Buffer for storing geometry data
  71018. * @returns glTF node
  71019. */
  71020. private createNodeAsync;
  71021. }
  71022. /**
  71023. * @hidden
  71024. *
  71025. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  71026. */
  71027. export class _BinaryWriter {
  71028. /**
  71029. * Array buffer which stores all binary data
  71030. */
  71031. private _arrayBuffer;
  71032. /**
  71033. * View of the array buffer
  71034. */
  71035. private _dataView;
  71036. /**
  71037. * byte offset of data in array buffer
  71038. */
  71039. private _byteOffset;
  71040. /**
  71041. * Initialize binary writer with an initial byte length
  71042. * @param byteLength Initial byte length of the array buffer
  71043. */
  71044. constructor(byteLength: number);
  71045. /**
  71046. * Resize the array buffer to the specified byte length
  71047. * @param byteLength
  71048. */
  71049. private resizeBuffer;
  71050. /**
  71051. * Get an array buffer with the length of the byte offset
  71052. * @returns ArrayBuffer resized to the byte offset
  71053. */
  71054. getArrayBuffer(): ArrayBuffer;
  71055. /**
  71056. * Get the byte offset of the array buffer
  71057. * @returns byte offset
  71058. */
  71059. getByteOffset(): number;
  71060. /**
  71061. * Stores an UInt8 in the array buffer
  71062. * @param entry
  71063. * @param byteOffset If defined, specifies where to set the value as an offset.
  71064. */
  71065. setUInt8(entry: number, byteOffset?: number): void;
  71066. /**
  71067. * Gets an UInt32 in the array buffer
  71068. * @param entry
  71069. * @param byteOffset If defined, specifies where to set the value as an offset.
  71070. */
  71071. getUInt32(byteOffset: number): number;
  71072. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71073. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  71074. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71075. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  71076. /**
  71077. * Stores a Float32 in the array buffer
  71078. * @param entry
  71079. */
  71080. setFloat32(entry: number, byteOffset?: number): void;
  71081. /**
  71082. * Stores an UInt32 in the array buffer
  71083. * @param entry
  71084. * @param byteOffset If defined, specifies where to set the value as an offset.
  71085. */
  71086. setUInt32(entry: number, byteOffset?: number): void;
  71087. }
  71088. }
  71089. declare module BABYLON.GLTF2.Exporter {
  71090. /**
  71091. * @hidden
  71092. * Interface to store animation data.
  71093. */
  71094. export interface _IAnimationData {
  71095. /**
  71096. * Keyframe data.
  71097. */
  71098. inputs: number[];
  71099. /**
  71100. * Value data.
  71101. */
  71102. outputs: number[][];
  71103. /**
  71104. * Animation interpolation data.
  71105. */
  71106. samplerInterpolation: AnimationSamplerInterpolation;
  71107. /**
  71108. * Minimum keyframe value.
  71109. */
  71110. inputsMin: number;
  71111. /**
  71112. * Maximum keyframe value.
  71113. */
  71114. inputsMax: number;
  71115. }
  71116. /**
  71117. * @hidden
  71118. */
  71119. export interface _IAnimationInfo {
  71120. /**
  71121. * The target channel for the animation
  71122. */
  71123. animationChannelTargetPath: AnimationChannelTargetPath;
  71124. /**
  71125. * The glTF accessor type for the data.
  71126. */
  71127. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  71128. /**
  71129. * Specifies if quaternions should be used.
  71130. */
  71131. useQuaternion: boolean;
  71132. }
  71133. /**
  71134. * @hidden
  71135. * Utility class for generating glTF animation data from BabylonJS.
  71136. */
  71137. export class _GLTFAnimation {
  71138. /**
  71139. * @ignore
  71140. *
  71141. * Creates glTF channel animation from BabylonJS animation.
  71142. * @param babylonTransformNode - BabylonJS mesh.
  71143. * @param animation - animation.
  71144. * @param animationChannelTargetPath - The target animation channel.
  71145. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  71146. * @param useQuaternion - Specifies if quaternions are used.
  71147. * @returns nullable IAnimationData
  71148. */
  71149. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  71150. private static _DeduceAnimationInfo;
  71151. /**
  71152. * @ignore
  71153. * Create node animations from the transform node animations
  71154. * @param babylonNode
  71155. * @param runtimeGLTFAnimation
  71156. * @param idleGLTFAnimations
  71157. * @param nodeMap
  71158. * @param nodes
  71159. * @param binaryWriter
  71160. * @param bufferViews
  71161. * @param accessors
  71162. * @param convertToRightHandedSystem
  71163. */
  71164. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  71165. [key: number]: number;
  71166. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71167. /**
  71168. * @ignore
  71169. * Create node animations from the animation groups
  71170. * @param babylonScene
  71171. * @param glTFAnimations
  71172. * @param nodeMap
  71173. * @param nodes
  71174. * @param binaryWriter
  71175. * @param bufferViews
  71176. * @param accessors
  71177. * @param convertToRightHandedSystem
  71178. */
  71179. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  71180. [key: number]: number;
  71181. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  71182. private static AddAnimation;
  71183. /**
  71184. * Create a baked animation
  71185. * @param babylonTransformNode BabylonJS mesh
  71186. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  71187. * @param animationChannelTargetPath animation target channel
  71188. * @param minFrame minimum animation frame
  71189. * @param maxFrame maximum animation frame
  71190. * @param fps frames per second of the animation
  71191. * @param inputs input key frames of the animation
  71192. * @param outputs output key frame data of the animation
  71193. * @param convertToRightHandedSystem converts the values to right-handed
  71194. * @param useQuaternion specifies if quaternions should be used
  71195. */
  71196. private static _CreateBakedAnimation;
  71197. private static _ConvertFactorToVector3OrQuaternion;
  71198. private static _SetInterpolatedValue;
  71199. /**
  71200. * Creates linear animation from the animation key frames
  71201. * @param babylonTransformNode BabylonJS mesh
  71202. * @param animation BabylonJS animation
  71203. * @param animationChannelTargetPath The target animation channel
  71204. * @param frameDelta The difference between the last and first frame of the animation
  71205. * @param inputs Array to store the key frame times
  71206. * @param outputs Array to store the key frame data
  71207. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71208. * @param useQuaternion Specifies if quaternions are used in the animation
  71209. */
  71210. private static _CreateLinearOrStepAnimation;
  71211. /**
  71212. * Creates cubic spline animation from the animation key frames
  71213. * @param babylonTransformNode BabylonJS mesh
  71214. * @param animation BabylonJS animation
  71215. * @param animationChannelTargetPath The target animation channel
  71216. * @param frameDelta The difference between the last and first frame of the animation
  71217. * @param inputs Array to store the key frame times
  71218. * @param outputs Array to store the key frame data
  71219. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  71220. * @param useQuaternion Specifies if quaternions are used in the animation
  71221. */
  71222. private static _CreateCubicSplineAnimation;
  71223. private static _GetBasePositionRotationOrScale;
  71224. /**
  71225. * Adds a key frame value
  71226. * @param keyFrame
  71227. * @param animation
  71228. * @param outputs
  71229. * @param animationChannelTargetPath
  71230. * @param basePositionRotationOrScale
  71231. * @param convertToRightHandedSystem
  71232. * @param useQuaternion
  71233. */
  71234. private static _AddKeyframeValue;
  71235. /**
  71236. * Determine the interpolation based on the key frames
  71237. * @param keyFrames
  71238. * @param animationChannelTargetPath
  71239. * @param useQuaternion
  71240. */
  71241. private static _DeduceInterpolation;
  71242. /**
  71243. * Adds an input tangent or output tangent to the output data
  71244. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  71245. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  71246. * @param outputs The animation data by keyframe
  71247. * @param animationChannelTargetPath The target animation channel
  71248. * @param interpolation The interpolation type
  71249. * @param keyFrame The key frame with the animation data
  71250. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  71251. * @param useQuaternion Specifies if quaternions are used
  71252. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  71253. */
  71254. private static AddSplineTangent;
  71255. /**
  71256. * Get the minimum and maximum key frames' frame values
  71257. * @param keyFrames animation key frames
  71258. * @returns the minimum and maximum key frame value
  71259. */
  71260. private static calculateMinMaxKeyFrames;
  71261. }
  71262. }
  71263. declare module BABYLON.GLTF2.Exporter {
  71264. /** @hidden */
  71265. export var textureTransformPixelShader: {
  71266. name: string;
  71267. shader: string;
  71268. };
  71269. }
  71270. declare module BABYLON.GLTF2.Exporter.Extensions {
  71271. /**
  71272. * @hidden
  71273. */
  71274. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  71275. /** Name of this extension */
  71276. readonly name: string;
  71277. /** Defines whether this extension is enabled */
  71278. enabled: boolean;
  71279. /** Defines whether this extension is required */
  71280. required: boolean;
  71281. /** Reference to the glTF exporter */
  71282. private _exporter;
  71283. constructor(exporter: _Exporter);
  71284. dispose(): void;
  71285. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  71286. /**
  71287. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  71288. * @param babylonTexture
  71289. * @param offset
  71290. * @param rotation
  71291. * @param scale
  71292. * @param scene
  71293. */
  71294. private _textureTransformTextureAsync;
  71295. }
  71296. }
  71297. declare module BABYLON.GLTF2.Exporter.Extensions {
  71298. /**
  71299. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  71300. */
  71301. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  71302. /** The name of this extension. */
  71303. readonly name: string;
  71304. /** Defines whether this extension is enabled. */
  71305. enabled: boolean;
  71306. /** Defines whether this extension is required */
  71307. required: boolean;
  71308. /** Reference to the glTF exporter */
  71309. private _exporter;
  71310. private _lights;
  71311. /** @hidden */
  71312. constructor(exporter: _Exporter);
  71313. /** @hidden */
  71314. dispose(): void;
  71315. /** @hidden */
  71316. onExporting(): void;
  71317. /**
  71318. * Define this method to modify the default behavior when exporting a node
  71319. * @param context The context when exporting the node
  71320. * @param node glTF node
  71321. * @param babylonNode BabylonJS node
  71322. * @returns nullable INode promise
  71323. */
  71324. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  71325. }
  71326. }
  71327. declare module BABYLON {
  71328. /**
  71329. * Class for generating STL data from a Babylon scene.
  71330. */
  71331. export class STLExport {
  71332. /**
  71333. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  71334. * @param meshes list defines the mesh to serialize
  71335. * @param download triggers the automatic download of the file.
  71336. * @param fileName changes the downloads fileName.
  71337. * @param binary changes the STL to a binary type.
  71338. * @param isLittleEndian toggle for binary type exporter.
  71339. * @returns the STL as UTF8 string
  71340. */
  71341. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  71342. }
  71343. }
  71344. declare module "babylonjs-gltf2interface" {
  71345. export = BABYLON.GLTF2;
  71346. }
  71347. /**
  71348. * Module for glTF 2.0 Interface
  71349. */
  71350. declare module BABYLON.GLTF2 {
  71351. /**
  71352. * The datatype of the components in the attribute
  71353. */
  71354. const enum AccessorComponentType {
  71355. /**
  71356. * Byte
  71357. */
  71358. BYTE = 5120,
  71359. /**
  71360. * Unsigned Byte
  71361. */
  71362. UNSIGNED_BYTE = 5121,
  71363. /**
  71364. * Short
  71365. */
  71366. SHORT = 5122,
  71367. /**
  71368. * Unsigned Short
  71369. */
  71370. UNSIGNED_SHORT = 5123,
  71371. /**
  71372. * Unsigned Int
  71373. */
  71374. UNSIGNED_INT = 5125,
  71375. /**
  71376. * Float
  71377. */
  71378. FLOAT = 5126,
  71379. }
  71380. /**
  71381. * Specifies if the attirbute is a scalar, vector, or matrix
  71382. */
  71383. const enum AccessorType {
  71384. /**
  71385. * Scalar
  71386. */
  71387. SCALAR = "SCALAR",
  71388. /**
  71389. * Vector2
  71390. */
  71391. VEC2 = "VEC2",
  71392. /**
  71393. * Vector3
  71394. */
  71395. VEC3 = "VEC3",
  71396. /**
  71397. * Vector4
  71398. */
  71399. VEC4 = "VEC4",
  71400. /**
  71401. * Matrix2x2
  71402. */
  71403. MAT2 = "MAT2",
  71404. /**
  71405. * Matrix3x3
  71406. */
  71407. MAT3 = "MAT3",
  71408. /**
  71409. * Matrix4x4
  71410. */
  71411. MAT4 = "MAT4",
  71412. }
  71413. /**
  71414. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71415. */
  71416. const enum AnimationChannelTargetPath {
  71417. /**
  71418. * Translation
  71419. */
  71420. TRANSLATION = "translation",
  71421. /**
  71422. * Rotation
  71423. */
  71424. ROTATION = "rotation",
  71425. /**
  71426. * Scale
  71427. */
  71428. SCALE = "scale",
  71429. /**
  71430. * Weights
  71431. */
  71432. WEIGHTS = "weights",
  71433. }
  71434. /**
  71435. * Interpolation algorithm
  71436. */
  71437. const enum AnimationSamplerInterpolation {
  71438. /**
  71439. * The animated values are linearly interpolated between keyframes
  71440. */
  71441. LINEAR = "LINEAR",
  71442. /**
  71443. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  71444. */
  71445. STEP = "STEP",
  71446. /**
  71447. * The animation's interpolation is computed using a cubic spline with specified tangents
  71448. */
  71449. CUBICSPLINE = "CUBICSPLINE",
  71450. }
  71451. /**
  71452. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71453. */
  71454. const enum CameraType {
  71455. /**
  71456. * A perspective camera containing properties to create a perspective projection matrix
  71457. */
  71458. PERSPECTIVE = "perspective",
  71459. /**
  71460. * An orthographic camera containing properties to create an orthographic projection matrix
  71461. */
  71462. ORTHOGRAPHIC = "orthographic",
  71463. }
  71464. /**
  71465. * The mime-type of the image
  71466. */
  71467. const enum ImageMimeType {
  71468. /**
  71469. * JPEG Mime-type
  71470. */
  71471. JPEG = "image/jpeg",
  71472. /**
  71473. * PNG Mime-type
  71474. */
  71475. PNG = "image/png",
  71476. }
  71477. /**
  71478. * The alpha rendering mode of the material
  71479. */
  71480. const enum MaterialAlphaMode {
  71481. /**
  71482. * The alpha value is ignored and the rendered output is fully opaque
  71483. */
  71484. OPAQUE = "OPAQUE",
  71485. /**
  71486. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  71487. */
  71488. MASK = "MASK",
  71489. /**
  71490. * 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)
  71491. */
  71492. BLEND = "BLEND",
  71493. }
  71494. /**
  71495. * The type of the primitives to render
  71496. */
  71497. const enum MeshPrimitiveMode {
  71498. /**
  71499. * Points
  71500. */
  71501. POINTS = 0,
  71502. /**
  71503. * Lines
  71504. */
  71505. LINES = 1,
  71506. /**
  71507. * Line Loop
  71508. */
  71509. LINE_LOOP = 2,
  71510. /**
  71511. * Line Strip
  71512. */
  71513. LINE_STRIP = 3,
  71514. /**
  71515. * Triangles
  71516. */
  71517. TRIANGLES = 4,
  71518. /**
  71519. * Triangle Strip
  71520. */
  71521. TRIANGLE_STRIP = 5,
  71522. /**
  71523. * Triangle Fan
  71524. */
  71525. TRIANGLE_FAN = 6,
  71526. }
  71527. /**
  71528. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  71529. */
  71530. const enum TextureMagFilter {
  71531. /**
  71532. * Nearest
  71533. */
  71534. NEAREST = 9728,
  71535. /**
  71536. * Linear
  71537. */
  71538. LINEAR = 9729,
  71539. }
  71540. /**
  71541. * Minification filter. All valid values correspond to WebGL enums
  71542. */
  71543. const enum TextureMinFilter {
  71544. /**
  71545. * Nearest
  71546. */
  71547. NEAREST = 9728,
  71548. /**
  71549. * Linear
  71550. */
  71551. LINEAR = 9729,
  71552. /**
  71553. * Nearest Mip-Map Nearest
  71554. */
  71555. NEAREST_MIPMAP_NEAREST = 9984,
  71556. /**
  71557. * Linear Mipmap Nearest
  71558. */
  71559. LINEAR_MIPMAP_NEAREST = 9985,
  71560. /**
  71561. * Nearest Mipmap Linear
  71562. */
  71563. NEAREST_MIPMAP_LINEAR = 9986,
  71564. /**
  71565. * Linear Mipmap Linear
  71566. */
  71567. LINEAR_MIPMAP_LINEAR = 9987,
  71568. }
  71569. /**
  71570. * S (U) wrapping mode. All valid values correspond to WebGL enums
  71571. */
  71572. const enum TextureWrapMode {
  71573. /**
  71574. * Clamp to Edge
  71575. */
  71576. CLAMP_TO_EDGE = 33071,
  71577. /**
  71578. * Mirrored Repeat
  71579. */
  71580. MIRRORED_REPEAT = 33648,
  71581. /**
  71582. * Repeat
  71583. */
  71584. REPEAT = 10497,
  71585. }
  71586. /**
  71587. * glTF Property
  71588. */
  71589. interface IProperty {
  71590. /**
  71591. * Dictionary object with extension-specific objects
  71592. */
  71593. extensions?: {
  71594. [key: string]: any;
  71595. };
  71596. /**
  71597. * Application-Specific data
  71598. */
  71599. extras?: any;
  71600. }
  71601. /**
  71602. * glTF Child of Root Property
  71603. */
  71604. interface IChildRootProperty extends IProperty {
  71605. /**
  71606. * The user-defined name of this object
  71607. */
  71608. name?: string;
  71609. }
  71610. /**
  71611. * Indices of those attributes that deviate from their initialization value
  71612. */
  71613. interface IAccessorSparseIndices extends IProperty {
  71614. /**
  71615. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71616. */
  71617. bufferView: number;
  71618. /**
  71619. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71620. */
  71621. byteOffset?: number;
  71622. /**
  71623. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  71624. */
  71625. componentType: AccessorComponentType;
  71626. }
  71627. /**
  71628. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  71629. */
  71630. interface IAccessorSparseValues extends IProperty {
  71631. /**
  71632. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  71633. */
  71634. bufferView: number;
  71635. /**
  71636. * The offset relative to the start of the bufferView in bytes. Must be aligned
  71637. */
  71638. byteOffset?: number;
  71639. }
  71640. /**
  71641. * Sparse storage of attributes that deviate from their initialization value
  71642. */
  71643. interface IAccessorSparse extends IProperty {
  71644. /**
  71645. * The number of attributes encoded in this sparse accessor
  71646. */
  71647. count: number;
  71648. /**
  71649. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  71650. */
  71651. indices: IAccessorSparseIndices;
  71652. /**
  71653. * 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
  71654. */
  71655. values: IAccessorSparseValues;
  71656. }
  71657. /**
  71658. * 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
  71659. */
  71660. interface IAccessor extends IChildRootProperty {
  71661. /**
  71662. * The index of the bufferview
  71663. */
  71664. bufferView?: number;
  71665. /**
  71666. * The offset relative to the start of the bufferView in bytes
  71667. */
  71668. byteOffset?: number;
  71669. /**
  71670. * The datatype of components in the attribute
  71671. */
  71672. componentType: AccessorComponentType;
  71673. /**
  71674. * Specifies whether integer data values should be normalized
  71675. */
  71676. normalized?: boolean;
  71677. /**
  71678. * The number of attributes referenced by this accessor
  71679. */
  71680. count: number;
  71681. /**
  71682. * Specifies if the attribute is a scalar, vector, or matrix
  71683. */
  71684. type: AccessorType;
  71685. /**
  71686. * Maximum value of each component in this attribute
  71687. */
  71688. max?: number[];
  71689. /**
  71690. * Minimum value of each component in this attribute
  71691. */
  71692. min?: number[];
  71693. /**
  71694. * Sparse storage of attributes that deviate from their initialization value
  71695. */
  71696. sparse?: IAccessorSparse;
  71697. }
  71698. /**
  71699. * Targets an animation's sampler at a node's property
  71700. */
  71701. interface IAnimationChannel extends IProperty {
  71702. /**
  71703. * The index of a sampler in this animation used to compute the value for the target
  71704. */
  71705. sampler: number;
  71706. /**
  71707. * The index of the node and TRS property to target
  71708. */
  71709. target: IAnimationChannelTarget;
  71710. }
  71711. /**
  71712. * The index of the node and TRS property that an animation channel targets
  71713. */
  71714. interface IAnimationChannelTarget extends IProperty {
  71715. /**
  71716. * The index of the node to target
  71717. */
  71718. node: number;
  71719. /**
  71720. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  71721. */
  71722. path: AnimationChannelTargetPath;
  71723. }
  71724. /**
  71725. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71726. */
  71727. interface IAnimationSampler extends IProperty {
  71728. /**
  71729. * The index of an accessor containing keyframe input values, e.g., time
  71730. */
  71731. input: number;
  71732. /**
  71733. * Interpolation algorithm
  71734. */
  71735. interpolation?: AnimationSamplerInterpolation;
  71736. /**
  71737. * The index of an accessor, containing keyframe output values
  71738. */
  71739. output: number;
  71740. }
  71741. /**
  71742. * A keyframe animation
  71743. */
  71744. interface IAnimation extends IChildRootProperty {
  71745. /**
  71746. * An array of channels, each of which targets an animation's sampler at a node's property
  71747. */
  71748. channels: IAnimationChannel[];
  71749. /**
  71750. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  71751. */
  71752. samplers: IAnimationSampler[];
  71753. }
  71754. /**
  71755. * Metadata about the glTF asset
  71756. */
  71757. interface IAsset extends IChildRootProperty {
  71758. /**
  71759. * A copyright message suitable for display to credit the content creator
  71760. */
  71761. copyright?: string;
  71762. /**
  71763. * Tool that generated this glTF model. Useful for debugging
  71764. */
  71765. generator?: string;
  71766. /**
  71767. * The glTF version that this asset targets
  71768. */
  71769. version: string;
  71770. /**
  71771. * The minimum glTF version that this asset targets
  71772. */
  71773. minVersion?: string;
  71774. }
  71775. /**
  71776. * A buffer points to binary geometry, animation, or skins
  71777. */
  71778. interface IBuffer extends IChildRootProperty {
  71779. /**
  71780. * 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
  71781. */
  71782. uri?: string;
  71783. /**
  71784. * The length of the buffer in bytes
  71785. */
  71786. byteLength: number;
  71787. }
  71788. /**
  71789. * A view into a buffer generally representing a subset of the buffer
  71790. */
  71791. interface IBufferView extends IChildRootProperty {
  71792. /**
  71793. * The index of the buffer
  71794. */
  71795. buffer: number;
  71796. /**
  71797. * The offset into the buffer in bytes
  71798. */
  71799. byteOffset?: number;
  71800. /**
  71801. * The lenth of the bufferView in bytes
  71802. */
  71803. byteLength: number;
  71804. /**
  71805. * The stride, in bytes
  71806. */
  71807. byteStride?: number;
  71808. }
  71809. /**
  71810. * An orthographic camera containing properties to create an orthographic projection matrix
  71811. */
  71812. interface ICameraOrthographic extends IProperty {
  71813. /**
  71814. * The floating-point horizontal magnification of the view. Must not be zero
  71815. */
  71816. xmag: number;
  71817. /**
  71818. * The floating-point vertical magnification of the view. Must not be zero
  71819. */
  71820. ymag: number;
  71821. /**
  71822. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  71823. */
  71824. zfar: number;
  71825. /**
  71826. * The floating-point distance to the near clipping plane
  71827. */
  71828. znear: number;
  71829. }
  71830. /**
  71831. * A perspective camera containing properties to create a perspective projection matrix
  71832. */
  71833. interface ICameraPerspective extends IProperty {
  71834. /**
  71835. * The floating-point aspect ratio of the field of view
  71836. */
  71837. aspectRatio?: number;
  71838. /**
  71839. * The floating-point vertical field of view in radians
  71840. */
  71841. yfov: number;
  71842. /**
  71843. * The floating-point distance to the far clipping plane
  71844. */
  71845. zfar?: number;
  71846. /**
  71847. * The floating-point distance to the near clipping plane
  71848. */
  71849. znear: number;
  71850. }
  71851. /**
  71852. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  71853. */
  71854. interface ICamera extends IChildRootProperty {
  71855. /**
  71856. * An orthographic camera containing properties to create an orthographic projection matrix
  71857. */
  71858. orthographic?: ICameraOrthographic;
  71859. /**
  71860. * A perspective camera containing properties to create a perspective projection matrix
  71861. */
  71862. perspective?: ICameraPerspective;
  71863. /**
  71864. * Specifies if the camera uses a perspective or orthographic projection
  71865. */
  71866. type: CameraType;
  71867. }
  71868. /**
  71869. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  71870. */
  71871. interface IImage extends IChildRootProperty {
  71872. /**
  71873. * 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
  71874. */
  71875. uri?: string;
  71876. /**
  71877. * The image's MIME type
  71878. */
  71879. mimeType?: ImageMimeType;
  71880. /**
  71881. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  71882. */
  71883. bufferView?: number;
  71884. }
  71885. /**
  71886. * Material Normal Texture Info
  71887. */
  71888. interface IMaterialNormalTextureInfo extends ITextureInfo {
  71889. /**
  71890. * The scalar multiplier applied to each normal vector of the normal texture
  71891. */
  71892. scale?: number;
  71893. }
  71894. /**
  71895. * Material Occlusion Texture Info
  71896. */
  71897. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  71898. /**
  71899. * A scalar multiplier controlling the amount of occlusion applied
  71900. */
  71901. strength?: number;
  71902. }
  71903. /**
  71904. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  71905. */
  71906. interface IMaterialPbrMetallicRoughness {
  71907. /**
  71908. * The material's base color factor
  71909. */
  71910. baseColorFactor?: number[];
  71911. /**
  71912. * The base color texture
  71913. */
  71914. baseColorTexture?: ITextureInfo;
  71915. /**
  71916. * The metalness of the material
  71917. */
  71918. metallicFactor?: number;
  71919. /**
  71920. * The roughness of the material
  71921. */
  71922. roughnessFactor?: number;
  71923. /**
  71924. * The metallic-roughness texture
  71925. */
  71926. metallicRoughnessTexture?: ITextureInfo;
  71927. }
  71928. /**
  71929. * The material appearance of a primitive
  71930. */
  71931. interface IMaterial extends IChildRootProperty {
  71932. /**
  71933. * 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
  71934. */
  71935. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  71936. /**
  71937. * The normal map texture
  71938. */
  71939. normalTexture?: IMaterialNormalTextureInfo;
  71940. /**
  71941. * The occlusion map texture
  71942. */
  71943. occlusionTexture?: IMaterialOcclusionTextureInfo;
  71944. /**
  71945. * The emissive map texture
  71946. */
  71947. emissiveTexture?: ITextureInfo;
  71948. /**
  71949. * 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
  71950. */
  71951. emissiveFactor?: number[];
  71952. /**
  71953. * The alpha rendering mode of the material
  71954. */
  71955. alphaMode?: MaterialAlphaMode;
  71956. /**
  71957. * The alpha cutoff value of the material
  71958. */
  71959. alphaCutoff?: number;
  71960. /**
  71961. * Specifies whether the material is double sided
  71962. */
  71963. doubleSided?: boolean;
  71964. }
  71965. /**
  71966. * Geometry to be rendered with the given material
  71967. */
  71968. interface IMeshPrimitive extends IProperty {
  71969. /**
  71970. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  71971. */
  71972. attributes: {
  71973. [name: string]: number;
  71974. };
  71975. /**
  71976. * The index of the accessor that contains the indices
  71977. */
  71978. indices?: number;
  71979. /**
  71980. * The index of the material to apply to this primitive when rendering
  71981. */
  71982. material?: number;
  71983. /**
  71984. * The type of primitives to render. All valid values correspond to WebGL enums
  71985. */
  71986. mode?: MeshPrimitiveMode;
  71987. /**
  71988. * 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
  71989. */
  71990. targets?: {
  71991. [name: string]: number;
  71992. }[];
  71993. }
  71994. /**
  71995. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  71996. */
  71997. interface IMesh extends IChildRootProperty {
  71998. /**
  71999. * An array of primitives, each defining geometry to be rendered with a material
  72000. */
  72001. primitives: IMeshPrimitive[];
  72002. /**
  72003. * Array of weights to be applied to the Morph Targets
  72004. */
  72005. weights?: number[];
  72006. }
  72007. /**
  72008. * A node in the node hierarchy
  72009. */
  72010. interface INode extends IChildRootProperty {
  72011. /**
  72012. * The index of the camera referenced by this node
  72013. */
  72014. camera?: number;
  72015. /**
  72016. * The indices of this node's children
  72017. */
  72018. children?: number[];
  72019. /**
  72020. * The index of the skin referenced by this node
  72021. */
  72022. skin?: number;
  72023. /**
  72024. * A floating-point 4x4 transformation matrix stored in column-major order
  72025. */
  72026. matrix?: number[];
  72027. /**
  72028. * The index of the mesh in this node
  72029. */
  72030. mesh?: number;
  72031. /**
  72032. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  72033. */
  72034. rotation?: number[];
  72035. /**
  72036. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  72037. */
  72038. scale?: number[];
  72039. /**
  72040. * The node's translation along the x, y, and z axes
  72041. */
  72042. translation?: number[];
  72043. /**
  72044. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  72045. */
  72046. weights?: number[];
  72047. }
  72048. /**
  72049. * Texture sampler properties for filtering and wrapping modes
  72050. */
  72051. interface ISampler extends IChildRootProperty {
  72052. /**
  72053. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  72054. */
  72055. magFilter?: TextureMagFilter;
  72056. /**
  72057. * Minification filter. All valid values correspond to WebGL enums
  72058. */
  72059. minFilter?: TextureMinFilter;
  72060. /**
  72061. * S (U) wrapping mode. All valid values correspond to WebGL enums
  72062. */
  72063. wrapS?: TextureWrapMode;
  72064. /**
  72065. * T (V) wrapping mode. All valid values correspond to WebGL enums
  72066. */
  72067. wrapT?: TextureWrapMode;
  72068. }
  72069. /**
  72070. * The root nodes of a scene
  72071. */
  72072. interface IScene extends IChildRootProperty {
  72073. /**
  72074. * The indices of each root node
  72075. */
  72076. nodes: number[];
  72077. }
  72078. /**
  72079. * Joints and matrices defining a skin
  72080. */
  72081. interface ISkin extends IChildRootProperty {
  72082. /**
  72083. * 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
  72084. */
  72085. inverseBindMatrices?: number;
  72086. /**
  72087. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  72088. */
  72089. skeleton?: number;
  72090. /**
  72091. * 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)
  72092. */
  72093. joints: number[];
  72094. }
  72095. /**
  72096. * A texture and its sampler
  72097. */
  72098. interface ITexture extends IChildRootProperty {
  72099. /**
  72100. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  72101. */
  72102. sampler?: number;
  72103. /**
  72104. * The index of the image used by this texture
  72105. */
  72106. source: number;
  72107. }
  72108. /**
  72109. * Reference to a texture
  72110. */
  72111. interface ITextureInfo extends IProperty {
  72112. /**
  72113. * The index of the texture
  72114. */
  72115. index: number;
  72116. /**
  72117. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  72118. */
  72119. texCoord?: number;
  72120. }
  72121. /**
  72122. * The root object for a glTF asset
  72123. */
  72124. interface IGLTF extends IProperty {
  72125. /**
  72126. * An array of accessors. An accessor is a typed view into a bufferView
  72127. */
  72128. accessors?: IAccessor[];
  72129. /**
  72130. * An array of keyframe animations
  72131. */
  72132. animations?: IAnimation[];
  72133. /**
  72134. * Metadata about the glTF asset
  72135. */
  72136. asset: IAsset;
  72137. /**
  72138. * An array of buffers. A buffer points to binary geometry, animation, or skins
  72139. */
  72140. buffers?: IBuffer[];
  72141. /**
  72142. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  72143. */
  72144. bufferViews?: IBufferView[];
  72145. /**
  72146. * An array of cameras
  72147. */
  72148. cameras?: ICamera[];
  72149. /**
  72150. * Names of glTF extensions used somewhere in this asset
  72151. */
  72152. extensionsUsed?: string[];
  72153. /**
  72154. * Names of glTF extensions required to properly load this asset
  72155. */
  72156. extensionsRequired?: string[];
  72157. /**
  72158. * An array of images. An image defines data used to create a texture
  72159. */
  72160. images?: IImage[];
  72161. /**
  72162. * An array of materials. A material defines the appearance of a primitive
  72163. */
  72164. materials?: IMaterial[];
  72165. /**
  72166. * An array of meshes. A mesh is a set of primitives to be rendered
  72167. */
  72168. meshes?: IMesh[];
  72169. /**
  72170. * An array of nodes
  72171. */
  72172. nodes?: INode[];
  72173. /**
  72174. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  72175. */
  72176. samplers?: ISampler[];
  72177. /**
  72178. * The index of the default scene
  72179. */
  72180. scene?: number;
  72181. /**
  72182. * An array of scenes
  72183. */
  72184. scenes?: IScene[];
  72185. /**
  72186. * An array of skins. A skin is defined by joints and matrices
  72187. */
  72188. skins?: ISkin[];
  72189. /**
  72190. * An array of textures
  72191. */
  72192. textures?: ITexture[];
  72193. }
  72194. /**
  72195. * The glTF validation results
  72196. * @ignore
  72197. */
  72198. interface IGLTFValidationResults {
  72199. info: {
  72200. generator: string;
  72201. hasAnimations: boolean;
  72202. hasDefaultScene: boolean;
  72203. hasMaterials: boolean;
  72204. hasMorphTargets: boolean;
  72205. hasSkins: boolean;
  72206. hasTextures: boolean;
  72207. maxAttributesUsed: number;
  72208. primitivesCount: number
  72209. };
  72210. issues: {
  72211. messages: Array<string>;
  72212. numErrors: number;
  72213. numHints: number;
  72214. numInfos: number;
  72215. numWarnings: number;
  72216. truncated: boolean
  72217. };
  72218. mimeType: string;
  72219. uri: string;
  72220. validatedAt: string;
  72221. validatorVersion: string;
  72222. }
  72223. /**
  72224. * The glTF validation options
  72225. */
  72226. interface IGLTFValidationOptions {
  72227. /** Uri to use */
  72228. uri?: string;
  72229. /** Function used to load external resources */
  72230. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  72231. /** Boolean indicating that we need to validate accessor data */
  72232. validateAccessorData?: boolean;
  72233. /** max number of issues allowed */
  72234. maxIssues?: number;
  72235. /** Ignored issues */
  72236. ignoredIssues?: Array<string>;
  72237. /** Value to override severy settings */
  72238. severityOverrides?: Object;
  72239. }
  72240. /**
  72241. * The glTF validator object
  72242. * @ignore
  72243. */
  72244. interface IGLTFValidator {
  72245. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72246. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  72247. }
  72248. }
  72249. declare module BABYLON {
  72250. /** @hidden */
  72251. export var cellPixelShader: {
  72252. name: string;
  72253. shader: string;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /** @hidden */
  72258. export var cellVertexShader: {
  72259. name: string;
  72260. shader: string;
  72261. };
  72262. }
  72263. declare module BABYLON {
  72264. export class CellMaterial extends BABYLON.PushMaterial {
  72265. private _diffuseTexture;
  72266. diffuseTexture: BABYLON.BaseTexture;
  72267. diffuseColor: BABYLON.Color3;
  72268. _computeHighLevel: boolean;
  72269. computeHighLevel: boolean;
  72270. private _disableLighting;
  72271. disableLighting: boolean;
  72272. private _maxSimultaneousLights;
  72273. maxSimultaneousLights: number;
  72274. private _renderId;
  72275. constructor(name: string, scene: BABYLON.Scene);
  72276. needAlphaBlending(): boolean;
  72277. needAlphaTesting(): boolean;
  72278. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72279. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72280. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72281. getAnimatables(): BABYLON.IAnimatable[];
  72282. getActiveTextures(): BABYLON.BaseTexture[];
  72283. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72284. dispose(forceDisposeEffect?: boolean): void;
  72285. getClassName(): string;
  72286. clone(name: string): CellMaterial;
  72287. serialize(): any;
  72288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  72289. }
  72290. }
  72291. declare module BABYLON {
  72292. export class CustomShaderStructure {
  72293. FragmentStore: string;
  72294. VertexStore: string;
  72295. constructor();
  72296. }
  72297. export class ShaderSpecialParts {
  72298. constructor();
  72299. Fragment_Begin: string;
  72300. Fragment_Definitions: string;
  72301. Fragment_MainBegin: string;
  72302. Fragment_Custom_Diffuse: string;
  72303. Fragment_Before_Lights: string;
  72304. Fragment_Before_Fog: string;
  72305. Fragment_Custom_Alpha: string;
  72306. Fragment_Before_FragColor: string;
  72307. Vertex_Begin: string;
  72308. Vertex_Definitions: string;
  72309. Vertex_MainBegin: string;
  72310. Vertex_Before_PositionUpdated: string;
  72311. Vertex_Before_NormalUpdated: string;
  72312. Vertex_MainEnd: string;
  72313. }
  72314. export class CustomMaterial extends BABYLON.StandardMaterial {
  72315. static ShaderIndexer: number;
  72316. CustomParts: ShaderSpecialParts;
  72317. _isCreatedShader: boolean;
  72318. _createdShaderName: string;
  72319. _customUniform: string[];
  72320. _newUniforms: string[];
  72321. _newUniformInstances: any[];
  72322. _newSamplerInstances: BABYLON.Texture[];
  72323. FragmentShader: string;
  72324. VertexShader: string;
  72325. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72326. ReviewUniform(name: string, arr: string[]): string[];
  72327. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  72328. constructor(name: string, scene: BABYLON.Scene);
  72329. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  72330. Fragment_Begin(shaderPart: string): CustomMaterial;
  72331. Fragment_Definitions(shaderPart: string): CustomMaterial;
  72332. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  72333. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  72334. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  72335. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  72336. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  72337. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  72338. Vertex_Begin(shaderPart: string): CustomMaterial;
  72339. Vertex_Definitions(shaderPart: string): CustomMaterial;
  72340. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  72341. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  72342. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  72343. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  72344. }
  72345. }
  72346. declare module BABYLON {
  72347. export class ShaderAlebdoParts {
  72348. constructor();
  72349. Fragment_Begin: string;
  72350. Fragment_Definitions: string;
  72351. Fragment_MainBegin: string;
  72352. Fragment_Custom_Albedo: string;
  72353. Fragment_Before_Lights: string;
  72354. Fragment_Custom_MetallicRoughness: string;
  72355. Fragment_Custom_MicroSurface: string;
  72356. Fragment_Before_Fog: string;
  72357. Fragment_Custom_Alpha: string;
  72358. Fragment_Before_FragColor: string;
  72359. Vertex_Begin: string;
  72360. Vertex_Definitions: string;
  72361. Vertex_MainBegin: string;
  72362. Vertex_Before_PositionUpdated: string;
  72363. Vertex_Before_NormalUpdated: string;
  72364. Vertex_MainEnd: string;
  72365. }
  72366. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  72367. static ShaderIndexer: number;
  72368. CustomParts: ShaderAlebdoParts;
  72369. _isCreatedShader: boolean;
  72370. _createdShaderName: string;
  72371. _customUniform: string[];
  72372. _newUniforms: string[];
  72373. _newUniformInstances: any[];
  72374. _newSamplerInstances: BABYLON.Texture[];
  72375. FragmentShader: string;
  72376. VertexShader: string;
  72377. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  72378. ReviewUniform(name: string, arr: string[]): string[];
  72379. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  72380. constructor(name: string, scene: BABYLON.Scene);
  72381. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  72382. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  72383. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  72384. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  72385. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  72386. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  72387. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  72388. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  72389. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  72390. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  72391. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  72392. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  72393. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  72394. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  72395. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  72396. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  72397. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  72398. }
  72399. }
  72400. declare module BABYLON {
  72401. /** @hidden */
  72402. export var firePixelShader: {
  72403. name: string;
  72404. shader: string;
  72405. };
  72406. }
  72407. declare module BABYLON {
  72408. /** @hidden */
  72409. export var fireVertexShader: {
  72410. name: string;
  72411. shader: string;
  72412. };
  72413. }
  72414. declare module BABYLON {
  72415. export class FireMaterial extends BABYLON.PushMaterial {
  72416. private _diffuseTexture;
  72417. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72418. private _distortionTexture;
  72419. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72420. private _opacityTexture;
  72421. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  72422. diffuseColor: BABYLON.Color3;
  72423. speed: number;
  72424. private _scaledDiffuse;
  72425. private _renderId;
  72426. private _lastTime;
  72427. constructor(name: string, scene: BABYLON.Scene);
  72428. needAlphaBlending(): boolean;
  72429. needAlphaTesting(): boolean;
  72430. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72431. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72432. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72433. getAnimatables(): BABYLON.IAnimatable[];
  72434. getActiveTextures(): BABYLON.BaseTexture[];
  72435. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72436. getClassName(): string;
  72437. dispose(forceDisposeEffect?: boolean): void;
  72438. clone(name: string): FireMaterial;
  72439. serialize(): any;
  72440. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  72441. }
  72442. }
  72443. declare module BABYLON {
  72444. /** @hidden */
  72445. export var furPixelShader: {
  72446. name: string;
  72447. shader: string;
  72448. };
  72449. }
  72450. declare module BABYLON {
  72451. /** @hidden */
  72452. export var furVertexShader: {
  72453. name: string;
  72454. shader: string;
  72455. };
  72456. }
  72457. declare module BABYLON {
  72458. export class FurMaterial extends BABYLON.PushMaterial {
  72459. private _diffuseTexture;
  72460. diffuseTexture: BABYLON.BaseTexture;
  72461. private _heightTexture;
  72462. heightTexture: BABYLON.BaseTexture;
  72463. diffuseColor: BABYLON.Color3;
  72464. furLength: number;
  72465. furAngle: number;
  72466. furColor: BABYLON.Color3;
  72467. furOffset: number;
  72468. furSpacing: number;
  72469. furGravity: BABYLON.Vector3;
  72470. furSpeed: number;
  72471. furDensity: number;
  72472. furOcclusion: number;
  72473. furTexture: BABYLON.DynamicTexture;
  72474. private _disableLighting;
  72475. disableLighting: boolean;
  72476. private _maxSimultaneousLights;
  72477. maxSimultaneousLights: number;
  72478. highLevelFur: boolean;
  72479. _meshes: BABYLON.AbstractMesh[];
  72480. private _renderId;
  72481. private _furTime;
  72482. constructor(name: string, scene: BABYLON.Scene);
  72483. furTime: number;
  72484. needAlphaBlending(): boolean;
  72485. needAlphaTesting(): boolean;
  72486. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72487. updateFur(): void;
  72488. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72489. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72490. getAnimatables(): BABYLON.IAnimatable[];
  72491. getActiveTextures(): BABYLON.BaseTexture[];
  72492. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72493. dispose(forceDisposeEffect?: boolean): void;
  72494. clone(name: string): FurMaterial;
  72495. serialize(): any;
  72496. getClassName(): string;
  72497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  72498. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  72499. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. /** @hidden */
  72504. export var gradientPixelShader: {
  72505. name: string;
  72506. shader: string;
  72507. };
  72508. }
  72509. declare module BABYLON {
  72510. /** @hidden */
  72511. export var gradientVertexShader: {
  72512. name: string;
  72513. shader: string;
  72514. };
  72515. }
  72516. declare module BABYLON {
  72517. export class GradientMaterial extends BABYLON.PushMaterial {
  72518. private _maxSimultaneousLights;
  72519. maxSimultaneousLights: number;
  72520. topColor: BABYLON.Color3;
  72521. topColorAlpha: number;
  72522. bottomColor: BABYLON.Color3;
  72523. bottomColorAlpha: number;
  72524. offset: number;
  72525. scale: number;
  72526. smoothness: number;
  72527. private _disableLighting;
  72528. disableLighting: boolean;
  72529. private _renderId;
  72530. constructor(name: string, scene: BABYLON.Scene);
  72531. needAlphaBlending(): boolean;
  72532. needAlphaTesting(): boolean;
  72533. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72536. getAnimatables(): BABYLON.IAnimatable[];
  72537. dispose(forceDisposeEffect?: boolean): void;
  72538. clone(name: string): GradientMaterial;
  72539. serialize(): any;
  72540. getClassName(): string;
  72541. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  72542. }
  72543. }
  72544. declare module BABYLON {
  72545. /** @hidden */
  72546. export var gridPixelShader: {
  72547. name: string;
  72548. shader: string;
  72549. };
  72550. }
  72551. declare module BABYLON {
  72552. /** @hidden */
  72553. export var gridVertexShader: {
  72554. name: string;
  72555. shader: string;
  72556. };
  72557. }
  72558. declare module BABYLON {
  72559. /**
  72560. * The grid materials allows you to wrap any shape with a grid.
  72561. * Colors are customizable.
  72562. */
  72563. export class GridMaterial extends BABYLON.PushMaterial {
  72564. /**
  72565. * Main color of the grid (e.g. between lines)
  72566. */
  72567. mainColor: BABYLON.Color3;
  72568. /**
  72569. * Color of the grid lines.
  72570. */
  72571. lineColor: BABYLON.Color3;
  72572. /**
  72573. * The scale of the grid compared to unit.
  72574. */
  72575. gridRatio: number;
  72576. /**
  72577. * Allows setting an offset for the grid lines.
  72578. */
  72579. gridOffset: BABYLON.Vector3;
  72580. /**
  72581. * The frequency of thicker lines.
  72582. */
  72583. majorUnitFrequency: number;
  72584. /**
  72585. * The visibility of minor units in the grid.
  72586. */
  72587. minorUnitVisibility: number;
  72588. /**
  72589. * The grid opacity outside of the lines.
  72590. */
  72591. opacity: number;
  72592. /**
  72593. * Determine RBG output is premultiplied by alpha value.
  72594. */
  72595. preMultiplyAlpha: boolean;
  72596. private _opacityTexture;
  72597. opacityTexture: BABYLON.BaseTexture;
  72598. private _gridControl;
  72599. private _renderId;
  72600. /**
  72601. * constructor
  72602. * @param name The name given to the material in order to identify it afterwards.
  72603. * @param scene The scene the material is used in.
  72604. */
  72605. constructor(name: string, scene: BABYLON.Scene);
  72606. /**
  72607. * Returns wehter or not the grid requires alpha blending.
  72608. */
  72609. needAlphaBlending(): boolean;
  72610. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72613. /**
  72614. * Dispose the material and its associated resources.
  72615. * @param forceDisposeEffect will also dispose the used effect when true
  72616. */
  72617. dispose(forceDisposeEffect?: boolean): void;
  72618. clone(name: string): GridMaterial;
  72619. serialize(): any;
  72620. getClassName(): string;
  72621. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  72622. }
  72623. }
  72624. declare module BABYLON {
  72625. /** @hidden */
  72626. export var lavaPixelShader: {
  72627. name: string;
  72628. shader: string;
  72629. };
  72630. }
  72631. declare module BABYLON {
  72632. /** @hidden */
  72633. export var lavaVertexShader: {
  72634. name: string;
  72635. shader: string;
  72636. };
  72637. }
  72638. declare module BABYLON {
  72639. export class LavaMaterial extends BABYLON.PushMaterial {
  72640. private _diffuseTexture;
  72641. diffuseTexture: BABYLON.BaseTexture;
  72642. noiseTexture: BABYLON.BaseTexture;
  72643. fogColor: BABYLON.Color3;
  72644. speed: number;
  72645. movingSpeed: number;
  72646. lowFrequencySpeed: number;
  72647. fogDensity: number;
  72648. private _lastTime;
  72649. diffuseColor: BABYLON.Color3;
  72650. private _disableLighting;
  72651. disableLighting: boolean;
  72652. private _unlit;
  72653. unlit: boolean;
  72654. private _maxSimultaneousLights;
  72655. maxSimultaneousLights: number;
  72656. private _scaledDiffuse;
  72657. private _renderId;
  72658. constructor(name: string, scene: BABYLON.Scene);
  72659. needAlphaBlending(): boolean;
  72660. needAlphaTesting(): boolean;
  72661. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72662. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72663. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72664. getAnimatables(): BABYLON.IAnimatable[];
  72665. getActiveTextures(): BABYLON.BaseTexture[];
  72666. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72667. dispose(forceDisposeEffect?: boolean): void;
  72668. clone(name: string): LavaMaterial;
  72669. serialize(): any;
  72670. getClassName(): string;
  72671. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  72672. }
  72673. }
  72674. declare module BABYLON {
  72675. /** @hidden */
  72676. export var mixPixelShader: {
  72677. name: string;
  72678. shader: string;
  72679. };
  72680. }
  72681. declare module BABYLON {
  72682. /** @hidden */
  72683. export var mixVertexShader: {
  72684. name: string;
  72685. shader: string;
  72686. };
  72687. }
  72688. declare module BABYLON {
  72689. export class MixMaterial extends BABYLON.PushMaterial {
  72690. /**
  72691. * Mix textures
  72692. */
  72693. private _mixTexture1;
  72694. mixTexture1: BABYLON.BaseTexture;
  72695. private _mixTexture2;
  72696. mixTexture2: BABYLON.BaseTexture;
  72697. /**
  72698. * Diffuse textures
  72699. */
  72700. private _diffuseTexture1;
  72701. diffuseTexture1: BABYLON.Texture;
  72702. private _diffuseTexture2;
  72703. diffuseTexture2: BABYLON.Texture;
  72704. private _diffuseTexture3;
  72705. diffuseTexture3: BABYLON.Texture;
  72706. private _diffuseTexture4;
  72707. diffuseTexture4: BABYLON.Texture;
  72708. private _diffuseTexture5;
  72709. diffuseTexture5: BABYLON.Texture;
  72710. private _diffuseTexture6;
  72711. diffuseTexture6: BABYLON.Texture;
  72712. private _diffuseTexture7;
  72713. diffuseTexture7: BABYLON.Texture;
  72714. private _diffuseTexture8;
  72715. diffuseTexture8: BABYLON.Texture;
  72716. /**
  72717. * Uniforms
  72718. */
  72719. diffuseColor: BABYLON.Color3;
  72720. specularColor: BABYLON.Color3;
  72721. specularPower: number;
  72722. private _disableLighting;
  72723. disableLighting: boolean;
  72724. private _maxSimultaneousLights;
  72725. maxSimultaneousLights: number;
  72726. private _renderId;
  72727. constructor(name: string, scene: BABYLON.Scene);
  72728. needAlphaBlending(): boolean;
  72729. needAlphaTesting(): boolean;
  72730. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72731. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72732. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72733. getAnimatables(): BABYLON.IAnimatable[];
  72734. getActiveTextures(): BABYLON.BaseTexture[];
  72735. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72736. dispose(forceDisposeEffect?: boolean): void;
  72737. clone(name: string): MixMaterial;
  72738. serialize(): any;
  72739. getClassName(): string;
  72740. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  72741. }
  72742. }
  72743. declare module BABYLON {
  72744. /** @hidden */
  72745. export var normalPixelShader: {
  72746. name: string;
  72747. shader: string;
  72748. };
  72749. }
  72750. declare module BABYLON {
  72751. /** @hidden */
  72752. export var normalVertexShader: {
  72753. name: string;
  72754. shader: string;
  72755. };
  72756. }
  72757. declare module BABYLON {
  72758. export class NormalMaterial extends BABYLON.PushMaterial {
  72759. private _diffuseTexture;
  72760. diffuseTexture: BABYLON.BaseTexture;
  72761. diffuseColor: BABYLON.Color3;
  72762. private _disableLighting;
  72763. disableLighting: boolean;
  72764. private _maxSimultaneousLights;
  72765. maxSimultaneousLights: number;
  72766. private _renderId;
  72767. constructor(name: string, scene: BABYLON.Scene);
  72768. needAlphaBlending(): boolean;
  72769. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  72770. needAlphaTesting(): boolean;
  72771. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72772. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72773. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72774. getAnimatables(): BABYLON.IAnimatable[];
  72775. getActiveTextures(): BABYLON.BaseTexture[];
  72776. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72777. dispose(forceDisposeEffect?: boolean): void;
  72778. clone(name: string): NormalMaterial;
  72779. serialize(): any;
  72780. getClassName(): string;
  72781. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  72782. }
  72783. }
  72784. declare module BABYLON {
  72785. /** @hidden */
  72786. export var shadowOnlyPixelShader: {
  72787. name: string;
  72788. shader: string;
  72789. };
  72790. }
  72791. declare module BABYLON {
  72792. /** @hidden */
  72793. export var shadowOnlyVertexShader: {
  72794. name: string;
  72795. shader: string;
  72796. };
  72797. }
  72798. declare module BABYLON {
  72799. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  72800. private _renderId;
  72801. private _activeLight;
  72802. constructor(name: string, scene: BABYLON.Scene);
  72803. shadowColor: BABYLON.Color3;
  72804. needAlphaBlending(): boolean;
  72805. needAlphaTesting(): boolean;
  72806. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72807. activeLight: BABYLON.IShadowLight;
  72808. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72810. clone(name: string): ShadowOnlyMaterial;
  72811. serialize(): any;
  72812. getClassName(): string;
  72813. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  72814. }
  72815. }
  72816. declare module BABYLON {
  72817. /** @hidden */
  72818. export var simplePixelShader: {
  72819. name: string;
  72820. shader: string;
  72821. };
  72822. }
  72823. declare module BABYLON {
  72824. /** @hidden */
  72825. export var simpleVertexShader: {
  72826. name: string;
  72827. shader: string;
  72828. };
  72829. }
  72830. declare module BABYLON {
  72831. export class SimpleMaterial extends BABYLON.PushMaterial {
  72832. private _diffuseTexture;
  72833. diffuseTexture: BABYLON.BaseTexture;
  72834. diffuseColor: BABYLON.Color3;
  72835. private _disableLighting;
  72836. disableLighting: boolean;
  72837. private _maxSimultaneousLights;
  72838. maxSimultaneousLights: number;
  72839. private _renderId;
  72840. constructor(name: string, scene: BABYLON.Scene);
  72841. needAlphaBlending(): boolean;
  72842. needAlphaTesting(): boolean;
  72843. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72844. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72845. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72846. getAnimatables(): BABYLON.IAnimatable[];
  72847. getActiveTextures(): BABYLON.BaseTexture[];
  72848. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72849. dispose(forceDisposeEffect?: boolean): void;
  72850. clone(name: string): SimpleMaterial;
  72851. serialize(): any;
  72852. getClassName(): string;
  72853. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  72854. }
  72855. }
  72856. declare module BABYLON {
  72857. /** @hidden */
  72858. export var skyPixelShader: {
  72859. name: string;
  72860. shader: string;
  72861. };
  72862. }
  72863. declare module BABYLON {
  72864. /** @hidden */
  72865. export var skyVertexShader: {
  72866. name: string;
  72867. shader: string;
  72868. };
  72869. }
  72870. declare module BABYLON {
  72871. /**
  72872. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  72873. * @see https://doc.babylonjs.com/extensions/sky
  72874. */
  72875. export class SkyMaterial extends BABYLON.PushMaterial {
  72876. /**
  72877. * Defines the overall luminance of sky in interval ]0, 1[.
  72878. */
  72879. luminance: number;
  72880. /**
  72881. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  72882. */
  72883. turbidity: number;
  72884. /**
  72885. * Defines the sky appearance (light intensity).
  72886. */
  72887. rayleigh: number;
  72888. /**
  72889. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  72890. */
  72891. mieCoefficient: number;
  72892. /**
  72893. * Defines the amount of haze particles following the Mie scattering theory.
  72894. */
  72895. mieDirectionalG: number;
  72896. /**
  72897. * Defines the distance of the sun according to the active scene camera.
  72898. */
  72899. distance: number;
  72900. /**
  72901. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  72902. * "inclined".
  72903. */
  72904. inclination: number;
  72905. /**
  72906. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  72907. * an object direction and a reference direction.
  72908. */
  72909. azimuth: number;
  72910. /**
  72911. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  72912. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  72913. */
  72914. sunPosition: BABYLON.Vector3;
  72915. /**
  72916. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  72917. * .sunPosition property.
  72918. */
  72919. useSunPosition: boolean;
  72920. /**
  72921. * Defines an offset vector used to get a horizon offset.
  72922. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  72923. */
  72924. cameraOffset: BABYLON.Vector3;
  72925. private _cameraPosition;
  72926. private _renderId;
  72927. /**
  72928. * Instantiates a new sky material.
  72929. * This material allows to create dynamic and texture free
  72930. * effects for skyboxes by taking care of the atmosphere state.
  72931. * @see https://doc.babylonjs.com/extensions/sky
  72932. * @param name Define the name of the material in the scene
  72933. * @param scene Define the scene the material belong to
  72934. */
  72935. constructor(name: string, scene: BABYLON.Scene);
  72936. /**
  72937. * Specifies if the material will require alpha blending
  72938. * @returns a boolean specifying if alpha blending is needed
  72939. */
  72940. needAlphaBlending(): boolean;
  72941. /**
  72942. * Specifies if this material should be rendered in alpha test mode
  72943. * @returns false as the sky material doesn't need alpha testing.
  72944. */
  72945. needAlphaTesting(): boolean;
  72946. /**
  72947. * Get the texture used for alpha test purpose.
  72948. * @returns null as the sky material has no texture.
  72949. */
  72950. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72951. /**
  72952. * Get if the submesh is ready to be used and all its information available.
  72953. * Child classes can use it to update shaders
  72954. * @param mesh defines the mesh to check
  72955. * @param subMesh defines which submesh to check
  72956. * @param useInstances specifies that instances should be used
  72957. * @returns a boolean indicating that the submesh is ready or not
  72958. */
  72959. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72960. /**
  72961. * Binds the submesh to this material by preparing the effect and shader to draw
  72962. * @param world defines the world transformation matrix
  72963. * @param mesh defines the mesh containing the submesh
  72964. * @param subMesh defines the submesh to bind the material to
  72965. */
  72966. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72967. /**
  72968. * Get the list of animatables in the material.
  72969. * @returns the list of animatables object used in the material
  72970. */
  72971. getAnimatables(): BABYLON.IAnimatable[];
  72972. /**
  72973. * Disposes the material
  72974. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72975. */
  72976. dispose(forceDisposeEffect?: boolean): void;
  72977. /**
  72978. * Makes a duplicate of the material, and gives it a new name
  72979. * @param name defines the new name for the duplicated material
  72980. * @returns the cloned material
  72981. */
  72982. clone(name: string): SkyMaterial;
  72983. /**
  72984. * Serializes this material in a JSON representation
  72985. * @returns the serialized material object
  72986. */
  72987. serialize(): any;
  72988. /**
  72989. * Gets the current class name of the material e.g. "SkyMaterial"
  72990. * Mainly use in serialization.
  72991. * @returns the class name
  72992. */
  72993. getClassName(): string;
  72994. /**
  72995. * Creates a sky material from parsed material data
  72996. * @param source defines the JSON representation of the material
  72997. * @param scene defines the hosting scene
  72998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72999. * @returns a new sky material
  73000. */
  73001. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  73002. }
  73003. }
  73004. declare module BABYLON {
  73005. /** @hidden */
  73006. export var terrainPixelShader: {
  73007. name: string;
  73008. shader: string;
  73009. };
  73010. }
  73011. declare module BABYLON {
  73012. /** @hidden */
  73013. export var terrainVertexShader: {
  73014. name: string;
  73015. shader: string;
  73016. };
  73017. }
  73018. declare module BABYLON {
  73019. export class TerrainMaterial extends BABYLON.PushMaterial {
  73020. private _mixTexture;
  73021. mixTexture: BABYLON.BaseTexture;
  73022. private _diffuseTexture1;
  73023. diffuseTexture1: BABYLON.Texture;
  73024. private _diffuseTexture2;
  73025. diffuseTexture2: BABYLON.Texture;
  73026. private _diffuseTexture3;
  73027. diffuseTexture3: BABYLON.Texture;
  73028. private _bumpTexture1;
  73029. bumpTexture1: BABYLON.Texture;
  73030. private _bumpTexture2;
  73031. bumpTexture2: BABYLON.Texture;
  73032. private _bumpTexture3;
  73033. bumpTexture3: BABYLON.Texture;
  73034. diffuseColor: BABYLON.Color3;
  73035. specularColor: BABYLON.Color3;
  73036. specularPower: number;
  73037. private _disableLighting;
  73038. disableLighting: boolean;
  73039. private _maxSimultaneousLights;
  73040. maxSimultaneousLights: number;
  73041. private _renderId;
  73042. constructor(name: string, scene: BABYLON.Scene);
  73043. needAlphaBlending(): boolean;
  73044. needAlphaTesting(): boolean;
  73045. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73046. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73047. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73048. getAnimatables(): BABYLON.IAnimatable[];
  73049. getActiveTextures(): BABYLON.BaseTexture[];
  73050. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73051. dispose(forceDisposeEffect?: boolean): void;
  73052. clone(name: string): TerrainMaterial;
  73053. serialize(): any;
  73054. getClassName(): string;
  73055. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  73056. }
  73057. }
  73058. declare module BABYLON {
  73059. /** @hidden */
  73060. export var triplanarPixelShader: {
  73061. name: string;
  73062. shader: string;
  73063. };
  73064. }
  73065. declare module BABYLON {
  73066. /** @hidden */
  73067. export var triplanarVertexShader: {
  73068. name: string;
  73069. shader: string;
  73070. };
  73071. }
  73072. declare module BABYLON {
  73073. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  73074. mixTexture: BABYLON.BaseTexture;
  73075. private _diffuseTextureX;
  73076. diffuseTextureX: BABYLON.BaseTexture;
  73077. private _diffuseTextureY;
  73078. diffuseTextureY: BABYLON.BaseTexture;
  73079. private _diffuseTextureZ;
  73080. diffuseTextureZ: BABYLON.BaseTexture;
  73081. private _normalTextureX;
  73082. normalTextureX: BABYLON.BaseTexture;
  73083. private _normalTextureY;
  73084. normalTextureY: BABYLON.BaseTexture;
  73085. private _normalTextureZ;
  73086. normalTextureZ: BABYLON.BaseTexture;
  73087. tileSize: number;
  73088. diffuseColor: BABYLON.Color3;
  73089. specularColor: BABYLON.Color3;
  73090. specularPower: number;
  73091. private _disableLighting;
  73092. disableLighting: boolean;
  73093. private _maxSimultaneousLights;
  73094. maxSimultaneousLights: number;
  73095. private _renderId;
  73096. constructor(name: string, scene: BABYLON.Scene);
  73097. needAlphaBlending(): boolean;
  73098. needAlphaTesting(): boolean;
  73099. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73100. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73101. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73102. getAnimatables(): BABYLON.IAnimatable[];
  73103. getActiveTextures(): BABYLON.BaseTexture[];
  73104. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73105. dispose(forceDisposeEffect?: boolean): void;
  73106. clone(name: string): TriPlanarMaterial;
  73107. serialize(): any;
  73108. getClassName(): string;
  73109. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  73110. }
  73111. }
  73112. declare module BABYLON {
  73113. /** @hidden */
  73114. export var waterPixelShader: {
  73115. name: string;
  73116. shader: string;
  73117. };
  73118. }
  73119. declare module BABYLON {
  73120. /** @hidden */
  73121. export var waterVertexShader: {
  73122. name: string;
  73123. shader: string;
  73124. };
  73125. }
  73126. declare module BABYLON {
  73127. export class WaterMaterial extends BABYLON.PushMaterial {
  73128. renderTargetSize: BABYLON.Vector2;
  73129. private _bumpTexture;
  73130. bumpTexture: BABYLON.BaseTexture;
  73131. diffuseColor: BABYLON.Color3;
  73132. specularColor: BABYLON.Color3;
  73133. specularPower: number;
  73134. private _disableLighting;
  73135. disableLighting: boolean;
  73136. private _maxSimultaneousLights;
  73137. maxSimultaneousLights: number;
  73138. /**
  73139. * @param {number}: Represents the wind force
  73140. */
  73141. windForce: number;
  73142. /**
  73143. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  73144. */
  73145. windDirection: BABYLON.Vector2;
  73146. /**
  73147. * @param {number}: Wave height, represents the height of the waves
  73148. */
  73149. waveHeight: number;
  73150. /**
  73151. * @param {number}: Bump height, represents the bump height related to the bump map
  73152. */
  73153. bumpHeight: number;
  73154. /**
  73155. * @param {boolean}: Add a smaller moving bump to less steady waves.
  73156. */
  73157. private _bumpSuperimpose;
  73158. bumpSuperimpose: boolean;
  73159. /**
  73160. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  73161. */
  73162. private _fresnelSeparate;
  73163. fresnelSeparate: boolean;
  73164. /**
  73165. * @param {boolean}: bump Waves modify the reflection.
  73166. */
  73167. private _bumpAffectsReflection;
  73168. bumpAffectsReflection: boolean;
  73169. /**
  73170. * @param {number}: The water color blended with the refraction (near)
  73171. */
  73172. waterColor: BABYLON.Color3;
  73173. /**
  73174. * @param {number}: The blend factor related to the water color
  73175. */
  73176. colorBlendFactor: number;
  73177. /**
  73178. * @param {number}: The water color blended with the reflection (far)
  73179. */
  73180. waterColor2: BABYLON.Color3;
  73181. /**
  73182. * @param {number}: The blend factor related to the water color (reflection, far)
  73183. */
  73184. colorBlendFactor2: number;
  73185. /**
  73186. * @param {number}: Represents the maximum length of a wave
  73187. */
  73188. waveLength: number;
  73189. /**
  73190. * @param {number}: Defines the waves speed
  73191. */
  73192. waveSpeed: number;
  73193. /**
  73194. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  73195. * will avoid calculating useless pixels in the pixel shader of the water material.
  73196. */
  73197. disableClipPlane: boolean;
  73198. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  73199. private _mesh;
  73200. private _refractionRTT;
  73201. private _reflectionRTT;
  73202. private _reflectionTransform;
  73203. private _lastTime;
  73204. private _lastDeltaTime;
  73205. private _renderId;
  73206. private _useLogarithmicDepth;
  73207. private _waitingRenderList;
  73208. private _imageProcessingConfiguration;
  73209. private _imageProcessingObserver;
  73210. /**
  73211. * Gets a boolean indicating that current material needs to register RTT
  73212. */
  73213. readonly hasRenderTargetTextures: boolean;
  73214. /**
  73215. * Constructor
  73216. */
  73217. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  73218. useLogarithmicDepth: boolean;
  73219. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73220. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  73221. addToRenderList(node: any): void;
  73222. enableRenderTargets(enable: boolean): void;
  73223. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  73224. readonly renderTargetsEnabled: boolean;
  73225. needAlphaBlending(): boolean;
  73226. needAlphaTesting(): boolean;
  73227. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73228. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73229. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73230. private _createRenderTargets;
  73231. getAnimatables(): BABYLON.IAnimatable[];
  73232. getActiveTextures(): BABYLON.BaseTexture[];
  73233. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73234. dispose(forceDisposeEffect?: boolean): void;
  73235. clone(name: string): WaterMaterial;
  73236. serialize(): any;
  73237. getClassName(): string;
  73238. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  73239. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  73240. }
  73241. }
  73242. declare module BABYLON {
  73243. /** @hidden */
  73244. export var asciiartPixelShader: {
  73245. name: string;
  73246. shader: string;
  73247. };
  73248. }
  73249. declare module BABYLON {
  73250. /**
  73251. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  73252. *
  73253. * It basically takes care rendering the font front the given font size to a texture.
  73254. * This is used later on in the postprocess.
  73255. */
  73256. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  73257. private _font;
  73258. private _text;
  73259. private _charSize;
  73260. /**
  73261. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73262. */
  73263. readonly charSize: number;
  73264. /**
  73265. * Create a new instance of the Ascii Art FontTexture class
  73266. * @param name the name of the texture
  73267. * @param font the font to use, use the W3C CSS notation
  73268. * @param text the caracter set to use in the rendering.
  73269. * @param scene the scene that owns the texture
  73270. */
  73271. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73272. /**
  73273. * Gets the max char width of a font.
  73274. * @param font the font to use, use the W3C CSS notation
  73275. * @return the max char width
  73276. */
  73277. private getFontWidth;
  73278. /**
  73279. * Gets the max char height of a font.
  73280. * @param font the font to use, use the W3C CSS notation
  73281. * @return the max char height
  73282. */
  73283. private getFontHeight;
  73284. /**
  73285. * Clones the current AsciiArtTexture.
  73286. * @return the clone of the texture.
  73287. */
  73288. clone(): AsciiArtFontTexture;
  73289. /**
  73290. * Parses a json object representing the texture and returns an instance of it.
  73291. * @param source the source JSON representation
  73292. * @param scene the scene to create the texture for
  73293. * @return the parsed texture
  73294. */
  73295. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  73296. }
  73297. /**
  73298. * Option available in the Ascii Art Post Process.
  73299. */
  73300. export interface IAsciiArtPostProcessOptions {
  73301. /**
  73302. * The font to use following the w3c font definition.
  73303. */
  73304. font?: string;
  73305. /**
  73306. * The character set to use in the postprocess.
  73307. */
  73308. characterSet?: string;
  73309. /**
  73310. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73311. * This number is defined between 0 and 1;
  73312. */
  73313. mixToTile?: number;
  73314. /**
  73315. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73316. * This number is defined between 0 and 1;
  73317. */
  73318. mixToNormal?: number;
  73319. }
  73320. /**
  73321. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  73322. *
  73323. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73324. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  73325. */
  73326. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  73327. /**
  73328. * The font texture used to render the char in the post process.
  73329. */
  73330. private _asciiArtFontTexture;
  73331. /**
  73332. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  73333. * This number is defined between 0 and 1;
  73334. */
  73335. mixToTile: number;
  73336. /**
  73337. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  73338. * This number is defined between 0 and 1;
  73339. */
  73340. mixToNormal: number;
  73341. /**
  73342. * Instantiates a new Ascii Art Post Process.
  73343. * @param name the name to give to the postprocess
  73344. * @camera the camera to apply the post process to.
  73345. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  73346. */
  73347. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  73348. }
  73349. }
  73350. declare module BABYLON {
  73351. /** @hidden */
  73352. export var digitalrainPixelShader: {
  73353. name: string;
  73354. shader: string;
  73355. };
  73356. }
  73357. declare module BABYLON {
  73358. /**
  73359. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  73360. *
  73361. * It basically takes care rendering the font front the given font size to a texture.
  73362. * This is used later on in the postprocess.
  73363. */
  73364. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  73365. private _font;
  73366. private _text;
  73367. private _charSize;
  73368. /**
  73369. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  73370. */
  73371. readonly charSize: number;
  73372. /**
  73373. * Create a new instance of the Digital Rain FontTexture class
  73374. * @param name the name of the texture
  73375. * @param font the font to use, use the W3C CSS notation
  73376. * @param text the caracter set to use in the rendering.
  73377. * @param scene the scene that owns the texture
  73378. */
  73379. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  73380. /**
  73381. * Gets the max char width of a font.
  73382. * @param font the font to use, use the W3C CSS notation
  73383. * @return the max char width
  73384. */
  73385. private getFontWidth;
  73386. /**
  73387. * Gets the max char height of a font.
  73388. * @param font the font to use, use the W3C CSS notation
  73389. * @return the max char height
  73390. */
  73391. private getFontHeight;
  73392. /**
  73393. * Clones the current DigitalRainFontTexture.
  73394. * @return the clone of the texture.
  73395. */
  73396. clone(): DigitalRainFontTexture;
  73397. /**
  73398. * Parses a json object representing the texture and returns an instance of it.
  73399. * @param source the source JSON representation
  73400. * @param scene the scene to create the texture for
  73401. * @return the parsed texture
  73402. */
  73403. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  73404. }
  73405. /**
  73406. * Option available in the Digital Rain Post Process.
  73407. */
  73408. export interface IDigitalRainPostProcessOptions {
  73409. /**
  73410. * The font to use following the w3c font definition.
  73411. */
  73412. font?: string;
  73413. /**
  73414. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73415. * This number is defined between 0 and 1;
  73416. */
  73417. mixToTile?: number;
  73418. /**
  73419. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73420. * This number is defined between 0 and 1;
  73421. */
  73422. mixToNormal?: number;
  73423. }
  73424. /**
  73425. * DigitalRainPostProcess helps rendering everithing in digital rain.
  73426. *
  73427. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73428. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  73429. */
  73430. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  73431. /**
  73432. * The font texture used to render the char in the post process.
  73433. */
  73434. private _digitalRainFontTexture;
  73435. /**
  73436. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  73437. * This number is defined between 0 and 1;
  73438. */
  73439. mixToTile: number;
  73440. /**
  73441. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  73442. * This number is defined between 0 and 1;
  73443. */
  73444. mixToNormal: number;
  73445. /**
  73446. * Instantiates a new Digital Rain Post Process.
  73447. * @param name the name to give to the postprocess
  73448. * @camera the camera to apply the post process to.
  73449. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  73450. */
  73451. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  73452. }
  73453. }
  73454. declare module BABYLON {
  73455. /** @hidden */
  73456. export var oceanPostProcessPixelShader: {
  73457. name: string;
  73458. shader: string;
  73459. };
  73460. }
  73461. declare module BABYLON {
  73462. /**
  73463. * Option available in the Ocean Post Process.
  73464. */
  73465. export interface IOceanPostProcessOptions {
  73466. /**
  73467. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73468. */
  73469. reflectionSize?: number | {
  73470. width: number;
  73471. height: number;
  73472. } | {
  73473. ratio: number;
  73474. };
  73475. /**
  73476. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  73477. */
  73478. refractionSize?: number | {
  73479. width: number;
  73480. height: number;
  73481. } | {
  73482. ratio: number;
  73483. };
  73484. }
  73485. /**
  73486. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  73487. *
  73488. * Simmply add it to your scene and let the nerd that lives in you have fun.
  73489. * Example usage:
  73490. * var pp = new OceanPostProcess("myOcean", camera);
  73491. * pp.reflectionEnabled = true;
  73492. * pp.refractionEnabled = true;
  73493. */
  73494. export class OceanPostProcess extends BABYLON.PostProcess {
  73495. /**
  73496. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  73497. */
  73498. /**
  73499. * Sets weither or not the real-time reflection is enabled on the ocean.
  73500. * Is set to true, the reflection mirror texture will be used as reflection texture.
  73501. */
  73502. reflectionEnabled: boolean;
  73503. /**
  73504. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  73505. */
  73506. /**
  73507. * Sets weither or not the real-time refraction is enabled on the ocean.
  73508. * Is set to true, the refraction render target texture will be used as refraction texture.
  73509. */
  73510. refractionEnabled: boolean;
  73511. /**
  73512. * Gets wether or not the post-processes is supported by the running hardware.
  73513. * This requires draw buffer supports.
  73514. */
  73515. readonly isSupported: boolean;
  73516. /**
  73517. * This is the reflection mirror texture used to display reflections on the ocean.
  73518. * By default, render list is empty.
  73519. */
  73520. reflectionTexture: BABYLON.MirrorTexture;
  73521. /**
  73522. * This is the refraction render target texture used to display refraction on the ocean.
  73523. * By default, render list is empty.
  73524. */
  73525. refractionTexture: BABYLON.RenderTargetTexture;
  73526. private _time;
  73527. private _cameraRotation;
  73528. private _cameraViewMatrix;
  73529. private _reflectionEnabled;
  73530. private _refractionEnabled;
  73531. private _geometryRenderer;
  73532. /**
  73533. * Instantiates a new Ocean Post Process.
  73534. * @param name the name to give to the postprocess.
  73535. * @camera the camera to apply the post process to.
  73536. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  73537. */
  73538. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  73539. /**
  73540. * Returns the appropriate defines according to the current configuration.
  73541. */
  73542. private _getDefines;
  73543. /**
  73544. * Computes the current camera rotation as the shader requires a camera rotation.
  73545. */
  73546. private _computeCameraRotation;
  73547. }
  73548. }
  73549. declare module BABYLON {
  73550. /** @hidden */
  73551. export var brickProceduralTexturePixelShader: {
  73552. name: string;
  73553. shader: string;
  73554. };
  73555. }
  73556. declare module BABYLON {
  73557. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  73558. private _numberOfBricksHeight;
  73559. private _numberOfBricksWidth;
  73560. private _jointColor;
  73561. private _brickColor;
  73562. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73563. updateShaderUniforms(): void;
  73564. numberOfBricksHeight: number;
  73565. numberOfBricksWidth: number;
  73566. jointColor: BABYLON.Color3;
  73567. brickColor: BABYLON.Color3;
  73568. /**
  73569. * Serializes this brick procedural texture
  73570. * @returns a serialized brick procedural texture object
  73571. */
  73572. serialize(): any;
  73573. /**
  73574. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  73575. * @param parsedTexture defines parsed texture data
  73576. * @param scene defines the current scene
  73577. * @param rootUrl defines the root URL containing brick procedural texture information
  73578. * @returns a parsed Brick Procedural BABYLON.Texture
  73579. */
  73580. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  73581. }
  73582. }
  73583. declare module BABYLON {
  73584. /** @hidden */
  73585. export var cloudProceduralTexturePixelShader: {
  73586. name: string;
  73587. shader: string;
  73588. };
  73589. }
  73590. declare module BABYLON {
  73591. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  73592. private _skyColor;
  73593. private _cloudColor;
  73594. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73595. updateShaderUniforms(): void;
  73596. skyColor: BABYLON.Color4;
  73597. cloudColor: BABYLON.Color4;
  73598. /**
  73599. * Serializes this cloud procedural texture
  73600. * @returns a serialized cloud procedural texture object
  73601. */
  73602. serialize(): any;
  73603. /**
  73604. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  73605. * @param parsedTexture defines parsed texture data
  73606. * @param scene defines the current scene
  73607. * @param rootUrl defines the root URL containing cloud procedural texture information
  73608. * @returns a parsed Cloud Procedural BABYLON.Texture
  73609. */
  73610. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  73611. }
  73612. }
  73613. declare module BABYLON {
  73614. /** @hidden */
  73615. export var fireProceduralTexturePixelShader: {
  73616. name: string;
  73617. shader: string;
  73618. };
  73619. }
  73620. declare module BABYLON {
  73621. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  73622. private _time;
  73623. private _speed;
  73624. private _autoGenerateTime;
  73625. private _fireColors;
  73626. private _alphaThreshold;
  73627. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73628. updateShaderUniforms(): void;
  73629. render(useCameraPostProcess?: boolean): void;
  73630. static readonly PurpleFireColors: BABYLON.Color3[];
  73631. static readonly GreenFireColors: BABYLON.Color3[];
  73632. static readonly RedFireColors: BABYLON.Color3[];
  73633. static readonly BlueFireColors: BABYLON.Color3[];
  73634. autoGenerateTime: boolean;
  73635. fireColors: BABYLON.Color3[];
  73636. time: number;
  73637. speed: BABYLON.Vector2;
  73638. alphaThreshold: number;
  73639. /**
  73640. * Serializes this fire procedural texture
  73641. * @returns a serialized fire procedural texture object
  73642. */
  73643. serialize(): any;
  73644. /**
  73645. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  73646. * @param parsedTexture defines parsed texture data
  73647. * @param scene defines the current scene
  73648. * @param rootUrl defines the root URL containing fire procedural texture information
  73649. * @returns a parsed Fire Procedural BABYLON.Texture
  73650. */
  73651. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  73652. }
  73653. }
  73654. declare module BABYLON {
  73655. /** @hidden */
  73656. export var grassProceduralTexturePixelShader: {
  73657. name: string;
  73658. shader: string;
  73659. };
  73660. }
  73661. declare module BABYLON {
  73662. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  73663. private _grassColors;
  73664. private _groundColor;
  73665. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73666. updateShaderUniforms(): void;
  73667. grassColors: BABYLON.Color3[];
  73668. groundColor: BABYLON.Color3;
  73669. /**
  73670. * Serializes this grass procedural texture
  73671. * @returns a serialized grass procedural texture object
  73672. */
  73673. serialize(): any;
  73674. /**
  73675. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  73676. * @param parsedTexture defines parsed texture data
  73677. * @param scene defines the current scene
  73678. * @param rootUrl defines the root URL containing grass procedural texture information
  73679. * @returns a parsed Grass Procedural BABYLON.Texture
  73680. */
  73681. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  73682. }
  73683. }
  73684. declare module BABYLON {
  73685. /** @hidden */
  73686. export var marbleProceduralTexturePixelShader: {
  73687. name: string;
  73688. shader: string;
  73689. };
  73690. }
  73691. declare module BABYLON {
  73692. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  73693. private _numberOfTilesHeight;
  73694. private _numberOfTilesWidth;
  73695. private _amplitude;
  73696. private _jointColor;
  73697. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73698. updateShaderUniforms(): void;
  73699. numberOfTilesHeight: number;
  73700. amplitude: number;
  73701. numberOfTilesWidth: number;
  73702. jointColor: BABYLON.Color3;
  73703. /**
  73704. * Serializes this marble procedural texture
  73705. * @returns a serialized marble procedural texture object
  73706. */
  73707. serialize(): any;
  73708. /**
  73709. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  73710. * @param parsedTexture defines parsed texture data
  73711. * @param scene defines the current scene
  73712. * @param rootUrl defines the root URL containing marble procedural texture information
  73713. * @returns a parsed Marble Procedural BABYLON.Texture
  73714. */
  73715. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  73716. }
  73717. }
  73718. declare module BABYLON {
  73719. /** @hidden */
  73720. export var normalMapProceduralTexturePixelShader: {
  73721. name: string;
  73722. shader: string;
  73723. };
  73724. }
  73725. declare module BABYLON {
  73726. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  73727. private _baseTexture;
  73728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73729. updateShaderUniforms(): void;
  73730. render(useCameraPostProcess?: boolean): void;
  73731. resize(size: any, generateMipMaps: any): void;
  73732. baseTexture: BABYLON.Texture;
  73733. /**
  73734. * Serializes this normal map procedural texture
  73735. * @returns a serialized normal map procedural texture object
  73736. */
  73737. serialize(): any;
  73738. /**
  73739. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  73740. * @param parsedTexture defines parsed texture data
  73741. * @param scene defines the current scene
  73742. * @param rootUrl defines the root URL containing normal map procedural texture information
  73743. * @returns a parsed Normal Map Procedural BABYLON.Texture
  73744. */
  73745. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  73746. }
  73747. }
  73748. declare module BABYLON {
  73749. /** @hidden */
  73750. export var perlinNoiseProceduralTexturePixelShader: {
  73751. name: string;
  73752. shader: string;
  73753. };
  73754. }
  73755. declare module BABYLON {
  73756. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  73757. time: number;
  73758. timeScale: number;
  73759. translationSpeed: number;
  73760. private _currentTranslation;
  73761. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73762. updateShaderUniforms(): void;
  73763. render(useCameraPostProcess?: boolean): void;
  73764. resize(size: any, generateMipMaps: any): void;
  73765. /**
  73766. * Serializes this perlin noise procedural texture
  73767. * @returns a serialized perlin noise procedural texture object
  73768. */
  73769. serialize(): any;
  73770. /**
  73771. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  73772. * @param parsedTexture defines parsed texture data
  73773. * @param scene defines the current scene
  73774. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  73775. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  73776. */
  73777. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /** @hidden */
  73782. export var roadProceduralTexturePixelShader: {
  73783. name: string;
  73784. shader: string;
  73785. };
  73786. }
  73787. declare module BABYLON {
  73788. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  73789. private _roadColor;
  73790. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73791. updateShaderUniforms(): void;
  73792. roadColor: BABYLON.Color3;
  73793. /**
  73794. * Serializes this road procedural texture
  73795. * @returns a serialized road procedural texture object
  73796. */
  73797. serialize(): any;
  73798. /**
  73799. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  73800. * @param parsedTexture defines parsed texture data
  73801. * @param scene defines the current scene
  73802. * @param rootUrl defines the root URL containing road procedural texture information
  73803. * @returns a parsed Road Procedural BABYLON.Texture
  73804. */
  73805. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  73806. }
  73807. }
  73808. declare module BABYLON {
  73809. /** @hidden */
  73810. export var starfieldProceduralTexturePixelShader: {
  73811. name: string;
  73812. shader: string;
  73813. };
  73814. }
  73815. declare module BABYLON {
  73816. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  73817. private _time;
  73818. private _alpha;
  73819. private _beta;
  73820. private _zoom;
  73821. private _formuparam;
  73822. private _stepsize;
  73823. private _tile;
  73824. private _brightness;
  73825. private _darkmatter;
  73826. private _distfading;
  73827. private _saturation;
  73828. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73829. updateShaderUniforms(): void;
  73830. time: number;
  73831. alpha: number;
  73832. beta: number;
  73833. formuparam: number;
  73834. stepsize: number;
  73835. zoom: number;
  73836. tile: number;
  73837. brightness: number;
  73838. darkmatter: number;
  73839. distfading: number;
  73840. saturation: number;
  73841. /**
  73842. * Serializes this starfield procedural texture
  73843. * @returns a serialized starfield procedural texture object
  73844. */
  73845. serialize(): any;
  73846. /**
  73847. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  73848. * @param parsedTexture defines parsed texture data
  73849. * @param scene defines the current scene
  73850. * @param rootUrl defines the root URL containing startfield procedural texture information
  73851. * @returns a parsed Starfield Procedural BABYLON.Texture
  73852. */
  73853. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  73854. }
  73855. }
  73856. declare module BABYLON {
  73857. /** @hidden */
  73858. export var woodProceduralTexturePixelShader: {
  73859. name: string;
  73860. shader: string;
  73861. };
  73862. }
  73863. declare module BABYLON {
  73864. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  73865. private _ampScale;
  73866. private _woodColor;
  73867. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  73868. updateShaderUniforms(): void;
  73869. ampScale: number;
  73870. woodColor: BABYLON.Color3;
  73871. /**
  73872. * Serializes this wood procedural texture
  73873. * @returns a serialized wood procedural texture object
  73874. */
  73875. serialize(): any;
  73876. /**
  73877. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  73878. * @param parsedTexture defines parsed texture data
  73879. * @param scene defines the current scene
  73880. * @param rootUrl defines the root URL containing wood procedural texture information
  73881. * @returns a parsed Wood Procedural BABYLON.Texture
  73882. */
  73883. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  73884. }
  73885. }