documentation.d.ts 3.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */
  110. _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  410. */
  411. export class WebRequest {
  412. private _xhr;
  413. /**
  414. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  415. * i.e. when loading files, where the server/service expects an Authorization header
  416. */
  417. static CustomRequestHeaders: {
  418. [key: string]: string;
  419. };
  420. /**
  421. * Add callback functions in this array to update all the requests before they get sent to the network
  422. */
  423. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  424. private _injectCustomRequestHeaders;
  425. /**
  426. * Gets or sets a function to be called when loading progress changes
  427. */
  428. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  429. /**
  430. * Returns client's state
  431. */
  432. readonly readyState: number;
  433. /**
  434. * Returns client's status
  435. */
  436. readonly status: number;
  437. /**
  438. * Returns client's status as a text
  439. */
  440. readonly statusText: string;
  441. /**
  442. * Returns client's response
  443. */
  444. readonly response: any;
  445. /**
  446. * Returns client's response url
  447. */
  448. readonly responseURL: string;
  449. /**
  450. * Returns client's response as text
  451. */
  452. readonly responseText: string;
  453. /**
  454. * Gets or sets the expected response type
  455. */
  456. responseType: XMLHttpRequestResponseType;
  457. /** @hidden */
  458. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  459. /** @hidden */
  460. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  461. /**
  462. * Cancels any network activity
  463. */
  464. abort(): void;
  465. /**
  466. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  467. * @param body defines an optional request body
  468. */
  469. send(body?: Document | BodyInit | null): void;
  470. /**
  471. * Sets the request method, request URL
  472. * @param method defines the method to use (GET, POST, etc..)
  473. * @param url defines the url to connect with
  474. */
  475. open(method: string, url: string): void;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * File request interface
  481. */
  482. export interface IFileRequest {
  483. /**
  484. * Raised when the request is complete (success or error).
  485. */
  486. onCompleteObservable: Observable<IFileRequest>;
  487. /**
  488. * Aborts the request for a file.
  489. */
  490. abort: () => void;
  491. }
  492. }
  493. declare module BABYLON {
  494. /**
  495. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2072. * The cross product is then orthogonal to both current and "other"
  2073. * @param other defines the right operand
  2074. * @returns the cross product
  2075. */
  2076. cross(other: Vector3): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 with the given input length.
  2079. * Please note that this is an in place operation.
  2080. * @param len the length of the vector
  2081. * @returns the current updated Vector3
  2082. */
  2083. normalizeFromLength(len: number): Vector3;
  2084. /**
  2085. * Normalize the current Vector3 to a new vector
  2086. * @returns the new Vector3
  2087. */
  2088. normalizeToNew(): Vector3;
  2089. /**
  2090. * Normalize the current Vector3 to the reference
  2091. * @param reference define the Vector3 to update
  2092. * @returns the updated Vector3
  2093. */
  2094. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2095. /**
  2096. * Creates a new Vector3 copied from the current Vector3
  2097. * @returns the new Vector3
  2098. */
  2099. clone(): Vector3;
  2100. /**
  2101. * Copies the given vector coordinates to the current Vector3 ones
  2102. * @param source defines the source Vector3
  2103. * @returns the current updated Vector3
  2104. */
  2105. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2106. /**
  2107. * Copies the given floats to the current Vector3 coordinates
  2108. * @param x defines the x coordinate of the operand
  2109. * @param y defines the y coordinate of the operand
  2110. * @param z defines the z coordinate of the operand
  2111. * @returns the current updated Vector3
  2112. */
  2113. copyFromFloats(x: number, y: number, z: number): Vector3;
  2114. /**
  2115. * Copies the given floats to the current Vector3 coordinates
  2116. * @param x defines the x coordinate of the operand
  2117. * @param y defines the y coordinate of the operand
  2118. * @param z defines the z coordinate of the operand
  2119. * @returns the current updated Vector3
  2120. */
  2121. set(x: number, y: number, z: number): Vector3;
  2122. /**
  2123. * Copies the given float to the current Vector3 coordinates
  2124. * @param v defines the x, y and z coordinates of the operand
  2125. * @returns the current updated Vector3
  2126. */
  2127. setAll(v: number): Vector3;
  2128. /**
  2129. * Get the clip factor between two vectors
  2130. * @param vector0 defines the first operand
  2131. * @param vector1 defines the second operand
  2132. * @param axis defines the axis to use
  2133. * @param size defines the size along the axis
  2134. * @returns the clip factor
  2135. */
  2136. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2137. /**
  2138. * Get angle between two vectors
  2139. * @param vector0 angle between vector0 and vector1
  2140. * @param vector1 angle between vector0 and vector1
  2141. * @param normal direction of the normal
  2142. * @return the angle between vector0 and vector1
  2143. */
  2144. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given array
  2147. * @param array defines the source array
  2148. * @param offset defines the offset in the source array
  2149. * @returns the new Vector3
  2150. */
  2151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2152. /**
  2153. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2154. * This function is deprecated. Use FromArray instead
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @returns the new Vector3
  2158. */
  2159. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2162. * @param array defines the source array
  2163. * @param offset defines the offset in the source array
  2164. * @param result defines the Vector3 where to store the result
  2165. */
  2166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2167. /**
  2168. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2169. * This function is deprecated. Use FromArrayToRef instead.
  2170. * @param array defines the source array
  2171. * @param offset defines the offset in the source array
  2172. * @param result defines the Vector3 where to store the result
  2173. */
  2174. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2175. /**
  2176. * Sets the given vector "result" with the given floats.
  2177. * @param x defines the x coordinate of the source
  2178. * @param y defines the y coordinate of the source
  2179. * @param z defines the z coordinate of the source
  2180. * @param result defines the Vector3 where to store the result
  2181. */
  2182. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2183. /**
  2184. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2185. * @returns a new empty Vector3
  2186. */
  2187. static Zero(): Vector3;
  2188. /**
  2189. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2190. * @returns a new unit Vector3
  2191. */
  2192. static One(): Vector3;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2195. * @returns a new up Vector3
  2196. */
  2197. static Up(): Vector3;
  2198. /**
  2199. * Gets a up Vector3 that must not be updated
  2200. */
  2201. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2202. /**
  2203. * Gets a zero Vector3 that must not be updated
  2204. */
  2205. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2206. /**
  2207. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2208. * @returns a new down Vector3
  2209. */
  2210. static Down(): Vector3;
  2211. /**
  2212. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2213. * @returns a new forward Vector3
  2214. */
  2215. static Forward(): Vector3;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2218. * @returns a new forward Vector3
  2219. */
  2220. static Backward(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2223. * @returns a new right Vector3
  2224. */
  2225. static Right(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2228. * @returns a new left Vector3
  2229. */
  2230. static Left(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2233. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2234. * @param vector defines the Vector3 to transform
  2235. * @param transformation defines the transformation matrix
  2236. * @returns the transformed Vector3
  2237. */
  2238. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2239. /**
  2240. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2241. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2242. * @param vector defines the Vector3 to transform
  2243. * @param transformation defines the transformation matrix
  2244. * @param result defines the Vector3 where to store the result
  2245. */
  2246. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2247. /**
  2248. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2249. * This method computes tranformed coordinates only, not transformed direction vectors
  2250. * @param x define the x coordinate of the source vector
  2251. * @param y define the y coordinate of the source vector
  2252. * @param z define the z coordinate of the source vector
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2259. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2260. * @param vector defines the Vector3 to transform
  2261. * @param transformation defines the transformation matrix
  2262. * @returns the new Vector3
  2263. */
  2264. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2265. /**
  2266. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2267. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2268. * @param vector defines the Vector3 to transform
  2269. * @param transformation defines the transformation matrix
  2270. * @param result defines the Vector3 where to store the result
  2271. */
  2272. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2273. /**
  2274. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2275. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2276. * @param x define the x coordinate of the source vector
  2277. * @param y define the y coordinate of the source vector
  2278. * @param z define the z coordinate of the source vector
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2285. * @param value1 defines the first control point
  2286. * @param value2 defines the second control point
  2287. * @param value3 defines the third control point
  2288. * @param value4 defines the fourth control point
  2289. * @param amount defines the amount on the spline to use
  2290. * @returns the new Vector3
  2291. */
  2292. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2293. /**
  2294. * 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"
  2295. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2296. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2297. * @param value defines the current value
  2298. * @param min defines the lower range value
  2299. * @param max defines the upper range value
  2300. * @returns the new Vector3
  2301. */
  2302. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @param result defines the Vector3 where to store the result
  2311. */
  2312. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2313. /**
  2314. * Checks if a given vector is inside a specific range
  2315. * @param v defines the vector to test
  2316. * @param min defines the minimum range
  2317. * @param max defines the maximum range
  2318. */
  2319. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2320. /**
  2321. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2322. * @param value1 defines the first control point
  2323. * @param tangent1 defines the first tangent vector
  2324. * @param value2 defines the second control point
  2325. * @param tangent2 defines the second tangent vector
  2326. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2327. * @returns the new Vector3
  2328. */
  2329. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2332. * @param start defines the start value
  2333. * @param end defines the end value
  2334. * @param amount max defines amount between both (between 0 and 1)
  2335. * @returns the new Vector3
  2336. */
  2337. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2338. /**
  2339. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2340. * @param start defines the start value
  2341. * @param end defines the end value
  2342. * @param amount max defines amount between both (between 0 and 1)
  2343. * @param result defines the Vector3 where to store the result
  2344. */
  2345. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2346. /**
  2347. * Returns the dot product (float) between the vectors "left" and "right"
  2348. * @param left defines the left operand
  2349. * @param right defines the right operand
  2350. * @returns the dot product
  2351. */
  2352. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2353. /**
  2354. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2355. * The cross product is then orthogonal to both "left" and "right"
  2356. * @param left defines the left operand
  2357. * @param right defines the right operand
  2358. * @returns the cross product
  2359. */
  2360. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2361. /**
  2362. * Sets the given vector "result" with the cross product of "left" and "right"
  2363. * The cross product is then orthogonal to both "left" and "right"
  2364. * @param left defines the left operand
  2365. * @param right defines the right operand
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2369. /**
  2370. * Returns a new Vector3 as the normalization of the given vector
  2371. * @param vector defines the Vector3 to normalize
  2372. * @returns the new Vector3
  2373. */
  2374. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Sets the given vector "result" with the normalization of the given first vector
  2377. * @param vector defines the Vector3 to normalize
  2378. * @param result defines the Vector3 where to store the result
  2379. */
  2380. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2381. /**
  2382. * Project a Vector3 onto screen space
  2383. * @param vector defines the Vector3 to project
  2384. * @param world defines the world matrix to use
  2385. * @param transform defines the transform (view x projection) matrix to use
  2386. * @param viewport defines the screen viewport to use
  2387. * @returns the new Vector3
  2388. */
  2389. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2390. /** @hidden */
  2391. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2392. /**
  2393. * Unproject from screen space to object space
  2394. * @param source defines the screen space Vector3 to use
  2395. * @param viewportWidth defines the current width of the viewport
  2396. * @param viewportHeight defines the current height of the viewport
  2397. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2398. * @param transform defines the transform (view x projection) matrix to use
  2399. * @returns the new Vector3
  2400. */
  2401. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param view defines the view matrix to use
  2409. * @param projection defines the projection matrix to use
  2410. * @returns the new Vector3
  2411. */
  2412. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2413. /**
  2414. * Unproject from screen space to object space
  2415. * @param source defines the screen space Vector3 to use
  2416. * @param viewportWidth defines the current width of the viewport
  2417. * @param viewportHeight defines the current height of the viewport
  2418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2419. * @param view defines the view matrix to use
  2420. * @param projection defines the projection matrix to use
  2421. * @param result defines the Vector3 where to store the result
  2422. */
  2423. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2424. /**
  2425. * Unproject from screen space to object space
  2426. * @param sourceX defines the screen space x coordinate to use
  2427. * @param sourceY defines the screen space y coordinate to use
  2428. * @param sourceZ defines the screen space z coordinate to use
  2429. * @param viewportWidth defines the current width of the viewport
  2430. * @param viewportHeight defines the current height of the viewport
  2431. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2432. * @param view defines the view matrix to use
  2433. * @param projection defines the projection matrix to use
  2434. * @param result defines the Vector3 where to store the result
  2435. */
  2436. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2437. /**
  2438. * Gets the minimal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Gets the maximal coordinate values between two Vector3
  2446. * @param left defines the first operand
  2447. * @param right defines the second operand
  2448. * @returns the new Vector3
  2449. */
  2450. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2451. /**
  2452. * Returns the distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the distance
  2456. */
  2457. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns the squared distance between the vectors "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the squared distance
  2463. */
  2464. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2465. /**
  2466. * Returns a new Vector3 located at the center between "value1" and "value2"
  2467. * @param value1 defines the first operand
  2468. * @param value2 defines the second operand
  2469. * @returns the new Vector3
  2470. */
  2471. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2472. /**
  2473. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2474. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2475. * to something in order to rotate it from its local system to the given target system
  2476. * Note: axis1, axis2 and axis3 are normalized during this operation
  2477. * @param axis1 defines the first axis
  2478. * @param axis2 defines the second axis
  2479. * @param axis3 defines the third axis
  2480. * @returns a new Vector3
  2481. */
  2482. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2483. /**
  2484. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2485. * @param axis1 defines the first axis
  2486. * @param axis2 defines the second axis
  2487. * @param axis3 defines the third axis
  2488. * @param ref defines the Vector3 where to store the result
  2489. */
  2490. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2491. }
  2492. /**
  2493. * Vector4 class created for EulerAngle class conversion to Quaternion
  2494. */
  2495. export class Vector4 {
  2496. /** x value of the vector */
  2497. x: number;
  2498. /** y value of the vector */
  2499. y: number;
  2500. /** z value of the vector */
  2501. z: number;
  2502. /** w value of the vector */
  2503. w: number;
  2504. /**
  2505. * Creates a Vector4 object from the given floats.
  2506. * @param x x value of the vector
  2507. * @param y y value of the vector
  2508. * @param z z value of the vector
  2509. * @param w w value of the vector
  2510. */
  2511. constructor(
  2512. /** x value of the vector */
  2513. x: number,
  2514. /** y value of the vector */
  2515. y: number,
  2516. /** z value of the vector */
  2517. z: number,
  2518. /** w value of the vector */
  2519. w: number);
  2520. /**
  2521. * Returns the string with the Vector4 coordinates.
  2522. * @returns a string containing all the vector values
  2523. */
  2524. toString(): string;
  2525. /**
  2526. * Returns the string "Vector4".
  2527. * @returns "Vector4"
  2528. */
  2529. getClassName(): string;
  2530. /**
  2531. * Returns the Vector4 hash code.
  2532. * @returns a unique hash code
  2533. */
  2534. getHashCode(): number;
  2535. /**
  2536. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2537. * @returns the resulting array
  2538. */
  2539. asArray(): number[];
  2540. /**
  2541. * Populates the given array from the given index with the Vector4 coordinates.
  2542. * @param array array to populate
  2543. * @param index index of the array to start at (default: 0)
  2544. * @returns the Vector4.
  2545. */
  2546. toArray(array: FloatArray, index?: number): Vector4;
  2547. /**
  2548. * Adds the given vector to the current Vector4.
  2549. * @param otherVector the vector to add
  2550. * @returns the updated Vector4.
  2551. */
  2552. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2553. /**
  2554. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2555. * @param otherVector the vector to add
  2556. * @returns the resulting vector
  2557. */
  2558. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2559. /**
  2560. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2561. * @param otherVector the vector to add
  2562. * @param result the vector to store the result
  2563. * @returns the current Vector4.
  2564. */
  2565. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2566. /**
  2567. * Subtract in place the given vector from the current Vector4.
  2568. * @param otherVector the vector to subtract
  2569. * @returns the updated Vector4.
  2570. */
  2571. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2572. /**
  2573. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2574. * @param otherVector the vector to add
  2575. * @returns the new vector with the result
  2576. */
  2577. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2578. /**
  2579. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2580. * @param otherVector the vector to subtract
  2581. * @param result the vector to store the result
  2582. * @returns the current Vector4.
  2583. */
  2584. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2585. /**
  2586. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2587. */
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. * @param x value to subtract
  2591. * @param y value to subtract
  2592. * @param z value to subtract
  2593. * @param w value to subtract
  2594. * @returns new vector containing the result
  2595. */
  2596. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2597. /**
  2598. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2599. * @param x value to subtract
  2600. * @param y value to subtract
  2601. * @param z value to subtract
  2602. * @param w value to subtract
  2603. * @param result the vector to store the result in
  2604. * @returns the current Vector4.
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2607. /**
  2608. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2609. * @returns a new vector with the negated values
  2610. */
  2611. negate(): Vector4;
  2612. /**
  2613. * Multiplies the current Vector4 coordinates by scale (float).
  2614. * @param scale the number to scale with
  2615. * @returns the updated Vector4.
  2616. */
  2617. scaleInPlace(scale: number): Vector4;
  2618. /**
  2619. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2620. * @param scale the number to scale with
  2621. * @returns a new vector with the result
  2622. */
  2623. scale(scale: number): Vector4;
  2624. /**
  2625. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2626. * @param scale the number to scale with
  2627. * @param result a vector to store the result in
  2628. * @returns the current Vector4.
  2629. */
  2630. scaleToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2633. * @param scale defines the scale factor
  2634. * @param result defines the Vector4 object where to store the result
  2635. * @returns the unmodified current Vector4
  2636. */
  2637. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2638. /**
  2639. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2640. * @param otherVector the vector to compare against
  2641. * @returns true if they are equal
  2642. */
  2643. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2644. /**
  2645. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2646. * @param otherVector vector to compare against
  2647. * @param epsilon (Default: very small number)
  2648. * @returns true if they are equal
  2649. */
  2650. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2651. /**
  2652. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2653. * @param x x value to compare against
  2654. * @param y y value to compare against
  2655. * @param z z value to compare against
  2656. * @param w w value to compare against
  2657. * @returns true if equal
  2658. */
  2659. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2660. /**
  2661. * Multiplies in place the current Vector4 by the given one.
  2662. * @param otherVector vector to multiple with
  2663. * @returns the updated Vector4.
  2664. */
  2665. multiplyInPlace(otherVector: Vector4): Vector4;
  2666. /**
  2667. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2668. * @param otherVector vector to multiple with
  2669. * @returns resulting new vector
  2670. */
  2671. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2672. /**
  2673. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2674. * @param otherVector vector to multiple with
  2675. * @param result vector to store the result
  2676. * @returns the current Vector4.
  2677. */
  2678. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2679. /**
  2680. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2681. * @param x x value multiply with
  2682. * @param y y value multiply with
  2683. * @param z z value multiply with
  2684. * @param w w value multiply with
  2685. * @returns resulting new vector
  2686. */
  2687. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2688. /**
  2689. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2690. * @param otherVector vector to devide with
  2691. * @returns resulting new vector
  2692. */
  2693. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2694. /**
  2695. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2696. * @param otherVector vector to devide with
  2697. * @param result vector to store the result
  2698. * @returns the current Vector4.
  2699. */
  2700. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2701. /**
  2702. * Divides the current Vector3 coordinates by the given ones.
  2703. * @param otherVector vector to devide with
  2704. * @returns the updated Vector3.
  2705. */
  2706. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2707. /**
  2708. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector4
  2711. */
  2712. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2713. /**
  2714. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2715. * @param other defines the second operand
  2716. * @returns the current updated Vector4
  2717. */
  2718. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2719. /**
  2720. * Gets a new Vector4 from current Vector4 floored values
  2721. * @returns a new Vector4
  2722. */
  2723. floor(): Vector4;
  2724. /**
  2725. * Gets a new Vector4 from current Vector3 floored values
  2726. * @returns a new Vector4
  2727. */
  2728. fract(): Vector4;
  2729. /**
  2730. * Returns the Vector4 length (float).
  2731. * @returns the length
  2732. */
  2733. length(): number;
  2734. /**
  2735. * Returns the Vector4 squared length (float).
  2736. * @returns the length squared
  2737. */
  2738. lengthSquared(): number;
  2739. /**
  2740. * Normalizes in place the Vector4.
  2741. * @returns the updated Vector4.
  2742. */
  2743. normalize(): Vector4;
  2744. /**
  2745. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2746. * @returns this converted to a new vector3
  2747. */
  2748. toVector3(): Vector3;
  2749. /**
  2750. * Returns a new Vector4 copied from the current one.
  2751. * @returns the new cloned vector
  2752. */
  2753. clone(): Vector4;
  2754. /**
  2755. * Updates the current Vector4 with the given one coordinates.
  2756. * @param source the source vector to copy from
  2757. * @returns the updated Vector4.
  2758. */
  2759. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2760. /**
  2761. * Updates the current Vector4 coordinates with the given floats.
  2762. * @param x float to copy from
  2763. * @param y float to copy from
  2764. * @param z float to copy from
  2765. * @param w float to copy from
  2766. * @returns the updated Vector4.
  2767. */
  2768. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2769. /**
  2770. * Updates the current Vector4 coordinates with the given floats.
  2771. * @param x float to set from
  2772. * @param y float to set from
  2773. * @param z float to set from
  2774. * @param w float to set from
  2775. * @returns the updated Vector4.
  2776. */
  2777. set(x: number, y: number, z: number, w: number): Vector4;
  2778. /**
  2779. * Copies the given float to the current Vector3 coordinates
  2780. * @param v defines the x, y, z and w coordinates of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. setAll(v: number): Vector4;
  2784. /**
  2785. * Returns a new Vector4 set from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @returns the new vector
  2789. */
  2790. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" from the starting index of the given Float32Array.
  2800. * @param array the array to pull values from
  2801. * @param offset the offset into the array to start at
  2802. * @param result the vector to store the result in
  2803. */
  2804. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2805. /**
  2806. * Updates the given vector "result" coordinates from the given floats.
  2807. * @param x float to set from
  2808. * @param y float to set from
  2809. * @param z float to set from
  2810. * @param w float to set from
  2811. * @param result the vector to the floats in
  2812. */
  2813. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2814. /**
  2815. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2816. * @returns the new vector
  2817. */
  2818. static Zero(): Vector4;
  2819. /**
  2820. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2821. * @returns the new vector
  2822. */
  2823. static One(): Vector4;
  2824. /**
  2825. * Returns a new normalized Vector4 from the given one.
  2826. * @param vector the vector to normalize
  2827. * @returns the vector
  2828. */
  2829. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2830. /**
  2831. * Updates the given vector "result" from the normalization of the given one.
  2832. * @param vector the vector to normalize
  2833. * @param result the vector to store the result in
  2834. */
  2835. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2836. /**
  2837. * Returns a vector with the minimum values from the left and right vectors
  2838. * @param left left vector to minimize
  2839. * @param right right vector to minimize
  2840. * @returns a new vector with the minimum of the left and right vector values
  2841. */
  2842. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns a vector with the maximum values from the left and right vectors
  2845. * @param left left vector to maximize
  2846. * @param right right vector to maximize
  2847. * @returns a new vector with the maximum of the left and right vector values
  2848. */
  2849. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2850. /**
  2851. * Returns the distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors
  2855. */
  2856. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the distance between
  2860. * @param value2 value to calulate the distance between
  2861. * @return the distance between the two vectors squared
  2862. */
  2863. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2864. /**
  2865. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2866. * @param value1 value to calulate the center between
  2867. * @param value2 value to calulate the center between
  2868. * @return the center between the two vectors
  2869. */
  2870. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2871. /**
  2872. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2873. * This methods computes transformed normalized direction vectors only.
  2874. * @param vector the vector to transform
  2875. * @param transformation the transformation matrix to apply
  2876. * @returns the new vector
  2877. */
  2878. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2879. /**
  2880. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2881. * This methods computes transformed normalized direction vectors only.
  2882. * @param vector the vector to transform
  2883. * @param transformation the transformation matrix to apply
  2884. * @param result the vector to store the result in
  2885. */
  2886. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2887. /**
  2888. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2889. * This methods computes transformed normalized direction vectors only.
  2890. * @param x value to transform
  2891. * @param y value to transform
  2892. * @param z value to transform
  2893. * @param w value to transform
  2894. * @param transformation the transformation matrix to apply
  2895. * @param result the vector to store the results in
  2896. */
  2897. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2898. /**
  2899. * Creates a new Vector4 from a Vector3
  2900. * @param source defines the source data
  2901. * @param w defines the 4th component (default is 0)
  2902. * @returns a new Vector4
  2903. */
  2904. static FromVector3(source: Vector3, w?: number): Vector4;
  2905. }
  2906. /**
  2907. * Class used to store quaternion data
  2908. * @see https://en.wikipedia.org/wiki/Quaternion
  2909. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2910. */
  2911. export class Quaternion {
  2912. /** defines the first component (0 by default) */
  2913. x: number;
  2914. /** defines the second component (0 by default) */
  2915. y: number;
  2916. /** defines the third component (0 by default) */
  2917. z: number;
  2918. /** defines the fourth component (1.0 by default) */
  2919. w: number;
  2920. /**
  2921. * Creates a new Quaternion from the given floats
  2922. * @param x defines the first component (0 by default)
  2923. * @param y defines the second component (0 by default)
  2924. * @param z defines the third component (0 by default)
  2925. * @param w defines the fourth component (1.0 by default)
  2926. */
  2927. constructor(
  2928. /** defines the first component (0 by default) */
  2929. x?: number,
  2930. /** defines the second component (0 by default) */
  2931. y?: number,
  2932. /** defines the third component (0 by default) */
  2933. z?: number,
  2934. /** defines the fourth component (1.0 by default) */
  2935. w?: number);
  2936. /**
  2937. * Gets a string representation for the current quaternion
  2938. * @returns a string with the Quaternion coordinates
  2939. */
  2940. toString(): string;
  2941. /**
  2942. * Gets the class name of the quaternion
  2943. * @returns the string "Quaternion"
  2944. */
  2945. getClassName(): string;
  2946. /**
  2947. * Gets a hash code for this quaternion
  2948. * @returns the quaternion hash code
  2949. */
  2950. getHashCode(): number;
  2951. /**
  2952. * Copy the quaternion to an array
  2953. * @returns a new array populated with 4 elements from the quaternion coordinates
  2954. */
  2955. asArray(): number[];
  2956. /**
  2957. * Check if two quaternions are equals
  2958. * @param otherQuaternion defines the second operand
  2959. * @return true if the current quaternion and the given one coordinates are strictly equals
  2960. */
  2961. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2962. /**
  2963. * Clone the current quaternion
  2964. * @returns a new quaternion copied from the current one
  2965. */
  2966. clone(): Quaternion;
  2967. /**
  2968. * Copy a quaternion to the current one
  2969. * @param other defines the other quaternion
  2970. * @returns the updated current quaternion
  2971. */
  2972. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2973. /**
  2974. * Updates the current quaternion with the given float coordinates
  2975. * @param x defines the x coordinate
  2976. * @param y defines the y coordinate
  2977. * @param z defines the z coordinate
  2978. * @param w defines the w coordinate
  2979. * @returns the updated current quaternion
  2980. */
  2981. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2982. /**
  2983. * Updates the current quaternion from the given float coordinates
  2984. * @param x defines the x coordinate
  2985. * @param y defines the y coordinate
  2986. * @param z defines the z coordinate
  2987. * @param w defines the w coordinate
  2988. * @returns the updated current quaternion
  2989. */
  2990. set(x: number, y: number, z: number, w: number): Quaternion;
  2991. /**
  2992. * Adds two quaternions
  2993. * @param other defines the second operand
  2994. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2995. */
  2996. add(other: DeepImmutable<Quaternion>): Quaternion;
  2997. /**
  2998. * Add a quaternion to the current one
  2999. * @param other defines the quaternion to add
  3000. * @returns the current quaternion
  3001. */
  3002. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3003. /**
  3004. * Subtract two quaternions
  3005. * @param other defines the second operand
  3006. * @returns a new quaternion as the subtraction result of the given one from the current one
  3007. */
  3008. subtract(other: Quaternion): Quaternion;
  3009. /**
  3010. * Multiplies the current quaternion by a scale factor
  3011. * @param value defines the scale factor
  3012. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3013. */
  3014. scale(value: number): Quaternion;
  3015. /**
  3016. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3017. * @param scale defines the scale factor
  3018. * @param result defines the Quaternion object where to store the result
  3019. * @returns the unmodified current quaternion
  3020. */
  3021. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3022. /**
  3023. * Multiplies in place the current quaternion by a scale factor
  3024. * @param value defines the scale factor
  3025. * @returns the current modified quaternion
  3026. */
  3027. scaleInPlace(value: number): Quaternion;
  3028. /**
  3029. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3030. * @param scale defines the scale factor
  3031. * @param result defines the Quaternion object where to store the result
  3032. * @returns the unmodified current quaternion
  3033. */
  3034. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3035. /**
  3036. * Multiplies two quaternions
  3037. * @param q1 defines the second operand
  3038. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3039. */
  3040. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3041. /**
  3042. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @param result defines the target quaternion
  3045. * @returns the current quaternion
  3046. */
  3047. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3048. /**
  3049. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3050. * @param q1 defines the second operand
  3051. * @returns the currentupdated quaternion
  3052. */
  3053. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3054. /**
  3055. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3056. * @param ref defines the target quaternion
  3057. * @returns the current quaternion
  3058. */
  3059. conjugateToRef(ref: Quaternion): Quaternion;
  3060. /**
  3061. * Conjugates in place (1-q) the current quaternion
  3062. * @returns the current updated quaternion
  3063. */
  3064. conjugateInPlace(): Quaternion;
  3065. /**
  3066. * Conjugates in place (1-q) the current quaternion
  3067. * @returns a new quaternion
  3068. */
  3069. conjugate(): Quaternion;
  3070. /**
  3071. * Gets length of current quaternion
  3072. * @returns the quaternion length (float)
  3073. */
  3074. length(): number;
  3075. /**
  3076. * Normalize in place the current quaternion
  3077. * @returns the current updated quaternion
  3078. */
  3079. normalize(): Quaternion;
  3080. /**
  3081. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns a new Vector3 containing the Euler angles
  3084. */
  3085. toEulerAngles(order?: string): Vector3;
  3086. /**
  3087. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3088. * @param result defines the vector which will be filled with the Euler angles
  3089. * @param order is a reserved parameter and is ignore for now
  3090. * @returns the current unchanged quaternion
  3091. */
  3092. toEulerAnglesToRef(result: Vector3): Quaternion;
  3093. /**
  3094. * Updates the given rotation matrix with the current quaternion values
  3095. * @param result defines the target matrix
  3096. * @returns the current unchanged quaternion
  3097. */
  3098. toRotationMatrix(result: Matrix): Quaternion;
  3099. /**
  3100. * Updates the current quaternion from the given rotation matrix values
  3101. * @param matrix defines the source matrix
  3102. * @returns the current updated quaternion
  3103. */
  3104. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3105. /**
  3106. * Creates a new quaternion from a rotation matrix
  3107. * @param matrix defines the source matrix
  3108. * @returns a new quaternion created from the given rotation matrix values
  3109. */
  3110. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3111. /**
  3112. * Updates the given quaternion with the given rotation matrix values
  3113. * @param matrix defines the source matrix
  3114. * @param result defines the target quaternion
  3115. */
  3116. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3117. /**
  3118. * Returns the dot product (float) between the quaternions "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @returns the dot product
  3122. */
  3123. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3124. /**
  3125. * Checks if the two quaternions are close to each other
  3126. * @param quat0 defines the first quaternion to check
  3127. * @param quat1 defines the second quaternion to check
  3128. * @returns true if the two quaternions are close to each other
  3129. */
  3130. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3131. /**
  3132. * Creates an empty quaternion
  3133. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3134. */
  3135. static Zero(): Quaternion;
  3136. /**
  3137. * Inverse a given quaternion
  3138. * @param q defines the source quaternion
  3139. * @returns a new quaternion as the inverted current quaternion
  3140. */
  3141. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3142. /**
  3143. * Inverse a given quaternion
  3144. * @param q defines the source quaternion
  3145. * @param result the quaternion the result will be stored in
  3146. * @returns the result quaternion
  3147. */
  3148. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3149. /**
  3150. * Creates an identity quaternion
  3151. * @returns the identity quaternion
  3152. */
  3153. static Identity(): Quaternion;
  3154. /**
  3155. * Gets a boolean indicating if the given quaternion is identity
  3156. * @param quaternion defines the quaternion to check
  3157. * @returns true if the quaternion is identity
  3158. */
  3159. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3160. /**
  3161. * Creates a quaternion from a rotation around an axis
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3165. */
  3166. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3167. /**
  3168. * Creates a rotation around an axis and stores it into the given quaternion
  3169. * @param axis defines the axis to use
  3170. * @param angle defines the angle to use
  3171. * @param result defines the target quaternion
  3172. * @returns the target quaternion
  3173. */
  3174. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3175. /**
  3176. * Creates a new quaternion from data stored into an array
  3177. * @param array defines the data source
  3178. * @param offset defines the offset in the source array where the data starts
  3179. * @returns a new quaternion
  3180. */
  3181. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3182. /**
  3183. * Create a quaternion from Euler rotation angles
  3184. * @param x Pitch
  3185. * @param y Yaw
  3186. * @param z Roll
  3187. * @returns the new Quaternion
  3188. */
  3189. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3190. /**
  3191. * Updates a quaternion from Euler rotation angles
  3192. * @param x Pitch
  3193. * @param y Yaw
  3194. * @param z Roll
  3195. * @param result the quaternion to store the result
  3196. * @returns the updated quaternion
  3197. */
  3198. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3199. /**
  3200. * Create a quaternion from Euler rotation vector
  3201. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3202. * @returns the new Quaternion
  3203. */
  3204. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3205. /**
  3206. * Updates a quaternion from Euler rotation vector
  3207. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3208. * @param result the quaternion to store the result
  3209. * @returns the updated quaternion
  3210. */
  3211. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3212. /**
  3213. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3214. * @param yaw defines the rotation around Y axis
  3215. * @param pitch defines the rotation around X axis
  3216. * @param roll defines the rotation around Z axis
  3217. * @returns the new quaternion
  3218. */
  3219. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3220. /**
  3221. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3222. * @param yaw defines the rotation around Y axis
  3223. * @param pitch defines the rotation around X axis
  3224. * @param roll defines the rotation around Z axis
  3225. * @param result defines the target quaternion
  3226. */
  3227. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3228. /**
  3229. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3230. * @param alpha defines the rotation around first axis
  3231. * @param beta defines the rotation around second axis
  3232. * @param gamma defines the rotation around third axis
  3233. * @returns the new quaternion
  3234. */
  3235. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3236. /**
  3237. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3238. * @param alpha defines the rotation around first axis
  3239. * @param beta defines the rotation around second axis
  3240. * @param gamma defines the rotation around third axis
  3241. * @param result defines the target quaternion
  3242. */
  3243. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3244. /**
  3245. * 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)
  3246. * @param axis1 defines the first axis
  3247. * @param axis2 defines the second axis
  3248. * @param axis3 defines the third axis
  3249. * @returns the new quaternion
  3250. */
  3251. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3252. /**
  3253. * 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
  3254. * @param axis1 defines the first axis
  3255. * @param axis2 defines the second axis
  3256. * @param axis3 defines the third axis
  3257. * @param ref defines the target quaternion
  3258. */
  3259. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3260. /**
  3261. * Interpolates between two quaternions
  3262. * @param left defines first quaternion
  3263. * @param right defines second quaternion
  3264. * @param amount defines the gradient to use
  3265. * @returns the new interpolated quaternion
  3266. */
  3267. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3268. /**
  3269. * Interpolates between two quaternions and stores it into a target quaternion
  3270. * @param left defines first quaternion
  3271. * @param right defines second quaternion
  3272. * @param amount defines the gradient to use
  3273. * @param result defines the target quaternion
  3274. */
  3275. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3276. /**
  3277. * Interpolate between two quaternions using Hermite interpolation
  3278. * @param value1 defines first quaternion
  3279. * @param tangent1 defines the incoming tangent
  3280. * @param value2 defines second quaternion
  3281. * @param tangent2 defines the outgoing tangent
  3282. * @param amount defines the target quaternion
  3283. * @returns the new interpolated quaternion
  3284. */
  3285. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3286. }
  3287. /**
  3288. * Class used to store matrix data (4x4)
  3289. */
  3290. export class Matrix {
  3291. private static _updateFlagSeed;
  3292. private static _identityReadOnly;
  3293. private _isIdentity;
  3294. private _isIdentityDirty;
  3295. private _isIdentity3x2;
  3296. private _isIdentity3x2Dirty;
  3297. /**
  3298. * Gets the update flag of the matrix which is an unique number for the matrix.
  3299. * It will be incremented every time the matrix data change.
  3300. * You can use it to speed the comparison between two versions of the same matrix.
  3301. */
  3302. updateFlag: number;
  3303. private readonly _m;
  3304. /**
  3305. * Gets the internal data of the matrix
  3306. */
  3307. readonly m: DeepImmutable<Float32Array>;
  3308. /** @hidden */
  3309. _markAsUpdated(): void;
  3310. /** @hidden */
  3311. private _updateIdentityStatus;
  3312. /**
  3313. * Creates an empty matrix (filled with zeros)
  3314. */
  3315. constructor();
  3316. /**
  3317. * Check if the current matrix is identity
  3318. * @returns true is the matrix is the identity matrix
  3319. */
  3320. isIdentity(): boolean;
  3321. /**
  3322. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3323. * @returns true is the matrix is the identity matrix
  3324. */
  3325. isIdentityAs3x2(): boolean;
  3326. /**
  3327. * Gets the determinant of the matrix
  3328. * @returns the matrix determinant
  3329. */
  3330. determinant(): number;
  3331. /**
  3332. * Returns the matrix as a Float32Array
  3333. * @returns the matrix underlying array
  3334. */
  3335. toArray(): DeepImmutable<Float32Array>;
  3336. /**
  3337. * Returns the matrix as a Float32Array
  3338. * @returns the matrix underlying array.
  3339. */
  3340. asArray(): DeepImmutable<Float32Array>;
  3341. /**
  3342. * Inverts the current matrix in place
  3343. * @returns the current inverted matrix
  3344. */
  3345. invert(): Matrix;
  3346. /**
  3347. * Sets all the matrix elements to zero
  3348. * @returns the current matrix
  3349. */
  3350. reset(): Matrix;
  3351. /**
  3352. * Adds the current matrix with a second one
  3353. * @param other defines the matrix to add
  3354. * @returns a new matrix as the addition of the current matrix and the given one
  3355. */
  3356. add(other: DeepImmutable<Matrix>): Matrix;
  3357. /**
  3358. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3359. * @param other defines the matrix to add
  3360. * @param result defines the target matrix
  3361. * @returns the current matrix
  3362. */
  3363. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3364. /**
  3365. * Adds in place the given matrix to the current matrix
  3366. * @param other defines the second operand
  3367. * @returns the current updated matrix
  3368. */
  3369. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3370. /**
  3371. * Sets the given matrix to the current inverted Matrix
  3372. * @param other defines the target matrix
  3373. * @returns the unmodified current matrix
  3374. */
  3375. invertToRef(other: Matrix): Matrix;
  3376. /**
  3377. * add a value at the specified position in the current Matrix
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. addAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * mutiply the specified position in the current Matrix by a value
  3385. * @param index the index of the value within the matrix. between 0 and 15.
  3386. * @param value the value to be added
  3387. * @returns the current updated matrix
  3388. */
  3389. multiplyAtIndex(index: number, value: number): Matrix;
  3390. /**
  3391. * Inserts the translation vector (using 3 floats) in the current matrix
  3392. * @param x defines the 1st component of the translation
  3393. * @param y defines the 2nd component of the translation
  3394. * @param z defines the 3rd component of the translation
  3395. * @returns the current updated matrix
  3396. */
  3397. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3398. /**
  3399. * Adds the translation vector (using 3 floats) in the current matrix
  3400. * @param x defines the 1st component of the translation
  3401. * @param y defines the 2nd component of the translation
  3402. * @param z defines the 3rd component of the translation
  3403. * @returns the current updated matrix
  3404. */
  3405. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3406. /**
  3407. * Inserts the translation vector in the current matrix
  3408. * @param vector3 defines the translation to insert
  3409. * @returns the current updated matrix
  3410. */
  3411. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3412. /**
  3413. * Gets the translation value of the current matrix
  3414. * @returns a new Vector3 as the extracted translation from the matrix
  3415. */
  3416. getTranslation(): Vector3;
  3417. /**
  3418. * Fill a Vector3 with the extracted translation from the matrix
  3419. * @param result defines the Vector3 where to store the translation
  3420. * @returns the current matrix
  3421. */
  3422. getTranslationToRef(result: Vector3): Matrix;
  3423. /**
  3424. * Remove rotation and scaling part from the matrix
  3425. * @returns the updated matrix
  3426. */
  3427. removeRotationAndScaling(): Matrix;
  3428. /**
  3429. * Multiply two matrices
  3430. * @param other defines the second operand
  3431. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3432. */
  3433. multiply(other: DeepImmutable<Matrix>): Matrix;
  3434. /**
  3435. * Copy the current matrix from the given one
  3436. * @param other defines the source matrix
  3437. * @returns the current updated matrix
  3438. */
  3439. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3440. /**
  3441. * Populates the given array from the starting index with the current matrix values
  3442. * @param array defines the target array
  3443. * @param offset defines the offset in the target array where to start storing values
  3444. * @returns the current matrix
  3445. */
  3446. copyToArray(array: Float32Array, offset?: number): Matrix;
  3447. /**
  3448. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the matrix where to store the multiplication
  3451. * @returns the current matrix
  3452. */
  3453. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3454. /**
  3455. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3456. * @param other defines the second operand
  3457. * @param result defines the array where to store the multiplication
  3458. * @param offset defines the offset in the target array where to start storing values
  3459. * @returns the current matrix
  3460. */
  3461. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3462. /**
  3463. * Check equality between this matrix and a second one
  3464. * @param value defines the second matrix to compare
  3465. * @returns true is the current matrix and the given one values are strictly equal
  3466. */
  3467. equals(value: DeepImmutable<Matrix>): boolean;
  3468. /**
  3469. * Clone the current matrix
  3470. * @returns a new matrix from the current matrix
  3471. */
  3472. clone(): Matrix;
  3473. /**
  3474. * Returns the name of the current matrix class
  3475. * @returns the string "Matrix"
  3476. */
  3477. getClassName(): string;
  3478. /**
  3479. * Gets the hash code of the current matrix
  3480. * @returns the hash code
  3481. */
  3482. getHashCode(): number;
  3483. /**
  3484. * Decomposes the current Matrix into a translation, rotation and scaling components
  3485. * @param scale defines the scale vector3 given as a reference to update
  3486. * @param rotation defines the rotation quaternion given as a reference to update
  3487. * @param translation defines the translation vector3 given as a reference to update
  3488. * @returns true if operation was successful
  3489. */
  3490. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3491. /**
  3492. * Gets specific row of the matrix
  3493. * @param index defines the number of the row to get
  3494. * @returns the index-th row of the current matrix as a new Vector4
  3495. */
  3496. getRow(index: number): Nullable<Vector4>;
  3497. /**
  3498. * Sets the index-th row of the current matrix to the vector4 values
  3499. * @param index defines the number of the row to set
  3500. * @param row defines the target vector4
  3501. * @returns the updated current matrix
  3502. */
  3503. setRow(index: number, row: Vector4): Matrix;
  3504. /**
  3505. * Compute the transpose of the matrix
  3506. * @returns the new transposed matrix
  3507. */
  3508. transpose(): Matrix;
  3509. /**
  3510. * Compute the transpose of the matrix and store it in a given matrix
  3511. * @param result defines the target matrix
  3512. * @returns the current matrix
  3513. */
  3514. transposeToRef(result: Matrix): Matrix;
  3515. /**
  3516. * Sets the index-th row of the current matrix with the given 4 x float values
  3517. * @param index defines the row index
  3518. * @param x defines the x component to set
  3519. * @param y defines the y component to set
  3520. * @param z defines the z component to set
  3521. * @param w defines the w component to set
  3522. * @returns the updated current matrix
  3523. */
  3524. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3525. /**
  3526. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3527. * @param scale defines the scale factor
  3528. * @returns a new matrix
  3529. */
  3530. scale(scale: number): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor to a given result matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Scale the current matrix values by a factor and add the result to a given matrix
  3540. * @param scale defines the scale factor
  3541. * @param result defines the Matrix to store the result
  3542. * @returns the current matrix
  3543. */
  3544. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3545. /**
  3546. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3547. * @param ref matrix to store the result
  3548. */
  3549. toNormalMatrix(ref: Matrix): void;
  3550. /**
  3551. * Gets only rotation part of the current matrix
  3552. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3553. */
  3554. getRotationMatrix(): Matrix;
  3555. /**
  3556. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3557. * @param result defines the target matrix to store data to
  3558. * @returns the current matrix
  3559. */
  3560. getRotationMatrixToRef(result: Matrix): Matrix;
  3561. /**
  3562. * Toggles model matrix from being right handed to left handed in place and vice versa
  3563. */
  3564. toggleModelMatrixHandInPlace(): void;
  3565. /**
  3566. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3567. */
  3568. toggleProjectionMatrixHandInPlace(): void;
  3569. /**
  3570. * Creates a matrix from an array
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @returns a new Matrix set from the starting index of the given array
  3574. */
  3575. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3576. /**
  3577. * Copy the content of an array into a given matrix
  3578. * @param array defines the source array
  3579. * @param offset defines an offset in the source array
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3583. /**
  3584. * Stores an array into a matrix after having multiplied each component by a given factor
  3585. * @param array defines the source array
  3586. * @param offset defines the offset in the source array
  3587. * @param scale defines the scaling factor
  3588. * @param result defines the target matrix
  3589. */
  3590. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3591. /**
  3592. * Gets an identity matrix that must not be updated
  3593. */
  3594. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3595. /**
  3596. * Stores a list of values (16) inside a given matrix
  3597. * @param initialM11 defines 1st value of 1st row
  3598. * @param initialM12 defines 2nd value of 1st row
  3599. * @param initialM13 defines 3rd value of 1st row
  3600. * @param initialM14 defines 4th value of 1st row
  3601. * @param initialM21 defines 1st value of 2nd row
  3602. * @param initialM22 defines 2nd value of 2nd row
  3603. * @param initialM23 defines 3rd value of 2nd row
  3604. * @param initialM24 defines 4th value of 2nd row
  3605. * @param initialM31 defines 1st value of 3rd row
  3606. * @param initialM32 defines 2nd value of 3rd row
  3607. * @param initialM33 defines 3rd value of 3rd row
  3608. * @param initialM34 defines 4th value of 3rd row
  3609. * @param initialM41 defines 1st value of 4th row
  3610. * @param initialM42 defines 2nd value of 4th row
  3611. * @param initialM43 defines 3rd value of 4th row
  3612. * @param initialM44 defines 4th value of 4th row
  3613. * @param result defines the target matrix
  3614. */
  3615. 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;
  3616. /**
  3617. * Creates new matrix from a list of values (16)
  3618. * @param initialM11 defines 1st value of 1st row
  3619. * @param initialM12 defines 2nd value of 1st row
  3620. * @param initialM13 defines 3rd value of 1st row
  3621. * @param initialM14 defines 4th value of 1st row
  3622. * @param initialM21 defines 1st value of 2nd row
  3623. * @param initialM22 defines 2nd value of 2nd row
  3624. * @param initialM23 defines 3rd value of 2nd row
  3625. * @param initialM24 defines 4th value of 2nd row
  3626. * @param initialM31 defines 1st value of 3rd row
  3627. * @param initialM32 defines 2nd value of 3rd row
  3628. * @param initialM33 defines 3rd value of 3rd row
  3629. * @param initialM34 defines 4th value of 3rd row
  3630. * @param initialM41 defines 1st value of 4th row
  3631. * @param initialM42 defines 2nd value of 4th row
  3632. * @param initialM43 defines 3rd value of 4th row
  3633. * @param initialM44 defines 4th value of 4th row
  3634. * @returns the new matrix
  3635. */
  3636. 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;
  3637. /**
  3638. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3639. * @param scale defines the scale vector3
  3640. * @param rotation defines the rotation quaternion
  3641. * @param translation defines the translation vector3
  3642. * @returns a new matrix
  3643. */
  3644. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3645. /**
  3646. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3647. * @param scale defines the scale vector3
  3648. * @param rotation defines the rotation quaternion
  3649. * @param translation defines the translation vector3
  3650. * @param result defines the target matrix
  3651. */
  3652. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3653. /**
  3654. * Creates a new identity matrix
  3655. * @returns a new identity matrix
  3656. */
  3657. static Identity(): Matrix;
  3658. /**
  3659. * Creates a new identity matrix and stores the result in a given matrix
  3660. * @param result defines the target matrix
  3661. */
  3662. static IdentityToRef(result: Matrix): void;
  3663. /**
  3664. * Creates a new zero matrix
  3665. * @returns a new zero matrix
  3666. */
  3667. static Zero(): Matrix;
  3668. /**
  3669. * Creates a new rotation matrix for "angle" radians around the X axis
  3670. * @param angle defines the angle (in radians) to use
  3671. * @return the new matrix
  3672. */
  3673. static RotationX(angle: number): Matrix;
  3674. /**
  3675. * Creates a new matrix as the invert of a given matrix
  3676. * @param source defines the source matrix
  3677. * @returns the new matrix
  3678. */
  3679. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3680. /**
  3681. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3682. * @param angle defines the angle (in radians) to use
  3683. * @param result defines the target matrix
  3684. */
  3685. static RotationXToRef(angle: number, result: Matrix): void;
  3686. /**
  3687. * Creates a new rotation matrix for "angle" radians around the Y axis
  3688. * @param angle defines the angle (in radians) to use
  3689. * @return the new matrix
  3690. */
  3691. static RotationY(angle: number): Matrix;
  3692. /**
  3693. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3694. * @param angle defines the angle (in radians) to use
  3695. * @param result defines the target matrix
  3696. */
  3697. static RotationYToRef(angle: number, result: Matrix): void;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the Z axis
  3700. * @param angle defines the angle (in radians) to use
  3701. * @return the new matrix
  3702. */
  3703. static RotationZ(angle: number): Matrix;
  3704. /**
  3705. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3706. * @param angle defines the angle (in radians) to use
  3707. * @param result defines the target matrix
  3708. */
  3709. static RotationZToRef(angle: number, result: Matrix): void;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @return the new matrix
  3715. */
  3716. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3717. /**
  3718. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3719. * @param axis defines the axis to use
  3720. * @param angle defines the angle (in radians) to use
  3721. * @param result defines the target matrix
  3722. */
  3723. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3724. /**
  3725. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3726. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3727. * @param from defines the vector to align
  3728. * @param to defines the vector to align to
  3729. * @param result defines the target matrix
  3730. */
  3731. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3732. /**
  3733. * Creates a rotation matrix
  3734. * @param yaw defines the yaw angle in radians (Y axis)
  3735. * @param pitch defines the pitch angle in radians (X axis)
  3736. * @param roll defines the roll angle in radians (X axis)
  3737. * @returns the new rotation matrix
  3738. */
  3739. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3740. /**
  3741. * Creates a rotation matrix and stores it in a given matrix
  3742. * @param yaw defines the yaw angle in radians (Y axis)
  3743. * @param pitch defines the pitch angle in radians (X axis)
  3744. * @param roll defines the roll angle in radians (X axis)
  3745. * @param result defines the target matrix
  3746. */
  3747. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3748. /**
  3749. * Creates a scaling matrix
  3750. * @param x defines the scale factor on X axis
  3751. * @param y defines the scale factor on Y axis
  3752. * @param z defines the scale factor on Z axis
  3753. * @returns the new matrix
  3754. */
  3755. static Scaling(x: number, y: number, z: number): Matrix;
  3756. /**
  3757. * Creates a scaling matrix and stores it in a given matrix
  3758. * @param x defines the scale factor on X axis
  3759. * @param y defines the scale factor on Y axis
  3760. * @param z defines the scale factor on Z axis
  3761. * @param result defines the target matrix
  3762. */
  3763. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3764. /**
  3765. * Creates a translation matrix
  3766. * @param x defines the translation on X axis
  3767. * @param y defines the translation on Y axis
  3768. * @param z defines the translationon Z axis
  3769. * @returns the new matrix
  3770. */
  3771. static Translation(x: number, y: number, z: number): Matrix;
  3772. /**
  3773. * Creates a translation matrix and stores it in a given matrix
  3774. * @param x defines the translation on X axis
  3775. * @param y defines the translation on Y axis
  3776. * @param z defines the translationon Z axis
  3777. * @param result defines the target matrix
  3778. */
  3779. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3780. /**
  3781. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3782. * @param startValue defines the start value
  3783. * @param endValue defines the end value
  3784. * @param gradient defines the gradient factor
  3785. * @returns the new matrix
  3786. */
  3787. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3788. /**
  3789. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3790. * @param startValue defines the start value
  3791. * @param endValue defines the end value
  3792. * @param gradient defines the gradient factor
  3793. * @param result defines the Matrix object where to store data
  3794. */
  3795. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3796. /**
  3797. * Builds a new matrix whose values are computed by:
  3798. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3799. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3800. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3801. * @param startValue defines the first matrix
  3802. * @param endValue defines the second matrix
  3803. * @param gradient defines the gradient between the two matrices
  3804. * @returns the new matrix
  3805. */
  3806. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3807. /**
  3808. * Update a matrix to values which are computed by:
  3809. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3810. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3811. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3812. * @param startValue defines the first matrix
  3813. * @param endValue defines the second matrix
  3814. * @param gradient defines the gradient between the two matrices
  3815. * @param result defines the target matrix
  3816. */
  3817. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3818. /**
  3819. * 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"
  3820. * This function works in left handed mode
  3821. * @param eye defines the final position of the entity
  3822. * @param target defines where the entity should look at
  3823. * @param up defines the up vector for the entity
  3824. * @returns the new matrix
  3825. */
  3826. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3827. /**
  3828. * 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".
  3829. * This function works in left handed mode
  3830. * @param eye defines the final position of the entity
  3831. * @param target defines where the entity should look at
  3832. * @param up defines the up vector for the entity
  3833. * @param result defines the target matrix
  3834. */
  3835. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3836. /**
  3837. * 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"
  3838. * This function works in right handed mode
  3839. * @param eye defines the final position of the entity
  3840. * @param target defines where the entity should look at
  3841. * @param up defines the up vector for the entity
  3842. * @returns the new matrix
  3843. */
  3844. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3845. /**
  3846. * 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".
  3847. * This function works in right handed mode
  3848. * @param eye defines the final position of the entity
  3849. * @param target defines where the entity should look at
  3850. * @param up defines the up vector for the entity
  3851. * @param result defines the target matrix
  3852. */
  3853. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3854. /**
  3855. * Create a left-handed orthographic projection matrix
  3856. * @param width defines the viewport width
  3857. * @param height defines the viewport height
  3858. * @param znear defines the near clip plane
  3859. * @param zfar defines the far clip plane
  3860. * @returns a new matrix as a left-handed orthographic projection matrix
  3861. */
  3862. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3863. /**
  3864. * Store a left-handed orthographic projection to a given matrix
  3865. * @param width defines the viewport width
  3866. * @param height defines the viewport height
  3867. * @param znear defines the near clip plane
  3868. * @param zfar defines the far clip plane
  3869. * @param result defines the target matrix
  3870. */
  3871. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3872. /**
  3873. * Create a left-handed orthographic projection matrix
  3874. * @param left defines the viewport left coordinate
  3875. * @param right defines the viewport right coordinate
  3876. * @param bottom defines the viewport bottom coordinate
  3877. * @param top defines the viewport top coordinate
  3878. * @param znear defines the near clip plane
  3879. * @param zfar defines the far clip plane
  3880. * @returns a new matrix as a left-handed orthographic projection matrix
  3881. */
  3882. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3883. /**
  3884. * Stores a left-handed orthographic projection into a given matrix
  3885. * @param left defines the viewport left coordinate
  3886. * @param right defines the viewport right coordinate
  3887. * @param bottom defines the viewport bottom coordinate
  3888. * @param top defines the viewport top coordinate
  3889. * @param znear defines the near clip plane
  3890. * @param zfar defines the far clip plane
  3891. * @param result defines the target matrix
  3892. */
  3893. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3894. /**
  3895. * Creates a right-handed orthographic projection matrix
  3896. * @param left defines the viewport left coordinate
  3897. * @param right defines the viewport right coordinate
  3898. * @param bottom defines the viewport bottom coordinate
  3899. * @param top defines the viewport top coordinate
  3900. * @param znear defines the near clip plane
  3901. * @param zfar defines the far clip plane
  3902. * @returns a new matrix as a right-handed orthographic projection matrix
  3903. */
  3904. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3905. /**
  3906. * Stores a right-handed orthographic projection into a given matrix
  3907. * @param left defines the viewport left coordinate
  3908. * @param right defines the viewport right coordinate
  3909. * @param bottom defines the viewport bottom coordinate
  3910. * @param top defines the viewport top coordinate
  3911. * @param znear defines the near clip plane
  3912. * @param zfar defines the far clip plane
  3913. * @param result defines the target matrix
  3914. */
  3915. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3916. /**
  3917. * Creates a left-handed perspective projection matrix
  3918. * @param width defines the viewport width
  3919. * @param height defines the viewport height
  3920. * @param znear defines the near clip plane
  3921. * @param zfar defines the far clip plane
  3922. * @returns a new matrix as a left-handed perspective projection matrix
  3923. */
  3924. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3925. /**
  3926. * Creates a left-handed perspective projection matrix
  3927. * @param fov defines the horizontal field of view
  3928. * @param aspect defines the aspect ratio
  3929. * @param znear defines the near clip plane
  3930. * @param zfar defines the far clip plane
  3931. * @returns a new matrix as a left-handed perspective projection matrix
  3932. */
  3933. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3934. /**
  3935. * Stores a left-handed perspective projection into a given matrix
  3936. * @param fov defines the horizontal field of view
  3937. * @param aspect defines the aspect ratio
  3938. * @param znear defines the near clip plane
  3939. * @param zfar defines the far clip plane
  3940. * @param result defines the target matrix
  3941. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3942. */
  3943. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3944. /**
  3945. * Creates a right-handed perspective projection matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @returns a new matrix as a right-handed perspective projection matrix
  3951. */
  3952. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3953. /**
  3954. * Stores a right-handed perspective projection into a given matrix
  3955. * @param fov defines the horizontal field of view
  3956. * @param aspect defines the aspect ratio
  3957. * @param znear defines the near clip plane
  3958. * @param zfar defines the far clip plane
  3959. * @param result defines the target matrix
  3960. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3961. */
  3962. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3963. /**
  3964. * Stores a perspective projection for WebVR info a given matrix
  3965. * @param fov defines the field of view
  3966. * @param znear defines the near clip plane
  3967. * @param zfar defines the far clip plane
  3968. * @param result defines the target matrix
  3969. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3970. */
  3971. static PerspectiveFovWebVRToRef(fov: {
  3972. upDegrees: number;
  3973. downDegrees: number;
  3974. leftDegrees: number;
  3975. rightDegrees: number;
  3976. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3977. /**
  3978. * Computes a complete transformation matrix
  3979. * @param viewport defines the viewport to use
  3980. * @param world defines the world matrix
  3981. * @param view defines the view matrix
  3982. * @param projection defines the projection matrix
  3983. * @param zmin defines the near clip plane
  3984. * @param zmax defines the far clip plane
  3985. * @returns the transformation matrix
  3986. */
  3987. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3988. /**
  3989. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3990. * @param matrix defines the matrix to use
  3991. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3992. */
  3993. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3994. /**
  3995. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3996. * @param matrix defines the matrix to use
  3997. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3998. */
  3999. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4000. /**
  4001. * Compute the transpose of a given matrix
  4002. * @param matrix defines the matrix to transpose
  4003. * @returns the new matrix
  4004. */
  4005. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4006. /**
  4007. * Compute the transpose of a matrix and store it in a target matrix
  4008. * @param matrix defines the matrix to transpose
  4009. * @param result defines the target matrix
  4010. */
  4011. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4012. /**
  4013. * Computes a reflection matrix from a plane
  4014. * @param plane defines the reflection plane
  4015. * @returns a new matrix
  4016. */
  4017. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4018. /**
  4019. * Computes a reflection matrix from a plane
  4020. * @param plane defines the reflection plane
  4021. * @param result defines the target matrix
  4022. */
  4023. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4024. /**
  4025. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4026. * @param xaxis defines the value of the 1st axis
  4027. * @param yaxis defines the value of the 2nd axis
  4028. * @param zaxis defines the value of the 3rd axis
  4029. * @param result defines the target matrix
  4030. */
  4031. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4032. /**
  4033. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4034. * @param quat defines the quaternion to use
  4035. * @param result defines the target matrix
  4036. */
  4037. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4038. }
  4039. /**
  4040. * @hidden
  4041. */
  4042. export class TmpVectors {
  4043. static Vector2: Vector2[];
  4044. static Vector3: Vector3[];
  4045. static Vector4: Vector4[];
  4046. static Quaternion: Quaternion[];
  4047. static Matrix: Matrix[];
  4048. }
  4049. }
  4050. declare module BABYLON {
  4051. /** Defines the cross module used constants to avoid circular dependncies */
  4052. export class Constants {
  4053. /** Defines that alpha blending is disabled */
  4054. static readonly ALPHA_DISABLE: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4056. static readonly ALPHA_ADD: number;
  4057. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4058. static readonly ALPHA_COMBINE: number;
  4059. /** Defines that alpha blending to DEST - SRC * DEST */
  4060. static readonly ALPHA_SUBTRACT: number;
  4061. /** Defines that alpha blending to SRC * DEST */
  4062. static readonly ALPHA_MULTIPLY: number;
  4063. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4064. static readonly ALPHA_MAXIMIZED: number;
  4065. /** Defines that alpha blending to SRC + DEST */
  4066. static readonly ALPHA_ONEONE: number;
  4067. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_PREMULTIPLIED: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4071. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4074. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4075. static readonly ALPHA_INTERPOLATE: number;
  4076. /**
  4077. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4078. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4079. */
  4080. static readonly ALPHA_SCREENMODE: number;
  4081. /**
  4082. * Defines that alpha blending to SRC + DST
  4083. * Alpha will be set to SRC ALPHA + DST ALPHA
  4084. */
  4085. static readonly ALPHA_ONEONE_ONEONE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC * DST ALPHA + DST
  4088. * Alpha will be set to 0
  4089. */
  4090. static readonly ALPHA_ALPHATOCOLOR: number;
  4091. /**
  4092. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4093. */
  4094. static readonly ALPHA_REVERSEONEMINUS: number;
  4095. /**
  4096. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4097. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4098. */
  4099. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4100. /**
  4101. * Defines that alpha blending to SRC + DST
  4102. * Alpha will be set to SRC ALPHA
  4103. */
  4104. static readonly ALPHA_ONEONE_ONEZERO: number;
  4105. /** Defines that alpha blending equation a SUM */
  4106. static readonly ALPHA_EQUATION_ADD: number;
  4107. /** Defines that alpha blending equation a SUBSTRACTION */
  4108. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4109. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4110. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4111. /** Defines that alpha blending equation a MAX operation */
  4112. static readonly ALPHA_EQUATION_MAX: number;
  4113. /** Defines that alpha blending equation a MIN operation */
  4114. static readonly ALPHA_EQUATION_MIN: number;
  4115. /**
  4116. * Defines that alpha blending equation a DARKEN operation:
  4117. * It takes the min of the src and sums the alpha channels.
  4118. */
  4119. static readonly ALPHA_EQUATION_DARKEN: number;
  4120. /** Defines that the ressource is not delayed*/
  4121. static readonly DELAYLOADSTATE_NONE: number;
  4122. /** Defines that the ressource was successfully delay loaded */
  4123. static readonly DELAYLOADSTATE_LOADED: number;
  4124. /** Defines that the ressource is currently delay loading */
  4125. static readonly DELAYLOADSTATE_LOADING: number;
  4126. /** Defines that the ressource is delayed and has not started loading */
  4127. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4129. static readonly NEVER: number;
  4130. /** 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 */
  4131. static readonly ALWAYS: number;
  4132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4133. static readonly LESS: number;
  4134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4135. static readonly EQUAL: number;
  4136. /** 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 */
  4137. static readonly LEQUAL: number;
  4138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4139. static readonly GREATER: number;
  4140. /** 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 */
  4141. static readonly GEQUAL: number;
  4142. /** 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 */
  4143. static readonly NOTEQUAL: number;
  4144. /** Passed to stencilOperation to specify that stencil value must be kept */
  4145. static readonly KEEP: number;
  4146. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4147. static readonly REPLACE: number;
  4148. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4149. static readonly INCR: number;
  4150. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4151. static readonly DECR: number;
  4152. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4153. static readonly INVERT: number;
  4154. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4155. static readonly INCR_WRAP: number;
  4156. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4157. static readonly DECR_WRAP: number;
  4158. /** Texture is not repeating outside of 0..1 UVs */
  4159. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4160. /** Texture is repeating outside of 0..1 UVs */
  4161. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4162. /** Texture is repeating and mirrored */
  4163. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4164. /** ALPHA */
  4165. static readonly TEXTUREFORMAT_ALPHA: number;
  4166. /** LUMINANCE */
  4167. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4168. /** LUMINANCE_ALPHA */
  4169. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4170. /** RGB */
  4171. static readonly TEXTUREFORMAT_RGB: number;
  4172. /** RGBA */
  4173. static readonly TEXTUREFORMAT_RGBA: number;
  4174. /** RED */
  4175. static readonly TEXTUREFORMAT_RED: number;
  4176. /** RED (2nd reference) */
  4177. static readonly TEXTUREFORMAT_R: number;
  4178. /** RG */
  4179. static readonly TEXTUREFORMAT_RG: number;
  4180. /** RED_INTEGER */
  4181. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4182. /** RED_INTEGER (2nd reference) */
  4183. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4184. /** RG_INTEGER */
  4185. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4186. /** RGB_INTEGER */
  4187. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4188. /** RGBA_INTEGER */
  4189. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4190. /** UNSIGNED_BYTE */
  4191. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4192. /** UNSIGNED_BYTE (2nd reference) */
  4193. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4194. /** FLOAT */
  4195. static readonly TEXTURETYPE_FLOAT: number;
  4196. /** HALF_FLOAT */
  4197. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4198. /** BYTE */
  4199. static readonly TEXTURETYPE_BYTE: number;
  4200. /** SHORT */
  4201. static readonly TEXTURETYPE_SHORT: number;
  4202. /** UNSIGNED_SHORT */
  4203. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4204. /** INT */
  4205. static readonly TEXTURETYPE_INT: number;
  4206. /** UNSIGNED_INT */
  4207. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4208. /** UNSIGNED_SHORT_4_4_4_4 */
  4209. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4210. /** UNSIGNED_SHORT_5_5_5_1 */
  4211. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4212. /** UNSIGNED_SHORT_5_6_5 */
  4213. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4214. /** UNSIGNED_INT_2_10_10_10_REV */
  4215. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4216. /** UNSIGNED_INT_24_8 */
  4217. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4218. /** UNSIGNED_INT_10F_11F_11F_REV */
  4219. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4220. /** UNSIGNED_INT_5_9_9_9_REV */
  4221. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4222. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4223. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4224. /** nearest is mag = nearest and min = nearest and mip = linear */
  4225. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4227. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4228. /** Trilinear is mag = linear and min = linear and mip = linear */
  4229. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4230. /** nearest is mag = nearest and min = nearest and mip = linear */
  4231. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4232. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4233. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4234. /** Trilinear is mag = linear and min = linear and mip = linear */
  4235. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4236. /** mag = nearest and min = nearest and mip = nearest */
  4237. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4238. /** mag = nearest and min = linear and mip = nearest */
  4239. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4240. /** mag = nearest and min = linear and mip = linear */
  4241. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4242. /** mag = nearest and min = linear and mip = none */
  4243. static readonly TEXTURE_NEAREST_LINEAR: number;
  4244. /** mag = nearest and min = nearest and mip = none */
  4245. static readonly TEXTURE_NEAREST_NEAREST: number;
  4246. /** mag = linear and min = nearest and mip = nearest */
  4247. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4248. /** mag = linear and min = nearest and mip = linear */
  4249. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4250. /** mag = linear and min = linear and mip = none */
  4251. static readonly TEXTURE_LINEAR_LINEAR: number;
  4252. /** mag = linear and min = nearest and mip = none */
  4253. static readonly TEXTURE_LINEAR_NEAREST: number;
  4254. /** Explicit coordinates mode */
  4255. static readonly TEXTURE_EXPLICIT_MODE: number;
  4256. /** Spherical coordinates mode */
  4257. static readonly TEXTURE_SPHERICAL_MODE: number;
  4258. /** Planar coordinates mode */
  4259. static readonly TEXTURE_PLANAR_MODE: number;
  4260. /** Cubic coordinates mode */
  4261. static readonly TEXTURE_CUBIC_MODE: number;
  4262. /** Projection coordinates mode */
  4263. static readonly TEXTURE_PROJECTION_MODE: number;
  4264. /** Skybox coordinates mode */
  4265. static readonly TEXTURE_SKYBOX_MODE: number;
  4266. /** Inverse Cubic coordinates mode */
  4267. static readonly TEXTURE_INVCUBIC_MODE: number;
  4268. /** Equirectangular coordinates mode */
  4269. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4270. /** Equirectangular Fixed coordinates mode */
  4271. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4272. /** Equirectangular Fixed Mirrored coordinates mode */
  4273. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4274. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4275. static readonly SCALEMODE_FLOOR: number;
  4276. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4277. static readonly SCALEMODE_NEAREST: number;
  4278. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4279. static readonly SCALEMODE_CEILING: number;
  4280. /**
  4281. * The dirty texture flag value
  4282. */
  4283. static readonly MATERIAL_TextureDirtyFlag: number;
  4284. /**
  4285. * The dirty light flag value
  4286. */
  4287. static readonly MATERIAL_LightDirtyFlag: number;
  4288. /**
  4289. * The dirty fresnel flag value
  4290. */
  4291. static readonly MATERIAL_FresnelDirtyFlag: number;
  4292. /**
  4293. * The dirty attribute flag value
  4294. */
  4295. static readonly MATERIAL_AttributesDirtyFlag: number;
  4296. /**
  4297. * The dirty misc flag value
  4298. */
  4299. static readonly MATERIAL_MiscDirtyFlag: number;
  4300. /**
  4301. * The all dirty flag value
  4302. */
  4303. static readonly MATERIAL_AllDirtyFlag: number;
  4304. /**
  4305. * Returns the triangle fill mode
  4306. */
  4307. static readonly MATERIAL_TriangleFillMode: number;
  4308. /**
  4309. * Returns the wireframe mode
  4310. */
  4311. static readonly MATERIAL_WireFrameFillMode: number;
  4312. /**
  4313. * Returns the point fill mode
  4314. */
  4315. static readonly MATERIAL_PointFillMode: number;
  4316. /**
  4317. * Returns the point list draw mode
  4318. */
  4319. static readonly MATERIAL_PointListDrawMode: number;
  4320. /**
  4321. * Returns the line list draw mode
  4322. */
  4323. static readonly MATERIAL_LineListDrawMode: number;
  4324. /**
  4325. * Returns the line loop draw mode
  4326. */
  4327. static readonly MATERIAL_LineLoopDrawMode: number;
  4328. /**
  4329. * Returns the line strip draw mode
  4330. */
  4331. static readonly MATERIAL_LineStripDrawMode: number;
  4332. /**
  4333. * Returns the triangle strip draw mode
  4334. */
  4335. static readonly MATERIAL_TriangleStripDrawMode: number;
  4336. /**
  4337. * Returns the triangle fan draw mode
  4338. */
  4339. static readonly MATERIAL_TriangleFanDrawMode: number;
  4340. /**
  4341. * Stores the clock-wise side orientation
  4342. */
  4343. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4344. /**
  4345. * Stores the counter clock-wise side orientation
  4346. */
  4347. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4348. /**
  4349. * Nothing
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_NothingTrigger: number;
  4353. /**
  4354. * On pick
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPickTrigger: number;
  4358. /**
  4359. * On left pick
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnLeftPickTrigger: number;
  4363. /**
  4364. * On right pick
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnRightPickTrigger: number;
  4368. /**
  4369. * On center pick
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnCenterPickTrigger: number;
  4373. /**
  4374. * On pick down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnPickDownTrigger: number;
  4378. /**
  4379. * On double pick
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnDoublePickTrigger: number;
  4383. /**
  4384. * On pick up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnPickUpTrigger: number;
  4388. /**
  4389. * On pick out.
  4390. * This trigger will only be raised if you also declared a OnPickDown
  4391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4392. */
  4393. static readonly ACTION_OnPickOutTrigger: number;
  4394. /**
  4395. * On long press
  4396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4397. */
  4398. static readonly ACTION_OnLongPressTrigger: number;
  4399. /**
  4400. * On pointer over
  4401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4402. */
  4403. static readonly ACTION_OnPointerOverTrigger: number;
  4404. /**
  4405. * On pointer out
  4406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4407. */
  4408. static readonly ACTION_OnPointerOutTrigger: number;
  4409. /**
  4410. * On every frame
  4411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4412. */
  4413. static readonly ACTION_OnEveryFrameTrigger: number;
  4414. /**
  4415. * On intersection enter
  4416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4417. */
  4418. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4419. /**
  4420. * On intersection exit
  4421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4422. */
  4423. static readonly ACTION_OnIntersectionExitTrigger: number;
  4424. /**
  4425. * On key down
  4426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4427. */
  4428. static readonly ACTION_OnKeyDownTrigger: number;
  4429. /**
  4430. * On key up
  4431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4432. */
  4433. static readonly ACTION_OnKeyUpTrigger: number;
  4434. /**
  4435. * Billboard mode will only apply to Y axis
  4436. */
  4437. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4438. /**
  4439. * Billboard mode will apply to all axes
  4440. */
  4441. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4442. /**
  4443. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4444. */
  4445. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4446. /**
  4447. * Gets or sets base Assets URL
  4448. */
  4449. static PARTICLES_BaseAssetsUrl: string;
  4450. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4451. * Test order :
  4452. * Is the bounding sphere outside the frustum ?
  4453. * If not, are the bounding box vertices outside the frustum ?
  4454. * It not, then the cullable object is in the frustum.
  4455. */
  4456. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4457. /** Culling strategy : Bounding Sphere Only.
  4458. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4459. * It's also less accurate than the standard because some not visible objects can still be selected.
  4460. * Test : is the bounding sphere outside the frustum ?
  4461. * If not, then the cullable object is in the frustum.
  4462. */
  4463. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4464. /** Culling strategy : Optimistic Inclusion.
  4465. * This in an inclusion test first, then the standard exclusion test.
  4466. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4467. * 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.
  4468. * Anyway, it's as accurate as the standard strategy.
  4469. * Test :
  4470. * Is the cullable object bounding sphere center in the frustum ?
  4471. * If not, apply the default culling strategy.
  4472. */
  4473. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4474. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4475. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4476. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4477. * 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.
  4478. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4479. * Test :
  4480. * Is the cullable object bounding sphere center in the frustum ?
  4481. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4482. */
  4483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4484. /**
  4485. * No logging while loading
  4486. */
  4487. static readonly SCENELOADER_NO_LOGGING: number;
  4488. /**
  4489. * Minimal logging while loading
  4490. */
  4491. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4492. /**
  4493. * Summary logging while loading
  4494. */
  4495. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4496. /**
  4497. * Detailled logging while loading
  4498. */
  4499. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4500. }
  4501. }
  4502. declare module BABYLON {
  4503. /**
  4504. * Class used to store and describe the pipeline context associated with an effect
  4505. */
  4506. export interface IPipelineContext {
  4507. /**
  4508. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4509. */
  4510. isAsync: boolean;
  4511. /**
  4512. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4513. */
  4514. isReady: boolean;
  4515. /** @hidden */
  4516. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4517. }
  4518. }
  4519. declare module BABYLON {
  4520. /** @hidden */
  4521. export interface IShaderProcessor {
  4522. attributeProcessor?: (attribute: string) => string;
  4523. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4524. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4525. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4526. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4527. lineProcessor?: (line: string, isFragment: boolean) => string;
  4528. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4529. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. /** @hidden */
  4534. export interface ProcessingOptions {
  4535. defines: string[];
  4536. indexParameters: any;
  4537. isFragment: boolean;
  4538. shouldUseHighPrecisionShader: boolean;
  4539. supportsUniformBuffers: boolean;
  4540. shadersRepository: string;
  4541. includesShadersStore: {
  4542. [key: string]: string;
  4543. };
  4544. processor?: IShaderProcessor;
  4545. version: string;
  4546. platformName: string;
  4547. lookForClosingBracketForUniformBuffer?: boolean;
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /**
  4552. * Helper to manipulate strings
  4553. */
  4554. export class StringTools {
  4555. /**
  4556. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4557. * @param str Source string
  4558. * @param suffix Suffix to search for in the source string
  4559. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4560. */
  4561. static EndsWith(str: string, suffix: string): boolean;
  4562. /**
  4563. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4564. * @param str Source string
  4565. * @param suffix Suffix to search for in the source string
  4566. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4567. */
  4568. static StartsWith(str: string, suffix: string): boolean;
  4569. }
  4570. }
  4571. declare module BABYLON {
  4572. /** @hidden */
  4573. export class ShaderCodeNode {
  4574. line: string;
  4575. children: ShaderCodeNode[];
  4576. additionalDefineKey?: string;
  4577. additionalDefineValue?: string;
  4578. isValid(preprocessors: {
  4579. [key: string]: string;
  4580. }): boolean;
  4581. process(preprocessors: {
  4582. [key: string]: string;
  4583. }, options: ProcessingOptions): string;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /** @hidden */
  4588. export class ShaderCodeCursor {
  4589. private _lines;
  4590. lineIndex: number;
  4591. readonly currentLine: string;
  4592. readonly canRead: boolean;
  4593. lines: string[];
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /** @hidden */
  4598. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4599. process(preprocessors: {
  4600. [key: string]: string;
  4601. }, options: ProcessingOptions): string;
  4602. }
  4603. }
  4604. declare module BABYLON {
  4605. /** @hidden */
  4606. export class ShaderDefineExpression {
  4607. isTrue(preprocessors: {
  4608. [key: string]: string;
  4609. }): boolean;
  4610. }
  4611. }
  4612. declare module BABYLON {
  4613. /** @hidden */
  4614. export class ShaderCodeTestNode extends ShaderCodeNode {
  4615. testExpression: ShaderDefineExpression;
  4616. isValid(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module BABYLON {
  4622. /** @hidden */
  4623. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. not: boolean;
  4626. constructor(define: string, not?: boolean);
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module BABYLON {
  4633. /** @hidden */
  4634. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4635. leftOperand: ShaderDefineExpression;
  4636. rightOperand: ShaderDefineExpression;
  4637. isTrue(preprocessors: {
  4638. [key: string]: string;
  4639. }): boolean;
  4640. }
  4641. }
  4642. declare module BABYLON {
  4643. /** @hidden */
  4644. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4645. leftOperand: ShaderDefineExpression;
  4646. rightOperand: ShaderDefineExpression;
  4647. isTrue(preprocessors: {
  4648. [key: string]: string;
  4649. }): boolean;
  4650. }
  4651. }
  4652. declare module BABYLON {
  4653. /** @hidden */
  4654. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4655. define: string;
  4656. operand: string;
  4657. testValue: string;
  4658. constructor(define: string, operand: string, testValue: string);
  4659. isTrue(preprocessors: {
  4660. [key: string]: string;
  4661. }): boolean;
  4662. }
  4663. }
  4664. declare module BABYLON {
  4665. /**
  4666. * @ignore
  4667. * Application error to support additional information when loading a file
  4668. */
  4669. export class LoadFileError extends Error {
  4670. /** defines the optional web request */
  4671. request?: WebRequest | undefined;
  4672. private static _setPrototypeOf;
  4673. /**
  4674. * Creates a new LoadFileError
  4675. * @param message defines the message of the error
  4676. * @param request defines the optional web request
  4677. */
  4678. constructor(message: string,
  4679. /** defines the optional web request */
  4680. request?: WebRequest | undefined);
  4681. }
  4682. }
  4683. declare module BABYLON {
  4684. /**
  4685. * Class used to enable access to offline support
  4686. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4687. */
  4688. export interface IOfflineProvider {
  4689. /**
  4690. * Gets a boolean indicating if scene must be saved in the database
  4691. */
  4692. enableSceneOffline: boolean;
  4693. /**
  4694. * Gets a boolean indicating if textures must be saved in the database
  4695. */
  4696. enableTexturesOffline: boolean;
  4697. /**
  4698. * Open the offline support and make it available
  4699. * @param successCallback defines the callback to call on success
  4700. * @param errorCallback defines the callback to call on error
  4701. */
  4702. open(successCallback: () => void, errorCallback: () => void): void;
  4703. /**
  4704. * Loads an image from the offline support
  4705. * @param url defines the url to load from
  4706. * @param image defines the target DOM image
  4707. */
  4708. loadImage(url: string, image: HTMLImageElement): void;
  4709. /**
  4710. * Loads a file from offline support
  4711. * @param url defines the URL to load from
  4712. * @param sceneLoaded defines a callback to call on success
  4713. * @param progressCallBack defines a callback to call when progress changed
  4714. * @param errorCallback defines a callback to call on error
  4715. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4716. */
  4717. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4718. }
  4719. }
  4720. declare module BABYLON {
  4721. /**
  4722. * Class used to help managing file picking and drag'n'drop
  4723. * File Storage
  4724. */
  4725. export class FilesInputStore {
  4726. /**
  4727. * List of files ready to be loaded
  4728. */
  4729. static FilesToLoad: {
  4730. [key: string]: File;
  4731. };
  4732. }
  4733. }
  4734. declare module BABYLON {
  4735. /**
  4736. * Class used to define a retry strategy when error happens while loading assets
  4737. */
  4738. export class RetryStrategy {
  4739. /**
  4740. * Function used to defines an exponential back off strategy
  4741. * @param maxRetries defines the maximum number of retries (3 by default)
  4742. * @param baseInterval defines the interval between retries
  4743. * @returns the strategy function to use
  4744. */
  4745. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4746. }
  4747. }
  4748. declare module BABYLON {
  4749. /**
  4750. * @hidden
  4751. */
  4752. export class FileTools {
  4753. /**
  4754. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4755. */
  4756. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4757. /**
  4758. * Gets or sets the base URL to use to load assets
  4759. */
  4760. static BaseUrl: string;
  4761. /**
  4762. * Default behaviour for cors in the application.
  4763. * It can be a string if the expected behavior is identical in the entire app.
  4764. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4765. */
  4766. static CorsBehavior: string | ((url: string | string[]) => string);
  4767. /**
  4768. * Gets or sets a function used to pre-process url before using them to load assets
  4769. */
  4770. static PreprocessUrl: (url: string) => string;
  4771. /**
  4772. * Removes unwanted characters from an url
  4773. * @param url defines the url to clean
  4774. * @returns the cleaned url
  4775. */
  4776. private static _CleanUrl;
  4777. /**
  4778. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4779. * @param url define the url we are trying
  4780. * @param element define the dom element where to configure the cors policy
  4781. */
  4782. static SetCorsBehavior(url: string | string[], element: {
  4783. crossOrigin: string | null;
  4784. }): void;
  4785. /**
  4786. * Loads an image as an HTMLImageElement.
  4787. * @param input url string, ArrayBuffer, or Blob to load
  4788. * @param onLoad callback called when the image successfully loads
  4789. * @param onError callback called when the image fails to load
  4790. * @param offlineProvider offline provider for caching
  4791. * @returns the HTMLImageElement of the loaded image
  4792. */
  4793. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4794. /**
  4795. * Loads a file
  4796. * @param fileToLoad defines the file to load
  4797. * @param callback defines the callback to call when data is loaded
  4798. * @param progressCallBack defines the callback to call during loading process
  4799. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4800. * @returns a file request object
  4801. */
  4802. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4803. /**
  4804. * Loads a file
  4805. * @param url url string, ArrayBuffer, or Blob to load
  4806. * @param onSuccess callback called when the file successfully loads
  4807. * @param onProgress callback called while file is loading (if the server supports this mode)
  4808. * @param offlineProvider defines the offline provider for caching
  4809. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4810. * @param onError callback called when the file fails to load
  4811. * @returns a file request object
  4812. */
  4813. 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;
  4814. /**
  4815. * Checks if the loaded document was accessed via `file:`-Protocol.
  4816. * @returns boolean
  4817. */
  4818. static IsFileURL(): boolean;
  4819. }
  4820. }
  4821. declare module BABYLON {
  4822. /** @hidden */
  4823. export class ShaderProcessor {
  4824. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4825. private static _ProcessPrecision;
  4826. private static _ExtractOperation;
  4827. private static _BuildSubExpression;
  4828. private static _BuildExpression;
  4829. private static _MoveCursorWithinIf;
  4830. private static _MoveCursor;
  4831. private static _EvaluatePreProcessors;
  4832. private static _PreparePreProcessors;
  4833. private static _ProcessShaderConversion;
  4834. private static _ProcessIncludes;
  4835. }
  4836. }
  4837. declare module BABYLON {
  4838. /**
  4839. * Class used to hold a RBG color
  4840. */
  4841. export class Color3 {
  4842. /**
  4843. * Defines the red component (between 0 and 1, default is 0)
  4844. */
  4845. r: number;
  4846. /**
  4847. * Defines the green component (between 0 and 1, default is 0)
  4848. */
  4849. g: number;
  4850. /**
  4851. * Defines the blue component (between 0 and 1, default is 0)
  4852. */
  4853. b: number;
  4854. /**
  4855. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4856. * @param r defines the red component (between 0 and 1, default is 0)
  4857. * @param g defines the green component (between 0 and 1, default is 0)
  4858. * @param b defines the blue component (between 0 and 1, default is 0)
  4859. */
  4860. constructor(
  4861. /**
  4862. * Defines the red component (between 0 and 1, default is 0)
  4863. */
  4864. r?: number,
  4865. /**
  4866. * Defines the green component (between 0 and 1, default is 0)
  4867. */
  4868. g?: number,
  4869. /**
  4870. * Defines the blue component (between 0 and 1, default is 0)
  4871. */
  4872. b?: number);
  4873. /**
  4874. * Creates a string with the Color3 current values
  4875. * @returns the string representation of the Color3 object
  4876. */
  4877. toString(): string;
  4878. /**
  4879. * Returns the string "Color3"
  4880. * @returns "Color3"
  4881. */
  4882. getClassName(): string;
  4883. /**
  4884. * Compute the Color3 hash code
  4885. * @returns an unique number that can be used to hash Color3 objects
  4886. */
  4887. getHashCode(): number;
  4888. /**
  4889. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4890. * @param array defines the array where to store the r,g,b components
  4891. * @param index defines an optional index in the target array to define where to start storing values
  4892. * @returns the current Color3 object
  4893. */
  4894. toArray(array: FloatArray, index?: number): Color3;
  4895. /**
  4896. * Returns a new Color4 object from the current Color3 and the given alpha
  4897. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4898. * @returns a new Color4 object
  4899. */
  4900. toColor4(alpha?: number): Color4;
  4901. /**
  4902. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4903. * @returns the new array
  4904. */
  4905. asArray(): number[];
  4906. /**
  4907. * Returns the luminance value
  4908. * @returns a float value
  4909. */
  4910. toLuminance(): number;
  4911. /**
  4912. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4913. * @param otherColor defines the second operand
  4914. * @returns the new Color3 object
  4915. */
  4916. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4917. /**
  4918. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4919. * @param otherColor defines the second operand
  4920. * @param result defines the Color3 object where to store the result
  4921. * @returns the current Color3
  4922. */
  4923. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4924. /**
  4925. * Determines equality between Color3 objects
  4926. * @param otherColor defines the second operand
  4927. * @returns true if the rgb values are equal to the given ones
  4928. */
  4929. equals(otherColor: DeepImmutable<Color3>): boolean;
  4930. /**
  4931. * Determines equality between the current Color3 object and a set of r,b,g values
  4932. * @param r defines the red component to check
  4933. * @param g defines the green component to check
  4934. * @param b defines the blue component to check
  4935. * @returns true if the rgb values are equal to the given ones
  4936. */
  4937. equalsFloats(r: number, g: number, b: number): boolean;
  4938. /**
  4939. * Multiplies in place each rgb value by scale
  4940. * @param scale defines the scaling factor
  4941. * @returns the updated Color3
  4942. */
  4943. scale(scale: number): Color3;
  4944. /**
  4945. * Multiplies the rgb values by scale and stores the result into "result"
  4946. * @param scale defines the scaling factor
  4947. * @param result defines the Color3 object where to store the result
  4948. * @returns the unmodified current Color3
  4949. */
  4950. scaleToRef(scale: number, result: Color3): Color3;
  4951. /**
  4952. * Scale the current Color3 values by a factor and add the result to a given Color3
  4953. * @param scale defines the scale factor
  4954. * @param result defines color to store the result into
  4955. * @returns the unmodified current Color3
  4956. */
  4957. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4958. /**
  4959. * Clamps the rgb values by the min and max values and stores the result into "result"
  4960. * @param min defines minimum clamping value (default is 0)
  4961. * @param max defines maximum clamping value (default is 1)
  4962. * @param result defines color to store the result into
  4963. * @returns the original Color3
  4964. */
  4965. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4966. /**
  4967. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4968. * @param otherColor defines the second operand
  4969. * @returns the new Color3
  4970. */
  4971. add(otherColor: DeepImmutable<Color3>): Color3;
  4972. /**
  4973. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4974. * @param otherColor defines the second operand
  4975. * @param result defines Color3 object to store the result into
  4976. * @returns the unmodified current Color3
  4977. */
  4978. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4979. /**
  4980. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4981. * @param otherColor defines the second operand
  4982. * @returns the new Color3
  4983. */
  4984. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4985. /**
  4986. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4987. * @param otherColor defines the second operand
  4988. * @param result defines Color3 object to store the result into
  4989. * @returns the unmodified current Color3
  4990. */
  4991. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4992. /**
  4993. * Copy the current object
  4994. * @returns a new Color3 copied the current one
  4995. */
  4996. clone(): Color3;
  4997. /**
  4998. * Copies the rgb values from the source in the current Color3
  4999. * @param source defines the source Color3 object
  5000. * @returns the updated Color3 object
  5001. */
  5002. copyFrom(source: DeepImmutable<Color3>): Color3;
  5003. /**
  5004. * Updates the Color3 rgb values from the given floats
  5005. * @param r defines the red component to read from
  5006. * @param g defines the green component to read from
  5007. * @param b defines the blue component to read from
  5008. * @returns the current Color3 object
  5009. */
  5010. copyFromFloats(r: number, g: number, b: number): Color3;
  5011. /**
  5012. * Updates the Color3 rgb values from the given floats
  5013. * @param r defines the red component to read from
  5014. * @param g defines the green component to read from
  5015. * @param b defines the blue component to read from
  5016. * @returns the current Color3 object
  5017. */
  5018. set(r: number, g: number, b: number): Color3;
  5019. /**
  5020. * Compute the Color3 hexadecimal code as a string
  5021. * @returns a string containing the hexadecimal representation of the Color3 object
  5022. */
  5023. toHexString(): string;
  5024. /**
  5025. * Computes a new Color3 converted from the current one to linear space
  5026. * @returns a new Color3 object
  5027. */
  5028. toLinearSpace(): Color3;
  5029. /**
  5030. * Converts current color in rgb space to HSV values
  5031. * @returns a new color3 representing the HSV values
  5032. */
  5033. toHSV(): Color3;
  5034. /**
  5035. * Converts current color in rgb space to HSV values
  5036. * @param result defines the Color3 where to store the HSV values
  5037. */
  5038. toHSVToRef(result: Color3): void;
  5039. /**
  5040. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the linear space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5045. /**
  5046. * Computes a new Color3 converted from the current one to gamma space
  5047. * @returns a new Color3 object
  5048. */
  5049. toGammaSpace(): Color3;
  5050. /**
  5051. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5052. * @param convertedColor defines the Color3 object where to store the gamma space version
  5053. * @returns the unmodified Color3
  5054. */
  5055. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5056. private static _BlackReadOnly;
  5057. /**
  5058. * Convert Hue, saturation and value to a Color3 (RGB)
  5059. * @param hue defines the hue
  5060. * @param saturation defines the saturation
  5061. * @param value defines the value
  5062. * @param result defines the Color3 where to store the RGB values
  5063. */
  5064. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5065. /**
  5066. * Creates a new Color3 from the string containing valid hexadecimal values
  5067. * @param hex defines a string containing valid hexadecimal values
  5068. * @returns a new Color3 object
  5069. */
  5070. static FromHexString(hex: string): Color3;
  5071. /**
  5072. * Creates a new Color3 from the starting index of the given array
  5073. * @param array defines the source array
  5074. * @param offset defines an offset in the source array
  5075. * @returns a new Color3 object
  5076. */
  5077. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5078. /**
  5079. * Creates a new Color3 from integer values (< 256)
  5080. * @param r defines the red component to read from (value between 0 and 255)
  5081. * @param g defines the green component to read from (value between 0 and 255)
  5082. * @param b defines the blue component to read from (value between 0 and 255)
  5083. * @returns a new Color3 object
  5084. */
  5085. static FromInts(r: number, g: number, b: number): Color3;
  5086. /**
  5087. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5088. * @param start defines the start Color3 value
  5089. * @param end defines the end Color3 value
  5090. * @param amount defines the gradient value between start and end
  5091. * @returns a new Color3 object
  5092. */
  5093. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5094. /**
  5095. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5096. * @param left defines the start value
  5097. * @param right defines the end value
  5098. * @param amount defines the gradient factor
  5099. * @param result defines the Color3 object where to store the result
  5100. */
  5101. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5102. /**
  5103. * Returns a Color3 value containing a red color
  5104. * @returns a new Color3 object
  5105. */
  5106. static Red(): Color3;
  5107. /**
  5108. * Returns a Color3 value containing a green color
  5109. * @returns a new Color3 object
  5110. */
  5111. static Green(): Color3;
  5112. /**
  5113. * Returns a Color3 value containing a blue color
  5114. * @returns a new Color3 object
  5115. */
  5116. static Blue(): Color3;
  5117. /**
  5118. * Returns a Color3 value containing a black color
  5119. * @returns a new Color3 object
  5120. */
  5121. static Black(): Color3;
  5122. /**
  5123. * Gets a Color3 value containing a black color that must not be updated
  5124. */
  5125. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5126. /**
  5127. * Returns a Color3 value containing a white color
  5128. * @returns a new Color3 object
  5129. */
  5130. static White(): Color3;
  5131. /**
  5132. * Returns a Color3 value containing a purple color
  5133. * @returns a new Color3 object
  5134. */
  5135. static Purple(): Color3;
  5136. /**
  5137. * Returns a Color3 value containing a magenta color
  5138. * @returns a new Color3 object
  5139. */
  5140. static Magenta(): Color3;
  5141. /**
  5142. * Returns a Color3 value containing a yellow color
  5143. * @returns a new Color3 object
  5144. */
  5145. static Yellow(): Color3;
  5146. /**
  5147. * Returns a Color3 value containing a gray color
  5148. * @returns a new Color3 object
  5149. */
  5150. static Gray(): Color3;
  5151. /**
  5152. * Returns a Color3 value containing a teal color
  5153. * @returns a new Color3 object
  5154. */
  5155. static Teal(): Color3;
  5156. /**
  5157. * Returns a Color3 value containing a random color
  5158. * @returns a new Color3 object
  5159. */
  5160. static Random(): Color3;
  5161. }
  5162. /**
  5163. * Class used to hold a RBGA color
  5164. */
  5165. export class Color4 {
  5166. /**
  5167. * Defines the red component (between 0 and 1, default is 0)
  5168. */
  5169. r: number;
  5170. /**
  5171. * Defines the green component (between 0 and 1, default is 0)
  5172. */
  5173. g: number;
  5174. /**
  5175. * Defines the blue component (between 0 and 1, default is 0)
  5176. */
  5177. b: number;
  5178. /**
  5179. * Defines the alpha component (between 0 and 1, default is 1)
  5180. */
  5181. a: number;
  5182. /**
  5183. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5184. * @param r defines the red component (between 0 and 1, default is 0)
  5185. * @param g defines the green component (between 0 and 1, default is 0)
  5186. * @param b defines the blue component (between 0 and 1, default is 0)
  5187. * @param a defines the alpha component (between 0 and 1, default is 1)
  5188. */
  5189. constructor(
  5190. /**
  5191. * Defines the red component (between 0 and 1, default is 0)
  5192. */
  5193. r?: number,
  5194. /**
  5195. * Defines the green component (between 0 and 1, default is 0)
  5196. */
  5197. g?: number,
  5198. /**
  5199. * Defines the blue component (between 0 and 1, default is 0)
  5200. */
  5201. b?: number,
  5202. /**
  5203. * Defines the alpha component (between 0 and 1, default is 1)
  5204. */
  5205. a?: number);
  5206. /**
  5207. * Adds in place the given Color4 values to the current Color4 object
  5208. * @param right defines the second operand
  5209. * @returns the current updated Color4 object
  5210. */
  5211. addInPlace(right: DeepImmutable<Color4>): Color4;
  5212. /**
  5213. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5214. * @returns the new array
  5215. */
  5216. asArray(): number[];
  5217. /**
  5218. * Stores from the starting index in the given array the Color4 successive values
  5219. * @param array defines the array where to store the r,g,b components
  5220. * @param index defines an optional index in the target array to define where to start storing values
  5221. * @returns the current Color4 object
  5222. */
  5223. toArray(array: number[], index?: number): Color4;
  5224. /**
  5225. * Determines equality between Color4 objects
  5226. * @param otherColor defines the second operand
  5227. * @returns true if the rgba values are equal to the given ones
  5228. */
  5229. equals(otherColor: DeepImmutable<Color4>): boolean;
  5230. /**
  5231. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5232. * @param right defines the second operand
  5233. * @returns a new Color4 object
  5234. */
  5235. add(right: DeepImmutable<Color4>): Color4;
  5236. /**
  5237. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5238. * @param right defines the second operand
  5239. * @returns a new Color4 object
  5240. */
  5241. subtract(right: DeepImmutable<Color4>): Color4;
  5242. /**
  5243. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5244. * @param right defines the second operand
  5245. * @param result defines the Color4 object where to store the result
  5246. * @returns the current Color4 object
  5247. */
  5248. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5249. /**
  5250. * Creates a new Color4 with the current Color4 values multiplied by scale
  5251. * @param scale defines the scaling factor to apply
  5252. * @returns a new Color4 object
  5253. */
  5254. scale(scale: number): Color4;
  5255. /**
  5256. * Multiplies the current Color4 values by scale and stores the result in "result"
  5257. * @param scale defines the scaling factor to apply
  5258. * @param result defines the Color4 object where to store the result
  5259. * @returns the current unmodified Color4
  5260. */
  5261. scaleToRef(scale: number, result: Color4): Color4;
  5262. /**
  5263. * Scale the current Color4 values by a factor and add the result to a given Color4
  5264. * @param scale defines the scale factor
  5265. * @param result defines the Color4 object where to store the result
  5266. * @returns the unmodified current Color4
  5267. */
  5268. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5269. /**
  5270. * Clamps the rgb values by the min and max values and stores the result into "result"
  5271. * @param min defines minimum clamping value (default is 0)
  5272. * @param max defines maximum clamping value (default is 1)
  5273. * @param result defines color to store the result into.
  5274. * @returns the cuurent Color4
  5275. */
  5276. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5277. /**
  5278. * Multipy an Color4 value by another and return a new Color4 object
  5279. * @param color defines the Color4 value to multiply by
  5280. * @returns a new Color4 object
  5281. */
  5282. multiply(color: Color4): Color4;
  5283. /**
  5284. * Multipy a Color4 value by another and push the result in a reference value
  5285. * @param color defines the Color4 value to multiply by
  5286. * @param result defines the Color4 to fill the result in
  5287. * @returns the result Color4
  5288. */
  5289. multiplyToRef(color: Color4, result: Color4): Color4;
  5290. /**
  5291. * Creates a string with the Color4 current values
  5292. * @returns the string representation of the Color4 object
  5293. */
  5294. toString(): string;
  5295. /**
  5296. * Returns the string "Color4"
  5297. * @returns "Color4"
  5298. */
  5299. getClassName(): string;
  5300. /**
  5301. * Compute the Color4 hash code
  5302. * @returns an unique number that can be used to hash Color4 objects
  5303. */
  5304. getHashCode(): number;
  5305. /**
  5306. * Creates a new Color4 copied from the current one
  5307. * @returns a new Color4 object
  5308. */
  5309. clone(): Color4;
  5310. /**
  5311. * Copies the given Color4 values into the current one
  5312. * @param source defines the source Color4 object
  5313. * @returns the current updated Color4 object
  5314. */
  5315. copyFrom(source: Color4): Color4;
  5316. /**
  5317. * Copies the given float values into the current one
  5318. * @param r defines the red component to read from
  5319. * @param g defines the green component to read from
  5320. * @param b defines the blue component to read from
  5321. * @param a defines the alpha component to read from
  5322. * @returns the current updated Color4 object
  5323. */
  5324. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5325. /**
  5326. * Copies the given float values into the current one
  5327. * @param r defines the red component to read from
  5328. * @param g defines the green component to read from
  5329. * @param b defines the blue component to read from
  5330. * @param a defines the alpha component to read from
  5331. * @returns the current updated Color4 object
  5332. */
  5333. set(r: number, g: number, b: number, a: number): Color4;
  5334. /**
  5335. * Compute the Color4 hexadecimal code as a string
  5336. * @returns a string containing the hexadecimal representation of the Color4 object
  5337. */
  5338. toHexString(): string;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to linear space
  5341. * @returns a new Color4 object
  5342. */
  5343. toLinearSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the linear space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Computes a new Color4 converted from the current one to gamma space
  5352. * @returns a new Color4 object
  5353. */
  5354. toGammaSpace(): Color4;
  5355. /**
  5356. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5357. * @param convertedColor defines the Color4 object where to store the gamma space version
  5358. * @returns the unmodified Color4
  5359. */
  5360. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5361. /**
  5362. * Creates a new Color4 from the string containing valid hexadecimal values
  5363. * @param hex defines a string containing valid hexadecimal values
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromHexString(hex: string): Color4;
  5367. /**
  5368. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5369. * @param left defines the start value
  5370. * @param right defines the end value
  5371. * @param amount defines the gradient factor
  5372. * @returns a new Color4 object
  5373. */
  5374. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5375. /**
  5376. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  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 Color4 object where to store data
  5381. */
  5382. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5383. /**
  5384. * Creates a new Color4 from a Color3 and an alpha value
  5385. * @param color3 defines the source Color3 to read from
  5386. * @param alpha defines the alpha component (1.0 by default)
  5387. * @returns a new Color4 object
  5388. */
  5389. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5390. /**
  5391. * Creates a new Color4 from the starting index element of the given array
  5392. * @param array defines the source array to read from
  5393. * @param offset defines the offset in the source array
  5394. * @returns a new Color4 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @param a defines the alpha component to read from (value between 0 and 255)
  5403. * @returns a new Color3 object
  5404. */
  5405. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5406. /**
  5407. * Check the content of a given array and convert it to an array containing RGBA data
  5408. * If the original array was already containing count * 4 values then it is returned directly
  5409. * @param colors defines the array to check
  5410. * @param count defines the number of RGBA data to expect
  5411. * @returns an array containing count * 4 values (RGBA)
  5412. */
  5413. static CheckColors4(colors: number[], count: number): number[];
  5414. }
  5415. /**
  5416. * @hidden
  5417. */
  5418. export class TmpColors {
  5419. static Color3: Color3[];
  5420. static Color4: Color4[];
  5421. }
  5422. }
  5423. declare module BABYLON {
  5424. /**
  5425. * Class representing spherical harmonics coefficients to the 3rd degree
  5426. */
  5427. export class SphericalHarmonics {
  5428. /**
  5429. * Defines whether or not the harmonics have been prescaled for rendering.
  5430. */
  5431. preScaled: boolean;
  5432. /**
  5433. * The l0,0 coefficients of the spherical harmonics
  5434. */
  5435. l00: Vector3;
  5436. /**
  5437. * The l1,-1 coefficients of the spherical harmonics
  5438. */
  5439. l1_1: Vector3;
  5440. /**
  5441. * The l1,0 coefficients of the spherical harmonics
  5442. */
  5443. l10: Vector3;
  5444. /**
  5445. * The l1,1 coefficients of the spherical harmonics
  5446. */
  5447. l11: Vector3;
  5448. /**
  5449. * The l2,-2 coefficients of the spherical harmonics
  5450. */
  5451. l2_2: Vector3;
  5452. /**
  5453. * The l2,-1 coefficients of the spherical harmonics
  5454. */
  5455. l2_1: Vector3;
  5456. /**
  5457. * The l2,0 coefficients of the spherical harmonics
  5458. */
  5459. l20: Vector3;
  5460. /**
  5461. * The l2,1 coefficients of the spherical harmonics
  5462. */
  5463. l21: Vector3;
  5464. /**
  5465. * The l2,2 coefficients of the spherical harmonics
  5466. */
  5467. l22: Vector3;
  5468. /**
  5469. * Adds a light to the spherical harmonics
  5470. * @param direction the direction of the light
  5471. * @param color the color of the light
  5472. * @param deltaSolidAngle the delta solid angle of the light
  5473. */
  5474. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5475. /**
  5476. * Scales the spherical harmonics by the given amount
  5477. * @param scale the amount to scale
  5478. */
  5479. scaleInPlace(scale: number): void;
  5480. /**
  5481. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5482. *
  5483. * ```
  5484. * E_lm = A_l * L_lm
  5485. * ```
  5486. *
  5487. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5488. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5489. * the scaling factors are given in equation 9.
  5490. */
  5491. convertIncidentRadianceToIrradiance(): void;
  5492. /**
  5493. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5494. *
  5495. * ```
  5496. * L = (1/pi) * E * rho
  5497. * ```
  5498. *
  5499. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5500. */
  5501. convertIrradianceToLambertianRadiance(): void;
  5502. /**
  5503. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5504. * required operations at run time.
  5505. *
  5506. * This is simply done by scaling back the SH with Ylm constants parameter.
  5507. * The trigonometric part being applied by the shader at run time.
  5508. */
  5509. preScaleForRendering(): void;
  5510. /**
  5511. * Constructs a spherical harmonics from an array.
  5512. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5513. * @returns the spherical harmonics
  5514. */
  5515. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5516. /**
  5517. * Gets the spherical harmonics from polynomial
  5518. * @param polynomial the spherical polynomial
  5519. * @returns the spherical harmonics
  5520. */
  5521. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5522. }
  5523. /**
  5524. * Class representing spherical polynomial coefficients to the 3rd degree
  5525. */
  5526. export class SphericalPolynomial {
  5527. private _harmonics;
  5528. /**
  5529. * The spherical harmonics used to create the polynomials.
  5530. */
  5531. readonly preScaledHarmonics: SphericalHarmonics;
  5532. /**
  5533. * The x coefficients of the spherical polynomial
  5534. */
  5535. x: Vector3;
  5536. /**
  5537. * The y coefficients of the spherical polynomial
  5538. */
  5539. y: Vector3;
  5540. /**
  5541. * The z coefficients of the spherical polynomial
  5542. */
  5543. z: Vector3;
  5544. /**
  5545. * The xx coefficients of the spherical polynomial
  5546. */
  5547. xx: Vector3;
  5548. /**
  5549. * The yy coefficients of the spherical polynomial
  5550. */
  5551. yy: Vector3;
  5552. /**
  5553. * The zz coefficients of the spherical polynomial
  5554. */
  5555. zz: Vector3;
  5556. /**
  5557. * The xy coefficients of the spherical polynomial
  5558. */
  5559. xy: Vector3;
  5560. /**
  5561. * The yz coefficients of the spherical polynomial
  5562. */
  5563. yz: Vector3;
  5564. /**
  5565. * The zx coefficients of the spherical polynomial
  5566. */
  5567. zx: Vector3;
  5568. /**
  5569. * Adds an ambient color to the spherical polynomial
  5570. * @param color the color to add
  5571. */
  5572. addAmbient(color: Color3): void;
  5573. /**
  5574. * Scales the spherical polynomial by the given amount
  5575. * @param scale the amount to scale
  5576. */
  5577. scaleInPlace(scale: number): void;
  5578. /**
  5579. * Gets the spherical polynomial from harmonics
  5580. * @param harmonics the spherical harmonics
  5581. * @returns the spherical polynomial
  5582. */
  5583. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5584. /**
  5585. * Constructs a spherical polynomial from an array.
  5586. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5587. * @returns the spherical polynomial
  5588. */
  5589. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5590. }
  5591. }
  5592. declare module BABYLON {
  5593. /**
  5594. * Define options used to create a render target texture
  5595. */
  5596. export class RenderTargetCreationOptions {
  5597. /**
  5598. * Specifies is mipmaps must be generated
  5599. */
  5600. generateMipMaps?: boolean;
  5601. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5602. generateDepthBuffer?: boolean;
  5603. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5604. generateStencilBuffer?: boolean;
  5605. /** Defines texture type (int by default) */
  5606. type?: number;
  5607. /** Defines sampling mode (trilinear by default) */
  5608. samplingMode?: number;
  5609. /** Defines format (RGBA by default) */
  5610. format?: number;
  5611. }
  5612. }
  5613. declare module BABYLON {
  5614. /**
  5615. * @hidden
  5616. **/
  5617. export class _AlphaState {
  5618. private _isAlphaBlendDirty;
  5619. private _isBlendFunctionParametersDirty;
  5620. private _isBlendEquationParametersDirty;
  5621. private _isBlendConstantsDirty;
  5622. private _alphaBlend;
  5623. private _blendFunctionParameters;
  5624. private _blendEquationParameters;
  5625. private _blendConstants;
  5626. /**
  5627. * Initializes the state.
  5628. */
  5629. constructor();
  5630. readonly isDirty: boolean;
  5631. alphaBlend: boolean;
  5632. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5633. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5634. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5635. reset(): void;
  5636. apply(gl: WebGLRenderingContext): void;
  5637. }
  5638. }
  5639. declare module BABYLON {
  5640. /**
  5641. * @hidden
  5642. **/
  5643. export class _DepthCullingState {
  5644. private _isDepthTestDirty;
  5645. private _isDepthMaskDirty;
  5646. private _isDepthFuncDirty;
  5647. private _isCullFaceDirty;
  5648. private _isCullDirty;
  5649. private _isZOffsetDirty;
  5650. private _isFrontFaceDirty;
  5651. private _depthTest;
  5652. private _depthMask;
  5653. private _depthFunc;
  5654. private _cull;
  5655. private _cullFace;
  5656. private _zOffset;
  5657. private _frontFace;
  5658. /**
  5659. * Initializes the state.
  5660. */
  5661. constructor();
  5662. readonly isDirty: boolean;
  5663. zOffset: number;
  5664. cullFace: Nullable<number>;
  5665. cull: Nullable<boolean>;
  5666. depthFunc: Nullable<number>;
  5667. depthMask: boolean;
  5668. depthTest: boolean;
  5669. frontFace: Nullable<number>;
  5670. reset(): void;
  5671. apply(gl: WebGLRenderingContext): void;
  5672. }
  5673. }
  5674. declare module BABYLON {
  5675. /**
  5676. * @hidden
  5677. **/
  5678. export class _StencilState {
  5679. /** 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 */
  5680. static readonly ALWAYS: number;
  5681. /** Passed to stencilOperation to specify that stencil value must be kept */
  5682. static readonly KEEP: number;
  5683. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5684. static readonly REPLACE: number;
  5685. private _isStencilTestDirty;
  5686. private _isStencilMaskDirty;
  5687. private _isStencilFuncDirty;
  5688. private _isStencilOpDirty;
  5689. private _stencilTest;
  5690. private _stencilMask;
  5691. private _stencilFunc;
  5692. private _stencilFuncRef;
  5693. private _stencilFuncMask;
  5694. private _stencilOpStencilFail;
  5695. private _stencilOpDepthFail;
  5696. private _stencilOpStencilDepthPass;
  5697. readonly isDirty: boolean;
  5698. stencilFunc: number;
  5699. stencilFuncRef: number;
  5700. stencilFuncMask: number;
  5701. stencilOpStencilFail: number;
  5702. stencilOpDepthFail: number;
  5703. stencilOpStencilDepthPass: number;
  5704. stencilMask: number;
  5705. stencilTest: boolean;
  5706. constructor();
  5707. reset(): void;
  5708. apply(gl: WebGLRenderingContext): void;
  5709. }
  5710. }
  5711. declare module BABYLON {
  5712. /**
  5713. * @hidden
  5714. **/
  5715. export class _TimeToken {
  5716. _startTimeQuery: Nullable<WebGLQuery>;
  5717. _endTimeQuery: Nullable<WebGLQuery>;
  5718. _timeElapsedQuery: Nullable<WebGLQuery>;
  5719. _timeElapsedQueryEnded: boolean;
  5720. }
  5721. }
  5722. declare module BABYLON {
  5723. /**
  5724. * Class used to evalaute queries containing `and` and `or` operators
  5725. */
  5726. export class AndOrNotEvaluator {
  5727. /**
  5728. * Evaluate a query
  5729. * @param query defines the query to evaluate
  5730. * @param evaluateCallback defines the callback used to filter result
  5731. * @returns true if the query matches
  5732. */
  5733. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5734. private static _HandleParenthesisContent;
  5735. private static _SimplifyNegation;
  5736. }
  5737. }
  5738. declare module BABYLON {
  5739. /**
  5740. * Class used to store custom tags
  5741. */
  5742. export class Tags {
  5743. /**
  5744. * Adds support for tags on the given object
  5745. * @param obj defines the object to use
  5746. */
  5747. static EnableFor(obj: any): void;
  5748. /**
  5749. * Removes tags support
  5750. * @param obj defines the object to use
  5751. */
  5752. static DisableFor(obj: any): void;
  5753. /**
  5754. * Gets a boolean indicating if the given object has tags
  5755. * @param obj defines the object to use
  5756. * @returns a boolean
  5757. */
  5758. static HasTags(obj: any): boolean;
  5759. /**
  5760. * Gets the tags available on a given object
  5761. * @param obj defines the object to use
  5762. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5763. * @returns the tags
  5764. */
  5765. static GetTags(obj: any, asString?: boolean): any;
  5766. /**
  5767. * Adds tags to an object
  5768. * @param obj defines the object to use
  5769. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5770. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5771. */
  5772. static AddTagsTo(obj: any, tagsString: string): void;
  5773. /**
  5774. * @hidden
  5775. */
  5776. static _AddTagTo(obj: any, tag: string): void;
  5777. /**
  5778. * Removes specific tags from a specific object
  5779. * @param obj defines the object to use
  5780. * @param tagsString defines the tags to remove
  5781. */
  5782. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5783. /**
  5784. * @hidden
  5785. */
  5786. static _RemoveTagFrom(obj: any, tag: string): void;
  5787. /**
  5788. * Defines if tags hosted on an object match a given query
  5789. * @param obj defines the object to use
  5790. * @param tagsQuery defines the tag query
  5791. * @returns a boolean
  5792. */
  5793. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5794. }
  5795. }
  5796. declare module BABYLON {
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * 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.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module BABYLON {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module BABYLON {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module BABYLON {
  6453. /**
  6454. * Interface used to define a behavior
  6455. */
  6456. export interface Behavior<T> {
  6457. /** gets or sets behavior's name */
  6458. name: string;
  6459. /**
  6460. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6461. */
  6462. init(): void;
  6463. /**
  6464. * Called when the behavior is attached to a target
  6465. * @param target defines the target where the behavior is attached to
  6466. */
  6467. attach(target: T): void;
  6468. /**
  6469. * Called when the behavior is detached from its target
  6470. */
  6471. detach(): void;
  6472. }
  6473. /**
  6474. * Interface implemented by classes supporting behaviors
  6475. */
  6476. export interface IBehaviorAware<T> {
  6477. /**
  6478. * Attach a behavior
  6479. * @param behavior defines the behavior to attach
  6480. * @returns the current host
  6481. */
  6482. addBehavior(behavior: Behavior<T>): T;
  6483. /**
  6484. * Remove a behavior from the current object
  6485. * @param behavior defines the behavior to detach
  6486. * @returns the current host
  6487. */
  6488. removeBehavior(behavior: Behavior<T>): T;
  6489. /**
  6490. * Gets a behavior using its name to search
  6491. * @param name defines the name to search
  6492. * @returns the behavior or null if not found
  6493. */
  6494. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Defines an array and its length.
  6500. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6501. */
  6502. export interface ISmartArrayLike<T> {
  6503. /**
  6504. * The data of the array.
  6505. */
  6506. data: Array<T>;
  6507. /**
  6508. * The active length of the array.
  6509. */
  6510. length: number;
  6511. }
  6512. /**
  6513. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6514. */
  6515. export class SmartArray<T> implements ISmartArrayLike<T> {
  6516. /**
  6517. * The full set of data from the array.
  6518. */
  6519. data: Array<T>;
  6520. /**
  6521. * The active length of the array.
  6522. */
  6523. length: number;
  6524. protected _id: number;
  6525. /**
  6526. * Instantiates a Smart Array.
  6527. * @param capacity defines the default capacity of the array.
  6528. */
  6529. constructor(capacity: number);
  6530. /**
  6531. * Pushes a value at the end of the active data.
  6532. * @param value defines the object to push in the array.
  6533. */
  6534. push(value: T): void;
  6535. /**
  6536. * Iterates over the active data and apply the lambda to them.
  6537. * @param func defines the action to apply on each value.
  6538. */
  6539. forEach(func: (content: T) => void): void;
  6540. /**
  6541. * Sorts the full sets of data.
  6542. * @param compareFn defines the comparison function to apply.
  6543. */
  6544. sort(compareFn: (a: T, b: T) => number): void;
  6545. /**
  6546. * Resets the active data to an empty array.
  6547. */
  6548. reset(): void;
  6549. /**
  6550. * Releases all the data from the array as well as the array.
  6551. */
  6552. dispose(): void;
  6553. /**
  6554. * Concats the active data with a given array.
  6555. * @param array defines the data to concatenate with.
  6556. */
  6557. concat(array: any): void;
  6558. /**
  6559. * Returns the position of a value in the active data.
  6560. * @param value defines the value to find the index for
  6561. * @returns the index if found in the active data otherwise -1
  6562. */
  6563. indexOf(value: T): number;
  6564. /**
  6565. * Returns whether an element is part of the active data.
  6566. * @param value defines the value to look for
  6567. * @returns true if found in the active data otherwise false
  6568. */
  6569. contains(value: T): boolean;
  6570. private static _GlobalId;
  6571. }
  6572. /**
  6573. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6574. * The data in this array can only be present once
  6575. */
  6576. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6577. private _duplicateId;
  6578. /**
  6579. * Pushes a value at the end of the active data.
  6580. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6581. * @param value defines the object to push in the array.
  6582. */
  6583. push(value: T): void;
  6584. /**
  6585. * Pushes a value at the end of the active data.
  6586. * If the data is already present, it won t be added again
  6587. * @param value defines the object to push in the array.
  6588. * @returns true if added false if it was already present
  6589. */
  6590. pushNoDuplicate(value: T): boolean;
  6591. /**
  6592. * Resets the active data to an empty array.
  6593. */
  6594. reset(): void;
  6595. /**
  6596. * Concats the active data with a given array.
  6597. * This ensures no dupplicate will be present in the result.
  6598. * @param array defines the data to concatenate with.
  6599. */
  6600. concatWithNoDuplicate(array: any): void;
  6601. }
  6602. }
  6603. declare module BABYLON {
  6604. /**
  6605. * @ignore
  6606. * This is a list of all the different input types that are available in the application.
  6607. * Fo instance: ArcRotateCameraGamepadInput...
  6608. */
  6609. export var CameraInputTypes: {};
  6610. /**
  6611. * This is the contract to implement in order to create a new input class.
  6612. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6613. */
  6614. export interface ICameraInput<TCamera extends Camera> {
  6615. /**
  6616. * Defines the camera the input is attached to.
  6617. */
  6618. camera: Nullable<TCamera>;
  6619. /**
  6620. * Gets the class name of the current intput.
  6621. * @returns the class name
  6622. */
  6623. getClassName(): string;
  6624. /**
  6625. * Get the friendly name associated with the input class.
  6626. * @returns the input friendly name
  6627. */
  6628. getSimpleName(): string;
  6629. /**
  6630. * Attach the input controls to a specific dom element to get the input from.
  6631. * @param element Defines the element the controls should be listened from
  6632. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6633. */
  6634. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6635. /**
  6636. * Detach the current controls from the specified dom element.
  6637. * @param element Defines the element to stop listening the inputs from
  6638. */
  6639. detachControl(element: Nullable<HTMLElement>): void;
  6640. /**
  6641. * Update the current camera state depending on the inputs that have been used this frame.
  6642. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6643. */
  6644. checkInputs?: () => void;
  6645. }
  6646. /**
  6647. * Represents a map of input types to input instance or input index to input instance.
  6648. */
  6649. export interface CameraInputsMap<TCamera extends Camera> {
  6650. /**
  6651. * Accessor to the input by input type.
  6652. */
  6653. [name: string]: ICameraInput<TCamera>;
  6654. /**
  6655. * Accessor to the input by input index.
  6656. */
  6657. [idx: number]: ICameraInput<TCamera>;
  6658. }
  6659. /**
  6660. * This represents the input manager used within a camera.
  6661. * It helps dealing with all the different kind of input attached to a camera.
  6662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6663. */
  6664. export class CameraInputsManager<TCamera extends Camera> {
  6665. /**
  6666. * Defines the list of inputs attahed to the camera.
  6667. */
  6668. attached: CameraInputsMap<TCamera>;
  6669. /**
  6670. * Defines the dom element the camera is collecting inputs from.
  6671. * This is null if the controls have not been attached.
  6672. */
  6673. attachedElement: Nullable<HTMLElement>;
  6674. /**
  6675. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6676. */
  6677. noPreventDefault: boolean;
  6678. /**
  6679. * Defined the camera the input manager belongs to.
  6680. */
  6681. camera: TCamera;
  6682. /**
  6683. * Update the current camera state depending on the inputs that have been used this frame.
  6684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6685. */
  6686. checkInputs: () => void;
  6687. /**
  6688. * Instantiate a new Camera Input Manager.
  6689. * @param camera Defines the camera the input manager blongs to
  6690. */
  6691. constructor(camera: TCamera);
  6692. /**
  6693. * Add an input method to a camera
  6694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6695. * @param input camera input method
  6696. */
  6697. add(input: ICameraInput<TCamera>): void;
  6698. /**
  6699. * Remove a specific input method from a camera
  6700. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6701. * @param inputToRemove camera input method
  6702. */
  6703. remove(inputToRemove: ICameraInput<TCamera>): void;
  6704. /**
  6705. * Remove a specific input type from a camera
  6706. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6707. * @param inputType the type of the input to remove
  6708. */
  6709. removeByType(inputType: string): void;
  6710. private _addCheckInputs;
  6711. /**
  6712. * Attach the input controls to the currently attached dom element to listen the events from.
  6713. * @param input Defines the input to attach
  6714. */
  6715. attachInput(input: ICameraInput<TCamera>): void;
  6716. /**
  6717. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6718. * @param element Defines the dom element to collect the events from
  6719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6720. */
  6721. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6722. /**
  6723. * Detach the current manager inputs controls from a specific dom element.
  6724. * @param element Defines the dom element to collect the events from
  6725. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6726. */
  6727. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6728. /**
  6729. * Rebuild the dynamic inputCheck function from the current list of
  6730. * defined inputs in the manager.
  6731. */
  6732. rebuildInputCheck(): void;
  6733. /**
  6734. * Remove all attached input methods from a camera
  6735. */
  6736. clear(): void;
  6737. /**
  6738. * Serialize the current input manager attached to a camera.
  6739. * This ensures than once parsed,
  6740. * the input associated to the camera will be identical to the current ones
  6741. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6742. */
  6743. serialize(serializedCamera: any): void;
  6744. /**
  6745. * Parses an input manager serialized JSON to restore the previous list of inputs
  6746. * and states associated to a camera.
  6747. * @param parsedCamera Defines the JSON to parse
  6748. */
  6749. parse(parsedCamera: any): void;
  6750. }
  6751. }
  6752. declare module BABYLON {
  6753. /**
  6754. * @hidden
  6755. */
  6756. export class IntersectionInfo {
  6757. bu: Nullable<number>;
  6758. bv: Nullable<number>;
  6759. distance: number;
  6760. faceId: number;
  6761. subMeshId: number;
  6762. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6763. }
  6764. }
  6765. declare module BABYLON {
  6766. /**
  6767. * Represens a plane by the equation ax + by + cz + d = 0
  6768. */
  6769. export class Plane {
  6770. private static _TmpMatrix;
  6771. /**
  6772. * Normal of the plane (a,b,c)
  6773. */
  6774. normal: Vector3;
  6775. /**
  6776. * d component of the plane
  6777. */
  6778. d: number;
  6779. /**
  6780. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6781. * @param a a component of the plane
  6782. * @param b b component of the plane
  6783. * @param c c component of the plane
  6784. * @param d d component of the plane
  6785. */
  6786. constructor(a: number, b: number, c: number, d: number);
  6787. /**
  6788. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6789. */
  6790. asArray(): number[];
  6791. /**
  6792. * @returns a new plane copied from the current Plane.
  6793. */
  6794. clone(): Plane;
  6795. /**
  6796. * @returns the string "Plane".
  6797. */
  6798. getClassName(): string;
  6799. /**
  6800. * @returns the Plane hash code.
  6801. */
  6802. getHashCode(): number;
  6803. /**
  6804. * Normalize the current Plane in place.
  6805. * @returns the updated Plane.
  6806. */
  6807. normalize(): Plane;
  6808. /**
  6809. * Applies a transformation the plane and returns the result
  6810. * @param transformation the transformation matrix to be applied to the plane
  6811. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6812. */
  6813. transform(transformation: DeepImmutable<Matrix>): Plane;
  6814. /**
  6815. * Calcualtte the dot product between the point and the plane normal
  6816. * @param point point to calculate the dot product with
  6817. * @returns the dot product (float) of the point coordinates and the plane normal.
  6818. */
  6819. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6820. /**
  6821. * Updates the current Plane from the plane defined by the three given points.
  6822. * @param point1 one of the points used to contruct the plane
  6823. * @param point2 one of the points used to contruct the plane
  6824. * @param point3 one of the points used to contruct the plane
  6825. * @returns the updated Plane.
  6826. */
  6827. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6828. /**
  6829. * Checks if the plane is facing a given direction
  6830. * @param direction the direction to check if the plane is facing
  6831. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6832. * @returns True is the vector "direction" is the same side than the plane normal.
  6833. */
  6834. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6835. /**
  6836. * Calculates the distance to a point
  6837. * @param point point to calculate distance to
  6838. * @returns the signed distance (float) from the given point to the Plane.
  6839. */
  6840. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6841. /**
  6842. * Creates a plane from an array
  6843. * @param array the array to create a plane from
  6844. * @returns a new Plane from the given array.
  6845. */
  6846. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6847. /**
  6848. * Creates a plane from three points
  6849. * @param point1 point used to create the plane
  6850. * @param point2 point used to create the plane
  6851. * @param point3 point used to create the plane
  6852. * @returns a new Plane defined by the three given points.
  6853. */
  6854. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6855. /**
  6856. * Creates a plane from an origin point and a normal
  6857. * @param origin origin of the plane to be constructed
  6858. * @param normal normal of the plane to be constructed
  6859. * @returns a new Plane the normal vector to this plane at the given origin point.
  6860. * Note : the vector "normal" is updated because normalized.
  6861. */
  6862. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6863. /**
  6864. * Calculates the distance from a plane and a point
  6865. * @param origin origin of the plane to be constructed
  6866. * @param normal normal of the plane to be constructed
  6867. * @param point point to calculate distance to
  6868. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6869. */
  6870. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6871. }
  6872. }
  6873. declare module BABYLON {
  6874. /**
  6875. * Class used to store bounding sphere information
  6876. */
  6877. export class BoundingSphere {
  6878. /**
  6879. * Gets the center of the bounding sphere in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Radius of the bounding sphere in local space
  6884. */
  6885. radius: number;
  6886. /**
  6887. * Gets the center of the bounding sphere in world space
  6888. */
  6889. readonly centerWorld: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in world space
  6892. */
  6893. radiusWorld: number;
  6894. /**
  6895. * Gets the minimum vector in local space
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * Gets the maximum vector in local space
  6900. */
  6901. readonly maximum: Vector3;
  6902. private _worldMatrix;
  6903. private static readonly TmpVector3;
  6904. /**
  6905. * Creates a new bounding sphere
  6906. * @param min defines the minimum vector (in local space)
  6907. * @param max defines the maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6911. /**
  6912. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6913. * @param min defines the new minimum vector (in local space)
  6914. * @param max defines the new maximum vector (in local space)
  6915. * @param worldMatrix defines the new world matrix
  6916. */
  6917. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Scale the current bounding sphere by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding box
  6922. */
  6923. scale(factor: number): BoundingSphere;
  6924. /**
  6925. * Gets the world matrix of the bounding box
  6926. * @returns a matrix
  6927. */
  6928. getWorldMatrix(): DeepImmutable<Matrix>;
  6929. /** @hidden */
  6930. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Tests if the bounding sphere is intersecting the frustum planes
  6933. * @param frustumPlanes defines the frustum planes to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6937. /**
  6938. * Tests if the bounding sphere center is in between the frustum planes.
  6939. * Used for optimistic fast inclusion.
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if the sphere center is in between the frustum planes
  6942. */
  6943. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding sphere
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding sphere
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Checks if two sphere intersct
  6952. * @param sphere0 sphere 0
  6953. * @param sphere1 sphere 1
  6954. * @returns true if the speres intersect
  6955. */
  6956. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6957. }
  6958. }
  6959. declare module BABYLON {
  6960. /**
  6961. * Class used to store bounding box information
  6962. */
  6963. export class BoundingBox implements ICullable {
  6964. /**
  6965. * Gets the 8 vectors representing the bounding box in local space
  6966. */
  6967. readonly vectors: Vector3[];
  6968. /**
  6969. * Gets the center of the bounding box in local space
  6970. */
  6971. readonly center: Vector3;
  6972. /**
  6973. * Gets the center of the bounding box in world space
  6974. */
  6975. readonly centerWorld: Vector3;
  6976. /**
  6977. * Gets the extend size in local space
  6978. */
  6979. readonly extendSize: Vector3;
  6980. /**
  6981. * Gets the extend size in world space
  6982. */
  6983. readonly extendSizeWorld: Vector3;
  6984. /**
  6985. * Gets the OBB (object bounding box) directions
  6986. */
  6987. readonly directions: Vector3[];
  6988. /**
  6989. * Gets the 8 vectors representing the bounding box in world space
  6990. */
  6991. readonly vectorsWorld: Vector3[];
  6992. /**
  6993. * Gets the minimum vector in world space
  6994. */
  6995. readonly minimumWorld: Vector3;
  6996. /**
  6997. * Gets the maximum vector in world space
  6998. */
  6999. readonly maximumWorld: Vector3;
  7000. /**
  7001. * Gets the minimum vector in local space
  7002. */
  7003. readonly minimum: Vector3;
  7004. /**
  7005. * Gets the maximum vector in local space
  7006. */
  7007. readonly maximum: Vector3;
  7008. private _worldMatrix;
  7009. private static readonly TmpVector3;
  7010. /**
  7011. * @hidden
  7012. */
  7013. _tag: number;
  7014. /**
  7015. * Creates a new bounding box
  7016. * @param min defines the minimum vector (in local space)
  7017. * @param max defines the maximum vector (in local space)
  7018. * @param worldMatrix defines the new world matrix
  7019. */
  7020. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7021. /**
  7022. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7023. * @param min defines the new minimum vector (in local space)
  7024. * @param max defines the new maximum vector (in local space)
  7025. * @param worldMatrix defines the new world matrix
  7026. */
  7027. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7028. /**
  7029. * Scale the current bounding box by applying a scale factor
  7030. * @param factor defines the scale factor to apply
  7031. * @returns the current bounding box
  7032. */
  7033. scale(factor: number): BoundingBox;
  7034. /**
  7035. * Gets the world matrix of the bounding box
  7036. * @returns a matrix
  7037. */
  7038. getWorldMatrix(): DeepImmutable<Matrix>;
  7039. /** @hidden */
  7040. _update(world: DeepImmutable<Matrix>): void;
  7041. /**
  7042. * Tests if the bounding box is intersecting the frustum planes
  7043. * @param frustumPlanes defines the frustum planes to test
  7044. * @returns true if there is an intersection
  7045. */
  7046. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7047. /**
  7048. * Tests if the bounding box is entirely inside the frustum planes
  7049. * @param frustumPlanes defines the frustum planes to test
  7050. * @returns true if there is an inclusion
  7051. */
  7052. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7053. /**
  7054. * Tests if a point is inside the bounding box
  7055. * @param point defines the point to test
  7056. * @returns true if the point is inside the bounding box
  7057. */
  7058. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7059. /**
  7060. * Tests if the bounding box intersects with a bounding sphere
  7061. * @param sphere defines the sphere to test
  7062. * @returns true if there is an intersection
  7063. */
  7064. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7065. /**
  7066. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7067. * @param min defines the min vector to use
  7068. * @param max defines the max vector to use
  7069. * @returns true if there is an intersection
  7070. */
  7071. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7072. /**
  7073. * Tests if two bounding boxes are intersections
  7074. * @param box0 defines the first box to test
  7075. * @param box1 defines the second box to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7079. /**
  7080. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7081. * @param minPoint defines the minimum vector of the bounding box
  7082. * @param maxPoint defines the maximum vector of the bounding box
  7083. * @param sphereCenter defines the sphere center
  7084. * @param sphereRadius defines the sphere radius
  7085. * @returns true if there is an intersection
  7086. */
  7087. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7088. /**
  7089. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7090. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7091. * @param frustumPlanes defines the frustum planes to test
  7092. * @return true if there is an inclusion
  7093. */
  7094. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7095. /**
  7096. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7098. * @param frustumPlanes defines the frustum planes to test
  7099. * @return true if there is an intersection
  7100. */
  7101. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /** @hidden */
  7106. export class Collider {
  7107. /** Define if a collision was found */
  7108. collisionFound: boolean;
  7109. /**
  7110. * Define last intersection point in local space
  7111. */
  7112. intersectionPoint: Vector3;
  7113. /**
  7114. * Define last collided mesh
  7115. */
  7116. collidedMesh: Nullable<AbstractMesh>;
  7117. private _collisionPoint;
  7118. private _planeIntersectionPoint;
  7119. private _tempVector;
  7120. private _tempVector2;
  7121. private _tempVector3;
  7122. private _tempVector4;
  7123. private _edge;
  7124. private _baseToVertex;
  7125. private _destinationPoint;
  7126. private _slidePlaneNormal;
  7127. private _displacementVector;
  7128. /** @hidden */
  7129. _radius: Vector3;
  7130. /** @hidden */
  7131. _retry: number;
  7132. private _velocity;
  7133. private _basePoint;
  7134. private _epsilon;
  7135. /** @hidden */
  7136. _velocityWorldLength: number;
  7137. /** @hidden */
  7138. _basePointWorld: Vector3;
  7139. private _velocityWorld;
  7140. private _normalizedVelocity;
  7141. /** @hidden */
  7142. _initialVelocity: Vector3;
  7143. /** @hidden */
  7144. _initialPosition: Vector3;
  7145. private _nearestDistance;
  7146. private _collisionMask;
  7147. collisionMask: number;
  7148. /**
  7149. * Gets the plane normal used to compute the sliding response (in local space)
  7150. */
  7151. readonly slidePlaneNormal: Vector3;
  7152. /** @hidden */
  7153. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7154. /** @hidden */
  7155. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7156. /** @hidden */
  7157. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7158. /** @hidden */
  7159. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7160. /** @hidden */
  7161. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7162. /** @hidden */
  7163. _getResponse(pos: Vector3, vel: Vector3): void;
  7164. }
  7165. }
  7166. declare module BABYLON {
  7167. /**
  7168. * Interface for cullable objects
  7169. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7170. */
  7171. export interface ICullable {
  7172. /**
  7173. * Checks if the object or part of the object is in the frustum
  7174. * @param frustumPlanes Camera near/planes
  7175. * @returns true if the object is in frustum otherwise false
  7176. */
  7177. isInFrustum(frustumPlanes: Plane[]): boolean;
  7178. /**
  7179. * Checks if a cullable object (mesh...) is in the camera frustum
  7180. * Unlike isInFrustum this cheks the full bounding box
  7181. * @param frustumPlanes Camera near/planes
  7182. * @returns true if the object is in frustum otherwise false
  7183. */
  7184. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7185. }
  7186. /**
  7187. * Info for a bounding data of a mesh
  7188. */
  7189. export class BoundingInfo implements ICullable {
  7190. /**
  7191. * Bounding box for the mesh
  7192. */
  7193. readonly boundingBox: BoundingBox;
  7194. /**
  7195. * Bounding sphere for the mesh
  7196. */
  7197. readonly boundingSphere: BoundingSphere;
  7198. private _isLocked;
  7199. private static readonly TmpVector3;
  7200. /**
  7201. * Constructs bounding info
  7202. * @param minimum min vector of the bounding box/sphere
  7203. * @param maximum max vector of the bounding box/sphere
  7204. * @param worldMatrix defines the new world matrix
  7205. */
  7206. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7207. /**
  7208. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7209. * @param min defines the new minimum vector (in local space)
  7210. * @param max defines the new maximum vector (in local space)
  7211. * @param worldMatrix defines the new world matrix
  7212. */
  7213. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * min vector of the bounding box/sphere
  7216. */
  7217. readonly minimum: Vector3;
  7218. /**
  7219. * max vector of the bounding box/sphere
  7220. */
  7221. readonly maximum: Vector3;
  7222. /**
  7223. * If the info is locked and won't be updated to avoid perf overhead
  7224. */
  7225. isLocked: boolean;
  7226. /**
  7227. * Updates the bounding sphere and box
  7228. * @param world world matrix to be used to update
  7229. */
  7230. update(world: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7233. * @param center New center of the bounding info
  7234. * @param extend New extend of the bounding info
  7235. * @returns the current bounding info
  7236. */
  7237. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7238. /**
  7239. * Scale the current bounding info by applying a scale factor
  7240. * @param factor defines the scale factor to apply
  7241. * @returns the current bounding info
  7242. */
  7243. scale(factor: number): BoundingInfo;
  7244. /**
  7245. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7246. * @param frustumPlanes defines the frustum to test
  7247. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7248. * @returns true if the bounding info is in the frustum planes
  7249. */
  7250. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7251. /**
  7252. * Gets the world distance between the min and max points of the bounding box
  7253. */
  7254. readonly diagonalLength: number;
  7255. /**
  7256. * Checks if a cullable object (mesh...) is in the camera frustum
  7257. * Unlike isInFrustum this cheks the full bounding box
  7258. * @param frustumPlanes Camera near/planes
  7259. * @returns true if the object is in frustum otherwise false
  7260. */
  7261. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7262. /** @hidden */
  7263. _checkCollision(collider: Collider): boolean;
  7264. /**
  7265. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7266. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7267. * @param point the point to check intersection with
  7268. * @returns if the point intersects
  7269. */
  7270. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7271. /**
  7272. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7273. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7274. * @param boundingInfo the bounding info to check intersection with
  7275. * @param precise if the intersection should be done using OBB
  7276. * @returns if the bounding info intersects
  7277. */
  7278. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7279. }
  7280. }
  7281. declare module BABYLON {
  7282. /**
  7283. * Extracts minimum and maximum values from a list of indexed positions
  7284. * @param positions defines the positions to use
  7285. * @param indices defines the indices to the positions
  7286. * @param indexStart defines the start index
  7287. * @param indexCount defines the end index
  7288. * @param bias defines bias value to add to the result
  7289. * @return minimum and maximum values
  7290. */
  7291. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7292. minimum: Vector3;
  7293. maximum: Vector3;
  7294. };
  7295. /**
  7296. * Extracts minimum and maximum values from a list of positions
  7297. * @param positions defines the positions to use
  7298. * @param start defines the start index in the positions array
  7299. * @param count defines the number of positions to handle
  7300. * @param bias defines bias value to add to the result
  7301. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7302. * @return minimum and maximum values
  7303. */
  7304. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7305. minimum: Vector3;
  7306. maximum: Vector3;
  7307. };
  7308. }
  7309. declare module BABYLON {
  7310. /**
  7311. * Enum that determines the text-wrapping mode to use.
  7312. */
  7313. export enum InspectableType {
  7314. /**
  7315. * Checkbox for booleans
  7316. */
  7317. Checkbox = 0,
  7318. /**
  7319. * Sliders for numbers
  7320. */
  7321. Slider = 1,
  7322. /**
  7323. * Vector3
  7324. */
  7325. Vector3 = 2,
  7326. /**
  7327. * Quaternions
  7328. */
  7329. Quaternion = 3,
  7330. /**
  7331. * Color3
  7332. */
  7333. Color3 = 4,
  7334. /**
  7335. * String
  7336. */
  7337. String = 5
  7338. }
  7339. /**
  7340. * Interface used to define custom inspectable properties.
  7341. * This interface is used by the inspector to display custom property grids
  7342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7343. */
  7344. export interface IInspectable {
  7345. /**
  7346. * Gets the label to display
  7347. */
  7348. label: string;
  7349. /**
  7350. * Gets the name of the property to edit
  7351. */
  7352. propertyName: string;
  7353. /**
  7354. * Gets the type of the editor to use
  7355. */
  7356. type: InspectableType;
  7357. /**
  7358. * Gets the minimum value of the property when using in "slider" mode
  7359. */
  7360. min?: number;
  7361. /**
  7362. * Gets the maximum value of the property when using in "slider" mode
  7363. */
  7364. max?: number;
  7365. /**
  7366. * Gets the setp to use when using in "slider" mode
  7367. */
  7368. step?: number;
  7369. }
  7370. }
  7371. declare module BABYLON {
  7372. /**
  7373. * Class used to provide helper for timing
  7374. */
  7375. export class TimingTools {
  7376. /**
  7377. * Polyfill for setImmediate
  7378. * @param action defines the action to execute after the current execution block
  7379. */
  7380. static SetImmediate(action: () => void): void;
  7381. }
  7382. }
  7383. declare module BABYLON {
  7384. /**
  7385. * Class used to enable instatition of objects by class name
  7386. */
  7387. export class InstantiationTools {
  7388. /**
  7389. * Use this object to register external classes like custom textures or material
  7390. * to allow the laoders to instantiate them
  7391. */
  7392. static RegisteredExternalClasses: {
  7393. [key: string]: Object;
  7394. };
  7395. /**
  7396. * Tries to instantiate a new object from a given class name
  7397. * @param className defines the class name to instantiate
  7398. * @returns the new object or null if the system was not able to do the instantiation
  7399. */
  7400. static Instantiate(className: string): any;
  7401. }
  7402. }
  7403. declare module BABYLON {
  7404. /**
  7405. * This represents the required contract to create a new type of texture loader.
  7406. */
  7407. export interface IInternalTextureLoader {
  7408. /**
  7409. * Defines wether the loader supports cascade loading the different faces.
  7410. */
  7411. supportCascades: boolean;
  7412. /**
  7413. * This returns if the loader support the current file information.
  7414. * @param extension defines the file extension of the file being loaded
  7415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7416. * @param fallback defines the fallback internal texture if any
  7417. * @param isBase64 defines whether the texture is encoded as a base64
  7418. * @param isBuffer defines whether the texture data are stored as a buffer
  7419. * @returns true if the loader can load the specified file
  7420. */
  7421. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7422. /**
  7423. * Transform the url before loading if required.
  7424. * @param rootUrl the url of the texture
  7425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7426. * @returns the transformed texture
  7427. */
  7428. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7429. /**
  7430. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7431. * @param rootUrl the url of the texture
  7432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7433. * @returns the fallback texture
  7434. */
  7435. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7436. /**
  7437. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7438. * @param data contains the texture data
  7439. * @param texture defines the BabylonJS internal texture
  7440. * @param createPolynomials will be true if polynomials have been requested
  7441. * @param onLoad defines the callback to trigger once the texture is ready
  7442. * @param onError defines the callback to trigger in case of error
  7443. */
  7444. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7445. /**
  7446. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7447. * @param data contains the texture data
  7448. * @param texture defines the BabylonJS internal texture
  7449. * @param callback defines the method to call once ready to upload
  7450. */
  7451. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7452. }
  7453. }
  7454. declare module BABYLON {
  7455. interface Engine {
  7456. /**
  7457. * Creates a depth stencil cube texture.
  7458. * This is only available in WebGL 2.
  7459. * @param size The size of face edge in the cube texture.
  7460. * @param options The options defining the cube texture.
  7461. * @returns The cube texture
  7462. */
  7463. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7464. /**
  7465. * Creates a cube texture
  7466. * @param rootUrl defines the url where the files to load is located
  7467. * @param scene defines the current scene
  7468. * @param files defines the list of files to load (1 per face)
  7469. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7470. * @param onLoad defines an optional callback raised when the texture is loaded
  7471. * @param onError defines an optional callback raised if there is an issue to load the texture
  7472. * @param format defines the format of the data
  7473. * @param forcedExtension defines the extension to use to pick the right loader
  7474. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7475. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7476. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7477. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7478. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7479. * @returns the cube texture as an InternalTexture
  7480. */
  7481. 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;
  7482. /**
  7483. * Creates a cube texture
  7484. * @param rootUrl defines the url where the files to load is located
  7485. * @param scene defines the current scene
  7486. * @param files defines the list of files to load (1 per face)
  7487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7488. * @param onLoad defines an optional callback raised when the texture is loaded
  7489. * @param onError defines an optional callback raised if there is an issue to load the texture
  7490. * @param format defines the format of the data
  7491. * @param forcedExtension defines the extension to use to pick the right loader
  7492. * @returns the cube texture as an InternalTexture
  7493. */
  7494. 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;
  7495. /**
  7496. * Creates a cube texture
  7497. * @param rootUrl defines the url where the files to load is located
  7498. * @param scene defines the current scene
  7499. * @param files defines the list of files to load (1 per face)
  7500. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7501. * @param onLoad defines an optional callback raised when the texture is loaded
  7502. * @param onError defines an optional callback raised if there is an issue to load the texture
  7503. * @param format defines the format of the data
  7504. * @param forcedExtension defines the extension to use to pick the right loader
  7505. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7506. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7507. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7508. * @returns the cube texture as an InternalTexture
  7509. */
  7510. 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;
  7511. /** @hidden */
  7512. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7513. /** @hidden */
  7514. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7515. /** @hidden */
  7516. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7517. /** @hidden */
  7518. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7519. }
  7520. }
  7521. declare module BABYLON {
  7522. /**
  7523. * Class for creating a cube texture
  7524. */
  7525. export class CubeTexture extends BaseTexture {
  7526. private _delayedOnLoad;
  7527. /**
  7528. * The url of the texture
  7529. */
  7530. url: string;
  7531. /**
  7532. * Gets or sets the center of the bounding box associated with the cube texture.
  7533. * It must define where the camera used to render the texture was set
  7534. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7535. */
  7536. boundingBoxPosition: Vector3;
  7537. private _boundingBoxSize;
  7538. /**
  7539. * Gets or sets the size of the bounding box associated with the cube texture
  7540. * When defined, the cubemap will switch to local mode
  7541. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7542. * @example https://www.babylonjs-playground.com/#RNASML
  7543. */
  7544. /**
  7545. * Returns the bounding box size
  7546. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7547. */
  7548. boundingBoxSize: Vector3;
  7549. protected _rotationY: number;
  7550. /**
  7551. * Sets texture matrix rotation angle around Y axis in radians.
  7552. */
  7553. /**
  7554. * Gets texture matrix rotation angle around Y axis radians.
  7555. */
  7556. rotationY: number;
  7557. /**
  7558. * Are mip maps generated for this texture or not.
  7559. */
  7560. readonly noMipmap: boolean;
  7561. private _noMipmap;
  7562. private _files;
  7563. private _extensions;
  7564. private _textureMatrix;
  7565. private _format;
  7566. private _createPolynomials;
  7567. /** @hidden */
  7568. _prefiltered: boolean;
  7569. /**
  7570. * Creates a cube texture from an array of image urls
  7571. * @param files defines an array of image urls
  7572. * @param scene defines the hosting scene
  7573. * @param noMipmap specifies if mip maps are not used
  7574. * @returns a cube texture
  7575. */
  7576. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7577. /**
  7578. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7579. * @param url defines the url of the prefiltered texture
  7580. * @param scene defines the scene the texture is attached to
  7581. * @param forcedExtension defines the extension of the file if different from the url
  7582. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7583. * @return the prefiltered texture
  7584. */
  7585. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7586. /**
  7587. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7588. * as prefiltered data.
  7589. * @param rootUrl defines the url of the texture or the root name of the six images
  7590. * @param scene defines the scene the texture is attached to
  7591. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7592. * @param noMipmap defines if mipmaps should be created or not
  7593. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7594. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7595. * @param onError defines a callback triggered in case of error during load
  7596. * @param format defines the internal format to use for the texture once loaded
  7597. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7598. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7599. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7602. * @return the cube texture
  7603. */
  7604. 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);
  7605. /**
  7606. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7607. */
  7608. readonly isPrefiltered: boolean;
  7609. /**
  7610. * Get the current class name of the texture useful for serialization or dynamic coding.
  7611. * @returns "CubeTexture"
  7612. */
  7613. getClassName(): string;
  7614. /**
  7615. * Update the url (and optional buffer) of this texture if url was null during construction.
  7616. * @param url the url of the texture
  7617. * @param forcedExtension defines the extension to use
  7618. * @param onLoad callback called when the texture is loaded (defaults to null)
  7619. */
  7620. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7621. /**
  7622. * Delays loading of the cube texture
  7623. * @param forcedExtension defines the extension to use
  7624. */
  7625. delayLoad(forcedExtension?: string): void;
  7626. /**
  7627. * Returns the reflection texture matrix
  7628. * @returns the reflection texture matrix
  7629. */
  7630. getReflectionTextureMatrix(): Matrix;
  7631. /**
  7632. * Sets the reflection texture matrix
  7633. * @param value Reflection texture matrix
  7634. */
  7635. setReflectionTextureMatrix(value: Matrix): void;
  7636. /**
  7637. * Parses text to create a cube texture
  7638. * @param parsedTexture define the serialized text to read from
  7639. * @param scene defines the hosting scene
  7640. * @param rootUrl defines the root url of the cube texture
  7641. * @returns a cube texture
  7642. */
  7643. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7644. /**
  7645. * Makes a clone, or deep copy, of the cube texture
  7646. * @returns a new cube texture
  7647. */
  7648. clone(): CubeTexture;
  7649. }
  7650. }
  7651. declare module BABYLON {
  7652. /**
  7653. * Manages the defines for the Material
  7654. */
  7655. export class MaterialDefines {
  7656. /** @hidden */
  7657. protected _keys: string[];
  7658. private _isDirty;
  7659. /** @hidden */
  7660. _renderId: number;
  7661. /** @hidden */
  7662. _areLightsDirty: boolean;
  7663. /** @hidden */
  7664. _areLightsDisposed: boolean;
  7665. /** @hidden */
  7666. _areAttributesDirty: boolean;
  7667. /** @hidden */
  7668. _areTexturesDirty: boolean;
  7669. /** @hidden */
  7670. _areFresnelDirty: boolean;
  7671. /** @hidden */
  7672. _areMiscDirty: boolean;
  7673. /** @hidden */
  7674. _areImageProcessingDirty: boolean;
  7675. /** @hidden */
  7676. _normals: boolean;
  7677. /** @hidden */
  7678. _uvs: boolean;
  7679. /** @hidden */
  7680. _needNormals: boolean;
  7681. /** @hidden */
  7682. _needUVs: boolean;
  7683. [id: string]: any;
  7684. /**
  7685. * Specifies if the material needs to be re-calculated
  7686. */
  7687. readonly isDirty: boolean;
  7688. /**
  7689. * Marks the material to indicate that it has been re-calculated
  7690. */
  7691. markAsProcessed(): void;
  7692. /**
  7693. * Marks the material to indicate that it needs to be re-calculated
  7694. */
  7695. markAsUnprocessed(): void;
  7696. /**
  7697. * Marks the material to indicate all of its defines need to be re-calculated
  7698. */
  7699. markAllAsDirty(): void;
  7700. /**
  7701. * Marks the material to indicate that image processing needs to be re-calculated
  7702. */
  7703. markAsImageProcessingDirty(): void;
  7704. /**
  7705. * Marks the material to indicate the lights need to be re-calculated
  7706. * @param disposed Defines whether the light is dirty due to dispose or not
  7707. */
  7708. markAsLightDirty(disposed?: boolean): void;
  7709. /**
  7710. * Marks the attribute state as changed
  7711. */
  7712. markAsAttributesDirty(): void;
  7713. /**
  7714. * Marks the texture state as changed
  7715. */
  7716. markAsTexturesDirty(): void;
  7717. /**
  7718. * Marks the fresnel state as changed
  7719. */
  7720. markAsFresnelDirty(): void;
  7721. /**
  7722. * Marks the misc state as changed
  7723. */
  7724. markAsMiscDirty(): void;
  7725. /**
  7726. * Rebuilds the material defines
  7727. */
  7728. rebuild(): void;
  7729. /**
  7730. * Specifies if two material defines are equal
  7731. * @param other - A material define instance to compare to
  7732. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7733. */
  7734. isEqual(other: MaterialDefines): boolean;
  7735. /**
  7736. * Clones this instance's defines to another instance
  7737. * @param other - material defines to clone values to
  7738. */
  7739. cloneTo(other: MaterialDefines): void;
  7740. /**
  7741. * Resets the material define values
  7742. */
  7743. reset(): void;
  7744. /**
  7745. * Converts the material define values to a string
  7746. * @returns - String of material define information
  7747. */
  7748. toString(): string;
  7749. }
  7750. }
  7751. declare module BABYLON {
  7752. /**
  7753. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7754. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7755. * 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;
  7756. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7757. */
  7758. export class ColorCurves {
  7759. private _dirty;
  7760. private _tempColor;
  7761. private _globalCurve;
  7762. private _highlightsCurve;
  7763. private _midtonesCurve;
  7764. private _shadowsCurve;
  7765. private _positiveCurve;
  7766. private _negativeCurve;
  7767. private _globalHue;
  7768. private _globalDensity;
  7769. private _globalSaturation;
  7770. private _globalExposure;
  7771. /**
  7772. * Gets the global Hue value.
  7773. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7774. */
  7775. /**
  7776. * Sets the global Hue value.
  7777. * 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).
  7778. */
  7779. globalHue: number;
  7780. /**
  7781. * Gets the global Density value.
  7782. * 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.
  7783. * Values less than zero provide a filter of opposite hue.
  7784. */
  7785. /**
  7786. * Sets the global Density value.
  7787. * 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.
  7788. * Values less than zero provide a filter of opposite hue.
  7789. */
  7790. globalDensity: number;
  7791. /**
  7792. * Gets the global Saturation value.
  7793. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7794. */
  7795. /**
  7796. * Sets the global Saturation value.
  7797. * 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.
  7798. */
  7799. globalSaturation: number;
  7800. /**
  7801. * Gets the global Exposure value.
  7802. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7803. */
  7804. /**
  7805. * Sets the global Exposure value.
  7806. * 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.
  7807. */
  7808. globalExposure: number;
  7809. private _highlightsHue;
  7810. private _highlightsDensity;
  7811. private _highlightsSaturation;
  7812. private _highlightsExposure;
  7813. /**
  7814. * Gets the highlights Hue value.
  7815. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7816. */
  7817. /**
  7818. * Sets the highlights Hue value.
  7819. * 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).
  7820. */
  7821. highlightsHue: number;
  7822. /**
  7823. * Gets the highlights Density value.
  7824. * 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.
  7825. * Values less than zero provide a filter of opposite hue.
  7826. */
  7827. /**
  7828. * Sets the highlights Density value.
  7829. * 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.
  7830. * Values less than zero provide a filter of opposite hue.
  7831. */
  7832. highlightsDensity: number;
  7833. /**
  7834. * Gets the highlights Saturation value.
  7835. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7836. */
  7837. /**
  7838. * Sets the highlights Saturation value.
  7839. * 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.
  7840. */
  7841. highlightsSaturation: number;
  7842. /**
  7843. * Gets the highlights Exposure value.
  7844. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7845. */
  7846. /**
  7847. * Sets the highlights Exposure value.
  7848. * 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.
  7849. */
  7850. highlightsExposure: number;
  7851. private _midtonesHue;
  7852. private _midtonesDensity;
  7853. private _midtonesSaturation;
  7854. private _midtonesExposure;
  7855. /**
  7856. * Gets the midtones Hue value.
  7857. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7858. */
  7859. /**
  7860. * Sets the midtones Hue value.
  7861. * 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).
  7862. */
  7863. midtonesHue: number;
  7864. /**
  7865. * Gets the midtones Density value.
  7866. * 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.
  7867. * Values less than zero provide a filter of opposite hue.
  7868. */
  7869. /**
  7870. * Sets the midtones Density value.
  7871. * 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.
  7872. * Values less than zero provide a filter of opposite hue.
  7873. */
  7874. midtonesDensity: number;
  7875. /**
  7876. * Gets the midtones Saturation value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7878. */
  7879. /**
  7880. * Sets the midtones Saturation value.
  7881. * 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.
  7882. */
  7883. midtonesSaturation: number;
  7884. /**
  7885. * Gets the midtones Exposure value.
  7886. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7887. */
  7888. /**
  7889. * Sets the midtones Exposure value.
  7890. * 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.
  7891. */
  7892. midtonesExposure: number;
  7893. private _shadowsHue;
  7894. private _shadowsDensity;
  7895. private _shadowsSaturation;
  7896. private _shadowsExposure;
  7897. /**
  7898. * Gets the shadows Hue value.
  7899. * 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).
  7900. */
  7901. /**
  7902. * Sets the shadows Hue value.
  7903. * 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).
  7904. */
  7905. shadowsHue: number;
  7906. /**
  7907. * Gets the shadows Density value.
  7908. * 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.
  7909. * Values less than zero provide a filter of opposite hue.
  7910. */
  7911. /**
  7912. * Sets the shadows Density value.
  7913. * 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.
  7914. * Values less than zero provide a filter of opposite hue.
  7915. */
  7916. shadowsDensity: number;
  7917. /**
  7918. * Gets the shadows Saturation value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the shadows Saturation value.
  7923. * 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.
  7924. */
  7925. shadowsSaturation: number;
  7926. /**
  7927. * Gets the shadows Exposure value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the shadows Exposure value.
  7932. * 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.
  7933. */
  7934. shadowsExposure: number;
  7935. /**
  7936. * Returns the class name
  7937. * @returns The class name
  7938. */
  7939. getClassName(): string;
  7940. /**
  7941. * Binds the color curves to the shader.
  7942. * @param colorCurves The color curve to bind
  7943. * @param effect The effect to bind to
  7944. * @param positiveUniform The positive uniform shader parameter
  7945. * @param neutralUniform The neutral uniform shader parameter
  7946. * @param negativeUniform The negative uniform shader parameter
  7947. */
  7948. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7949. /**
  7950. * Prepare the list of uniforms associated with the ColorCurves effects.
  7951. * @param uniformsList The list of uniforms used in the effect
  7952. */
  7953. static PrepareUniforms(uniformsList: string[]): void;
  7954. /**
  7955. * Returns color grading data based on a hue, density, saturation and exposure value.
  7956. * @param filterHue The hue of the color filter.
  7957. * @param filterDensity The density of the color filter.
  7958. * @param saturation The saturation.
  7959. * @param exposure The exposure.
  7960. * @param result The result data container.
  7961. */
  7962. private getColorGradingDataToRef;
  7963. /**
  7964. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7965. * @param value The input slider value in range [-100,100].
  7966. * @returns Adjusted value.
  7967. */
  7968. private static applyColorGradingSliderNonlinear;
  7969. /**
  7970. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7971. * @param hue The hue (H) input.
  7972. * @param saturation The saturation (S) input.
  7973. * @param brightness The brightness (B) input.
  7974. * @result An RGBA color represented as Vector4.
  7975. */
  7976. private static fromHSBToRef;
  7977. /**
  7978. * Returns a value clamped between min and max
  7979. * @param value The value to clamp
  7980. * @param min The minimum of value
  7981. * @param max The maximum of value
  7982. * @returns The clamped value.
  7983. */
  7984. private static clamp;
  7985. /**
  7986. * Clones the current color curve instance.
  7987. * @return The cloned curves
  7988. */
  7989. clone(): ColorCurves;
  7990. /**
  7991. * Serializes the current color curve instance to a json representation.
  7992. * @return a JSON representation
  7993. */
  7994. serialize(): any;
  7995. /**
  7996. * Parses the color curve from a json representation.
  7997. * @param source the JSON source to parse
  7998. * @return The parsed curves
  7999. */
  8000. static Parse(source: any): ColorCurves;
  8001. }
  8002. }
  8003. declare module BABYLON {
  8004. /**
  8005. * Interface to follow in your material defines to integrate easily the
  8006. * Image proccessing functions.
  8007. * @hidden
  8008. */
  8009. export interface IImageProcessingConfigurationDefines {
  8010. IMAGEPROCESSING: boolean;
  8011. VIGNETTE: boolean;
  8012. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8013. VIGNETTEBLENDMODEOPAQUE: boolean;
  8014. TONEMAPPING: boolean;
  8015. TONEMAPPING_ACES: boolean;
  8016. CONTRAST: boolean;
  8017. EXPOSURE: boolean;
  8018. COLORCURVES: boolean;
  8019. COLORGRADING: boolean;
  8020. COLORGRADING3D: boolean;
  8021. SAMPLER3DGREENDEPTH: boolean;
  8022. SAMPLER3DBGRMAP: boolean;
  8023. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8024. }
  8025. /**
  8026. * @hidden
  8027. */
  8028. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8029. IMAGEPROCESSING: boolean;
  8030. VIGNETTE: boolean;
  8031. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8032. VIGNETTEBLENDMODEOPAQUE: boolean;
  8033. TONEMAPPING: boolean;
  8034. TONEMAPPING_ACES: boolean;
  8035. CONTRAST: boolean;
  8036. COLORCURVES: boolean;
  8037. COLORGRADING: boolean;
  8038. COLORGRADING3D: boolean;
  8039. SAMPLER3DGREENDEPTH: boolean;
  8040. SAMPLER3DBGRMAP: boolean;
  8041. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8042. EXPOSURE: boolean;
  8043. constructor();
  8044. }
  8045. /**
  8046. * This groups together the common properties used for image processing either in direct forward pass
  8047. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8048. * or not.
  8049. */
  8050. export class ImageProcessingConfiguration {
  8051. /**
  8052. * Default tone mapping applied in BabylonJS.
  8053. */
  8054. static readonly TONEMAPPING_STANDARD: number;
  8055. /**
  8056. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8057. * to other engines rendering to increase portability.
  8058. */
  8059. static readonly TONEMAPPING_ACES: number;
  8060. /**
  8061. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8062. */
  8063. colorCurves: Nullable<ColorCurves>;
  8064. private _colorCurvesEnabled;
  8065. /**
  8066. * Gets wether the color curves effect is enabled.
  8067. */
  8068. /**
  8069. * Sets wether the color curves effect is enabled.
  8070. */
  8071. colorCurvesEnabled: boolean;
  8072. private _colorGradingTexture;
  8073. /**
  8074. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8075. */
  8076. /**
  8077. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8078. */
  8079. colorGradingTexture: Nullable<BaseTexture>;
  8080. private _colorGradingEnabled;
  8081. /**
  8082. * Gets wether the color grading effect is enabled.
  8083. */
  8084. /**
  8085. * Sets wether the color grading effect is enabled.
  8086. */
  8087. colorGradingEnabled: boolean;
  8088. private _colorGradingWithGreenDepth;
  8089. /**
  8090. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8091. */
  8092. /**
  8093. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8094. */
  8095. colorGradingWithGreenDepth: boolean;
  8096. private _colorGradingBGR;
  8097. /**
  8098. * Gets wether the color grading texture contains BGR values.
  8099. */
  8100. /**
  8101. * Sets wether the color grading texture contains BGR values.
  8102. */
  8103. colorGradingBGR: boolean;
  8104. /** @hidden */
  8105. _exposure: number;
  8106. /**
  8107. * Gets the Exposure used in the effect.
  8108. */
  8109. /**
  8110. * Sets the Exposure used in the effect.
  8111. */
  8112. exposure: number;
  8113. private _toneMappingEnabled;
  8114. /**
  8115. * Gets wether the tone mapping effect is enabled.
  8116. */
  8117. /**
  8118. * Sets wether the tone mapping effect is enabled.
  8119. */
  8120. toneMappingEnabled: boolean;
  8121. private _toneMappingType;
  8122. /**
  8123. * Gets the type of tone mapping effect.
  8124. */
  8125. /**
  8126. * Sets the type of tone mapping effect used in BabylonJS.
  8127. */
  8128. toneMappingType: number;
  8129. protected _contrast: number;
  8130. /**
  8131. * Gets the contrast used in the effect.
  8132. */
  8133. /**
  8134. * Sets the contrast used in the effect.
  8135. */
  8136. contrast: number;
  8137. /**
  8138. * Vignette stretch size.
  8139. */
  8140. vignetteStretch: number;
  8141. /**
  8142. * Vignette centre X Offset.
  8143. */
  8144. vignetteCentreX: number;
  8145. /**
  8146. * Vignette centre Y Offset.
  8147. */
  8148. vignetteCentreY: number;
  8149. /**
  8150. * Vignette weight or intensity of the vignette effect.
  8151. */
  8152. vignetteWeight: number;
  8153. /**
  8154. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8155. * if vignetteEnabled is set to true.
  8156. */
  8157. vignetteColor: Color4;
  8158. /**
  8159. * Camera field of view used by the Vignette effect.
  8160. */
  8161. vignetteCameraFov: number;
  8162. private _vignetteBlendMode;
  8163. /**
  8164. * Gets the vignette blend mode allowing different kind of effect.
  8165. */
  8166. /**
  8167. * Sets the vignette blend mode allowing different kind of effect.
  8168. */
  8169. vignetteBlendMode: number;
  8170. private _vignetteEnabled;
  8171. /**
  8172. * Gets wether the vignette effect is enabled.
  8173. */
  8174. /**
  8175. * Sets wether the vignette effect is enabled.
  8176. */
  8177. vignetteEnabled: boolean;
  8178. private _applyByPostProcess;
  8179. /**
  8180. * Gets wether the image processing is applied through a post process or not.
  8181. */
  8182. /**
  8183. * Sets wether the image processing is applied through a post process or not.
  8184. */
  8185. applyByPostProcess: boolean;
  8186. private _isEnabled;
  8187. /**
  8188. * Gets wether the image processing is enabled or not.
  8189. */
  8190. /**
  8191. * Sets wether the image processing is enabled or not.
  8192. */
  8193. isEnabled: boolean;
  8194. /**
  8195. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8196. */
  8197. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8198. /**
  8199. * Method called each time the image processing information changes requires to recompile the effect.
  8200. */
  8201. protected _updateParameters(): void;
  8202. /**
  8203. * Gets the current class name.
  8204. * @return "ImageProcessingConfiguration"
  8205. */
  8206. getClassName(): string;
  8207. /**
  8208. * Prepare the list of uniforms associated with the Image Processing effects.
  8209. * @param uniforms The list of uniforms used in the effect
  8210. * @param defines the list of defines currently in use
  8211. */
  8212. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8213. /**
  8214. * Prepare the list of samplers associated with the Image Processing effects.
  8215. * @param samplersList The list of uniforms used in the effect
  8216. * @param defines the list of defines currently in use
  8217. */
  8218. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8219. /**
  8220. * Prepare the list of defines associated to the shader.
  8221. * @param defines the list of defines to complete
  8222. * @param forPostProcess Define if we are currently in post process mode or not
  8223. */
  8224. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8225. /**
  8226. * Returns true if all the image processing information are ready.
  8227. * @returns True if ready, otherwise, false
  8228. */
  8229. isReady(): boolean;
  8230. /**
  8231. * Binds the image processing to the shader.
  8232. * @param effect The effect to bind to
  8233. * @param aspectRatio Define the current aspect ratio of the effect
  8234. */
  8235. bind(effect: Effect, aspectRatio?: number): void;
  8236. /**
  8237. * Clones the current image processing instance.
  8238. * @return The cloned image processing
  8239. */
  8240. clone(): ImageProcessingConfiguration;
  8241. /**
  8242. * Serializes the current image processing instance to a json representation.
  8243. * @return a JSON representation
  8244. */
  8245. serialize(): any;
  8246. /**
  8247. * Parses the image processing from a json representation.
  8248. * @param source the JSON source to parse
  8249. * @return The parsed image processing
  8250. */
  8251. static Parse(source: any): ImageProcessingConfiguration;
  8252. private static _VIGNETTEMODE_MULTIPLY;
  8253. private static _VIGNETTEMODE_OPAQUE;
  8254. /**
  8255. * Used to apply the vignette as a mix with the pixel color.
  8256. */
  8257. static readonly VIGNETTEMODE_MULTIPLY: number;
  8258. /**
  8259. * Used to apply the vignette as a replacement of the pixel color.
  8260. */
  8261. static readonly VIGNETTEMODE_OPAQUE: number;
  8262. }
  8263. }
  8264. declare module BABYLON {
  8265. /** @hidden */
  8266. export var postprocessVertexShader: {
  8267. name: string;
  8268. shader: string;
  8269. };
  8270. }
  8271. declare module BABYLON {
  8272. /** Defines supported spaces */
  8273. export enum Space {
  8274. /** Local (object) space */
  8275. LOCAL = 0,
  8276. /** World space */
  8277. WORLD = 1,
  8278. /** Bone space */
  8279. BONE = 2
  8280. }
  8281. /** Defines the 3 main axes */
  8282. export class Axis {
  8283. /** X axis */
  8284. static X: Vector3;
  8285. /** Y axis */
  8286. static Y: Vector3;
  8287. /** Z axis */
  8288. static Z: Vector3;
  8289. }
  8290. }
  8291. declare module BABYLON {
  8292. /**
  8293. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8294. * This is the base of the follow, arc rotate cameras and Free camera
  8295. * @see http://doc.babylonjs.com/features/cameras
  8296. */
  8297. export class TargetCamera extends Camera {
  8298. private static _RigCamTransformMatrix;
  8299. private static _TargetTransformMatrix;
  8300. private static _TargetFocalPoint;
  8301. /**
  8302. * Define the current direction the camera is moving to
  8303. */
  8304. cameraDirection: Vector3;
  8305. /**
  8306. * Define the current rotation the camera is rotating to
  8307. */
  8308. cameraRotation: Vector2;
  8309. /**
  8310. * When set, the up vector of the camera will be updated by the rotation of the camera
  8311. */
  8312. updateUpVectorFromRotation: boolean;
  8313. private _tmpQuaternion;
  8314. /**
  8315. * Define the current rotation of the camera
  8316. */
  8317. rotation: Vector3;
  8318. /**
  8319. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8320. */
  8321. rotationQuaternion: Quaternion;
  8322. /**
  8323. * Define the current speed of the camera
  8324. */
  8325. speed: number;
  8326. /**
  8327. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8328. * around all axis.
  8329. */
  8330. noRotationConstraint: boolean;
  8331. /**
  8332. * Define the current target of the camera as an object or a position.
  8333. */
  8334. lockedTarget: any;
  8335. /** @hidden */
  8336. _currentTarget: Vector3;
  8337. /** @hidden */
  8338. _initialFocalDistance: number;
  8339. /** @hidden */
  8340. _viewMatrix: Matrix;
  8341. /** @hidden */
  8342. _camMatrix: Matrix;
  8343. /** @hidden */
  8344. _cameraTransformMatrix: Matrix;
  8345. /** @hidden */
  8346. _cameraRotationMatrix: Matrix;
  8347. /** @hidden */
  8348. _referencePoint: Vector3;
  8349. /** @hidden */
  8350. _transformedReferencePoint: Vector3;
  8351. protected _globalCurrentTarget: Vector3;
  8352. protected _globalCurrentUpVector: Vector3;
  8353. /** @hidden */
  8354. _reset: () => void;
  8355. private _defaultUp;
  8356. /**
  8357. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8358. * This is the base of the follow, arc rotate cameras and Free camera
  8359. * @see http://doc.babylonjs.com/features/cameras
  8360. * @param name Defines the name of the camera in the scene
  8361. * @param position Defines the start position of the camera in the scene
  8362. * @param scene Defines the scene the camera belongs to
  8363. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8364. */
  8365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8366. /**
  8367. * Gets the position in front of the camera at a given distance.
  8368. * @param distance The distance from the camera we want the position to be
  8369. * @returns the position
  8370. */
  8371. getFrontPosition(distance: number): Vector3;
  8372. /** @hidden */
  8373. _getLockedTargetPosition(): Nullable<Vector3>;
  8374. private _storedPosition;
  8375. private _storedRotation;
  8376. private _storedRotationQuaternion;
  8377. /**
  8378. * Store current camera state of the camera (fov, position, rotation, etc..)
  8379. * @returns the camera
  8380. */
  8381. storeState(): Camera;
  8382. /**
  8383. * Restored camera state. You must call storeState() first
  8384. * @returns whether it was successful or not
  8385. * @hidden
  8386. */
  8387. _restoreStateValues(): boolean;
  8388. /** @hidden */
  8389. _initCache(): void;
  8390. /** @hidden */
  8391. _updateCache(ignoreParentClass?: boolean): void;
  8392. /** @hidden */
  8393. _isSynchronizedViewMatrix(): boolean;
  8394. /** @hidden */
  8395. _computeLocalCameraSpeed(): number;
  8396. /**
  8397. * Defines the target the camera should look at.
  8398. * @param target Defines the new target as a Vector or a mesh
  8399. */
  8400. setTarget(target: Vector3): void;
  8401. /**
  8402. * Return the current target position of the camera. This value is expressed in local space.
  8403. * @returns the target position
  8404. */
  8405. getTarget(): Vector3;
  8406. /** @hidden */
  8407. _decideIfNeedsToMove(): boolean;
  8408. /** @hidden */
  8409. _updatePosition(): void;
  8410. /** @hidden */
  8411. _checkInputs(): void;
  8412. protected _updateCameraRotationMatrix(): void;
  8413. /**
  8414. * 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)
  8415. * @returns the current camera
  8416. */
  8417. private _rotateUpVectorWithCameraRotationMatrix;
  8418. private _cachedRotationZ;
  8419. private _cachedQuaternionRotationZ;
  8420. /** @hidden */
  8421. _getViewMatrix(): Matrix;
  8422. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8423. /**
  8424. * @hidden
  8425. */
  8426. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8427. /**
  8428. * @hidden
  8429. */
  8430. _updateRigCameras(): void;
  8431. private _getRigCamPositionAndTarget;
  8432. /**
  8433. * Gets the current object class name.
  8434. * @return the class name
  8435. */
  8436. getClassName(): string;
  8437. }
  8438. }
  8439. declare module BABYLON {
  8440. /**
  8441. * Gather the list of keyboard event types as constants.
  8442. */
  8443. export class KeyboardEventTypes {
  8444. /**
  8445. * The keydown event is fired when a key becomes active (pressed).
  8446. */
  8447. static readonly KEYDOWN: number;
  8448. /**
  8449. * The keyup event is fired when a key has been released.
  8450. */
  8451. static readonly KEYUP: number;
  8452. }
  8453. /**
  8454. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8455. */
  8456. export class KeyboardInfo {
  8457. /**
  8458. * Defines the type of event (KeyboardEventTypes)
  8459. */
  8460. type: number;
  8461. /**
  8462. * Defines the related dom event
  8463. */
  8464. event: KeyboardEvent;
  8465. /**
  8466. * Instantiates a new keyboard info.
  8467. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8468. * @param type Defines the type of event (KeyboardEventTypes)
  8469. * @param event Defines the related dom event
  8470. */
  8471. constructor(
  8472. /**
  8473. * Defines the type of event (KeyboardEventTypes)
  8474. */
  8475. type: number,
  8476. /**
  8477. * Defines the related dom event
  8478. */
  8479. event: KeyboardEvent);
  8480. }
  8481. /**
  8482. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8483. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8484. */
  8485. export class KeyboardInfoPre extends KeyboardInfo {
  8486. /**
  8487. * Defines the type of event (KeyboardEventTypes)
  8488. */
  8489. type: number;
  8490. /**
  8491. * Defines the related dom event
  8492. */
  8493. event: KeyboardEvent;
  8494. /**
  8495. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8496. */
  8497. skipOnPointerObservable: boolean;
  8498. /**
  8499. * Instantiates a new keyboard pre info.
  8500. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8501. * @param type Defines the type of event (KeyboardEventTypes)
  8502. * @param event Defines the related dom event
  8503. */
  8504. constructor(
  8505. /**
  8506. * Defines the type of event (KeyboardEventTypes)
  8507. */
  8508. type: number,
  8509. /**
  8510. * Defines the related dom event
  8511. */
  8512. event: KeyboardEvent);
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /**
  8517. * Manage the keyboard inputs to control the movement of a free camera.
  8518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8519. */
  8520. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8521. /**
  8522. * Defines the camera the input is attached to.
  8523. */
  8524. camera: FreeCamera;
  8525. /**
  8526. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8527. */
  8528. keysUp: number[];
  8529. /**
  8530. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8531. */
  8532. keysDown: number[];
  8533. /**
  8534. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8535. */
  8536. keysLeft: number[];
  8537. /**
  8538. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8539. */
  8540. keysRight: number[];
  8541. private _keys;
  8542. private _onCanvasBlurObserver;
  8543. private _onKeyboardObserver;
  8544. private _engine;
  8545. private _scene;
  8546. /**
  8547. * Attach the input controls to a specific dom element to get the input from.
  8548. * @param element Defines the element the controls should be listened from
  8549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8550. */
  8551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8552. /**
  8553. * Detach the current controls from the specified dom element.
  8554. * @param element Defines the element to stop listening the inputs from
  8555. */
  8556. detachControl(element: Nullable<HTMLElement>): void;
  8557. /**
  8558. * Update the current camera state depending on the inputs that have been used this frame.
  8559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8560. */
  8561. checkInputs(): void;
  8562. /**
  8563. * Gets the class name of the current intput.
  8564. * @returns the class name
  8565. */
  8566. getClassName(): string;
  8567. /** @hidden */
  8568. _onLostFocus(): void;
  8569. /**
  8570. * Get the friendly name associated with the input class.
  8571. * @returns the input friendly name
  8572. */
  8573. getSimpleName(): string;
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Interface describing all the common properties and methods a shadow light needs to implement.
  8579. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8580. * as well as binding the different shadow properties to the effects.
  8581. */
  8582. export interface IShadowLight extends Light {
  8583. /**
  8584. * The light id in the scene (used in scene.findLighById for instance)
  8585. */
  8586. id: string;
  8587. /**
  8588. * The position the shdow will be casted from.
  8589. */
  8590. position: Vector3;
  8591. /**
  8592. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8593. */
  8594. direction: Vector3;
  8595. /**
  8596. * The transformed position. Position of the light in world space taking parenting in account.
  8597. */
  8598. transformedPosition: Vector3;
  8599. /**
  8600. * The transformed direction. Direction of the light in world space taking parenting in account.
  8601. */
  8602. transformedDirection: Vector3;
  8603. /**
  8604. * The friendly name of the light in the scene.
  8605. */
  8606. name: string;
  8607. /**
  8608. * Defines the shadow projection clipping minimum z value.
  8609. */
  8610. shadowMinZ: number;
  8611. /**
  8612. * Defines the shadow projection clipping maximum z value.
  8613. */
  8614. shadowMaxZ: number;
  8615. /**
  8616. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8617. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8618. */
  8619. computeTransformedInformation(): boolean;
  8620. /**
  8621. * Gets the scene the light belongs to.
  8622. * @returns The scene
  8623. */
  8624. getScene(): Scene;
  8625. /**
  8626. * Callback defining a custom Projection Matrix Builder.
  8627. * This can be used to override the default projection matrix computation.
  8628. */
  8629. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8630. /**
  8631. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8632. * @param matrix The materix to updated with the projection information
  8633. * @param viewMatrix The transform matrix of the light
  8634. * @param renderList The list of mesh to render in the map
  8635. * @returns The current light
  8636. */
  8637. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8638. /**
  8639. * Gets the current depth scale used in ESM.
  8640. * @returns The scale
  8641. */
  8642. getDepthScale(): number;
  8643. /**
  8644. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8645. * @returns true if a cube texture needs to be use
  8646. */
  8647. needCube(): boolean;
  8648. /**
  8649. * Detects if the projection matrix requires to be recomputed this frame.
  8650. * @returns true if it requires to be recomputed otherwise, false.
  8651. */
  8652. needProjectionMatrixCompute(): boolean;
  8653. /**
  8654. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8655. */
  8656. forceProjectionMatrixCompute(): void;
  8657. /**
  8658. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8659. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8660. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8661. */
  8662. getShadowDirection(faceIndex?: number): Vector3;
  8663. /**
  8664. * Gets the minZ used for shadow according to both the scene and the light.
  8665. * @param activeCamera The camera we are returning the min for
  8666. * @returns the depth min z
  8667. */
  8668. getDepthMinZ(activeCamera: Camera): number;
  8669. /**
  8670. * Gets the maxZ used for shadow according to both the scene and the light.
  8671. * @param activeCamera The camera we are returning the max for
  8672. * @returns the depth max z
  8673. */
  8674. getDepthMaxZ(activeCamera: Camera): number;
  8675. }
  8676. /**
  8677. * Base implementation IShadowLight
  8678. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8679. */
  8680. export abstract class ShadowLight extends Light implements IShadowLight {
  8681. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8682. protected _position: Vector3;
  8683. protected _setPosition(value: Vector3): void;
  8684. /**
  8685. * Sets the position the shadow will be casted from. Also use as the light position for both
  8686. * point and spot lights.
  8687. */
  8688. /**
  8689. * Sets the position the shadow will be casted from. Also use as the light position for both
  8690. * point and spot lights.
  8691. */
  8692. position: Vector3;
  8693. protected _direction: Vector3;
  8694. protected _setDirection(value: Vector3): void;
  8695. /**
  8696. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8697. * Also use as the light direction on spot and directional lights.
  8698. */
  8699. /**
  8700. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8701. * Also use as the light direction on spot and directional lights.
  8702. */
  8703. direction: Vector3;
  8704. private _shadowMinZ;
  8705. /**
  8706. * Gets the shadow projection clipping minimum z value.
  8707. */
  8708. /**
  8709. * Sets the shadow projection clipping minimum z value.
  8710. */
  8711. shadowMinZ: number;
  8712. private _shadowMaxZ;
  8713. /**
  8714. * Sets the shadow projection clipping maximum z value.
  8715. */
  8716. /**
  8717. * Gets the shadow projection clipping maximum z value.
  8718. */
  8719. shadowMaxZ: number;
  8720. /**
  8721. * Callback defining a custom Projection Matrix Builder.
  8722. * This can be used to override the default projection matrix computation.
  8723. */
  8724. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. private _needProjectionMatrixCompute;
  8734. /**
  8735. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8736. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8737. */
  8738. computeTransformedInformation(): boolean;
  8739. /**
  8740. * Return the depth scale used for the shadow map.
  8741. * @returns the depth scale.
  8742. */
  8743. getDepthScale(): number;
  8744. /**
  8745. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8746. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8747. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8748. */
  8749. getShadowDirection(faceIndex?: number): Vector3;
  8750. /**
  8751. * Returns the ShadowLight absolute position in the World.
  8752. * @returns the position vector in world space
  8753. */
  8754. getAbsolutePosition(): Vector3;
  8755. /**
  8756. * Sets the ShadowLight direction toward the passed target.
  8757. * @param target The point to target in local space
  8758. * @returns the updated ShadowLight direction
  8759. */
  8760. setDirectionToTarget(target: Vector3): Vector3;
  8761. /**
  8762. * Returns the light rotation in euler definition.
  8763. * @returns the x y z rotation in local space.
  8764. */
  8765. getRotation(): Vector3;
  8766. /**
  8767. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8768. * @returns true if a cube texture needs to be use
  8769. */
  8770. needCube(): boolean;
  8771. /**
  8772. * Detects if the projection matrix requires to be recomputed this frame.
  8773. * @returns true if it requires to be recomputed otherwise, false.
  8774. */
  8775. needProjectionMatrixCompute(): boolean;
  8776. /**
  8777. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8778. */
  8779. forceProjectionMatrixCompute(): void;
  8780. /** @hidden */
  8781. _initCache(): void;
  8782. /** @hidden */
  8783. _isSynchronized(): boolean;
  8784. /**
  8785. * Computes the world matrix of the node
  8786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8787. * @returns the world matrix
  8788. */
  8789. computeWorldMatrix(force?: boolean): Matrix;
  8790. /**
  8791. * Gets the minZ used for shadow according to both the scene and the light.
  8792. * @param activeCamera The camera we are returning the min for
  8793. * @returns the depth min z
  8794. */
  8795. getDepthMinZ(activeCamera: Camera): number;
  8796. /**
  8797. * Gets the maxZ used for shadow according to both the scene and the light.
  8798. * @param activeCamera The camera we are returning the max for
  8799. * @returns the depth max z
  8800. */
  8801. getDepthMaxZ(activeCamera: Camera): number;
  8802. /**
  8803. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8804. * @param matrix The materix to updated with the projection information
  8805. * @param viewMatrix The transform matrix of the light
  8806. * @param renderList The list of mesh to render in the map
  8807. * @returns The current light
  8808. */
  8809. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8810. }
  8811. }
  8812. declare module BABYLON {
  8813. /**
  8814. * "Static Class" containing the most commonly used helper while dealing with material for
  8815. * rendering purpose.
  8816. *
  8817. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8818. *
  8819. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8820. */
  8821. export class MaterialHelper {
  8822. /**
  8823. * Bind the current view position to an effect.
  8824. * @param effect The effect to be bound
  8825. * @param scene The scene the eyes position is used from
  8826. */
  8827. static BindEyePosition(effect: Effect, scene: Scene): void;
  8828. /**
  8829. * Helps preparing the defines values about the UVs in used in the effect.
  8830. * UVs are shared as much as we can accross channels in the shaders.
  8831. * @param texture The texture we are preparing the UVs for
  8832. * @param defines The defines to update
  8833. * @param key The channel key "diffuse", "specular"... used in the shader
  8834. */
  8835. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8836. /**
  8837. * Binds a texture matrix value to its corrsponding uniform
  8838. * @param texture The texture to bind the matrix for
  8839. * @param uniformBuffer The uniform buffer receivin the data
  8840. * @param key The channel key "diffuse", "specular"... used in the shader
  8841. */
  8842. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8843. /**
  8844. * Gets the current status of the fog (should it be enabled?)
  8845. * @param mesh defines the mesh to evaluate for fog support
  8846. * @param scene defines the hosting scene
  8847. * @returns true if fog must be enabled
  8848. */
  8849. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8850. /**
  8851. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8852. * @param mesh defines the current mesh
  8853. * @param scene defines the current scene
  8854. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8855. * @param pointsCloud defines if point cloud rendering has to be turned on
  8856. * @param fogEnabled defines if fog has to be turned on
  8857. * @param alphaTest defines if alpha testing has to be turned on
  8858. * @param defines defines the current list of defines
  8859. */
  8860. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8861. /**
  8862. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8863. * @param scene defines the current scene
  8864. * @param engine defines the current engine
  8865. * @param defines specifies the list of active defines
  8866. * @param useInstances defines if instances have to be turned on
  8867. * @param useClipPlane defines if clip plane have to be turned on
  8868. */
  8869. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8870. /**
  8871. * Prepares the defines for bones
  8872. * @param mesh The mesh containing the geometry data we will draw
  8873. * @param defines The defines to update
  8874. */
  8875. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8876. /**
  8877. * Prepares the defines for morph targets
  8878. * @param mesh The mesh containing the geometry data we will draw
  8879. * @param defines The defines to update
  8880. */
  8881. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8882. /**
  8883. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8884. * @param mesh The mesh containing the geometry data we will draw
  8885. * @param defines The defines to update
  8886. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8887. * @param useBones Precise whether bones should be used or not (override mesh info)
  8888. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8889. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8890. * @returns false if defines are considered not dirty and have not been checked
  8891. */
  8892. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8893. /**
  8894. * Prepares the defines related to multiview
  8895. * @param scene The scene we are intending to draw
  8896. * @param defines The defines to update
  8897. */
  8898. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8899. /**
  8900. * Prepares the defines related to the light information passed in parameter
  8901. * @param scene The scene we are intending to draw
  8902. * @param mesh The mesh the effect is compiling for
  8903. * @param light The light the effect is compiling for
  8904. * @param lightIndex The index of the light
  8905. * @param defines The defines to update
  8906. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8907. * @param state Defines the current state regarding what is needed (normals, etc...)
  8908. */
  8909. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8910. needNormals: boolean;
  8911. needRebuild: boolean;
  8912. shadowEnabled: boolean;
  8913. specularEnabled: boolean;
  8914. lightmapMode: boolean;
  8915. }): void;
  8916. /**
  8917. * Prepares the defines related to the light information passed in parameter
  8918. * @param scene The scene we are intending to draw
  8919. * @param mesh The mesh the effect is compiling for
  8920. * @param defines The defines to update
  8921. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8922. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8923. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8924. * @returns true if normals will be required for the rest of the effect
  8925. */
  8926. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8927. /**
  8928. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8929. * @param lightIndex defines the light index
  8930. * @param uniformsList The uniform list
  8931. * @param samplersList The sampler list
  8932. * @param projectedLightTexture defines if projected texture must be used
  8933. * @param uniformBuffersList defines an optional list of uniform buffers
  8934. */
  8935. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8936. /**
  8937. * Prepares the uniforms and samplers list to be used in the effect
  8938. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8939. * @param samplersList The sampler list
  8940. * @param defines The defines helping in the list generation
  8941. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8942. */
  8943. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8944. /**
  8945. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8946. * @param defines The defines to update while falling back
  8947. * @param fallbacks The authorized effect fallbacks
  8948. * @param maxSimultaneousLights The maximum number of lights allowed
  8949. * @param rank the current rank of the Effect
  8950. * @returns The newly affected rank
  8951. */
  8952. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8953. private static _TmpMorphInfluencers;
  8954. /**
  8955. * Prepares the list of attributes required for morph targets according to the effect defines.
  8956. * @param attribs The current list of supported attribs
  8957. * @param mesh The mesh to prepare the morph targets attributes for
  8958. * @param influencers The number of influencers
  8959. */
  8960. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8961. /**
  8962. * Prepares the list of attributes required for morph targets according to the effect defines.
  8963. * @param attribs The current list of supported attribs
  8964. * @param mesh The mesh to prepare the morph targets attributes for
  8965. * @param defines The current Defines of the effect
  8966. */
  8967. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8968. /**
  8969. * Prepares the list of attributes required for bones according to the effect defines.
  8970. * @param attribs The current list of supported attribs
  8971. * @param mesh The mesh to prepare the bones attributes for
  8972. * @param defines The current Defines of the effect
  8973. * @param fallbacks The current efffect fallback strategy
  8974. */
  8975. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8976. /**
  8977. * Check and prepare the list of attributes required for instances according to the effect defines.
  8978. * @param attribs The current list of supported attribs
  8979. * @param defines The current MaterialDefines of the effect
  8980. */
  8981. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8982. /**
  8983. * Add the list of attributes required for instances to the attribs array.
  8984. * @param attribs The current list of supported attribs
  8985. */
  8986. static PushAttributesForInstances(attribs: string[]): void;
  8987. /**
  8988. * Binds the light shadow information to the effect for the given mesh.
  8989. * @param light The light containing the generator
  8990. * @param scene The scene the lights belongs to
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param lightIndex The light index in the effect used to render the mesh
  8993. * @param effect The effect we are binding the data to
  8994. */
  8995. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8996. /**
  8997. * Binds the light information to the effect.
  8998. * @param light The light containing the generator
  8999. * @param effect The effect we are binding the data to
  9000. * @param lightIndex The light index in the effect used to render
  9001. */
  9002. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9003. /**
  9004. * Binds the lights information from the scene to the effect for the given mesh.
  9005. * @param light Light to bind
  9006. * @param lightIndex Light index
  9007. * @param scene The scene where the light belongs to
  9008. * @param mesh The mesh we are binding the information to render
  9009. * @param effect The effect we are binding the data to
  9010. * @param useSpecular Defines if specular is supported
  9011. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9012. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9013. */
  9014. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9015. /**
  9016. * Binds the lights information from the scene to the effect for the given mesh.
  9017. * @param scene The scene the lights belongs to
  9018. * @param mesh The mesh we are binding the information to render
  9019. * @param effect The effect we are binding the data to
  9020. * @param defines The generated defines for the effect
  9021. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9022. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9023. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9024. */
  9025. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9026. private static _tempFogColor;
  9027. /**
  9028. * Binds the fog information from the scene to the effect for the given mesh.
  9029. * @param scene The scene the lights belongs to
  9030. * @param mesh The mesh we are binding the information to render
  9031. * @param effect The effect we are binding the data to
  9032. * @param linearSpace Defines if the fog effect is applied in linear space
  9033. */
  9034. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9035. /**
  9036. * Binds the bones information from the mesh to the effect.
  9037. * @param mesh The mesh we are binding the information to render
  9038. * @param effect The effect we are binding the data to
  9039. */
  9040. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9041. /**
  9042. * Binds the morph targets information from the mesh to the effect.
  9043. * @param abstractMesh The mesh we are binding the information to render
  9044. * @param effect The effect we are binding the data to
  9045. */
  9046. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9047. /**
  9048. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9049. * @param defines The generated defines used in the effect
  9050. * @param effect The effect we are binding the data to
  9051. * @param scene The scene we are willing to render with logarithmic scale for
  9052. */
  9053. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9054. /**
  9055. * Binds the clip plane information from the scene to the effect.
  9056. * @param scene The scene the clip plane information are extracted from
  9057. * @param effect The effect we are binding the data to
  9058. */
  9059. static BindClipPlane(effect: Effect, scene: Scene): void;
  9060. }
  9061. }
  9062. declare module BABYLON {
  9063. /** @hidden */
  9064. export var packingFunctions: {
  9065. name: string;
  9066. shader: string;
  9067. };
  9068. }
  9069. declare module BABYLON {
  9070. /** @hidden */
  9071. export var shadowMapPixelShader: {
  9072. name: string;
  9073. shader: string;
  9074. };
  9075. }
  9076. declare module BABYLON {
  9077. /** @hidden */
  9078. export var bonesDeclaration: {
  9079. name: string;
  9080. shader: string;
  9081. };
  9082. }
  9083. declare module BABYLON {
  9084. /** @hidden */
  9085. export var morphTargetsVertexGlobalDeclaration: {
  9086. name: string;
  9087. shader: string;
  9088. };
  9089. }
  9090. declare module BABYLON {
  9091. /** @hidden */
  9092. export var morphTargetsVertexDeclaration: {
  9093. name: string;
  9094. shader: string;
  9095. };
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var instancesDeclaration: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var helperFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var morphTargetsVertex: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var instancesVertex: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var bonesVertex: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapVertexShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var depthBoxBlurPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /**
  9148. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9149. */
  9150. export interface ICustomShaderOptions {
  9151. /**
  9152. * Gets or sets the custom shader name to use
  9153. */
  9154. shaderName: string;
  9155. /**
  9156. * The list of attribute names used in the shader
  9157. */
  9158. attributes?: string[];
  9159. /**
  9160. * The list of unifrom names used in the shader
  9161. */
  9162. uniforms?: string[];
  9163. /**
  9164. * The list of sampler names used in the shader
  9165. */
  9166. samplers?: string[];
  9167. /**
  9168. * The list of defines used in the shader
  9169. */
  9170. defines?: string[];
  9171. }
  9172. /**
  9173. * Interface to implement to create a shadow generator compatible with BJS.
  9174. */
  9175. export interface IShadowGenerator {
  9176. /**
  9177. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9178. * @returns The render target texture if present otherwise, null
  9179. */
  9180. getShadowMap(): Nullable<RenderTargetTexture>;
  9181. /**
  9182. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9183. * @returns The render target texture if the shadow map is present otherwise, null
  9184. */
  9185. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9186. /**
  9187. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9188. * @param subMesh The submesh we want to render in the shadow map
  9189. * @param useInstances Defines wether will draw in the map using instances
  9190. * @returns true if ready otherwise, false
  9191. */
  9192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9193. /**
  9194. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9195. * @param defines Defines of the material we want to update
  9196. * @param lightIndex Index of the light in the enabled light list of the material
  9197. */
  9198. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9199. /**
  9200. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9201. * defined in the generator but impacting the effect).
  9202. * It implies the unifroms available on the materials are the standard BJS ones.
  9203. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9204. * @param effect The effect we are binfing the information for
  9205. */
  9206. bindShadowLight(lightIndex: string, effect: Effect): void;
  9207. /**
  9208. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9209. * (eq to shadow prjection matrix * light transform matrix)
  9210. * @returns The transform matrix used to create the shadow map
  9211. */
  9212. getTransformMatrix(): Matrix;
  9213. /**
  9214. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9215. * Cube and 2D textures for instance.
  9216. */
  9217. recreateShadowMap(): void;
  9218. /**
  9219. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9220. * @param onCompiled Callback triggered at the and of the effects compilation
  9221. * @param options Sets of optional options forcing the compilation with different modes
  9222. */
  9223. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9224. useInstances: boolean;
  9225. }>): void;
  9226. /**
  9227. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9228. * @param options Sets of optional options forcing the compilation with different modes
  9229. * @returns A promise that resolves when the compilation completes
  9230. */
  9231. forceCompilationAsync(options?: Partial<{
  9232. useInstances: boolean;
  9233. }>): Promise<void>;
  9234. /**
  9235. * Serializes the shadow generator setup to a json object.
  9236. * @returns The serialized JSON object
  9237. */
  9238. serialize(): any;
  9239. /**
  9240. * Disposes the Shadow map and related Textures and effects.
  9241. */
  9242. dispose(): void;
  9243. }
  9244. /**
  9245. * Default implementation IShadowGenerator.
  9246. * This is the main object responsible of generating shadows in the framework.
  9247. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9248. */
  9249. export class ShadowGenerator implements IShadowGenerator {
  9250. /**
  9251. * Shadow generator mode None: no filtering applied.
  9252. */
  9253. static readonly FILTER_NONE: number;
  9254. /**
  9255. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9256. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9257. */
  9258. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9259. /**
  9260. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9261. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9262. */
  9263. static readonly FILTER_POISSONSAMPLING: number;
  9264. /**
  9265. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9266. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9267. */
  9268. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9269. /**
  9270. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9271. * edge artifacts on steep falloff.
  9272. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9273. */
  9274. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9275. /**
  9276. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9277. * edge artifacts on steep falloff.
  9278. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9279. */
  9280. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9281. /**
  9282. * Shadow generator mode PCF: Percentage Closer Filtering
  9283. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9284. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9285. */
  9286. static readonly FILTER_PCF: number;
  9287. /**
  9288. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9289. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9290. * Contact Hardening
  9291. */
  9292. static readonly FILTER_PCSS: number;
  9293. /**
  9294. * Reserved for PCF and PCSS
  9295. * Highest Quality.
  9296. *
  9297. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9298. *
  9299. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9300. */
  9301. static readonly QUALITY_HIGH: number;
  9302. /**
  9303. * Reserved for PCF and PCSS
  9304. * Good tradeoff for quality/perf cross devices
  9305. *
  9306. * Execute PCF on a 3*3 kernel.
  9307. *
  9308. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9309. */
  9310. static readonly QUALITY_MEDIUM: number;
  9311. /**
  9312. * Reserved for PCF and PCSS
  9313. * The lowest quality but the fastest.
  9314. *
  9315. * Execute PCF on a 1*1 kernel.
  9316. *
  9317. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9318. */
  9319. static readonly QUALITY_LOW: number;
  9320. /** Gets or sets the custom shader name to use */
  9321. customShaderOptions: ICustomShaderOptions;
  9322. /**
  9323. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9324. */
  9325. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9326. /**
  9327. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9328. */
  9329. onAfterShadowMapRenderObservable: Observable<Effect>;
  9330. /**
  9331. * Observable triggered before a mesh is rendered in the shadow map.
  9332. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9333. */
  9334. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9335. /**
  9336. * Observable triggered after a mesh is rendered in the shadow map.
  9337. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9338. */
  9339. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9340. private _bias;
  9341. /**
  9342. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9343. */
  9344. /**
  9345. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9346. */
  9347. bias: number;
  9348. private _normalBias;
  9349. /**
  9350. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9351. */
  9352. /**
  9353. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9354. */
  9355. normalBias: number;
  9356. private _blurBoxOffset;
  9357. /**
  9358. * Gets the blur box offset: offset applied during the blur pass.
  9359. * Only useful if useKernelBlur = false
  9360. */
  9361. /**
  9362. * Sets the blur box offset: offset applied during the blur pass.
  9363. * Only useful if useKernelBlur = false
  9364. */
  9365. blurBoxOffset: number;
  9366. private _blurScale;
  9367. /**
  9368. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9369. * 2 means half of the size.
  9370. */
  9371. /**
  9372. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9373. * 2 means half of the size.
  9374. */
  9375. blurScale: number;
  9376. private _blurKernel;
  9377. /**
  9378. * Gets the blur kernel: kernel size of the blur pass.
  9379. * Only useful if useKernelBlur = true
  9380. */
  9381. /**
  9382. * Sets the blur kernel: kernel size of the blur pass.
  9383. * Only useful if useKernelBlur = true
  9384. */
  9385. blurKernel: number;
  9386. private _useKernelBlur;
  9387. /**
  9388. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9389. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9390. */
  9391. /**
  9392. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9393. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9394. */
  9395. useKernelBlur: boolean;
  9396. private _depthScale;
  9397. /**
  9398. * Gets the depth scale used in ESM mode.
  9399. */
  9400. /**
  9401. * Sets the depth scale used in ESM mode.
  9402. * This can override the scale stored on the light.
  9403. */
  9404. depthScale: number;
  9405. private _filter;
  9406. /**
  9407. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9408. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9409. */
  9410. /**
  9411. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9412. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9413. */
  9414. filter: number;
  9415. /**
  9416. * Gets if the current filter is set to Poisson Sampling.
  9417. */
  9418. /**
  9419. * Sets the current filter to Poisson Sampling.
  9420. */
  9421. usePoissonSampling: boolean;
  9422. /**
  9423. * Gets if the current filter is set to ESM.
  9424. */
  9425. /**
  9426. * Sets the current filter is to ESM.
  9427. */
  9428. useExponentialShadowMap: boolean;
  9429. /**
  9430. * Gets if the current filter is set to filtered ESM.
  9431. */
  9432. /**
  9433. * Gets if the current filter is set to filtered ESM.
  9434. */
  9435. useBlurExponentialShadowMap: boolean;
  9436. /**
  9437. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9438. * exponential to prevent steep falloff artifacts).
  9439. */
  9440. /**
  9441. * Sets the current filter to "close ESM" (using the inverse of the
  9442. * exponential to prevent steep falloff artifacts).
  9443. */
  9444. useCloseExponentialShadowMap: boolean;
  9445. /**
  9446. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9447. * exponential to prevent steep falloff artifacts).
  9448. */
  9449. /**
  9450. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9451. * exponential to prevent steep falloff artifacts).
  9452. */
  9453. useBlurCloseExponentialShadowMap: boolean;
  9454. /**
  9455. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9456. */
  9457. /**
  9458. * Sets the current filter to "PCF" (percentage closer filtering).
  9459. */
  9460. usePercentageCloserFiltering: boolean;
  9461. private _filteringQuality;
  9462. /**
  9463. * Gets the PCF or PCSS Quality.
  9464. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9465. */
  9466. /**
  9467. * Sets the PCF or PCSS Quality.
  9468. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9469. */
  9470. filteringQuality: number;
  9471. /**
  9472. * Gets if the current filter is set to "PCSS" (contact hardening).
  9473. */
  9474. /**
  9475. * Sets the current filter to "PCSS" (contact hardening).
  9476. */
  9477. useContactHardeningShadow: boolean;
  9478. private _contactHardeningLightSizeUVRatio;
  9479. /**
  9480. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9481. * Using a ratio helps keeping shape stability independently of the map size.
  9482. *
  9483. * It does not account for the light projection as it was having too much
  9484. * instability during the light setup or during light position changes.
  9485. *
  9486. * Only valid if useContactHardeningShadow is true.
  9487. */
  9488. /**
  9489. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9490. * Using a ratio helps keeping shape stability independently of the map size.
  9491. *
  9492. * It does not account for the light projection as it was having too much
  9493. * instability during the light setup or during light position changes.
  9494. *
  9495. * Only valid if useContactHardeningShadow is true.
  9496. */
  9497. contactHardeningLightSizeUVRatio: number;
  9498. private _darkness;
  9499. /** Gets or sets the actual darkness of a shadow */
  9500. darkness: number;
  9501. /**
  9502. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9503. * 0 means strongest and 1 would means no shadow.
  9504. * @returns the darkness.
  9505. */
  9506. getDarkness(): number;
  9507. /**
  9508. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9509. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9510. * @returns the shadow generator allowing fluent coding.
  9511. */
  9512. setDarkness(darkness: number): ShadowGenerator;
  9513. private _transparencyShadow;
  9514. /** Gets or sets the ability to have transparent shadow */
  9515. transparencyShadow: boolean;
  9516. /**
  9517. * Sets the ability to have transparent shadow (boolean).
  9518. * @param transparent True if transparent else False
  9519. * @returns the shadow generator allowing fluent coding
  9520. */
  9521. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9522. private _shadowMap;
  9523. private _shadowMap2;
  9524. /**
  9525. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9526. * @returns The render target texture if present otherwise, null
  9527. */
  9528. getShadowMap(): Nullable<RenderTargetTexture>;
  9529. /**
  9530. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9531. * @returns The render target texture if the shadow map is present otherwise, null
  9532. */
  9533. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9534. /**
  9535. * Gets the class name of that object
  9536. * @returns "ShadowGenerator"
  9537. */
  9538. getClassName(): string;
  9539. /**
  9540. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9541. * @param mesh Mesh to add
  9542. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9543. * @returns the Shadow Generator itself
  9544. */
  9545. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9546. /**
  9547. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9548. * @param mesh Mesh to remove
  9549. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9550. * @returns the Shadow Generator itself
  9551. */
  9552. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9553. /**
  9554. * Controls the extent to which the shadows fade out at the edge of the frustum
  9555. * Used only by directionals and spots
  9556. */
  9557. frustumEdgeFalloff: number;
  9558. private _light;
  9559. /**
  9560. * Returns the associated light object.
  9561. * @returns the light generating the shadow
  9562. */
  9563. getLight(): IShadowLight;
  9564. /**
  9565. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9566. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9567. * It might on the other hand introduce peter panning.
  9568. */
  9569. forceBackFacesOnly: boolean;
  9570. private _scene;
  9571. private _lightDirection;
  9572. private _effect;
  9573. private _viewMatrix;
  9574. private _projectionMatrix;
  9575. private _transformMatrix;
  9576. private _cachedPosition;
  9577. private _cachedDirection;
  9578. private _cachedDefines;
  9579. private _currentRenderID;
  9580. private _boxBlurPostprocess;
  9581. private _kernelBlurXPostprocess;
  9582. private _kernelBlurYPostprocess;
  9583. private _blurPostProcesses;
  9584. private _mapSize;
  9585. private _currentFaceIndex;
  9586. private _currentFaceIndexCache;
  9587. private _textureType;
  9588. private _defaultTextureMatrix;
  9589. /** @hidden */
  9590. static _SceneComponentInitialization: (scene: Scene) => void;
  9591. /**
  9592. * Creates a ShadowGenerator object.
  9593. * A ShadowGenerator is the required tool to use the shadows.
  9594. * Each light casting shadows needs to use its own ShadowGenerator.
  9595. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9596. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9597. * @param light The light object generating the shadows.
  9598. * @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.
  9599. */
  9600. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9601. private _initializeGenerator;
  9602. private _initializeShadowMap;
  9603. private _initializeBlurRTTAndPostProcesses;
  9604. private _renderForShadowMap;
  9605. private _renderSubMeshForShadowMap;
  9606. private _applyFilterValues;
  9607. /**
  9608. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9609. * @param onCompiled Callback triggered at the and of the effects compilation
  9610. * @param options Sets of optional options forcing the compilation with different modes
  9611. */
  9612. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9613. useInstances: boolean;
  9614. }>): void;
  9615. /**
  9616. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9617. * @param options Sets of optional options forcing the compilation with different modes
  9618. * @returns A promise that resolves when the compilation completes
  9619. */
  9620. forceCompilationAsync(options?: Partial<{
  9621. useInstances: boolean;
  9622. }>): Promise<void>;
  9623. /**
  9624. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9625. * @param subMesh The submesh we want to render in the shadow map
  9626. * @param useInstances Defines wether will draw in the map using instances
  9627. * @returns true if ready otherwise, false
  9628. */
  9629. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9630. /**
  9631. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9632. * @param defines Defines of the material we want to update
  9633. * @param lightIndex Index of the light in the enabled light list of the material
  9634. */
  9635. prepareDefines(defines: any, lightIndex: number): void;
  9636. /**
  9637. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9638. * defined in the generator but impacting the effect).
  9639. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9640. * @param effect The effect we are binfing the information for
  9641. */
  9642. bindShadowLight(lightIndex: string, effect: Effect): void;
  9643. /**
  9644. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9645. * (eq to shadow prjection matrix * light transform matrix)
  9646. * @returns The transform matrix used to create the shadow map
  9647. */
  9648. getTransformMatrix(): Matrix;
  9649. /**
  9650. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9651. * Cube and 2D textures for instance.
  9652. */
  9653. recreateShadowMap(): void;
  9654. private _disposeBlurPostProcesses;
  9655. private _disposeRTTandPostProcesses;
  9656. /**
  9657. * Disposes the ShadowGenerator.
  9658. * Returns nothing.
  9659. */
  9660. dispose(): void;
  9661. /**
  9662. * Serializes the shadow generator setup to a json object.
  9663. * @returns The serialized JSON object
  9664. */
  9665. serialize(): any;
  9666. /**
  9667. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9668. * @param parsedShadowGenerator The JSON object to parse
  9669. * @param scene The scene to create the shadow map for
  9670. * @returns The parsed shadow generator
  9671. */
  9672. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9673. }
  9674. }
  9675. declare module BABYLON {
  9676. /**
  9677. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9678. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9679. * 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.
  9680. */
  9681. export abstract class Light extends Node {
  9682. /**
  9683. * Falloff Default: light is falling off following the material specification:
  9684. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9685. */
  9686. static readonly FALLOFF_DEFAULT: number;
  9687. /**
  9688. * Falloff Physical: light is falling off following the inverse squared distance law.
  9689. */
  9690. static readonly FALLOFF_PHYSICAL: number;
  9691. /**
  9692. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9693. * to enhance interoperability with other engines.
  9694. */
  9695. static readonly FALLOFF_GLTF: number;
  9696. /**
  9697. * Falloff Standard: light is falling off like in the standard material
  9698. * to enhance interoperability with other materials.
  9699. */
  9700. static readonly FALLOFF_STANDARD: number;
  9701. /**
  9702. * If every light affecting the material is in this lightmapMode,
  9703. * material.lightmapTexture adds or multiplies
  9704. * (depends on material.useLightmapAsShadowmap)
  9705. * after every other light calculations.
  9706. */
  9707. static readonly LIGHTMAP_DEFAULT: number;
  9708. /**
  9709. * material.lightmapTexture as only diffuse lighting from this light
  9710. * adds only specular lighting from this light
  9711. * adds dynamic shadows
  9712. */
  9713. static readonly LIGHTMAP_SPECULAR: number;
  9714. /**
  9715. * material.lightmapTexture as only lighting
  9716. * no light calculation from this light
  9717. * only adds dynamic shadows from this light
  9718. */
  9719. static readonly LIGHTMAP_SHADOWSONLY: number;
  9720. /**
  9721. * Each light type uses the default quantity according to its type:
  9722. * point/spot lights use luminous intensity
  9723. * directional lights use illuminance
  9724. */
  9725. static readonly INTENSITYMODE_AUTOMATIC: number;
  9726. /**
  9727. * lumen (lm)
  9728. */
  9729. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9730. /**
  9731. * candela (lm/sr)
  9732. */
  9733. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9734. /**
  9735. * lux (lm/m^2)
  9736. */
  9737. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9738. /**
  9739. * nit (cd/m^2)
  9740. */
  9741. static readonly INTENSITYMODE_LUMINANCE: number;
  9742. /**
  9743. * Light type const id of the point light.
  9744. */
  9745. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9746. /**
  9747. * Light type const id of the directional light.
  9748. */
  9749. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9750. /**
  9751. * Light type const id of the spot light.
  9752. */
  9753. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9754. /**
  9755. * Light type const id of the hemispheric light.
  9756. */
  9757. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9758. /**
  9759. * Diffuse gives the basic color to an object.
  9760. */
  9761. diffuse: Color3;
  9762. /**
  9763. * Specular produces a highlight color on an object.
  9764. * Note: This is note affecting PBR materials.
  9765. */
  9766. specular: Color3;
  9767. /**
  9768. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9769. * falling off base on range or angle.
  9770. * This can be set to any values in Light.FALLOFF_x.
  9771. *
  9772. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9773. * other types of materials.
  9774. */
  9775. falloffType: number;
  9776. /**
  9777. * Strength of the light.
  9778. * Note: By default it is define in the framework own unit.
  9779. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9780. */
  9781. intensity: number;
  9782. private _range;
  9783. protected _inverseSquaredRange: number;
  9784. /**
  9785. * Defines how far from the source the light is impacting in scene units.
  9786. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9787. */
  9788. /**
  9789. * Defines how far from the source the light is impacting in scene units.
  9790. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9791. */
  9792. range: number;
  9793. /**
  9794. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9795. * of light.
  9796. */
  9797. private _photometricScale;
  9798. private _intensityMode;
  9799. /**
  9800. * Gets the photometric scale used to interpret the intensity.
  9801. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9802. */
  9803. /**
  9804. * Sets the photometric scale used to interpret the intensity.
  9805. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9806. */
  9807. intensityMode: number;
  9808. private _radius;
  9809. /**
  9810. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9811. */
  9812. /**
  9813. * sets the light radius used by PBR Materials to simulate soft area lights.
  9814. */
  9815. radius: number;
  9816. private _renderPriority;
  9817. /**
  9818. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9819. * exceeding the number allowed of the materials.
  9820. */
  9821. renderPriority: number;
  9822. private _shadowEnabled;
  9823. /**
  9824. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9825. * the current shadow generator.
  9826. */
  9827. /**
  9828. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9829. * the current shadow generator.
  9830. */
  9831. shadowEnabled: boolean;
  9832. private _includedOnlyMeshes;
  9833. /**
  9834. * Gets the only meshes impacted by this light.
  9835. */
  9836. /**
  9837. * Sets the only meshes impacted by this light.
  9838. */
  9839. includedOnlyMeshes: AbstractMesh[];
  9840. private _excludedMeshes;
  9841. /**
  9842. * Gets the meshes not impacted by this light.
  9843. */
  9844. /**
  9845. * Sets the meshes not impacted by this light.
  9846. */
  9847. excludedMeshes: AbstractMesh[];
  9848. private _excludeWithLayerMask;
  9849. /**
  9850. * Gets the layer id use to find what meshes are not impacted by the light.
  9851. * Inactive if 0
  9852. */
  9853. /**
  9854. * Sets the layer id use to find what meshes are not impacted by the light.
  9855. * Inactive if 0
  9856. */
  9857. excludeWithLayerMask: number;
  9858. private _includeOnlyWithLayerMask;
  9859. /**
  9860. * Gets the layer id use to find what meshes are impacted by the light.
  9861. * Inactive if 0
  9862. */
  9863. /**
  9864. * Sets the layer id use to find what meshes are impacted by the light.
  9865. * Inactive if 0
  9866. */
  9867. includeOnlyWithLayerMask: number;
  9868. private _lightmapMode;
  9869. /**
  9870. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9871. */
  9872. /**
  9873. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9874. */
  9875. lightmapMode: number;
  9876. /**
  9877. * Shadow generator associted to the light.
  9878. * @hidden Internal use only.
  9879. */
  9880. _shadowGenerator: Nullable<IShadowGenerator>;
  9881. /**
  9882. * @hidden Internal use only.
  9883. */
  9884. _excludedMeshesIds: string[];
  9885. /**
  9886. * @hidden Internal use only.
  9887. */
  9888. _includedOnlyMeshesIds: string[];
  9889. /**
  9890. * The current light unifom buffer.
  9891. * @hidden Internal use only.
  9892. */
  9893. _uniformBuffer: UniformBuffer;
  9894. /**
  9895. * Creates a Light object in the scene.
  9896. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9897. * @param name The firendly name of the light
  9898. * @param scene The scene the light belongs too
  9899. */
  9900. constructor(name: string, scene: Scene);
  9901. protected abstract _buildUniformLayout(): void;
  9902. /**
  9903. * Sets the passed Effect "effect" with the Light information.
  9904. * @param effect The effect to update
  9905. * @param lightIndex The index of the light in the effect to update
  9906. * @returns The light
  9907. */
  9908. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9909. /**
  9910. * Sets the passed Effect "effect" with the Light information.
  9911. * @param effect The effect to update
  9912. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9913. * @returns The light
  9914. */
  9915. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9916. /**
  9917. * Returns the string "Light".
  9918. * @returns the class name
  9919. */
  9920. getClassName(): string;
  9921. /** @hidden */
  9922. readonly _isLight: boolean;
  9923. /**
  9924. * Converts the light information to a readable string for debug purpose.
  9925. * @param fullDetails Supports for multiple levels of logging within scene loading
  9926. * @returns the human readable light info
  9927. */
  9928. toString(fullDetails?: boolean): string;
  9929. /** @hidden */
  9930. protected _syncParentEnabledState(): void;
  9931. /**
  9932. * Set the enabled state of this node.
  9933. * @param value - the new enabled state
  9934. */
  9935. setEnabled(value: boolean): void;
  9936. /**
  9937. * Returns the Light associated shadow generator if any.
  9938. * @return the associated shadow generator.
  9939. */
  9940. getShadowGenerator(): Nullable<IShadowGenerator>;
  9941. /**
  9942. * Returns a Vector3, the absolute light position in the World.
  9943. * @returns the world space position of the light
  9944. */
  9945. getAbsolutePosition(): Vector3;
  9946. /**
  9947. * Specifies if the light will affect the passed mesh.
  9948. * @param mesh The mesh to test against the light
  9949. * @return true the mesh is affected otherwise, false.
  9950. */
  9951. canAffectMesh(mesh: AbstractMesh): boolean;
  9952. /**
  9953. * Sort function to order lights for rendering.
  9954. * @param a First Light object to compare to second.
  9955. * @param b Second Light object to compare first.
  9956. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9957. */
  9958. static CompareLightsPriority(a: Light, b: Light): number;
  9959. /**
  9960. * Releases resources associated with this node.
  9961. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9962. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9963. */
  9964. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9965. /**
  9966. * Returns the light type ID (integer).
  9967. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9968. */
  9969. getTypeID(): number;
  9970. /**
  9971. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9972. * @returns the scaled intensity in intensity mode unit
  9973. */
  9974. getScaledIntensity(): number;
  9975. /**
  9976. * Returns a new Light object, named "name", from the current one.
  9977. * @param name The name of the cloned light
  9978. * @returns the new created light
  9979. */
  9980. clone(name: string): Nullable<Light>;
  9981. /**
  9982. * Serializes the current light into a Serialization object.
  9983. * @returns the serialized object.
  9984. */
  9985. serialize(): any;
  9986. /**
  9987. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9988. * This new light is named "name" and added to the passed scene.
  9989. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9990. * @param name The friendly name of the light
  9991. * @param scene The scene the new light will belong to
  9992. * @returns the constructor function
  9993. */
  9994. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9995. /**
  9996. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9997. * @param parsedLight The JSON representation of the light
  9998. * @param scene The scene to create the parsed light in
  9999. * @returns the created light after parsing
  10000. */
  10001. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10002. private _hookArrayForExcluded;
  10003. private _hookArrayForIncludedOnly;
  10004. private _resyncMeshes;
  10005. /**
  10006. * Forces the meshes to update their light related information in their rendering used effects
  10007. * @hidden Internal Use Only
  10008. */
  10009. _markMeshesAsLightDirty(): void;
  10010. /**
  10011. * Recomputes the cached photometric scale if needed.
  10012. */
  10013. private _computePhotometricScale;
  10014. /**
  10015. * Returns the Photometric Scale according to the light type and intensity mode.
  10016. */
  10017. private _getPhotometricScale;
  10018. /**
  10019. * Reorder the light in the scene according to their defined priority.
  10020. * @hidden Internal Use Only
  10021. */
  10022. _reorderLightsInScene(): void;
  10023. /**
  10024. * Prepares the list of defines specific to the light type.
  10025. * @param defines the list of defines
  10026. * @param lightIndex defines the index of the light for the effect
  10027. */
  10028. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10029. }
  10030. }
  10031. declare module BABYLON {
  10032. /**
  10033. * Interface used to define Action
  10034. */
  10035. export interface IAction {
  10036. /**
  10037. * Trigger for the action
  10038. */
  10039. trigger: number;
  10040. /** Options of the trigger */
  10041. triggerOptions: any;
  10042. /**
  10043. * Gets the trigger parameters
  10044. * @returns the trigger parameters
  10045. */
  10046. getTriggerParameter(): any;
  10047. /**
  10048. * Internal only - executes current action event
  10049. * @hidden
  10050. */
  10051. _executeCurrent(evt?: ActionEvent): void;
  10052. /**
  10053. * Serialize placeholder for child classes
  10054. * @param parent of child
  10055. * @returns the serialized object
  10056. */
  10057. serialize(parent: any): any;
  10058. /**
  10059. * Internal only
  10060. * @hidden
  10061. */
  10062. _prepare(): void;
  10063. /**
  10064. * Internal only - manager for action
  10065. * @hidden
  10066. */
  10067. _actionManager: AbstractActionManager;
  10068. /**
  10069. * Adds action to chain of actions, may be a DoNothingAction
  10070. * @param action defines the next action to execute
  10071. * @returns The action passed in
  10072. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10073. */
  10074. then(action: IAction): IAction;
  10075. }
  10076. /**
  10077. * The action to be carried out following a trigger
  10078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10079. */
  10080. export class Action implements IAction {
  10081. /** the trigger, with or without parameters, for the action */
  10082. triggerOptions: any;
  10083. /**
  10084. * Trigger for the action
  10085. */
  10086. trigger: number;
  10087. /**
  10088. * Internal only - manager for action
  10089. * @hidden
  10090. */
  10091. _actionManager: ActionManager;
  10092. private _nextActiveAction;
  10093. private _child;
  10094. private _condition?;
  10095. private _triggerParameter;
  10096. /**
  10097. * An event triggered prior to action being executed.
  10098. */
  10099. onBeforeExecuteObservable: Observable<Action>;
  10100. /**
  10101. * Creates a new Action
  10102. * @param triggerOptions the trigger, with or without parameters, for the action
  10103. * @param condition an optional determinant of action
  10104. */
  10105. constructor(
  10106. /** the trigger, with or without parameters, for the action */
  10107. triggerOptions: any, condition?: Condition);
  10108. /**
  10109. * Internal only
  10110. * @hidden
  10111. */
  10112. _prepare(): void;
  10113. /**
  10114. * Gets the trigger parameters
  10115. * @returns the trigger parameters
  10116. */
  10117. getTriggerParameter(): any;
  10118. /**
  10119. * Internal only - executes current action event
  10120. * @hidden
  10121. */
  10122. _executeCurrent(evt?: ActionEvent): void;
  10123. /**
  10124. * Execute placeholder for child classes
  10125. * @param evt optional action event
  10126. */
  10127. execute(evt?: ActionEvent): void;
  10128. /**
  10129. * Skips to next active action
  10130. */
  10131. skipToNextActiveAction(): void;
  10132. /**
  10133. * Adds action to chain of actions, may be a DoNothingAction
  10134. * @param action defines the next action to execute
  10135. * @returns The action passed in
  10136. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10137. */
  10138. then(action: Action): Action;
  10139. /**
  10140. * Internal only
  10141. * @hidden
  10142. */
  10143. _getProperty(propertyPath: string): string;
  10144. /**
  10145. * Internal only
  10146. * @hidden
  10147. */
  10148. _getEffectiveTarget(target: any, propertyPath: string): any;
  10149. /**
  10150. * Serialize placeholder for child classes
  10151. * @param parent of child
  10152. * @returns the serialized object
  10153. */
  10154. serialize(parent: any): any;
  10155. /**
  10156. * Internal only called by serialize
  10157. * @hidden
  10158. */
  10159. protected _serialize(serializedAction: any, parent?: any): any;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. static _SerializeValueAsString: (value: any) => string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. static _GetTargetProperty: (target: Node | Scene) => {
  10170. name: string;
  10171. targetType: string;
  10172. value: string;
  10173. };
  10174. }
  10175. }
  10176. declare module BABYLON {
  10177. /**
  10178. * A Condition applied to an Action
  10179. */
  10180. export class Condition {
  10181. /**
  10182. * Internal only - manager for action
  10183. * @hidden
  10184. */
  10185. _actionManager: ActionManager;
  10186. /**
  10187. * Internal only
  10188. * @hidden
  10189. */
  10190. _evaluationId: number;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. _currentResult: boolean;
  10196. /**
  10197. * Creates a new Condition
  10198. * @param actionManager the manager of the action the condition is applied to
  10199. */
  10200. constructor(actionManager: ActionManager);
  10201. /**
  10202. * Check if the current condition is valid
  10203. * @returns a boolean
  10204. */
  10205. isValid(): boolean;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. _getProperty(propertyPath: string): string;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. _getEffectiveTarget(target: any, propertyPath: string): any;
  10216. /**
  10217. * Serialize placeholder for child classes
  10218. * @returns the serialized object
  10219. */
  10220. serialize(): any;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. protected _serialize(serializedCondition: any): any;
  10226. }
  10227. /**
  10228. * Defines specific conditional operators as extensions of Condition
  10229. */
  10230. export class ValueCondition extends Condition {
  10231. /** path to specify the property of the target the conditional operator uses */
  10232. propertyPath: string;
  10233. /** the value compared by the conditional operator against the current value of the property */
  10234. value: any;
  10235. /** the conditional operator, default ValueCondition.IsEqual */
  10236. operator: number;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private static _IsEqual;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. private static _IsDifferent;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. private static _IsGreater;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. private static _IsLesser;
  10257. /**
  10258. * returns the number for IsEqual
  10259. */
  10260. static readonly IsEqual: number;
  10261. /**
  10262. * Returns the number for IsDifferent
  10263. */
  10264. static readonly IsDifferent: number;
  10265. /**
  10266. * Returns the number for IsGreater
  10267. */
  10268. static readonly IsGreater: number;
  10269. /**
  10270. * Returns the number for IsLesser
  10271. */
  10272. static readonly IsLesser: number;
  10273. /**
  10274. * Internal only The action manager for the condition
  10275. * @hidden
  10276. */
  10277. _actionManager: ActionManager;
  10278. /**
  10279. * Internal only
  10280. * @hidden
  10281. */
  10282. private _target;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private _effectiveTarget;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. private _property;
  10293. /**
  10294. * Creates a new ValueCondition
  10295. * @param actionManager manager for the action the condition applies to
  10296. * @param target for the action
  10297. * @param propertyPath path to specify the property of the target the conditional operator uses
  10298. * @param value the value compared by the conditional operator against the current value of the property
  10299. * @param operator the conditional operator, default ValueCondition.IsEqual
  10300. */
  10301. constructor(actionManager: ActionManager, target: any,
  10302. /** path to specify the property of the target the conditional operator uses */
  10303. propertyPath: string,
  10304. /** the value compared by the conditional operator against the current value of the property */
  10305. value: any,
  10306. /** the conditional operator, default ValueCondition.IsEqual */
  10307. operator?: number);
  10308. /**
  10309. * Compares the given value with the property value for the specified conditional operator
  10310. * @returns the result of the comparison
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Serialize the ValueCondition into a JSON compatible object
  10315. * @returns serialization object
  10316. */
  10317. serialize(): any;
  10318. /**
  10319. * Gets the name of the conditional operator for the ValueCondition
  10320. * @param operator the conditional operator
  10321. * @returns the name
  10322. */
  10323. static GetOperatorName(operator: number): string;
  10324. }
  10325. /**
  10326. * Defines a predicate condition as an extension of Condition
  10327. */
  10328. export class PredicateCondition extends Condition {
  10329. /** defines the predicate function used to validate the condition */
  10330. predicate: () => boolean;
  10331. /**
  10332. * Internal only - manager for action
  10333. * @hidden
  10334. */
  10335. _actionManager: ActionManager;
  10336. /**
  10337. * Creates a new PredicateCondition
  10338. * @param actionManager manager for the action the condition applies to
  10339. * @param predicate defines the predicate function used to validate the condition
  10340. */
  10341. constructor(actionManager: ActionManager,
  10342. /** defines the predicate function used to validate the condition */
  10343. predicate: () => boolean);
  10344. /**
  10345. * @returns the validity of the predicate condition
  10346. */
  10347. isValid(): boolean;
  10348. }
  10349. /**
  10350. * Defines a state condition as an extension of Condition
  10351. */
  10352. export class StateCondition extends Condition {
  10353. /** Value to compare with target state */
  10354. value: string;
  10355. /**
  10356. * Internal only - manager for action
  10357. * @hidden
  10358. */
  10359. _actionManager: ActionManager;
  10360. /**
  10361. * Internal only
  10362. * @hidden
  10363. */
  10364. private _target;
  10365. /**
  10366. * Creates a new StateCondition
  10367. * @param actionManager manager for the action the condition applies to
  10368. * @param target of the condition
  10369. * @param value to compare with target state
  10370. */
  10371. constructor(actionManager: ActionManager, target: any,
  10372. /** Value to compare with target state */
  10373. value: string);
  10374. /**
  10375. * Gets a boolean indicating if the current condition is met
  10376. * @returns the validity of the state
  10377. */
  10378. isValid(): boolean;
  10379. /**
  10380. * Serialize the StateCondition into a JSON compatible object
  10381. * @returns serialization object
  10382. */
  10383. serialize(): any;
  10384. }
  10385. }
  10386. declare module BABYLON {
  10387. /**
  10388. * This defines an action responsible to toggle a boolean once triggered.
  10389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10390. */
  10391. export class SwitchBooleanAction extends Action {
  10392. /**
  10393. * The path to the boolean property in the target object
  10394. */
  10395. propertyPath: string;
  10396. private _target;
  10397. private _effectiveTarget;
  10398. private _property;
  10399. /**
  10400. * Instantiate the action
  10401. * @param triggerOptions defines the trigger options
  10402. * @param target defines the object containing the boolean
  10403. * @param propertyPath defines the path to the boolean property in the target object
  10404. * @param condition defines the trigger related conditions
  10405. */
  10406. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10407. /** @hidden */
  10408. _prepare(): void;
  10409. /**
  10410. * Execute the action toggle the boolean value.
  10411. */
  10412. execute(): void;
  10413. /**
  10414. * Serializes the actions and its related information.
  10415. * @param parent defines the object to serialize in
  10416. * @returns the serialized object
  10417. */
  10418. serialize(parent: any): any;
  10419. }
  10420. /**
  10421. * This defines an action responsible to set a the state field of the target
  10422. * to a desired value once triggered.
  10423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10424. */
  10425. export class SetStateAction extends Action {
  10426. /**
  10427. * The value to store in the state field.
  10428. */
  10429. value: string;
  10430. private _target;
  10431. /**
  10432. * Instantiate the action
  10433. * @param triggerOptions defines the trigger options
  10434. * @param target defines the object containing the state property
  10435. * @param value defines the value to store in the state field
  10436. * @param condition defines the trigger related conditions
  10437. */
  10438. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10439. /**
  10440. * Execute the action and store the value on the target state property.
  10441. */
  10442. execute(): void;
  10443. /**
  10444. * Serializes the actions and its related information.
  10445. * @param parent defines the object to serialize in
  10446. * @returns the serialized object
  10447. */
  10448. serialize(parent: any): any;
  10449. }
  10450. /**
  10451. * This defines an action responsible to set a property of the target
  10452. * to a desired value once triggered.
  10453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class SetValueAction extends Action {
  10456. /**
  10457. * The path of the property to set in the target.
  10458. */
  10459. propertyPath: string;
  10460. /**
  10461. * The value to set in the property
  10462. */
  10463. value: any;
  10464. private _target;
  10465. private _effectiveTarget;
  10466. private _property;
  10467. /**
  10468. * Instantiate the action
  10469. * @param triggerOptions defines the trigger options
  10470. * @param target defines the object containing the property
  10471. * @param propertyPath defines the path of the property to set in the target
  10472. * @param value defines the value to set in the property
  10473. * @param condition defines the trigger related conditions
  10474. */
  10475. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10476. /** @hidden */
  10477. _prepare(): void;
  10478. /**
  10479. * Execute the action and set the targetted property to the desired value.
  10480. */
  10481. execute(): void;
  10482. /**
  10483. * Serializes the actions and its related information.
  10484. * @param parent defines the object to serialize in
  10485. * @returns the serialized object
  10486. */
  10487. serialize(parent: any): any;
  10488. }
  10489. /**
  10490. * This defines an action responsible to increment the target value
  10491. * to a desired value once triggered.
  10492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10493. */
  10494. export class IncrementValueAction extends Action {
  10495. /**
  10496. * The path of the property to increment in the target.
  10497. */
  10498. propertyPath: string;
  10499. /**
  10500. * The value we should increment the property by.
  10501. */
  10502. value: any;
  10503. private _target;
  10504. private _effectiveTarget;
  10505. private _property;
  10506. /**
  10507. * Instantiate the action
  10508. * @param triggerOptions defines the trigger options
  10509. * @param target defines the object containing the property
  10510. * @param propertyPath defines the path of the property to increment in the target
  10511. * @param value defines the value value we should increment the property by
  10512. * @param condition defines the trigger related conditions
  10513. */
  10514. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10515. /** @hidden */
  10516. _prepare(): void;
  10517. /**
  10518. * Execute the action and increment the target of the value amount.
  10519. */
  10520. execute(): void;
  10521. /**
  10522. * Serializes the actions and its related information.
  10523. * @param parent defines the object to serialize in
  10524. * @returns the serialized object
  10525. */
  10526. serialize(parent: any): any;
  10527. }
  10528. /**
  10529. * This defines an action responsible to start an animation once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class PlayAnimationAction extends Action {
  10533. /**
  10534. * Where the animation should start (animation frame)
  10535. */
  10536. from: number;
  10537. /**
  10538. * Where the animation should stop (animation frame)
  10539. */
  10540. to: number;
  10541. /**
  10542. * Define if the animation should loop or stop after the first play.
  10543. */
  10544. loop?: boolean;
  10545. private _target;
  10546. /**
  10547. * Instantiate the action
  10548. * @param triggerOptions defines the trigger options
  10549. * @param target defines the target animation or animation name
  10550. * @param from defines from where the animation should start (animation frame)
  10551. * @param end defines where the animation should stop (animation frame)
  10552. * @param loop defines if the animation should loop or stop after the first play
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action and play the animation.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to stop an animation once triggered.
  10571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10572. */
  10573. export class StopAnimationAction extends Action {
  10574. private _target;
  10575. /**
  10576. * Instantiate the action
  10577. * @param triggerOptions defines the trigger options
  10578. * @param target defines the target animation or animation name
  10579. * @param condition defines the trigger related conditions
  10580. */
  10581. constructor(triggerOptions: any, target: any, condition?: Condition);
  10582. /** @hidden */
  10583. _prepare(): void;
  10584. /**
  10585. * Execute the action and stop the animation.
  10586. */
  10587. execute(): void;
  10588. /**
  10589. * Serializes the actions and its related information.
  10590. * @param parent defines the object to serialize in
  10591. * @returns the serialized object
  10592. */
  10593. serialize(parent: any): any;
  10594. }
  10595. /**
  10596. * This defines an action responsible that does nothing once triggered.
  10597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10598. */
  10599. export class DoNothingAction extends Action {
  10600. /**
  10601. * Instantiate the action
  10602. * @param triggerOptions defines the trigger options
  10603. * @param condition defines the trigger related conditions
  10604. */
  10605. constructor(triggerOptions?: any, condition?: Condition);
  10606. /**
  10607. * Execute the action and do nothing.
  10608. */
  10609. execute(): void;
  10610. /**
  10611. * Serializes the actions and its related information.
  10612. * @param parent defines the object to serialize in
  10613. * @returns the serialized object
  10614. */
  10615. serialize(parent: any): any;
  10616. }
  10617. /**
  10618. * This defines an action responsible to trigger several actions once triggered.
  10619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10620. */
  10621. export class CombineAction extends Action {
  10622. /**
  10623. * The list of aggregated animations to run.
  10624. */
  10625. children: Action[];
  10626. /**
  10627. * Instantiate the action
  10628. * @param triggerOptions defines the trigger options
  10629. * @param children defines the list of aggregated animations to run
  10630. * @param condition defines the trigger related conditions
  10631. */
  10632. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10633. /** @hidden */
  10634. _prepare(): void;
  10635. /**
  10636. * Execute the action and executes all the aggregated actions.
  10637. */
  10638. execute(evt: ActionEvent): void;
  10639. /**
  10640. * Serializes the actions and its related information.
  10641. * @param parent defines the object to serialize in
  10642. * @returns the serialized object
  10643. */
  10644. serialize(parent: any): any;
  10645. }
  10646. /**
  10647. * This defines an action responsible to run code (external event) once triggered.
  10648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10649. */
  10650. export class ExecuteCodeAction extends Action {
  10651. /**
  10652. * The callback function to run.
  10653. */
  10654. func: (evt: ActionEvent) => void;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param func defines the callback function to run
  10659. * @param condition defines the trigger related conditions
  10660. */
  10661. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10662. /**
  10663. * Execute the action and run the attached code.
  10664. */
  10665. execute(evt: ActionEvent): void;
  10666. }
  10667. /**
  10668. * This defines an action responsible to set the parent property of the target once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetParentAction extends Action {
  10672. private _parent;
  10673. private _target;
  10674. /**
  10675. * Instantiate the action
  10676. * @param triggerOptions defines the trigger options
  10677. * @param target defines the target containing the parent property
  10678. * @param parent defines from where the animation should start (animation frame)
  10679. * @param condition defines the trigger related conditions
  10680. */
  10681. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10682. /** @hidden */
  10683. _prepare(): void;
  10684. /**
  10685. * Execute the action and set the parent property.
  10686. */
  10687. execute(): void;
  10688. /**
  10689. * Serializes the actions and its related information.
  10690. * @param parent defines the object to serialize in
  10691. * @returns the serialized object
  10692. */
  10693. serialize(parent: any): any;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. /**
  10698. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10699. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class ActionManager extends AbstractActionManager {
  10703. /**
  10704. * Nothing
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly NothingTrigger: number;
  10708. /**
  10709. * On pick
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPickTrigger: number;
  10713. /**
  10714. * On left pick
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnLeftPickTrigger: number;
  10718. /**
  10719. * On right pick
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnRightPickTrigger: number;
  10723. /**
  10724. * On center pick
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnCenterPickTrigger: number;
  10728. /**
  10729. * On pick down
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnPickDownTrigger: number;
  10733. /**
  10734. * On double pick
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnDoublePickTrigger: number;
  10738. /**
  10739. * On pick up
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnPickUpTrigger: number;
  10743. /**
  10744. * On pick out.
  10745. * This trigger will only be raised if you also declared a OnPickDown
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10747. */
  10748. static readonly OnPickOutTrigger: number;
  10749. /**
  10750. * On long press
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly OnLongPressTrigger: number;
  10754. /**
  10755. * On pointer over
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnPointerOverTrigger: number;
  10759. /**
  10760. * On pointer out
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnPointerOutTrigger: number;
  10764. /**
  10765. * On every frame
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10767. */
  10768. static readonly OnEveryFrameTrigger: number;
  10769. /**
  10770. * On intersection enter
  10771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnIntersectionEnterTrigger: number;
  10774. /**
  10775. * On intersection exit
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnIntersectionExitTrigger: number;
  10779. /**
  10780. * On key down
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnKeyDownTrigger: number;
  10784. /**
  10785. * On key up
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnKeyUpTrigger: number;
  10789. private _scene;
  10790. /**
  10791. * Creates a new action manager
  10792. * @param scene defines the hosting scene
  10793. */
  10794. constructor(scene: Scene);
  10795. /**
  10796. * Releases all associated resources
  10797. */
  10798. dispose(): void;
  10799. /**
  10800. * Gets hosting scene
  10801. * @returns the hosting scene
  10802. */
  10803. getScene(): Scene;
  10804. /**
  10805. * Does this action manager handles actions of any of the given triggers
  10806. * @param triggers defines the triggers to be tested
  10807. * @return a boolean indicating whether one (or more) of the triggers is handled
  10808. */
  10809. hasSpecificTriggers(triggers: number[]): boolean;
  10810. /**
  10811. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10812. * speed.
  10813. * @param triggerA defines the trigger to be tested
  10814. * @param triggerB defines the trigger to be tested
  10815. * @return a boolean indicating whether one (or more) of the triggers is handled
  10816. */
  10817. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10818. /**
  10819. * Does this action manager handles actions of a given trigger
  10820. * @param trigger defines the trigger to be tested
  10821. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10822. * @return whether the trigger is handled
  10823. */
  10824. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10825. /**
  10826. * Does this action manager has pointer triggers
  10827. */
  10828. readonly hasPointerTriggers: boolean;
  10829. /**
  10830. * Does this action manager has pick triggers
  10831. */
  10832. readonly hasPickTriggers: boolean;
  10833. /**
  10834. * Registers an action to this action manager
  10835. * @param action defines the action to be registered
  10836. * @return the action amended (prepared) after registration
  10837. */
  10838. registerAction(action: IAction): Nullable<IAction>;
  10839. /**
  10840. * Unregisters an action to this action manager
  10841. * @param action defines the action to be unregistered
  10842. * @return a boolean indicating whether the action has been unregistered
  10843. */
  10844. unregisterAction(action: IAction): Boolean;
  10845. /**
  10846. * Process a specific trigger
  10847. * @param trigger defines the trigger to process
  10848. * @param evt defines the event details to be processed
  10849. */
  10850. processTrigger(trigger: number, evt?: IActionEvent): void;
  10851. /** @hidden */
  10852. _getEffectiveTarget(target: any, propertyPath: string): any;
  10853. /** @hidden */
  10854. _getProperty(propertyPath: string): string;
  10855. /**
  10856. * Serialize this manager to a JSON object
  10857. * @param name defines the property name to store this manager
  10858. * @returns a JSON representation of this manager
  10859. */
  10860. serialize(name: string): any;
  10861. /**
  10862. * Creates a new ActionManager from a JSON data
  10863. * @param parsedActions defines the JSON data to read from
  10864. * @param object defines the hosting mesh
  10865. * @param scene defines the hosting scene
  10866. */
  10867. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10868. /**
  10869. * Get a trigger name by index
  10870. * @param trigger defines the trigger index
  10871. * @returns a trigger name
  10872. */
  10873. static GetTriggerName(trigger: number): string;
  10874. }
  10875. }
  10876. declare module BABYLON {
  10877. /**
  10878. * Class representing a ray with position and direction
  10879. */
  10880. export class Ray {
  10881. /** origin point */
  10882. origin: Vector3;
  10883. /** direction */
  10884. direction: Vector3;
  10885. /** length of the ray */
  10886. length: number;
  10887. private static readonly TmpVector3;
  10888. private _tmpRay;
  10889. /**
  10890. * Creates a new ray
  10891. * @param origin origin point
  10892. * @param direction direction
  10893. * @param length length of the ray
  10894. */
  10895. constructor(
  10896. /** origin point */
  10897. origin: Vector3,
  10898. /** direction */
  10899. direction: Vector3,
  10900. /** length of the ray */
  10901. length?: number);
  10902. /**
  10903. * Checks if the ray intersects a box
  10904. * @param minimum bound of the box
  10905. * @param maximum bound of the box
  10906. * @param intersectionTreshold extra extend to be added to the box in all direction
  10907. * @returns if the box was hit
  10908. */
  10909. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10910. /**
  10911. * Checks if the ray intersects a box
  10912. * @param box the bounding box to check
  10913. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10914. * @returns if the box was hit
  10915. */
  10916. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10917. /**
  10918. * If the ray hits a sphere
  10919. * @param sphere the bounding sphere to check
  10920. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10921. * @returns true if it hits the sphere
  10922. */
  10923. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10924. /**
  10925. * If the ray hits a triange
  10926. * @param vertex0 triangle vertex
  10927. * @param vertex1 triangle vertex
  10928. * @param vertex2 triangle vertex
  10929. * @returns intersection information if hit
  10930. */
  10931. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10932. /**
  10933. * Checks if ray intersects a plane
  10934. * @param plane the plane to check
  10935. * @returns the distance away it was hit
  10936. */
  10937. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10938. /**
  10939. * Calculate the intercept of a ray on a given axis
  10940. * @param axis to check 'x' | 'y' | 'z'
  10941. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10942. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10943. */
  10944. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10945. /**
  10946. * Checks if ray intersects a mesh
  10947. * @param mesh the mesh to check
  10948. * @param fastCheck if only the bounding box should checked
  10949. * @returns picking info of the intersecton
  10950. */
  10951. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10952. /**
  10953. * Checks if ray intersects a mesh
  10954. * @param meshes the meshes to check
  10955. * @param fastCheck if only the bounding box should checked
  10956. * @param results array to store result in
  10957. * @returns Array of picking infos
  10958. */
  10959. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10960. private _comparePickingInfo;
  10961. private static smallnum;
  10962. private static rayl;
  10963. /**
  10964. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10965. * @param sega the first point of the segment to test the intersection against
  10966. * @param segb the second point of the segment to test the intersection against
  10967. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10968. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10969. */
  10970. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10971. /**
  10972. * Update the ray from viewport position
  10973. * @param x position
  10974. * @param y y position
  10975. * @param viewportWidth viewport width
  10976. * @param viewportHeight viewport height
  10977. * @param world world matrix
  10978. * @param view view matrix
  10979. * @param projection projection matrix
  10980. * @returns this ray updated
  10981. */
  10982. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10983. /**
  10984. * Creates a ray with origin and direction of 0,0,0
  10985. * @returns the new ray
  10986. */
  10987. static Zero(): Ray;
  10988. /**
  10989. * Creates a new ray from screen space and viewport
  10990. * @param x position
  10991. * @param y y position
  10992. * @param viewportWidth viewport width
  10993. * @param viewportHeight viewport height
  10994. * @param world world matrix
  10995. * @param view view matrix
  10996. * @param projection projection matrix
  10997. * @returns new ray
  10998. */
  10999. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11000. /**
  11001. * 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
  11002. * transformed to the given world matrix.
  11003. * @param origin The origin point
  11004. * @param end The end point
  11005. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11006. * @returns the new ray
  11007. */
  11008. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11009. /**
  11010. * Transforms a ray by a matrix
  11011. * @param ray ray to transform
  11012. * @param matrix matrix to apply
  11013. * @returns the resulting new ray
  11014. */
  11015. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11016. /**
  11017. * Transforms a ray by a matrix
  11018. * @param ray ray to transform
  11019. * @param matrix matrix to apply
  11020. * @param result ray to store result in
  11021. */
  11022. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11023. /**
  11024. * Unproject a ray from screen space to object space
  11025. * @param sourceX defines the screen space x coordinate to use
  11026. * @param sourceY defines the screen space y coordinate to use
  11027. * @param viewportWidth defines the current width of the viewport
  11028. * @param viewportHeight defines the current height of the viewport
  11029. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11030. * @param view defines the view matrix to use
  11031. * @param projection defines the projection matrix to use
  11032. */
  11033. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11034. }
  11035. /**
  11036. * Type used to define predicate used to select faces when a mesh intersection is detected
  11037. */
  11038. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11039. interface Scene {
  11040. /** @hidden */
  11041. _tempPickingRay: Nullable<Ray>;
  11042. /** @hidden */
  11043. _cachedRayForTransform: Ray;
  11044. /** @hidden */
  11045. _pickWithRayInverseMatrix: Matrix;
  11046. /** @hidden */
  11047. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11048. /** @hidden */
  11049. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11050. }
  11051. }
  11052. declare module BABYLON {
  11053. /**
  11054. * Groups all the scene component constants in one place to ease maintenance.
  11055. * @hidden
  11056. */
  11057. export class SceneComponentConstants {
  11058. static readonly NAME_EFFECTLAYER: string;
  11059. static readonly NAME_LAYER: string;
  11060. static readonly NAME_LENSFLARESYSTEM: string;
  11061. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11062. static readonly NAME_PARTICLESYSTEM: string;
  11063. static readonly NAME_GAMEPAD: string;
  11064. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11065. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11066. static readonly NAME_DEPTHRENDERER: string;
  11067. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11068. static readonly NAME_SPRITE: string;
  11069. static readonly NAME_OUTLINERENDERER: string;
  11070. static readonly NAME_PROCEDURALTEXTURE: string;
  11071. static readonly NAME_SHADOWGENERATOR: string;
  11072. static readonly NAME_OCTREE: string;
  11073. static readonly NAME_PHYSICSENGINE: string;
  11074. static readonly NAME_AUDIO: string;
  11075. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11076. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11077. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11078. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11079. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11080. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11081. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11082. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11083. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11084. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11085. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11086. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11087. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11088. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11089. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11090. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11091. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11092. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11093. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11094. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11095. static readonly STEP_AFTERRENDER_AUDIO: number;
  11096. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11097. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11098. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11099. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11100. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11101. static readonly STEP_POINTERMOVE_SPRITE: number;
  11102. static readonly STEP_POINTERDOWN_SPRITE: number;
  11103. static readonly STEP_POINTERUP_SPRITE: number;
  11104. }
  11105. /**
  11106. * This represents a scene component.
  11107. *
  11108. * This is used to decouple the dependency the scene is having on the different workloads like
  11109. * layers, post processes...
  11110. */
  11111. export interface ISceneComponent {
  11112. /**
  11113. * The name of the component. Each component must have a unique name.
  11114. */
  11115. name: string;
  11116. /**
  11117. * The scene the component belongs to.
  11118. */
  11119. scene: Scene;
  11120. /**
  11121. * Register the component to one instance of a scene.
  11122. */
  11123. register(): void;
  11124. /**
  11125. * Rebuilds the elements related to this component in case of
  11126. * context lost for instance.
  11127. */
  11128. rebuild(): void;
  11129. /**
  11130. * Disposes the component and the associated ressources.
  11131. */
  11132. dispose(): void;
  11133. }
  11134. /**
  11135. * This represents a SERIALIZABLE scene component.
  11136. *
  11137. * This extends Scene Component to add Serialization methods on top.
  11138. */
  11139. export interface ISceneSerializableComponent extends ISceneComponent {
  11140. /**
  11141. * Adds all the elements from the container to the scene
  11142. * @param container the container holding the elements
  11143. */
  11144. addFromContainer(container: AbstractScene): void;
  11145. /**
  11146. * Removes all the elements in the container from the scene
  11147. * @param container contains the elements to remove
  11148. * @param dispose if the removed element should be disposed (default: false)
  11149. */
  11150. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11151. /**
  11152. * Serializes the component data to the specified json object
  11153. * @param serializationObject The object to serialize to
  11154. */
  11155. serialize(serializationObject: any): void;
  11156. }
  11157. /**
  11158. * Strong typing of a Mesh related stage step action
  11159. */
  11160. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11161. /**
  11162. * Strong typing of a Evaluate Sub Mesh related stage step action
  11163. */
  11164. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11165. /**
  11166. * Strong typing of a Active Mesh related stage step action
  11167. */
  11168. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11169. /**
  11170. * Strong typing of a Camera related stage step action
  11171. */
  11172. export type CameraStageAction = (camera: Camera) => void;
  11173. /**
  11174. * Strong typing of a Camera Frame buffer related stage step action
  11175. */
  11176. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11177. /**
  11178. * Strong typing of a Render Target related stage step action
  11179. */
  11180. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11181. /**
  11182. * Strong typing of a RenderingGroup related stage step action
  11183. */
  11184. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11185. /**
  11186. * Strong typing of a Mesh Render related stage step action
  11187. */
  11188. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11189. /**
  11190. * Strong typing of a simple stage step action
  11191. */
  11192. export type SimpleStageAction = () => void;
  11193. /**
  11194. * Strong typing of a render target action.
  11195. */
  11196. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11197. /**
  11198. * Strong typing of a pointer move action.
  11199. */
  11200. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11201. /**
  11202. * Strong typing of a pointer up/down action.
  11203. */
  11204. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11205. /**
  11206. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11207. * @hidden
  11208. */
  11209. export class Stage<T extends Function> extends Array<{
  11210. index: number;
  11211. component: ISceneComponent;
  11212. action: T;
  11213. }> {
  11214. /**
  11215. * Hide ctor from the rest of the world.
  11216. * @param items The items to add.
  11217. */
  11218. private constructor();
  11219. /**
  11220. * Creates a new Stage.
  11221. * @returns A new instance of a Stage
  11222. */
  11223. static Create<T extends Function>(): Stage<T>;
  11224. /**
  11225. * Registers a step in an ordered way in the targeted stage.
  11226. * @param index Defines the position to register the step in
  11227. * @param component Defines the component attached to the step
  11228. * @param action Defines the action to launch during the step
  11229. */
  11230. registerStep(index: number, component: ISceneComponent, action: T): void;
  11231. /**
  11232. * Clears all the steps from the stage.
  11233. */
  11234. clear(): void;
  11235. }
  11236. }
  11237. declare module BABYLON {
  11238. interface Scene {
  11239. /** @hidden */
  11240. _pointerOverSprite: Nullable<Sprite>;
  11241. /** @hidden */
  11242. _pickedDownSprite: Nullable<Sprite>;
  11243. /** @hidden */
  11244. _tempSpritePickingRay: Nullable<Ray>;
  11245. /**
  11246. * All of the sprite managers added to this scene
  11247. * @see http://doc.babylonjs.com/babylon101/sprites
  11248. */
  11249. spriteManagers: Array<ISpriteManager>;
  11250. /**
  11251. * An event triggered when sprites rendering is about to start
  11252. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11253. */
  11254. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11255. /**
  11256. * An event triggered when sprites rendering is done
  11257. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11258. */
  11259. onAfterSpritesRenderingObservable: Observable<Scene>;
  11260. /** @hidden */
  11261. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11262. /** Launch a ray to try to pick a sprite in the scene
  11263. * @param x position on screen
  11264. * @param y position on screen
  11265. * @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
  11266. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11267. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11268. * @returns a PickingInfo
  11269. */
  11270. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11271. /** Use the given ray to pick a sprite in the scene
  11272. * @param ray The ray (in world space) to use to pick meshes
  11273. * @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
  11274. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11275. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11276. * @returns a PickingInfo
  11277. */
  11278. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11281. /** Launch a ray to try to pick sprites in the scene
  11282. * @param x position on screen
  11283. * @param y position on screen
  11284. * @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
  11285. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11286. * @returns a PickingInfo array
  11287. */
  11288. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11289. /** Use the given ray to pick sprites in the scene
  11290. * @param ray The ray (in world space) to use to pick meshes
  11291. * @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
  11292. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11293. * @returns a PickingInfo array
  11294. */
  11295. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11296. /**
  11297. * Force the sprite under the pointer
  11298. * @param sprite defines the sprite to use
  11299. */
  11300. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11301. /**
  11302. * Gets the sprite under the pointer
  11303. * @returns a Sprite or null if no sprite is under the pointer
  11304. */
  11305. getPointerOverSprite(): Nullable<Sprite>;
  11306. }
  11307. /**
  11308. * Defines the sprite scene component responsible to manage sprites
  11309. * in a given scene.
  11310. */
  11311. export class SpriteSceneComponent implements ISceneComponent {
  11312. /**
  11313. * The component name helpfull to identify the component in the list of scene components.
  11314. */
  11315. readonly name: string;
  11316. /**
  11317. * The scene the component belongs to.
  11318. */
  11319. scene: Scene;
  11320. /** @hidden */
  11321. private _spritePredicate;
  11322. /**
  11323. * Creates a new instance of the component for the given scene
  11324. * @param scene Defines the scene to register the component in
  11325. */
  11326. constructor(scene: Scene);
  11327. /**
  11328. * Registers the component in a given scene
  11329. */
  11330. register(): void;
  11331. /**
  11332. * Rebuilds the elements related to this component in case of
  11333. * context lost for instance.
  11334. */
  11335. rebuild(): void;
  11336. /**
  11337. * Disposes the component and the associated ressources.
  11338. */
  11339. dispose(): void;
  11340. private _pickSpriteButKeepRay;
  11341. private _pointerMove;
  11342. private _pointerDown;
  11343. private _pointerUp;
  11344. }
  11345. }
  11346. declare module BABYLON {
  11347. /** @hidden */
  11348. export var fogFragmentDeclaration: {
  11349. name: string;
  11350. shader: string;
  11351. };
  11352. }
  11353. declare module BABYLON {
  11354. /** @hidden */
  11355. export var fogFragment: {
  11356. name: string;
  11357. shader: string;
  11358. };
  11359. }
  11360. declare module BABYLON {
  11361. /** @hidden */
  11362. export var spritesPixelShader: {
  11363. name: string;
  11364. shader: string;
  11365. };
  11366. }
  11367. declare module BABYLON {
  11368. /** @hidden */
  11369. export var fogVertexDeclaration: {
  11370. name: string;
  11371. shader: string;
  11372. };
  11373. }
  11374. declare module BABYLON {
  11375. /** @hidden */
  11376. export var spritesVertexShader: {
  11377. name: string;
  11378. shader: string;
  11379. };
  11380. }
  11381. declare module BABYLON {
  11382. /**
  11383. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11384. */
  11385. export interface ISpriteManager extends IDisposable {
  11386. /**
  11387. * Restricts the camera to viewing objects with the same layerMask.
  11388. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11389. */
  11390. layerMask: number;
  11391. /**
  11392. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11393. */
  11394. isPickable: boolean;
  11395. /**
  11396. * Specifies the rendering group id for this mesh (0 by default)
  11397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11398. */
  11399. renderingGroupId: number;
  11400. /**
  11401. * Defines the list of sprites managed by the manager.
  11402. */
  11403. sprites: Array<Sprite>;
  11404. /**
  11405. * Tests the intersection of a sprite with a specific ray.
  11406. * @param ray The ray we are sending to test the collision
  11407. * @param camera The camera space we are sending rays in
  11408. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11409. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11410. * @returns picking info or null.
  11411. */
  11412. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11413. /**
  11414. * Intersects the sprites with a ray
  11415. * @param ray defines the ray to intersect with
  11416. * @param camera defines the current active camera
  11417. * @param predicate defines a predicate used to select candidate sprites
  11418. * @returns null if no hit or a PickingInfo array
  11419. */
  11420. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11421. /**
  11422. * Renders the list of sprites on screen.
  11423. */
  11424. render(): void;
  11425. }
  11426. /**
  11427. * Class used to manage multiple sprites on the same spritesheet
  11428. * @see http://doc.babylonjs.com/babylon101/sprites
  11429. */
  11430. export class SpriteManager implements ISpriteManager {
  11431. /** defines the manager's name */
  11432. name: string;
  11433. /** Gets the list of sprites */
  11434. sprites: Sprite[];
  11435. /** Gets or sets the rendering group id (0 by default) */
  11436. renderingGroupId: number;
  11437. /** Gets or sets camera layer mask */
  11438. layerMask: number;
  11439. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11440. fogEnabled: boolean;
  11441. /** Gets or sets a boolean indicating if the sprites are pickable */
  11442. isPickable: boolean;
  11443. /** Defines the default width of a cell in the spritesheet */
  11444. cellWidth: number;
  11445. /** Defines the default height of a cell in the spritesheet */
  11446. cellHeight: number;
  11447. /** Associative array from JSON sprite data file */
  11448. private _cellData;
  11449. /** Array of sprite names from JSON sprite data file */
  11450. private _spriteMap;
  11451. /** True when packed cell data from JSON file is ready*/
  11452. private _packedAndReady;
  11453. /**
  11454. * An event triggered when the manager is disposed.
  11455. */
  11456. onDisposeObservable: Observable<SpriteManager>;
  11457. private _onDisposeObserver;
  11458. /**
  11459. * Callback called when the manager is disposed
  11460. */
  11461. onDispose: () => void;
  11462. private _capacity;
  11463. private _fromPacked;
  11464. private _spriteTexture;
  11465. private _epsilon;
  11466. private _scene;
  11467. private _vertexData;
  11468. private _buffer;
  11469. private _vertexBuffers;
  11470. private _indexBuffer;
  11471. private _effectBase;
  11472. private _effectFog;
  11473. /**
  11474. * Gets or sets the spritesheet texture
  11475. */
  11476. texture: Texture;
  11477. /**
  11478. * Creates a new sprite manager
  11479. * @param name defines the manager's name
  11480. * @param imgUrl defines the sprite sheet url
  11481. * @param capacity defines the maximum allowed number of sprites
  11482. * @param cellSize defines the size of a sprite cell
  11483. * @param scene defines the hosting scene
  11484. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11485. * @param samplingMode defines the smapling mode to use with spritesheet
  11486. * @param fromPacked set to false; do not alter
  11487. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11488. */
  11489. constructor(
  11490. /** defines the manager's name */
  11491. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11492. private _makePacked;
  11493. private _appendSpriteVertex;
  11494. /**
  11495. * Intersects the sprites with a ray
  11496. * @param ray defines the ray to intersect with
  11497. * @param camera defines the current active camera
  11498. * @param predicate defines a predicate used to select candidate sprites
  11499. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11500. * @returns null if no hit or a PickingInfo
  11501. */
  11502. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11503. /**
  11504. * Intersects the sprites with a ray
  11505. * @param ray defines the ray to intersect with
  11506. * @param camera defines the current active camera
  11507. * @param predicate defines a predicate used to select candidate sprites
  11508. * @returns null if no hit or a PickingInfo array
  11509. */
  11510. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11511. /**
  11512. * Render all child sprites
  11513. */
  11514. render(): void;
  11515. /**
  11516. * Release associated resources
  11517. */
  11518. dispose(): void;
  11519. }
  11520. }
  11521. declare module BABYLON {
  11522. /**
  11523. * Class used to represent a sprite
  11524. * @see http://doc.babylonjs.com/babylon101/sprites
  11525. */
  11526. export class Sprite {
  11527. /** defines the name */
  11528. name: string;
  11529. /** Gets or sets the current world position */
  11530. position: Vector3;
  11531. /** Gets or sets the main color */
  11532. color: Color4;
  11533. /** Gets or sets the width */
  11534. width: number;
  11535. /** Gets or sets the height */
  11536. height: number;
  11537. /** Gets or sets rotation angle */
  11538. angle: number;
  11539. /** Gets or sets the cell index in the sprite sheet */
  11540. cellIndex: number;
  11541. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11542. cellRef: string;
  11543. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11544. invertU: number;
  11545. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11546. invertV: number;
  11547. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11548. disposeWhenFinishedAnimating: boolean;
  11549. /** Gets the list of attached animations */
  11550. animations: Animation[];
  11551. /** Gets or sets a boolean indicating if the sprite can be picked */
  11552. isPickable: boolean;
  11553. /**
  11554. * Gets or sets the associated action manager
  11555. */
  11556. actionManager: Nullable<ActionManager>;
  11557. private _animationStarted;
  11558. private _loopAnimation;
  11559. private _fromIndex;
  11560. private _toIndex;
  11561. private _delay;
  11562. private _direction;
  11563. private _manager;
  11564. private _time;
  11565. private _onAnimationEnd;
  11566. /**
  11567. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11568. */
  11569. isVisible: boolean;
  11570. /**
  11571. * Gets or sets the sprite size
  11572. */
  11573. size: number;
  11574. /**
  11575. * Creates a new Sprite
  11576. * @param name defines the name
  11577. * @param manager defines the manager
  11578. */
  11579. constructor(
  11580. /** defines the name */
  11581. name: string, manager: ISpriteManager);
  11582. /**
  11583. * Starts an animation
  11584. * @param from defines the initial key
  11585. * @param to defines the end key
  11586. * @param loop defines if the animation must loop
  11587. * @param delay defines the start delay (in ms)
  11588. * @param onAnimationEnd defines a callback to call when animation ends
  11589. */
  11590. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11591. /** Stops current animation (if any) */
  11592. stopAnimation(): void;
  11593. /** @hidden */
  11594. _animate(deltaTime: number): void;
  11595. /** Release associated resources */
  11596. dispose(): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. /**
  11601. * Information about the result of picking within a scene
  11602. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11603. */
  11604. export class PickingInfo {
  11605. /** @hidden */
  11606. _pickingUnavailable: boolean;
  11607. /**
  11608. * If the pick collided with an object
  11609. */
  11610. hit: boolean;
  11611. /**
  11612. * Distance away where the pick collided
  11613. */
  11614. distance: number;
  11615. /**
  11616. * The location of pick collision
  11617. */
  11618. pickedPoint: Nullable<Vector3>;
  11619. /**
  11620. * The mesh corresponding the the pick collision
  11621. */
  11622. pickedMesh: Nullable<AbstractMesh>;
  11623. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11624. bu: number;
  11625. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11626. bv: number;
  11627. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11628. faceId: number;
  11629. /** Id of the the submesh that was picked */
  11630. subMeshId: number;
  11631. /** If a sprite was picked, this will be the sprite the pick collided with */
  11632. pickedSprite: Nullable<Sprite>;
  11633. /**
  11634. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11635. */
  11636. originMesh: Nullable<AbstractMesh>;
  11637. /**
  11638. * The ray that was used to perform the picking.
  11639. */
  11640. ray: Nullable<Ray>;
  11641. /**
  11642. * Gets the normal correspodning to the face the pick collided with
  11643. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11644. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11645. * @returns The normal correspodning to the face the pick collided with
  11646. */
  11647. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11648. /**
  11649. * Gets the texture coordinates of where the pick occured
  11650. * @returns the vector containing the coordnates of the texture
  11651. */
  11652. getTextureCoordinates(): Nullable<Vector2>;
  11653. }
  11654. }
  11655. declare module BABYLON {
  11656. /**
  11657. * Gather the list of pointer event types as constants.
  11658. */
  11659. export class PointerEventTypes {
  11660. /**
  11661. * 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.
  11662. */
  11663. static readonly POINTERDOWN: number;
  11664. /**
  11665. * The pointerup event is fired when a pointer is no longer active.
  11666. */
  11667. static readonly POINTERUP: number;
  11668. /**
  11669. * The pointermove event is fired when a pointer changes coordinates.
  11670. */
  11671. static readonly POINTERMOVE: number;
  11672. /**
  11673. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11674. */
  11675. static readonly POINTERWHEEL: number;
  11676. /**
  11677. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11678. */
  11679. static readonly POINTERPICK: number;
  11680. /**
  11681. * The pointertap event is fired when a the object has been touched and released without drag.
  11682. */
  11683. static readonly POINTERTAP: number;
  11684. /**
  11685. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11686. */
  11687. static readonly POINTERDOUBLETAP: number;
  11688. }
  11689. /**
  11690. * Base class of pointer info types.
  11691. */
  11692. export class PointerInfoBase {
  11693. /**
  11694. * Defines the type of event (PointerEventTypes)
  11695. */
  11696. type: number;
  11697. /**
  11698. * Defines the related dom event
  11699. */
  11700. event: PointerEvent | MouseWheelEvent;
  11701. /**
  11702. * Instantiates the base class of pointers info.
  11703. * @param type Defines the type of event (PointerEventTypes)
  11704. * @param event Defines the related dom event
  11705. */
  11706. constructor(
  11707. /**
  11708. * Defines the type of event (PointerEventTypes)
  11709. */
  11710. type: number,
  11711. /**
  11712. * Defines the related dom event
  11713. */
  11714. event: PointerEvent | MouseWheelEvent);
  11715. }
  11716. /**
  11717. * This class is used to store pointer related info for the onPrePointerObservable event.
  11718. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11719. */
  11720. export class PointerInfoPre extends PointerInfoBase {
  11721. /**
  11722. * Ray from a pointer if availible (eg. 6dof controller)
  11723. */
  11724. ray: Nullable<Ray>;
  11725. /**
  11726. * Defines the local position of the pointer on the canvas.
  11727. */
  11728. localPosition: Vector2;
  11729. /**
  11730. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11731. */
  11732. skipOnPointerObservable: boolean;
  11733. /**
  11734. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11735. * @param type Defines the type of event (PointerEventTypes)
  11736. * @param event Defines the related dom event
  11737. * @param localX Defines the local x coordinates of the pointer when the event occured
  11738. * @param localY Defines the local y coordinates of the pointer when the event occured
  11739. */
  11740. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11741. }
  11742. /**
  11743. * This type contains all the data related to a pointer event in Babylon.js.
  11744. * 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.
  11745. */
  11746. export class PointerInfo extends PointerInfoBase {
  11747. /**
  11748. * Defines the picking info associated to the info (if any)\
  11749. */
  11750. pickInfo: Nullable<PickingInfo>;
  11751. /**
  11752. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11753. * @param type Defines the type of event (PointerEventTypes)
  11754. * @param event Defines the related dom event
  11755. * @param pickInfo Defines the picking info associated to the info (if any)\
  11756. */
  11757. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11758. /**
  11759. * Defines the picking info associated to the info (if any)\
  11760. */
  11761. pickInfo: Nullable<PickingInfo>);
  11762. }
  11763. /**
  11764. * Data relating to a touch event on the screen.
  11765. */
  11766. export interface PointerTouch {
  11767. /**
  11768. * X coordinate of touch.
  11769. */
  11770. x: number;
  11771. /**
  11772. * Y coordinate of touch.
  11773. */
  11774. y: number;
  11775. /**
  11776. * Id of touch. Unique for each finger.
  11777. */
  11778. pointerId: number;
  11779. /**
  11780. * Event type passed from DOM.
  11781. */
  11782. type: any;
  11783. }
  11784. }
  11785. declare module BABYLON {
  11786. /**
  11787. * Manage the mouse inputs to control the movement of a free camera.
  11788. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11789. */
  11790. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11791. /**
  11792. * Define if touch is enabled in the mouse input
  11793. */
  11794. touchEnabled: boolean;
  11795. /**
  11796. * Defines the camera the input is attached to.
  11797. */
  11798. camera: FreeCamera;
  11799. /**
  11800. * Defines the buttons associated with the input to handle camera move.
  11801. */
  11802. buttons: number[];
  11803. /**
  11804. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11805. */
  11806. angularSensibility: number;
  11807. private _pointerInput;
  11808. private _onMouseMove;
  11809. private _observer;
  11810. private previousPosition;
  11811. /**
  11812. * Observable for when a pointer move event occurs containing the move offset
  11813. */
  11814. onPointerMovedObservable: Observable<{
  11815. offsetX: number;
  11816. offsetY: number;
  11817. }>;
  11818. /**
  11819. * @hidden
  11820. * If the camera should be rotated automatically based on pointer movement
  11821. */
  11822. _allowCameraRotation: boolean;
  11823. /**
  11824. * Manage the mouse inputs to control the movement of a free camera.
  11825. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11826. * @param touchEnabled Defines if touch is enabled or not
  11827. */
  11828. constructor(
  11829. /**
  11830. * Define if touch is enabled in the mouse input
  11831. */
  11832. touchEnabled?: boolean);
  11833. /**
  11834. * Attach the input controls to a specific dom element to get the input from.
  11835. * @param element Defines the element the controls should be listened from
  11836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11837. */
  11838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11839. /**
  11840. * Called on JS contextmenu event.
  11841. * Override this method to provide functionality.
  11842. */
  11843. protected onContextMenu(evt: PointerEvent): void;
  11844. /**
  11845. * Detach the current controls from the specified dom element.
  11846. * @param element Defines the element to stop listening the inputs from
  11847. */
  11848. detachControl(element: Nullable<HTMLElement>): void;
  11849. /**
  11850. * Gets the class name of the current intput.
  11851. * @returns the class name
  11852. */
  11853. getClassName(): string;
  11854. /**
  11855. * Get the friendly name associated with the input class.
  11856. * @returns the input friendly name
  11857. */
  11858. getSimpleName(): string;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * Manage the touch inputs to control the movement of a free camera.
  11864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11865. */
  11866. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11867. /**
  11868. * Defines the camera the input is attached to.
  11869. */
  11870. camera: FreeCamera;
  11871. /**
  11872. * Defines the touch sensibility for rotation.
  11873. * The higher the faster.
  11874. */
  11875. touchAngularSensibility: number;
  11876. /**
  11877. * Defines the touch sensibility for move.
  11878. * The higher the faster.
  11879. */
  11880. touchMoveSensibility: number;
  11881. private _offsetX;
  11882. private _offsetY;
  11883. private _pointerPressed;
  11884. private _pointerInput;
  11885. private _observer;
  11886. private _onLostFocus;
  11887. /**
  11888. * Attach the input controls to a specific dom element to get the input from.
  11889. * @param element Defines the element the controls should be listened from
  11890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11891. */
  11892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11893. /**
  11894. * Detach the current controls from the specified dom element.
  11895. * @param element Defines the element to stop listening the inputs from
  11896. */
  11897. detachControl(element: Nullable<HTMLElement>): void;
  11898. /**
  11899. * Update the current camera state depending on the inputs that have been used this frame.
  11900. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11901. */
  11902. checkInputs(): void;
  11903. /**
  11904. * Gets the class name of the current intput.
  11905. * @returns the class name
  11906. */
  11907. getClassName(): string;
  11908. /**
  11909. * Get the friendly name associated with the input class.
  11910. * @returns the input friendly name
  11911. */
  11912. getSimpleName(): string;
  11913. }
  11914. }
  11915. declare module BABYLON {
  11916. /**
  11917. * Default Inputs manager for the FreeCamera.
  11918. * It groups all the default supported inputs for ease of use.
  11919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11920. */
  11921. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11922. /**
  11923. * @hidden
  11924. */
  11925. _mouseInput: Nullable<FreeCameraMouseInput>;
  11926. /**
  11927. * Instantiates a new FreeCameraInputsManager.
  11928. * @param camera Defines the camera the inputs belong to
  11929. */
  11930. constructor(camera: FreeCamera);
  11931. /**
  11932. * Add keyboard input support to the input manager.
  11933. * @returns the current input manager
  11934. */
  11935. addKeyboard(): FreeCameraInputsManager;
  11936. /**
  11937. * Add mouse input support to the input manager.
  11938. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11939. * @returns the current input manager
  11940. */
  11941. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11942. /**
  11943. * Removes the mouse input support from the manager
  11944. * @returns the current input manager
  11945. */
  11946. removeMouse(): FreeCameraInputsManager;
  11947. /**
  11948. * Add touch input support to the input manager.
  11949. * @returns the current input manager
  11950. */
  11951. addTouch(): FreeCameraInputsManager;
  11952. /**
  11953. * Remove all attached input methods from a camera
  11954. */
  11955. clear(): void;
  11956. }
  11957. }
  11958. declare module BABYLON {
  11959. /**
  11960. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11961. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11963. */
  11964. export class FreeCamera extends TargetCamera {
  11965. /**
  11966. * Define the collision ellipsoid of the camera.
  11967. * This is helpful to simulate a camera body like the player body around the camera
  11968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11969. */
  11970. ellipsoid: Vector3;
  11971. /**
  11972. * Define an offset for the position of the ellipsoid around the camera.
  11973. * This can be helpful to determine the center of the body near the gravity center of the body
  11974. * instead of its head.
  11975. */
  11976. ellipsoidOffset: Vector3;
  11977. /**
  11978. * Enable or disable collisions of the camera with the rest of the scene objects.
  11979. */
  11980. checkCollisions: boolean;
  11981. /**
  11982. * Enable or disable gravity on the camera.
  11983. */
  11984. applyGravity: boolean;
  11985. /**
  11986. * Define the input manager associated to the camera.
  11987. */
  11988. inputs: FreeCameraInputsManager;
  11989. /**
  11990. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11991. * Higher values reduce sensitivity.
  11992. */
  11993. /**
  11994. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11995. * Higher values reduce sensitivity.
  11996. */
  11997. angularSensibility: number;
  11998. /**
  11999. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12000. */
  12001. keysUp: number[];
  12002. /**
  12003. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12004. */
  12005. keysDown: number[];
  12006. /**
  12007. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12008. */
  12009. keysLeft: number[];
  12010. /**
  12011. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12012. */
  12013. keysRight: number[];
  12014. /**
  12015. * Event raised when the camera collide with a mesh in the scene.
  12016. */
  12017. onCollide: (collidedMesh: AbstractMesh) => void;
  12018. private _collider;
  12019. private _needMoveForGravity;
  12020. private _oldPosition;
  12021. private _diffPosition;
  12022. private _newPosition;
  12023. /** @hidden */
  12024. _localDirection: Vector3;
  12025. /** @hidden */
  12026. _transformedDirection: Vector3;
  12027. /**
  12028. * Instantiates a Free Camera.
  12029. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12030. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12031. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12032. * @param name Define the name of the camera in the scene
  12033. * @param position Define the start position of the camera in the scene
  12034. * @param scene Define the scene the camera belongs to
  12035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12036. */
  12037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12038. /**
  12039. * Attached controls to the current camera.
  12040. * @param element Defines the element the controls should be listened from
  12041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12042. */
  12043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12044. /**
  12045. * Detach the current controls from the camera.
  12046. * The camera will stop reacting to inputs.
  12047. * @param element Defines the element to stop listening the inputs from
  12048. */
  12049. detachControl(element: HTMLElement): void;
  12050. private _collisionMask;
  12051. /**
  12052. * Define a collision mask to limit the list of object the camera can collide with
  12053. */
  12054. collisionMask: number;
  12055. /** @hidden */
  12056. _collideWithWorld(displacement: Vector3): void;
  12057. private _onCollisionPositionChange;
  12058. /** @hidden */
  12059. _checkInputs(): void;
  12060. /** @hidden */
  12061. _decideIfNeedsToMove(): boolean;
  12062. /** @hidden */
  12063. _updatePosition(): void;
  12064. /**
  12065. * Destroy the camera and release the current resources hold by it.
  12066. */
  12067. dispose(): void;
  12068. /**
  12069. * Gets the current object class name.
  12070. * @return the class name
  12071. */
  12072. getClassName(): string;
  12073. }
  12074. }
  12075. declare module BABYLON {
  12076. /**
  12077. * Represents a gamepad control stick position
  12078. */
  12079. export class StickValues {
  12080. /**
  12081. * The x component of the control stick
  12082. */
  12083. x: number;
  12084. /**
  12085. * The y component of the control stick
  12086. */
  12087. y: number;
  12088. /**
  12089. * Initializes the gamepad x and y control stick values
  12090. * @param x The x component of the gamepad control stick value
  12091. * @param y The y component of the gamepad control stick value
  12092. */
  12093. constructor(
  12094. /**
  12095. * The x component of the control stick
  12096. */
  12097. x: number,
  12098. /**
  12099. * The y component of the control stick
  12100. */
  12101. y: number);
  12102. }
  12103. /**
  12104. * An interface which manages callbacks for gamepad button changes
  12105. */
  12106. export interface GamepadButtonChanges {
  12107. /**
  12108. * Called when a gamepad has been changed
  12109. */
  12110. changed: boolean;
  12111. /**
  12112. * Called when a gamepad press event has been triggered
  12113. */
  12114. pressChanged: boolean;
  12115. /**
  12116. * Called when a touch event has been triggered
  12117. */
  12118. touchChanged: boolean;
  12119. /**
  12120. * Called when a value has changed
  12121. */
  12122. valueChanged: boolean;
  12123. }
  12124. /**
  12125. * Represents a gamepad
  12126. */
  12127. export class Gamepad {
  12128. /**
  12129. * The id of the gamepad
  12130. */
  12131. id: string;
  12132. /**
  12133. * The index of the gamepad
  12134. */
  12135. index: number;
  12136. /**
  12137. * The browser gamepad
  12138. */
  12139. browserGamepad: any;
  12140. /**
  12141. * Specifies what type of gamepad this represents
  12142. */
  12143. type: number;
  12144. private _leftStick;
  12145. private _rightStick;
  12146. /** @hidden */
  12147. _isConnected: boolean;
  12148. private _leftStickAxisX;
  12149. private _leftStickAxisY;
  12150. private _rightStickAxisX;
  12151. private _rightStickAxisY;
  12152. /**
  12153. * Triggered when the left control stick has been changed
  12154. */
  12155. private _onleftstickchanged;
  12156. /**
  12157. * Triggered when the right control stick has been changed
  12158. */
  12159. private _onrightstickchanged;
  12160. /**
  12161. * Represents a gamepad controller
  12162. */
  12163. static GAMEPAD: number;
  12164. /**
  12165. * Represents a generic controller
  12166. */
  12167. static GENERIC: number;
  12168. /**
  12169. * Represents an XBox controller
  12170. */
  12171. static XBOX: number;
  12172. /**
  12173. * Represents a pose-enabled controller
  12174. */
  12175. static POSE_ENABLED: number;
  12176. /**
  12177. * Represents an Dual Shock controller
  12178. */
  12179. static DUALSHOCK: number;
  12180. /**
  12181. * Specifies whether the left control stick should be Y-inverted
  12182. */
  12183. protected _invertLeftStickY: boolean;
  12184. /**
  12185. * Specifies if the gamepad has been connected
  12186. */
  12187. readonly isConnected: boolean;
  12188. /**
  12189. * Initializes the gamepad
  12190. * @param id The id of the gamepad
  12191. * @param index The index of the gamepad
  12192. * @param browserGamepad The browser gamepad
  12193. * @param leftStickX The x component of the left joystick
  12194. * @param leftStickY The y component of the left joystick
  12195. * @param rightStickX The x component of the right joystick
  12196. * @param rightStickY The y component of the right joystick
  12197. */
  12198. constructor(
  12199. /**
  12200. * The id of the gamepad
  12201. */
  12202. id: string,
  12203. /**
  12204. * The index of the gamepad
  12205. */
  12206. index: number,
  12207. /**
  12208. * The browser gamepad
  12209. */
  12210. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12211. /**
  12212. * Callback triggered when the left joystick has changed
  12213. * @param callback
  12214. */
  12215. onleftstickchanged(callback: (values: StickValues) => void): void;
  12216. /**
  12217. * Callback triggered when the right joystick has changed
  12218. * @param callback
  12219. */
  12220. onrightstickchanged(callback: (values: StickValues) => void): void;
  12221. /**
  12222. * Gets the left joystick
  12223. */
  12224. /**
  12225. * Sets the left joystick values
  12226. */
  12227. leftStick: StickValues;
  12228. /**
  12229. * Gets the right joystick
  12230. */
  12231. /**
  12232. * Sets the right joystick value
  12233. */
  12234. rightStick: StickValues;
  12235. /**
  12236. * Updates the gamepad joystick positions
  12237. */
  12238. update(): void;
  12239. /**
  12240. * Disposes the gamepad
  12241. */
  12242. dispose(): void;
  12243. }
  12244. /**
  12245. * Represents a generic gamepad
  12246. */
  12247. export class GenericPad extends Gamepad {
  12248. private _buttons;
  12249. private _onbuttondown;
  12250. private _onbuttonup;
  12251. /**
  12252. * Observable triggered when a button has been pressed
  12253. */
  12254. onButtonDownObservable: Observable<number>;
  12255. /**
  12256. * Observable triggered when a button has been released
  12257. */
  12258. onButtonUpObservable: Observable<number>;
  12259. /**
  12260. * Callback triggered when a button has been pressed
  12261. * @param callback Called when a button has been pressed
  12262. */
  12263. onbuttondown(callback: (buttonPressed: number) => void): void;
  12264. /**
  12265. * Callback triggered when a button has been released
  12266. * @param callback Called when a button has been released
  12267. */
  12268. onbuttonup(callback: (buttonReleased: number) => void): void;
  12269. /**
  12270. * Initializes the generic gamepad
  12271. * @param id The id of the generic gamepad
  12272. * @param index The index of the generic gamepad
  12273. * @param browserGamepad The browser gamepad
  12274. */
  12275. constructor(id: string, index: number, browserGamepad: any);
  12276. private _setButtonValue;
  12277. /**
  12278. * Updates the generic gamepad
  12279. */
  12280. update(): void;
  12281. /**
  12282. * Disposes the generic gamepad
  12283. */
  12284. dispose(): void;
  12285. }
  12286. }
  12287. declare module BABYLON {
  12288. interface Engine {
  12289. /**
  12290. * Creates a raw texture
  12291. * @param data defines the data to store in the texture
  12292. * @param width defines the width of the texture
  12293. * @param height defines the height of the texture
  12294. * @param format defines the format of the data
  12295. * @param generateMipMaps defines if the engine should generate the mip levels
  12296. * @param invertY defines if data must be stored with Y axis inverted
  12297. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12298. * @param compression defines the compression used (null by default)
  12299. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12300. * @returns the raw texture inside an InternalTexture
  12301. */
  12302. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12303. /**
  12304. * Update a raw texture
  12305. * @param texture defines the texture to update
  12306. * @param data defines the data to store in the texture
  12307. * @param format defines the format of the data
  12308. * @param invertY defines if data must be stored with Y axis inverted
  12309. */
  12310. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12311. /**
  12312. * Update a raw texture
  12313. * @param texture defines the texture to update
  12314. * @param data defines the data to store in the texture
  12315. * @param format defines the format of the data
  12316. * @param invertY defines if data must be stored with Y axis inverted
  12317. * @param compression defines the compression used (null by default)
  12318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12319. */
  12320. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12321. /**
  12322. * Creates a new raw cube texture
  12323. * @param data defines the array of data to use to create each face
  12324. * @param size defines the size of the textures
  12325. * @param format defines the format of the data
  12326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12327. * @param generateMipMaps defines if the engine should generate the mip levels
  12328. * @param invertY defines if data must be stored with Y axis inverted
  12329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12330. * @param compression defines the compression used (null by default)
  12331. * @returns the cube texture as an InternalTexture
  12332. */
  12333. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12334. /**
  12335. * Update a raw cube texture
  12336. * @param texture defines the texture to udpdate
  12337. * @param data defines the data to store
  12338. * @param format defines the data format
  12339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12340. * @param invertY defines if data must be stored with Y axis inverted
  12341. */
  12342. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12343. /**
  12344. * Update a raw cube texture
  12345. * @param texture defines the texture to udpdate
  12346. * @param data defines the data to store
  12347. * @param format defines the data format
  12348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12349. * @param invertY defines if data must be stored with Y axis inverted
  12350. * @param compression defines the compression used (null by default)
  12351. */
  12352. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12353. /**
  12354. * Update a raw cube texture
  12355. * @param texture defines the texture to udpdate
  12356. * @param data defines the data to store
  12357. * @param format defines the data format
  12358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12359. * @param invertY defines if data must be stored with Y axis inverted
  12360. * @param compression defines the compression used (null by default)
  12361. * @param level defines which level of the texture to update
  12362. */
  12363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12364. /**
  12365. * Creates a new raw cube texture from a specified url
  12366. * @param url defines the url where the data is located
  12367. * @param scene defines the current scene
  12368. * @param size defines the size of the textures
  12369. * @param format defines the format of the data
  12370. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12371. * @param noMipmap defines if the engine should avoid generating the mip levels
  12372. * @param callback defines a callback used to extract texture data from loaded data
  12373. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12374. * @param onLoad defines a callback called when texture is loaded
  12375. * @param onError defines a callback called if there is an error
  12376. * @returns the cube texture as an InternalTexture
  12377. */
  12378. 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;
  12379. /**
  12380. * Creates a new raw cube texture from a specified url
  12381. * @param url defines the url where the data is located
  12382. * @param scene defines the current scene
  12383. * @param size defines the size of the textures
  12384. * @param format defines the format of the data
  12385. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12386. * @param noMipmap defines if the engine should avoid generating the mip levels
  12387. * @param callback defines a callback used to extract texture data from loaded data
  12388. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12389. * @param onLoad defines a callback called when texture is loaded
  12390. * @param onError defines a callback called if there is an error
  12391. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12392. * @param invertY defines if data must be stored with Y axis inverted
  12393. * @returns the cube texture as an InternalTexture
  12394. */
  12395. 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;
  12396. /**
  12397. * Creates a new raw 3D texture
  12398. * @param data defines the data used to create the texture
  12399. * @param width defines the width of the texture
  12400. * @param height defines the height of the texture
  12401. * @param depth defines the depth of the texture
  12402. * @param format defines the format of the texture
  12403. * @param generateMipMaps defines if the engine must generate mip levels
  12404. * @param invertY defines if data must be stored with Y axis inverted
  12405. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12406. * @param compression defines the compressed used (can be null)
  12407. * @param textureType defines the compressed used (can be null)
  12408. * @returns a new raw 3D texture (stored in an InternalTexture)
  12409. */
  12410. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12411. /**
  12412. * Update a raw 3D texture
  12413. * @param texture defines the texture to update
  12414. * @param data defines the data to store
  12415. * @param format defines the data format
  12416. * @param invertY defines if data must be stored with Y axis inverted
  12417. */
  12418. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12419. /**
  12420. * Update a raw 3D texture
  12421. * @param texture defines the texture to update
  12422. * @param data defines the data to store
  12423. * @param format defines the data format
  12424. * @param invertY defines if data must be stored with Y axis inverted
  12425. * @param compression defines the used compression (can be null)
  12426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12427. */
  12428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12429. }
  12430. }
  12431. declare module BABYLON {
  12432. /**
  12433. * Raw texture can help creating a texture directly from an array of data.
  12434. * This can be super useful if you either get the data from an uncompressed source or
  12435. * if you wish to create your texture pixel by pixel.
  12436. */
  12437. export class RawTexture extends Texture {
  12438. /**
  12439. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12440. */
  12441. format: number;
  12442. private _engine;
  12443. /**
  12444. * Instantiates a new RawTexture.
  12445. * Raw texture can help creating a texture directly from an array of data.
  12446. * This can be super useful if you either get the data from an uncompressed source or
  12447. * if you wish to create your texture pixel by pixel.
  12448. * @param data define the array of data to use to create the texture
  12449. * @param width define the width of the texture
  12450. * @param height define the height of the texture
  12451. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12452. * @param scene define the scene the texture belongs to
  12453. * @param generateMipMaps define whether mip maps should be generated or not
  12454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12456. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12457. */
  12458. constructor(data: ArrayBufferView, width: number, height: number,
  12459. /**
  12460. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12461. */
  12462. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12463. /**
  12464. * Updates the texture underlying data.
  12465. * @param data Define the new data of the texture
  12466. */
  12467. update(data: ArrayBufferView): void;
  12468. /**
  12469. * Creates a luminance texture from some data.
  12470. * @param data Define the texture data
  12471. * @param width Define the width of the texture
  12472. * @param height Define the height of the texture
  12473. * @param scene Define the scene the texture belongs to
  12474. * @param generateMipMaps Define whether or not to create mip maps for the texture
  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. * @returns the luminance texture
  12478. */
  12479. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12480. /**
  12481. * Creates a luminance alpha texture from some data.
  12482. * @param data Define the texture data
  12483. * @param width Define the width of the texture
  12484. * @param height Define the height of the texture
  12485. * @param scene Define the scene the texture belongs to
  12486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12489. * @returns the luminance alpha texture
  12490. */
  12491. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12492. /**
  12493. * Creates an alpha texture from some data.
  12494. * @param data Define the texture data
  12495. * @param width Define the width of the texture
  12496. * @param height Define the height of the texture
  12497. * @param scene Define the scene the texture belongs to
  12498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12501. * @returns the alpha texture
  12502. */
  12503. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12504. /**
  12505. * Creates a RGB texture from some data.
  12506. * @param data Define the texture data
  12507. * @param width Define the width of the texture
  12508. * @param height Define the height of the texture
  12509. * @param scene Define the scene the texture belongs to
  12510. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12511. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12512. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12513. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12514. * @returns the RGB alpha texture
  12515. */
  12516. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12517. /**
  12518. * Creates a RGBA texture from some data.
  12519. * @param data Define the texture data
  12520. * @param width Define the width of the texture
  12521. * @param height Define the height of the texture
  12522. * @param scene Define the scene the texture belongs to
  12523. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12526. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12527. * @returns the RGBA texture
  12528. */
  12529. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12530. /**
  12531. * Creates a R texture from some data.
  12532. * @param data Define the texture data
  12533. * @param width Define the width of the texture
  12534. * @param height Define the height of the texture
  12535. * @param scene Define the scene the texture belongs to
  12536. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12537. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12538. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12539. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12540. * @returns the R texture
  12541. */
  12542. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12543. }
  12544. }
  12545. declare module BABYLON {
  12546. /**
  12547. * Interface for the size containing width and height
  12548. */
  12549. export interface ISize {
  12550. /**
  12551. * Width
  12552. */
  12553. width: number;
  12554. /**
  12555. * Heighht
  12556. */
  12557. height: number;
  12558. }
  12559. /**
  12560. * Size containing widht and height
  12561. */
  12562. export class Size implements ISize {
  12563. /**
  12564. * Width
  12565. */
  12566. width: number;
  12567. /**
  12568. * Height
  12569. */
  12570. height: number;
  12571. /**
  12572. * Creates a Size object from the given width and height (floats).
  12573. * @param width width of the new size
  12574. * @param height height of the new size
  12575. */
  12576. constructor(width: number, height: number);
  12577. /**
  12578. * Returns a string with the Size width and height
  12579. * @returns a string with the Size width and height
  12580. */
  12581. toString(): string;
  12582. /**
  12583. * "Size"
  12584. * @returns the string "Size"
  12585. */
  12586. getClassName(): string;
  12587. /**
  12588. * Returns the Size hash code.
  12589. * @returns a hash code for a unique width and height
  12590. */
  12591. getHashCode(): number;
  12592. /**
  12593. * Updates the current size from the given one.
  12594. * @param src the given size
  12595. */
  12596. copyFrom(src: Size): void;
  12597. /**
  12598. * Updates in place the current Size from the given floats.
  12599. * @param width width of the new size
  12600. * @param height height of the new size
  12601. * @returns the updated Size.
  12602. */
  12603. copyFromFloats(width: number, height: number): Size;
  12604. /**
  12605. * Updates in place the current Size from the given floats.
  12606. * @param width width to set
  12607. * @param height height to set
  12608. * @returns the updated Size.
  12609. */
  12610. set(width: number, height: number): Size;
  12611. /**
  12612. * Multiplies the width and height by numbers
  12613. * @param w factor to multiple the width by
  12614. * @param h factor to multiple the height by
  12615. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12616. */
  12617. multiplyByFloats(w: number, h: number): Size;
  12618. /**
  12619. * Clones the size
  12620. * @returns a new Size copied from the given one.
  12621. */
  12622. clone(): Size;
  12623. /**
  12624. * True if the current Size and the given one width and height are strictly equal.
  12625. * @param other the other size to compare against
  12626. * @returns True if the current Size and the given one width and height are strictly equal.
  12627. */
  12628. equals(other: Size): boolean;
  12629. /**
  12630. * The surface of the Size : width * height (float).
  12631. */
  12632. readonly surface: number;
  12633. /**
  12634. * Create a new size of zero
  12635. * @returns a new Size set to (0.0, 0.0)
  12636. */
  12637. static Zero(): Size;
  12638. /**
  12639. * Sums the width and height of two sizes
  12640. * @param otherSize size to add to this size
  12641. * @returns a new Size set as the addition result of the current Size and the given one.
  12642. */
  12643. add(otherSize: Size): Size;
  12644. /**
  12645. * Subtracts the width and height of two
  12646. * @param otherSize size to subtract to this size
  12647. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12648. */
  12649. subtract(otherSize: Size): Size;
  12650. /**
  12651. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12652. * @param start starting size to lerp between
  12653. * @param end end size to lerp between
  12654. * @param amount amount to lerp between the start and end values
  12655. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12656. */
  12657. static Lerp(start: Size, end: Size, amount: number): Size;
  12658. }
  12659. }
  12660. declare module BABYLON {
  12661. /**
  12662. * Defines a runtime animation
  12663. */
  12664. export class RuntimeAnimation {
  12665. private _events;
  12666. /**
  12667. * The current frame of the runtime animation
  12668. */
  12669. private _currentFrame;
  12670. /**
  12671. * The animation used by the runtime animation
  12672. */
  12673. private _animation;
  12674. /**
  12675. * The target of the runtime animation
  12676. */
  12677. private _target;
  12678. /**
  12679. * The initiating animatable
  12680. */
  12681. private _host;
  12682. /**
  12683. * The original value of the runtime animation
  12684. */
  12685. private _originalValue;
  12686. /**
  12687. * The original blend value of the runtime animation
  12688. */
  12689. private _originalBlendValue;
  12690. /**
  12691. * The offsets cache of the runtime animation
  12692. */
  12693. private _offsetsCache;
  12694. /**
  12695. * The high limits cache of the runtime animation
  12696. */
  12697. private _highLimitsCache;
  12698. /**
  12699. * Specifies if the runtime animation has been stopped
  12700. */
  12701. private _stopped;
  12702. /**
  12703. * The blending factor of the runtime animation
  12704. */
  12705. private _blendingFactor;
  12706. /**
  12707. * The BabylonJS scene
  12708. */
  12709. private _scene;
  12710. /**
  12711. * The current value of the runtime animation
  12712. */
  12713. private _currentValue;
  12714. /** @hidden */
  12715. _animationState: _IAnimationState;
  12716. /**
  12717. * The active target of the runtime animation
  12718. */
  12719. private _activeTargets;
  12720. private _currentActiveTarget;
  12721. private _directTarget;
  12722. /**
  12723. * The target path of the runtime animation
  12724. */
  12725. private _targetPath;
  12726. /**
  12727. * The weight of the runtime animation
  12728. */
  12729. private _weight;
  12730. /**
  12731. * The ratio offset of the runtime animation
  12732. */
  12733. private _ratioOffset;
  12734. /**
  12735. * The previous delay of the runtime animation
  12736. */
  12737. private _previousDelay;
  12738. /**
  12739. * The previous ratio of the runtime animation
  12740. */
  12741. private _previousRatio;
  12742. private _enableBlending;
  12743. private _keys;
  12744. private _minFrame;
  12745. private _maxFrame;
  12746. private _minValue;
  12747. private _maxValue;
  12748. private _targetIsArray;
  12749. /**
  12750. * Gets the current frame of the runtime animation
  12751. */
  12752. readonly currentFrame: number;
  12753. /**
  12754. * Gets the weight of the runtime animation
  12755. */
  12756. readonly weight: number;
  12757. /**
  12758. * Gets the current value of the runtime animation
  12759. */
  12760. readonly currentValue: any;
  12761. /**
  12762. * Gets the target path of the runtime animation
  12763. */
  12764. readonly targetPath: string;
  12765. /**
  12766. * Gets the actual target of the runtime animation
  12767. */
  12768. readonly target: any;
  12769. /** @hidden */
  12770. _onLoop: () => void;
  12771. /**
  12772. * Create a new RuntimeAnimation object
  12773. * @param target defines the target of the animation
  12774. * @param animation defines the source animation object
  12775. * @param scene defines the hosting scene
  12776. * @param host defines the initiating Animatable
  12777. */
  12778. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12779. private _preparePath;
  12780. /**
  12781. * Gets the animation from the runtime animation
  12782. */
  12783. readonly animation: Animation;
  12784. /**
  12785. * Resets the runtime animation to the beginning
  12786. * @param restoreOriginal defines whether to restore the target property to the original value
  12787. */
  12788. reset(restoreOriginal?: boolean): void;
  12789. /**
  12790. * Specifies if the runtime animation is stopped
  12791. * @returns Boolean specifying if the runtime animation is stopped
  12792. */
  12793. isStopped(): boolean;
  12794. /**
  12795. * Disposes of the runtime animation
  12796. */
  12797. dispose(): void;
  12798. /**
  12799. * Apply the interpolated value to the target
  12800. * @param currentValue defines the value computed by the animation
  12801. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12802. */
  12803. setValue(currentValue: any, weight: number): void;
  12804. private _getOriginalValues;
  12805. private _setValue;
  12806. /**
  12807. * Gets the loop pmode of the runtime animation
  12808. * @returns Loop Mode
  12809. */
  12810. private _getCorrectLoopMode;
  12811. /**
  12812. * Move the current animation to a given frame
  12813. * @param frame defines the frame to move to
  12814. */
  12815. goToFrame(frame: number): void;
  12816. /**
  12817. * @hidden Internal use only
  12818. */
  12819. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12820. /**
  12821. * Execute the current animation
  12822. * @param delay defines the delay to add to the current frame
  12823. * @param from defines the lower bound of the animation range
  12824. * @param to defines the upper bound of the animation range
  12825. * @param loop defines if the current animation must loop
  12826. * @param speedRatio defines the current speed ratio
  12827. * @param weight defines the weight of the animation (default is -1 so no weight)
  12828. * @param onLoop optional callback called when animation loops
  12829. * @returns a boolean indicating if the animation is running
  12830. */
  12831. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12832. }
  12833. }
  12834. declare module BABYLON {
  12835. /**
  12836. * Class used to store an actual running animation
  12837. */
  12838. export class Animatable {
  12839. /** defines the target object */
  12840. target: any;
  12841. /** defines the starting frame number (default is 0) */
  12842. fromFrame: number;
  12843. /** defines the ending frame number (default is 100) */
  12844. toFrame: number;
  12845. /** defines if the animation must loop (default is false) */
  12846. loopAnimation: boolean;
  12847. /** defines a callback to call when animation ends if it is not looping */
  12848. onAnimationEnd?: (() => void) | null | undefined;
  12849. /** defines a callback to call when animation loops */
  12850. onAnimationLoop?: (() => void) | null | undefined;
  12851. private _localDelayOffset;
  12852. private _pausedDelay;
  12853. private _runtimeAnimations;
  12854. private _paused;
  12855. private _scene;
  12856. private _speedRatio;
  12857. private _weight;
  12858. private _syncRoot;
  12859. /**
  12860. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12861. * This will only apply for non looping animation (default is true)
  12862. */
  12863. disposeOnEnd: boolean;
  12864. /**
  12865. * Gets a boolean indicating if the animation has started
  12866. */
  12867. animationStarted: boolean;
  12868. /**
  12869. * Observer raised when the animation ends
  12870. */
  12871. onAnimationEndObservable: Observable<Animatable>;
  12872. /**
  12873. * Observer raised when the animation loops
  12874. */
  12875. onAnimationLoopObservable: Observable<Animatable>;
  12876. /**
  12877. * Gets the root Animatable used to synchronize and normalize animations
  12878. */
  12879. readonly syncRoot: Nullable<Animatable>;
  12880. /**
  12881. * Gets the current frame of the first RuntimeAnimation
  12882. * Used to synchronize Animatables
  12883. */
  12884. readonly masterFrame: number;
  12885. /**
  12886. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12887. */
  12888. weight: number;
  12889. /**
  12890. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12891. */
  12892. speedRatio: number;
  12893. /**
  12894. * Creates a new Animatable
  12895. * @param scene defines the hosting scene
  12896. * @param target defines the target object
  12897. * @param fromFrame defines the starting frame number (default is 0)
  12898. * @param toFrame defines the ending frame number (default is 100)
  12899. * @param loopAnimation defines if the animation must loop (default is false)
  12900. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12901. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12902. * @param animations defines a group of animation to add to the new Animatable
  12903. * @param onAnimationLoop defines a callback to call when animation loops
  12904. */
  12905. constructor(scene: Scene,
  12906. /** defines the target object */
  12907. target: any,
  12908. /** defines the starting frame number (default is 0) */
  12909. fromFrame?: number,
  12910. /** defines the ending frame number (default is 100) */
  12911. toFrame?: number,
  12912. /** defines if the animation must loop (default is false) */
  12913. loopAnimation?: boolean, speedRatio?: number,
  12914. /** defines a callback to call when animation ends if it is not looping */
  12915. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12916. /** defines a callback to call when animation loops */
  12917. onAnimationLoop?: (() => void) | null | undefined);
  12918. /**
  12919. * Synchronize and normalize current Animatable with a source Animatable
  12920. * This is useful when using animation weights and when animations are not of the same length
  12921. * @param root defines the root Animatable to synchronize with
  12922. * @returns the current Animatable
  12923. */
  12924. syncWith(root: Animatable): Animatable;
  12925. /**
  12926. * Gets the list of runtime animations
  12927. * @returns an array of RuntimeAnimation
  12928. */
  12929. getAnimations(): RuntimeAnimation[];
  12930. /**
  12931. * Adds more animations to the current animatable
  12932. * @param target defines the target of the animations
  12933. * @param animations defines the new animations to add
  12934. */
  12935. appendAnimations(target: any, animations: Animation[]): void;
  12936. /**
  12937. * Gets the source animation for a specific property
  12938. * @param property defines the propertyu to look for
  12939. * @returns null or the source animation for the given property
  12940. */
  12941. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12942. /**
  12943. * Gets the runtime animation for a specific property
  12944. * @param property defines the propertyu to look for
  12945. * @returns null or the runtime animation for the given property
  12946. */
  12947. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12948. /**
  12949. * Resets the animatable to its original state
  12950. */
  12951. reset(): void;
  12952. /**
  12953. * Allows the animatable to blend with current running animations
  12954. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12955. * @param blendingSpeed defines the blending speed to use
  12956. */
  12957. enableBlending(blendingSpeed: number): void;
  12958. /**
  12959. * Disable animation blending
  12960. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12961. */
  12962. disableBlending(): void;
  12963. /**
  12964. * Jump directly to a given frame
  12965. * @param frame defines the frame to jump to
  12966. */
  12967. goToFrame(frame: number): void;
  12968. /**
  12969. * Pause the animation
  12970. */
  12971. pause(): void;
  12972. /**
  12973. * Restart the animation
  12974. */
  12975. restart(): void;
  12976. private _raiseOnAnimationEnd;
  12977. /**
  12978. * Stop and delete the current animation
  12979. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12980. * @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)
  12981. */
  12982. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12983. /**
  12984. * Wait asynchronously for the animation to end
  12985. * @returns a promise which will be fullfilled when the animation ends
  12986. */
  12987. waitAsync(): Promise<Animatable>;
  12988. /** @hidden */
  12989. _animate(delay: number): boolean;
  12990. }
  12991. interface Scene {
  12992. /** @hidden */
  12993. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12994. /** @hidden */
  12995. _processLateAnimationBindingsForMatrices(holder: {
  12996. totalWeight: number;
  12997. animations: RuntimeAnimation[];
  12998. originalValue: Matrix;
  12999. }): any;
  13000. /** @hidden */
  13001. _processLateAnimationBindingsForQuaternions(holder: {
  13002. totalWeight: number;
  13003. animations: RuntimeAnimation[];
  13004. originalValue: Quaternion;
  13005. }, refQuaternion: Quaternion): Quaternion;
  13006. /** @hidden */
  13007. _processLateAnimationBindings(): void;
  13008. /**
  13009. * Will start the animation sequence of a given target
  13010. * @param target defines the target
  13011. * @param from defines from which frame should animation start
  13012. * @param to defines until which frame should animation run.
  13013. * @param weight defines the weight to apply to the animation (1.0 by default)
  13014. * @param loop defines if the animation loops
  13015. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13016. * @param onAnimationEnd defines the function to be executed when the animation ends
  13017. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13018. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13019. * @param onAnimationLoop defines the callback to call when an animation loops
  13020. * @returns the animatable object created for this animation
  13021. */
  13022. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13023. /**
  13024. * Will start the animation sequence of a given target
  13025. * @param target defines the target
  13026. * @param from defines from which frame should animation start
  13027. * @param to defines until which frame should animation run.
  13028. * @param loop defines if the animation loops
  13029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13030. * @param onAnimationEnd defines the function to be executed when the animation ends
  13031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13032. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13033. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13034. * @param onAnimationLoop defines the callback to call when an animation loops
  13035. * @returns the animatable object created for this animation
  13036. */
  13037. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13038. /**
  13039. * Will start the animation sequence of a given target and its hierarchy
  13040. * @param target defines the target
  13041. * @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.
  13042. * @param from defines from which frame should animation start
  13043. * @param to defines until which frame should animation run.
  13044. * @param loop defines if the animation loops
  13045. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13046. * @param onAnimationEnd defines the function to be executed when the animation ends
  13047. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13048. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13049. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13050. * @param onAnimationLoop defines the callback to call when an animation loops
  13051. * @returns the list of created animatables
  13052. */
  13053. 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[];
  13054. /**
  13055. * Begin a new animation on a given node
  13056. * @param target defines the target where the animation will take place
  13057. * @param animations defines the list of animations to start
  13058. * @param from defines the initial value
  13059. * @param to defines the final value
  13060. * @param loop defines if you want animation to loop (off by default)
  13061. * @param speedRatio defines the speed ratio to apply to all animations
  13062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13063. * @param onAnimationLoop defines the callback to call when an animation loops
  13064. * @returns the list of created animatables
  13065. */
  13066. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13067. /**
  13068. * Begin a new animation on a given node and its hierarchy
  13069. * @param target defines the root node where the animation will take place
  13070. * @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.
  13071. * @param animations defines the list of animations to start
  13072. * @param from defines the initial value
  13073. * @param to defines the final value
  13074. * @param loop defines if you want animation to loop (off by default)
  13075. * @param speedRatio defines the speed ratio to apply to all animations
  13076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13077. * @param onAnimationLoop defines the callback to call when an animation loops
  13078. * @returns the list of animatables created for all nodes
  13079. */
  13080. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13081. /**
  13082. * Gets the animatable associated with a specific target
  13083. * @param target defines the target of the animatable
  13084. * @returns the required animatable if found
  13085. */
  13086. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13087. /**
  13088. * Gets all animatables associated with a given target
  13089. * @param target defines the target to look animatables for
  13090. * @returns an array of Animatables
  13091. */
  13092. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13093. /**
  13094. * Stops and removes all animations that have been applied to the scene
  13095. */
  13096. stopAllAnimations(): void;
  13097. }
  13098. interface Bone {
  13099. /**
  13100. * Copy an animation range from another bone
  13101. * @param source defines the source bone
  13102. * @param rangeName defines the range name to copy
  13103. * @param frameOffset defines the frame offset
  13104. * @param rescaleAsRequired defines if rescaling must be applied if required
  13105. * @param skelDimensionsRatio defines the scaling ratio
  13106. * @returns true if operation was successful
  13107. */
  13108. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13109. }
  13110. }
  13111. declare module BABYLON {
  13112. /**
  13113. * Class used to override all child animations of a given target
  13114. */
  13115. export class AnimationPropertiesOverride {
  13116. /**
  13117. * Gets or sets a value indicating if animation blending must be used
  13118. */
  13119. enableBlending: boolean;
  13120. /**
  13121. * Gets or sets the blending speed to use when enableBlending is true
  13122. */
  13123. blendingSpeed: number;
  13124. /**
  13125. * Gets or sets the default loop mode to use
  13126. */
  13127. loopMode: number;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * Class used to handle skinning animations
  13133. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13134. */
  13135. export class Skeleton implements IAnimatable {
  13136. /** defines the skeleton name */
  13137. name: string;
  13138. /** defines the skeleton Id */
  13139. id: string;
  13140. /**
  13141. * Defines the list of child bones
  13142. */
  13143. bones: Bone[];
  13144. /**
  13145. * Defines an estimate of the dimension of the skeleton at rest
  13146. */
  13147. dimensionsAtRest: Vector3;
  13148. /**
  13149. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13150. */
  13151. needInitialSkinMatrix: boolean;
  13152. /**
  13153. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13154. */
  13155. overrideMesh: Nullable<AbstractMesh>;
  13156. /**
  13157. * Gets the list of animations attached to this skeleton
  13158. */
  13159. animations: Array<Animation>;
  13160. private _scene;
  13161. private _isDirty;
  13162. private _transformMatrices;
  13163. private _transformMatrixTexture;
  13164. private _meshesWithPoseMatrix;
  13165. private _animatables;
  13166. private _identity;
  13167. private _synchronizedWithMesh;
  13168. private _ranges;
  13169. private _lastAbsoluteTransformsUpdateId;
  13170. private _canUseTextureForBones;
  13171. private _uniqueId;
  13172. /** @hidden */
  13173. _numBonesWithLinkedTransformNode: number;
  13174. /** @hidden */
  13175. _hasWaitingData: Nullable<boolean>;
  13176. /**
  13177. * Specifies if the skeleton should be serialized
  13178. */
  13179. doNotSerialize: boolean;
  13180. private _useTextureToStoreBoneMatrices;
  13181. /**
  13182. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13183. * Please note that this option is not available if the hardware does not support it
  13184. */
  13185. useTextureToStoreBoneMatrices: boolean;
  13186. private _animationPropertiesOverride;
  13187. /**
  13188. * Gets or sets the animation properties override
  13189. */
  13190. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13191. /**
  13192. * List of inspectable custom properties (used by the Inspector)
  13193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13194. */
  13195. inspectableCustomProperties: IInspectable[];
  13196. /**
  13197. * An observable triggered before computing the skeleton's matrices
  13198. */
  13199. onBeforeComputeObservable: Observable<Skeleton>;
  13200. /**
  13201. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13202. */
  13203. readonly isUsingTextureForMatrices: boolean;
  13204. /**
  13205. * Gets the unique ID of this skeleton
  13206. */
  13207. readonly uniqueId: number;
  13208. /**
  13209. * Creates a new skeleton
  13210. * @param name defines the skeleton name
  13211. * @param id defines the skeleton Id
  13212. * @param scene defines the hosting scene
  13213. */
  13214. constructor(
  13215. /** defines the skeleton name */
  13216. name: string,
  13217. /** defines the skeleton Id */
  13218. id: string, scene: Scene);
  13219. /**
  13220. * Gets the current object class name.
  13221. * @return the class name
  13222. */
  13223. getClassName(): string;
  13224. /**
  13225. * Returns an array containing the root bones
  13226. * @returns an array containing the root bones
  13227. */
  13228. getChildren(): Array<Bone>;
  13229. /**
  13230. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13231. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13232. * @returns a Float32Array containing matrices data
  13233. */
  13234. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13235. /**
  13236. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13237. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13238. * @returns a raw texture containing the data
  13239. */
  13240. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13241. /**
  13242. * Gets the current hosting scene
  13243. * @returns a scene object
  13244. */
  13245. getScene(): Scene;
  13246. /**
  13247. * Gets a string representing the current skeleton data
  13248. * @param fullDetails defines a boolean indicating if we want a verbose version
  13249. * @returns a string representing the current skeleton data
  13250. */
  13251. toString(fullDetails?: boolean): string;
  13252. /**
  13253. * Get bone's index searching by name
  13254. * @param name defines bone's name to search for
  13255. * @return the indice of the bone. Returns -1 if not found
  13256. */
  13257. getBoneIndexByName(name: string): number;
  13258. /**
  13259. * Creater a new animation range
  13260. * @param name defines the name of the range
  13261. * @param from defines the start key
  13262. * @param to defines the end key
  13263. */
  13264. createAnimationRange(name: string, from: number, to: number): void;
  13265. /**
  13266. * Delete a specific animation range
  13267. * @param name defines the name of the range
  13268. * @param deleteFrames defines if frames must be removed as well
  13269. */
  13270. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13271. /**
  13272. * Gets a specific animation range
  13273. * @param name defines the name of the range to look for
  13274. * @returns the requested animation range or null if not found
  13275. */
  13276. getAnimationRange(name: string): Nullable<AnimationRange>;
  13277. /**
  13278. * Gets the list of all animation ranges defined on this skeleton
  13279. * @returns an array
  13280. */
  13281. getAnimationRanges(): Nullable<AnimationRange>[];
  13282. /**
  13283. * Copy animation range from a source skeleton.
  13284. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13285. * @param source defines the source skeleton
  13286. * @param name defines the name of the range to copy
  13287. * @param rescaleAsRequired defines if rescaling must be applied if required
  13288. * @returns true if operation was successful
  13289. */
  13290. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13291. /**
  13292. * Forces the skeleton to go to rest pose
  13293. */
  13294. returnToRest(): void;
  13295. private _getHighestAnimationFrame;
  13296. /**
  13297. * Begin a specific animation range
  13298. * @param name defines the name of the range to start
  13299. * @param loop defines if looping must be turned on (false by default)
  13300. * @param speedRatio defines the speed ratio to apply (1 by default)
  13301. * @param onAnimationEnd defines a callback which will be called when animation will end
  13302. * @returns a new animatable
  13303. */
  13304. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13305. /** @hidden */
  13306. _markAsDirty(): void;
  13307. /** @hidden */
  13308. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13309. /** @hidden */
  13310. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13311. private _computeTransformMatrices;
  13312. /**
  13313. * Build all resources required to render a skeleton
  13314. */
  13315. prepare(): void;
  13316. /**
  13317. * Gets the list of animatables currently running for this skeleton
  13318. * @returns an array of animatables
  13319. */
  13320. getAnimatables(): IAnimatable[];
  13321. /**
  13322. * Clone the current skeleton
  13323. * @param name defines the name of the new skeleton
  13324. * @param id defines the id of the new skeleton
  13325. * @returns the new skeleton
  13326. */
  13327. clone(name: string, id: string): Skeleton;
  13328. /**
  13329. * Enable animation blending for this skeleton
  13330. * @param blendingSpeed defines the blending speed to apply
  13331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13332. */
  13333. enableBlending(blendingSpeed?: number): void;
  13334. /**
  13335. * Releases all resources associated with the current skeleton
  13336. */
  13337. dispose(): void;
  13338. /**
  13339. * Serialize the skeleton in a JSON object
  13340. * @returns a JSON object
  13341. */
  13342. serialize(): any;
  13343. /**
  13344. * Creates a new skeleton from serialized data
  13345. * @param parsedSkeleton defines the serialized data
  13346. * @param scene defines the hosting scene
  13347. * @returns a new skeleton
  13348. */
  13349. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13350. /**
  13351. * Compute all node absolute transforms
  13352. * @param forceUpdate defines if computation must be done even if cache is up to date
  13353. */
  13354. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13355. /**
  13356. * Gets the root pose matrix
  13357. * @returns a matrix
  13358. */
  13359. getPoseMatrix(): Nullable<Matrix>;
  13360. /**
  13361. * Sorts bones per internal index
  13362. */
  13363. sortBones(): void;
  13364. private _sortBones;
  13365. }
  13366. }
  13367. declare module BABYLON {
  13368. /**
  13369. * Class used to store bone information
  13370. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13371. */
  13372. export class Bone extends Node {
  13373. /**
  13374. * defines the bone name
  13375. */
  13376. name: string;
  13377. private static _tmpVecs;
  13378. private static _tmpQuat;
  13379. private static _tmpMats;
  13380. /**
  13381. * Gets the list of child bones
  13382. */
  13383. children: Bone[];
  13384. /** Gets the animations associated with this bone */
  13385. animations: Animation[];
  13386. /**
  13387. * Gets or sets bone length
  13388. */
  13389. length: number;
  13390. /**
  13391. * @hidden Internal only
  13392. * Set this value to map this bone to a different index in the transform matrices
  13393. * Set this value to -1 to exclude the bone from the transform matrices
  13394. */
  13395. _index: Nullable<number>;
  13396. private _skeleton;
  13397. private _localMatrix;
  13398. private _restPose;
  13399. private _baseMatrix;
  13400. private _absoluteTransform;
  13401. private _invertedAbsoluteTransform;
  13402. private _parent;
  13403. private _scalingDeterminant;
  13404. private _worldTransform;
  13405. private _localScaling;
  13406. private _localRotation;
  13407. private _localPosition;
  13408. private _needToDecompose;
  13409. private _needToCompose;
  13410. /** @hidden */
  13411. _linkedTransformNode: Nullable<TransformNode>;
  13412. /** @hidden */
  13413. _waitingTransformNodeId: Nullable<string>;
  13414. /** @hidden */
  13415. /** @hidden */
  13416. _matrix: Matrix;
  13417. /**
  13418. * Create a new bone
  13419. * @param name defines the bone name
  13420. * @param skeleton defines the parent skeleton
  13421. * @param parentBone defines the parent (can be null if the bone is the root)
  13422. * @param localMatrix defines the local matrix
  13423. * @param restPose defines the rest pose matrix
  13424. * @param baseMatrix defines the base matrix
  13425. * @param index defines index of the bone in the hiearchy
  13426. */
  13427. constructor(
  13428. /**
  13429. * defines the bone name
  13430. */
  13431. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13432. /**
  13433. * Gets the current object class name.
  13434. * @return the class name
  13435. */
  13436. getClassName(): string;
  13437. /**
  13438. * Gets the parent skeleton
  13439. * @returns a skeleton
  13440. */
  13441. getSkeleton(): Skeleton;
  13442. /**
  13443. * Gets parent bone
  13444. * @returns a bone or null if the bone is the root of the bone hierarchy
  13445. */
  13446. getParent(): Nullable<Bone>;
  13447. /**
  13448. * Returns an array containing the root bones
  13449. * @returns an array containing the root bones
  13450. */
  13451. getChildren(): Array<Bone>;
  13452. /**
  13453. * Sets the parent bone
  13454. * @param parent defines the parent (can be null if the bone is the root)
  13455. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13456. */
  13457. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13458. /**
  13459. * Gets the local matrix
  13460. * @returns a matrix
  13461. */
  13462. getLocalMatrix(): Matrix;
  13463. /**
  13464. * Gets the base matrix (initial matrix which remains unchanged)
  13465. * @returns a matrix
  13466. */
  13467. getBaseMatrix(): Matrix;
  13468. /**
  13469. * Gets the rest pose matrix
  13470. * @returns a matrix
  13471. */
  13472. getRestPose(): Matrix;
  13473. /**
  13474. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13475. */
  13476. getWorldMatrix(): Matrix;
  13477. /**
  13478. * Sets the local matrix to rest pose matrix
  13479. */
  13480. returnToRest(): void;
  13481. /**
  13482. * Gets the inverse of the absolute transform matrix.
  13483. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13484. * @returns a matrix
  13485. */
  13486. getInvertedAbsoluteTransform(): Matrix;
  13487. /**
  13488. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13489. * @returns a matrix
  13490. */
  13491. getAbsoluteTransform(): Matrix;
  13492. /**
  13493. * Links with the given transform node.
  13494. * The local matrix of this bone is copied from the transform node every frame.
  13495. * @param transformNode defines the transform node to link to
  13496. */
  13497. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13498. /**
  13499. * Gets the node used to drive the bone's transformation
  13500. * @returns a transform node or null
  13501. */
  13502. getTransformNode(): Nullable<TransformNode>;
  13503. /** Gets or sets current position (in local space) */
  13504. position: Vector3;
  13505. /** Gets or sets current rotation (in local space) */
  13506. rotation: Vector3;
  13507. /** Gets or sets current rotation quaternion (in local space) */
  13508. rotationQuaternion: Quaternion;
  13509. /** Gets or sets current scaling (in local space) */
  13510. scaling: Vector3;
  13511. /**
  13512. * Gets the animation properties override
  13513. */
  13514. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13515. private _decompose;
  13516. private _compose;
  13517. /**
  13518. * Update the base and local matrices
  13519. * @param matrix defines the new base or local matrix
  13520. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13521. * @param updateLocalMatrix defines if the local matrix should be updated
  13522. */
  13523. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13524. /** @hidden */
  13525. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13526. /**
  13527. * Flag the bone as dirty (Forcing it to update everything)
  13528. */
  13529. markAsDirty(): void;
  13530. /** @hidden */
  13531. _markAsDirtyAndCompose(): void;
  13532. private _markAsDirtyAndDecompose;
  13533. /**
  13534. * Translate the bone in local or world space
  13535. * @param vec The amount to translate the bone
  13536. * @param space The space that the translation is in
  13537. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13538. */
  13539. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13540. /**
  13541. * Set the postion of the bone in local or world space
  13542. * @param position The position to set the bone
  13543. * @param space The space that the position is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13547. /**
  13548. * Set the absolute position of the bone (world space)
  13549. * @param position The position to set the bone
  13550. * @param mesh The mesh that this bone is attached to
  13551. */
  13552. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13553. /**
  13554. * Scale the bone on the x, y and z axes (in local space)
  13555. * @param x The amount to scale the bone on the x axis
  13556. * @param y The amount to scale the bone on the y axis
  13557. * @param z The amount to scale the bone on the z axis
  13558. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13559. */
  13560. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13561. /**
  13562. * Set the bone scaling in local space
  13563. * @param scale defines the scaling vector
  13564. */
  13565. setScale(scale: Vector3): void;
  13566. /**
  13567. * Gets the current scaling in local space
  13568. * @returns the current scaling vector
  13569. */
  13570. getScale(): Vector3;
  13571. /**
  13572. * Gets the current scaling in local space and stores it in a target vector
  13573. * @param result defines the target vector
  13574. */
  13575. getScaleToRef(result: Vector3): void;
  13576. /**
  13577. * Set the yaw, pitch, and roll of the bone in local or world space
  13578. * @param yaw The rotation of the bone on the y axis
  13579. * @param pitch The rotation of the bone on the x axis
  13580. * @param roll The rotation of the bone on the z axis
  13581. * @param space The space that the axes of rotation are in
  13582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13583. */
  13584. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13585. /**
  13586. * Add a rotation to the bone on an axis in local or world space
  13587. * @param axis The axis to rotate the bone on
  13588. * @param amount The amount to rotate the bone
  13589. * @param space The space that the axis is in
  13590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13591. */
  13592. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13593. /**
  13594. * Set the rotation of the bone to a particular axis angle in local or world space
  13595. * @param axis The axis to rotate the bone on
  13596. * @param angle The angle that the bone should be rotated to
  13597. * @param space The space that the axis is in
  13598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13599. */
  13600. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13601. /**
  13602. * Set the euler rotation of the bone in local of world space
  13603. * @param rotation The euler rotation that the bone should be set to
  13604. * @param space The space that the rotation is in
  13605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13606. */
  13607. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13608. /**
  13609. * Set the quaternion rotation of the bone in local of world space
  13610. * @param quat The quaternion rotation that the bone should be set to
  13611. * @param space The space that the rotation is in
  13612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13613. */
  13614. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13615. /**
  13616. * Set the rotation matrix of the bone in local of world space
  13617. * @param rotMat The rotation matrix that the bone should be set to
  13618. * @param space The space that the rotation is in
  13619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13620. */
  13621. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13622. private _rotateWithMatrix;
  13623. private _getNegativeRotationToRef;
  13624. /**
  13625. * Get the position of the bone in local or world space
  13626. * @param space The space that the returned position is in
  13627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13628. * @returns The position of the bone
  13629. */
  13630. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13631. /**
  13632. * Copy the position of the bone to a vector3 in local or world space
  13633. * @param space The space that the returned position is in
  13634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13635. * @param result The vector3 to copy the position to
  13636. */
  13637. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13638. /**
  13639. * Get the absolute position of the bone (world space)
  13640. * @param mesh The mesh that this bone is attached to
  13641. * @returns The absolute position of the bone
  13642. */
  13643. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13644. /**
  13645. * Copy the absolute position of the bone (world space) to the result param
  13646. * @param mesh The mesh that this bone is attached to
  13647. * @param result The vector3 to copy the absolute position to
  13648. */
  13649. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13650. /**
  13651. * Compute the absolute transforms of this bone and its children
  13652. */
  13653. computeAbsoluteTransforms(): void;
  13654. /**
  13655. * Get the world direction from an axis that is in the local space of the bone
  13656. * @param localAxis The local direction that is used to compute the world direction
  13657. * @param mesh The mesh that this bone is attached to
  13658. * @returns The world direction
  13659. */
  13660. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13661. /**
  13662. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13663. * @param localAxis The local direction that is used to compute the world direction
  13664. * @param mesh The mesh that this bone is attached to
  13665. * @param result The vector3 that the world direction will be copied to
  13666. */
  13667. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13668. /**
  13669. * Get the euler rotation of the bone in local or world space
  13670. * @param space The space that the rotation should be in
  13671. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13672. * @returns The euler rotation
  13673. */
  13674. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13675. /**
  13676. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13677. * @param space The space that the rotation should be in
  13678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13679. * @param result The vector3 that the rotation should be copied to
  13680. */
  13681. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13682. /**
  13683. * Get the quaternion rotation of the bone in either local or world space
  13684. * @param space The space that the rotation should be in
  13685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13686. * @returns The quaternion rotation
  13687. */
  13688. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13689. /**
  13690. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13691. * @param space The space that the rotation should be in
  13692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13693. * @param result The quaternion that the rotation should be copied to
  13694. */
  13695. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13696. /**
  13697. * Get the rotation matrix of the bone in local or world space
  13698. * @param space The space that the rotation should be in
  13699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13700. * @returns The rotation matrix
  13701. */
  13702. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13703. /**
  13704. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13705. * @param space The space that the rotation should be in
  13706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13707. * @param result The quaternion that the rotation should be copied to
  13708. */
  13709. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13710. /**
  13711. * Get the world position of a point that is in the local space of the bone
  13712. * @param position The local position
  13713. * @param mesh The mesh that this bone is attached to
  13714. * @returns The world position
  13715. */
  13716. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13717. /**
  13718. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13719. * @param position The local position
  13720. * @param mesh The mesh that this bone is attached to
  13721. * @param result The vector3 that the world position should be copied to
  13722. */
  13723. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13724. /**
  13725. * Get the local position of a point that is in world space
  13726. * @param position The world position
  13727. * @param mesh The mesh that this bone is attached to
  13728. * @returns The local position
  13729. */
  13730. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13731. /**
  13732. * Get the local position of a point that is in world space and copy it to the result param
  13733. * @param position The world position
  13734. * @param mesh The mesh that this bone is attached to
  13735. * @param result The vector3 that the local position should be copied to
  13736. */
  13737. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * 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.
  13743. * @see https://doc.babylonjs.com/how_to/transformnode
  13744. */
  13745. export class TransformNode extends Node {
  13746. /**
  13747. * Object will not rotate to face the camera
  13748. */
  13749. static BILLBOARDMODE_NONE: number;
  13750. /**
  13751. * Object will rotate to face the camera but only on the x axis
  13752. */
  13753. static BILLBOARDMODE_X: number;
  13754. /**
  13755. * Object will rotate to face the camera but only on the y axis
  13756. */
  13757. static BILLBOARDMODE_Y: number;
  13758. /**
  13759. * Object will rotate to face the camera but only on the z axis
  13760. */
  13761. static BILLBOARDMODE_Z: number;
  13762. /**
  13763. * Object will rotate to face the camera
  13764. */
  13765. static BILLBOARDMODE_ALL: number;
  13766. /**
  13767. * Object will rotate to face the camera's position instead of orientation
  13768. */
  13769. static BILLBOARDMODE_USE_POSITION: number;
  13770. private _forward;
  13771. private _forwardInverted;
  13772. private _up;
  13773. private _right;
  13774. private _rightInverted;
  13775. private _position;
  13776. private _rotation;
  13777. private _rotationQuaternion;
  13778. protected _scaling: Vector3;
  13779. protected _isDirty: boolean;
  13780. private _transformToBoneReferal;
  13781. private _isAbsoluteSynced;
  13782. private _billboardMode;
  13783. /**
  13784. * Gets or sets the billboard mode. Default is 0.
  13785. *
  13786. * | Value | Type | Description |
  13787. * | --- | --- | --- |
  13788. * | 0 | BILLBOARDMODE_NONE | |
  13789. * | 1 | BILLBOARDMODE_X | |
  13790. * | 2 | BILLBOARDMODE_Y | |
  13791. * | 4 | BILLBOARDMODE_Z | |
  13792. * | 7 | BILLBOARDMODE_ALL | |
  13793. *
  13794. */
  13795. billboardMode: number;
  13796. private _preserveParentRotationForBillboard;
  13797. /**
  13798. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13799. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13800. */
  13801. preserveParentRotationForBillboard: boolean;
  13802. /**
  13803. * 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
  13804. */
  13805. scalingDeterminant: number;
  13806. private _infiniteDistance;
  13807. /**
  13808. * Gets or sets the distance of the object to max, often used by skybox
  13809. */
  13810. infiniteDistance: boolean;
  13811. /**
  13812. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13813. * By default the system will update normals to compensate
  13814. */
  13815. ignoreNonUniformScaling: boolean;
  13816. /**
  13817. * 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
  13818. */
  13819. reIntegrateRotationIntoRotationQuaternion: boolean;
  13820. /** @hidden */
  13821. _poseMatrix: Nullable<Matrix>;
  13822. /** @hidden */
  13823. _localMatrix: Matrix;
  13824. private _usePivotMatrix;
  13825. private _absolutePosition;
  13826. private _absoluteScaling;
  13827. private _absoluteRotationQuaternion;
  13828. private _pivotMatrix;
  13829. private _pivotMatrixInverse;
  13830. protected _postMultiplyPivotMatrix: boolean;
  13831. protected _isWorldMatrixFrozen: boolean;
  13832. /** @hidden */
  13833. _indexInSceneTransformNodesArray: number;
  13834. /**
  13835. * An event triggered after the world matrix is updated
  13836. */
  13837. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13838. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13839. /**
  13840. * Gets a string identifying the name of the class
  13841. * @returns "TransformNode" string
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13846. */
  13847. position: Vector3;
  13848. /**
  13849. * 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)).
  13850. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13851. */
  13852. rotation: Vector3;
  13853. /**
  13854. * 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)).
  13855. */
  13856. scaling: Vector3;
  13857. /**
  13858. * 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).
  13859. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13860. */
  13861. rotationQuaternion: Nullable<Quaternion>;
  13862. /**
  13863. * The forward direction of that transform in world space.
  13864. */
  13865. readonly forward: Vector3;
  13866. /**
  13867. * The up direction of that transform in world space.
  13868. */
  13869. readonly up: Vector3;
  13870. /**
  13871. * The right direction of that transform in world space.
  13872. */
  13873. readonly right: Vector3;
  13874. /**
  13875. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13876. * @param matrix the matrix to copy the pose from
  13877. * @returns this TransformNode.
  13878. */
  13879. updatePoseMatrix(matrix: Matrix): TransformNode;
  13880. /**
  13881. * Returns the mesh Pose matrix.
  13882. * @returns the pose matrix
  13883. */
  13884. getPoseMatrix(): Matrix;
  13885. /** @hidden */
  13886. _isSynchronized(): boolean;
  13887. /** @hidden */
  13888. _initCache(): void;
  13889. /**
  13890. * Flag the transform node as dirty (Forcing it to update everything)
  13891. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13892. * @returns this transform node
  13893. */
  13894. markAsDirty(property: string): TransformNode;
  13895. /**
  13896. * Returns the current mesh absolute position.
  13897. * Returns a Vector3.
  13898. */
  13899. readonly absolutePosition: Vector3;
  13900. /**
  13901. * Returns the current mesh absolute scaling.
  13902. * Returns a Vector3.
  13903. */
  13904. readonly absoluteScaling: Vector3;
  13905. /**
  13906. * Returns the current mesh absolute rotation.
  13907. * Returns a Quaternion.
  13908. */
  13909. readonly absoluteRotationQuaternion: Quaternion;
  13910. /**
  13911. * Sets a new matrix to apply before all other transformation
  13912. * @param matrix defines the transform matrix
  13913. * @returns the current TransformNode
  13914. */
  13915. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13916. /**
  13917. * Sets a new pivot matrix to the current node
  13918. * @param matrix defines the new pivot matrix to use
  13919. * @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
  13920. * @returns the current TransformNode
  13921. */
  13922. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13923. /**
  13924. * Returns the mesh pivot matrix.
  13925. * Default : Identity.
  13926. * @returns the matrix
  13927. */
  13928. getPivotMatrix(): Matrix;
  13929. /**
  13930. * Instantiate (when possible) or clone that node with its hierarchy
  13931. * @param newParent defines the new parent to use for the instance (or clone)
  13932. * @returns an instance (or a clone) of the current node with its hiearchy
  13933. */
  13934. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13935. /**
  13936. * Prevents the World matrix to be computed any longer
  13937. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13938. * @returns the TransformNode.
  13939. */
  13940. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13941. /**
  13942. * Allows back the World matrix computation.
  13943. * @returns the TransformNode.
  13944. */
  13945. unfreezeWorldMatrix(): this;
  13946. /**
  13947. * True if the World matrix has been frozen.
  13948. */
  13949. readonly isWorldMatrixFrozen: boolean;
  13950. /**
  13951. * Retuns the mesh absolute position in the World.
  13952. * @returns a Vector3.
  13953. */
  13954. getAbsolutePosition(): Vector3;
  13955. /**
  13956. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13957. * @param absolutePosition the absolute position to set
  13958. * @returns the TransformNode.
  13959. */
  13960. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13961. /**
  13962. * Sets the mesh position in its local space.
  13963. * @param vector3 the position to set in localspace
  13964. * @returns the TransformNode.
  13965. */
  13966. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13967. /**
  13968. * Returns the mesh position in the local space from the current World matrix values.
  13969. * @returns a new Vector3.
  13970. */
  13971. getPositionExpressedInLocalSpace(): Vector3;
  13972. /**
  13973. * Translates the mesh along the passed Vector3 in its local space.
  13974. * @param vector3 the distance to translate in localspace
  13975. * @returns the TransformNode.
  13976. */
  13977. locallyTranslate(vector3: Vector3): TransformNode;
  13978. private static _lookAtVectorCache;
  13979. /**
  13980. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13981. * @param targetPoint the position (must be in same space as current mesh) to look at
  13982. * @param yawCor optional yaw (y-axis) correction in radians
  13983. * @param pitchCor optional pitch (x-axis) correction in radians
  13984. * @param rollCor optional roll (z-axis) correction in radians
  13985. * @param space the choosen space of the target
  13986. * @returns the TransformNode.
  13987. */
  13988. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13989. /**
  13990. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13991. * This Vector3 is expressed in the World space.
  13992. * @param localAxis axis to rotate
  13993. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13994. */
  13995. getDirection(localAxis: Vector3): Vector3;
  13996. /**
  13997. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13998. * localAxis is expressed in the mesh local space.
  13999. * result is computed in the Wordl space from the mesh World matrix.
  14000. * @param localAxis axis to rotate
  14001. * @param result the resulting transformnode
  14002. * @returns this TransformNode.
  14003. */
  14004. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14005. /**
  14006. * Sets this transform node rotation to the given local axis.
  14007. * @param localAxis the axis in local space
  14008. * @param yawCor optional yaw (y-axis) correction in radians
  14009. * @param pitchCor optional pitch (x-axis) correction in radians
  14010. * @param rollCor optional roll (z-axis) correction in radians
  14011. * @returns this TransformNode
  14012. */
  14013. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14014. /**
  14015. * Sets a new pivot point to the current node
  14016. * @param point defines the new pivot point to use
  14017. * @param space defines if the point is in world or local space (local by default)
  14018. * @returns the current TransformNode
  14019. */
  14020. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14021. /**
  14022. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14023. * @returns the pivot point
  14024. */
  14025. getPivotPoint(): Vector3;
  14026. /**
  14027. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14028. * @param result the vector3 to store the result
  14029. * @returns this TransformNode.
  14030. */
  14031. getPivotPointToRef(result: Vector3): TransformNode;
  14032. /**
  14033. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14034. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14035. */
  14036. getAbsolutePivotPoint(): Vector3;
  14037. /**
  14038. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14039. * @param result vector3 to store the result
  14040. * @returns this TransformNode.
  14041. */
  14042. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14043. /**
  14044. * Defines the passed node as the parent of the current node.
  14045. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14046. * @see https://doc.babylonjs.com/how_to/parenting
  14047. * @param node the node ot set as the parent
  14048. * @returns this TransformNode.
  14049. */
  14050. setParent(node: Nullable<Node>): TransformNode;
  14051. private _nonUniformScaling;
  14052. /**
  14053. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14054. */
  14055. readonly nonUniformScaling: boolean;
  14056. /** @hidden */
  14057. _updateNonUniformScalingState(value: boolean): boolean;
  14058. /**
  14059. * Attach the current TransformNode to another TransformNode associated with a bone
  14060. * @param bone Bone affecting the TransformNode
  14061. * @param affectedTransformNode TransformNode associated with the bone
  14062. * @returns this object
  14063. */
  14064. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14065. /**
  14066. * Detach the transform node if its associated with a bone
  14067. * @returns this object
  14068. */
  14069. detachFromBone(): TransformNode;
  14070. private static _rotationAxisCache;
  14071. /**
  14072. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14073. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14075. * The passed axis is also normalized.
  14076. * @param axis the axis to rotate around
  14077. * @param amount the amount to rotate in radians
  14078. * @param space Space to rotate in (Default: local)
  14079. * @returns the TransformNode.
  14080. */
  14081. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14082. /**
  14083. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14084. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14085. * The passed axis is also normalized. .
  14086. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14087. * @param point the point to rotate around
  14088. * @param axis the axis to rotate around
  14089. * @param amount the amount to rotate in radians
  14090. * @returns the TransformNode
  14091. */
  14092. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14093. /**
  14094. * Translates the mesh along the axis vector for the passed distance in the given space.
  14095. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14096. * @param axis the axis to translate in
  14097. * @param distance the distance to translate
  14098. * @param space Space to rotate in (Default: local)
  14099. * @returns the TransformNode.
  14100. */
  14101. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14102. /**
  14103. * Adds a rotation step to the mesh current rotation.
  14104. * x, y, z are Euler angles expressed in radians.
  14105. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14106. * This means this rotation is made in the mesh local space only.
  14107. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14108. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14109. * ```javascript
  14110. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14111. * ```
  14112. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14113. * 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.
  14114. * @param x Rotation to add
  14115. * @param y Rotation to add
  14116. * @param z Rotation to add
  14117. * @returns the TransformNode.
  14118. */
  14119. addRotation(x: number, y: number, z: number): TransformNode;
  14120. /**
  14121. * @hidden
  14122. */
  14123. protected _getEffectiveParent(): Nullable<Node>;
  14124. /**
  14125. * Computes the world matrix of the node
  14126. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14127. * @returns the world matrix
  14128. */
  14129. computeWorldMatrix(force?: boolean): Matrix;
  14130. protected _afterComputeWorldMatrix(): void;
  14131. /**
  14132. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14133. * @param func callback function to add
  14134. *
  14135. * @returns the TransformNode.
  14136. */
  14137. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14138. /**
  14139. * Removes a registered callback function.
  14140. * @param func callback function to remove
  14141. * @returns the TransformNode.
  14142. */
  14143. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14144. /**
  14145. * Gets the position of the current mesh in camera space
  14146. * @param camera defines the camera to use
  14147. * @returns a position
  14148. */
  14149. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14150. /**
  14151. * Returns the distance from the mesh to the active camera
  14152. * @param camera defines the camera to use
  14153. * @returns the distance
  14154. */
  14155. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14156. /**
  14157. * Clone the current transform node
  14158. * @param name Name of the new clone
  14159. * @param newParent New parent for the clone
  14160. * @param doNotCloneChildren Do not clone children hierarchy
  14161. * @returns the new transform node
  14162. */
  14163. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14164. /**
  14165. * Serializes the objects information.
  14166. * @param currentSerializationObject defines the object to serialize in
  14167. * @returns the serialized object
  14168. */
  14169. serialize(currentSerializationObject?: any): any;
  14170. /**
  14171. * Returns a new TransformNode object parsed from the source provided.
  14172. * @param parsedTransformNode is the source.
  14173. * @param scene the scne the object belongs to
  14174. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14175. * @returns a new TransformNode object parsed from the source provided.
  14176. */
  14177. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14178. /**
  14179. * Get all child-transformNodes of this node
  14180. * @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
  14181. * @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
  14182. * @returns an array of TransformNode
  14183. */
  14184. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14185. /**
  14186. * Releases resources associated with this transform node.
  14187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14189. */
  14190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14191. /**
  14192. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14193. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14194. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14195. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14196. * @returns the current mesh
  14197. */
  14198. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14199. private _syncAbsoluteScalingAndRotation;
  14200. }
  14201. }
  14202. declare module BABYLON {
  14203. /**
  14204. * Defines the types of pose enabled controllers that are supported
  14205. */
  14206. export enum PoseEnabledControllerType {
  14207. /**
  14208. * HTC Vive
  14209. */
  14210. VIVE = 0,
  14211. /**
  14212. * Oculus Rift
  14213. */
  14214. OCULUS = 1,
  14215. /**
  14216. * Windows mixed reality
  14217. */
  14218. WINDOWS = 2,
  14219. /**
  14220. * Samsung gear VR
  14221. */
  14222. GEAR_VR = 3,
  14223. /**
  14224. * Google Daydream
  14225. */
  14226. DAYDREAM = 4,
  14227. /**
  14228. * Generic
  14229. */
  14230. GENERIC = 5
  14231. }
  14232. /**
  14233. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14234. */
  14235. export interface MutableGamepadButton {
  14236. /**
  14237. * Value of the button/trigger
  14238. */
  14239. value: number;
  14240. /**
  14241. * If the button/trigger is currently touched
  14242. */
  14243. touched: boolean;
  14244. /**
  14245. * If the button/trigger is currently pressed
  14246. */
  14247. pressed: boolean;
  14248. }
  14249. /**
  14250. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14251. * @hidden
  14252. */
  14253. export interface ExtendedGamepadButton extends GamepadButton {
  14254. /**
  14255. * If the button/trigger is currently pressed
  14256. */
  14257. readonly pressed: boolean;
  14258. /**
  14259. * If the button/trigger is currently touched
  14260. */
  14261. readonly touched: boolean;
  14262. /**
  14263. * Value of the button/trigger
  14264. */
  14265. readonly value: number;
  14266. }
  14267. /** @hidden */
  14268. export interface _GamePadFactory {
  14269. /**
  14270. * Returns wether or not the current gamepad can be created for this type of controller.
  14271. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14272. * @returns true if it can be created, otherwise false
  14273. */
  14274. canCreate(gamepadInfo: any): boolean;
  14275. /**
  14276. * Creates a new instance of the Gamepad.
  14277. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14278. * @returns the new gamepad instance
  14279. */
  14280. create(gamepadInfo: any): Gamepad;
  14281. }
  14282. /**
  14283. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14284. */
  14285. export class PoseEnabledControllerHelper {
  14286. /** @hidden */
  14287. static _ControllerFactories: _GamePadFactory[];
  14288. /** @hidden */
  14289. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14290. /**
  14291. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14292. * @param vrGamepad the gamepad to initialized
  14293. * @returns a vr controller of the type the gamepad identified as
  14294. */
  14295. static InitiateController(vrGamepad: any): Gamepad;
  14296. }
  14297. /**
  14298. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14299. */
  14300. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14301. /**
  14302. * If the controller is used in a webXR session
  14303. */
  14304. isXR: boolean;
  14305. private _deviceRoomPosition;
  14306. private _deviceRoomRotationQuaternion;
  14307. /**
  14308. * The device position in babylon space
  14309. */
  14310. devicePosition: Vector3;
  14311. /**
  14312. * The device rotation in babylon space
  14313. */
  14314. deviceRotationQuaternion: Quaternion;
  14315. /**
  14316. * The scale factor of the device in babylon space
  14317. */
  14318. deviceScaleFactor: number;
  14319. /**
  14320. * (Likely devicePosition should be used instead) The device position in its room space
  14321. */
  14322. position: Vector3;
  14323. /**
  14324. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14325. */
  14326. rotationQuaternion: Quaternion;
  14327. /**
  14328. * The type of controller (Eg. Windows mixed reality)
  14329. */
  14330. controllerType: PoseEnabledControllerType;
  14331. protected _calculatedPosition: Vector3;
  14332. private _calculatedRotation;
  14333. /**
  14334. * The raw pose from the device
  14335. */
  14336. rawPose: DevicePose;
  14337. private _trackPosition;
  14338. private _maxRotationDistFromHeadset;
  14339. private _draggedRoomRotation;
  14340. /**
  14341. * @hidden
  14342. */
  14343. _disableTrackPosition(fixedPosition: Vector3): void;
  14344. /**
  14345. * Internal, the mesh attached to the controller
  14346. * @hidden
  14347. */
  14348. _mesh: Nullable<AbstractMesh>;
  14349. private _poseControlledCamera;
  14350. private _leftHandSystemQuaternion;
  14351. /**
  14352. * Internal, matrix used to convert room space to babylon space
  14353. * @hidden
  14354. */
  14355. _deviceToWorld: Matrix;
  14356. /**
  14357. * Node to be used when casting a ray from the controller
  14358. * @hidden
  14359. */
  14360. _pointingPoseNode: Nullable<TransformNode>;
  14361. /**
  14362. * Name of the child mesh that can be used to cast a ray from the controller
  14363. */
  14364. static readonly POINTING_POSE: string;
  14365. /**
  14366. * Creates a new PoseEnabledController from a gamepad
  14367. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14368. */
  14369. constructor(browserGamepad: any);
  14370. private _workingMatrix;
  14371. /**
  14372. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14373. */
  14374. update(): void;
  14375. /**
  14376. * Updates only the pose device and mesh without doing any button event checking
  14377. */
  14378. protected _updatePoseAndMesh(): void;
  14379. /**
  14380. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14381. * @param poseData raw pose fromthe device
  14382. */
  14383. updateFromDevice(poseData: DevicePose): void;
  14384. /**
  14385. * @hidden
  14386. */
  14387. _meshAttachedObservable: Observable<AbstractMesh>;
  14388. /**
  14389. * Attaches a mesh to the controller
  14390. * @param mesh the mesh to be attached
  14391. */
  14392. attachToMesh(mesh: AbstractMesh): void;
  14393. /**
  14394. * Attaches the controllers mesh to a camera
  14395. * @param camera the camera the mesh should be attached to
  14396. */
  14397. attachToPoseControlledCamera(camera: TargetCamera): void;
  14398. /**
  14399. * Disposes of the controller
  14400. */
  14401. dispose(): void;
  14402. /**
  14403. * The mesh that is attached to the controller
  14404. */
  14405. readonly mesh: Nullable<AbstractMesh>;
  14406. /**
  14407. * Gets the ray of the controller in the direction the controller is pointing
  14408. * @param length the length the resulting ray should be
  14409. * @returns a ray in the direction the controller is pointing
  14410. */
  14411. getForwardRay(length?: number): Ray;
  14412. }
  14413. }
  14414. declare module BABYLON {
  14415. /**
  14416. * Defines the WebVRController object that represents controllers tracked in 3D space
  14417. */
  14418. export abstract class WebVRController extends PoseEnabledController {
  14419. /**
  14420. * Internal, the default controller model for the controller
  14421. */
  14422. protected _defaultModel: AbstractMesh;
  14423. /**
  14424. * Fired when the trigger state has changed
  14425. */
  14426. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14427. /**
  14428. * Fired when the main button state has changed
  14429. */
  14430. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14431. /**
  14432. * Fired when the secondary button state has changed
  14433. */
  14434. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14435. /**
  14436. * Fired when the pad state has changed
  14437. */
  14438. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14439. /**
  14440. * Fired when controllers stick values have changed
  14441. */
  14442. onPadValuesChangedObservable: Observable<StickValues>;
  14443. /**
  14444. * Array of button availible on the controller
  14445. */
  14446. protected _buttons: Array<MutableGamepadButton>;
  14447. private _onButtonStateChange;
  14448. /**
  14449. * Fired when a controller button's state has changed
  14450. * @param callback the callback containing the button that was modified
  14451. */
  14452. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14453. /**
  14454. * X and Y axis corresponding to the controllers joystick
  14455. */
  14456. pad: StickValues;
  14457. /**
  14458. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14459. */
  14460. hand: string;
  14461. /**
  14462. * The default controller model for the controller
  14463. */
  14464. readonly defaultModel: AbstractMesh;
  14465. /**
  14466. * Creates a new WebVRController from a gamepad
  14467. * @param vrGamepad the gamepad that the WebVRController should be created from
  14468. */
  14469. constructor(vrGamepad: any);
  14470. /**
  14471. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14472. */
  14473. update(): void;
  14474. /**
  14475. * Function to be called when a button is modified
  14476. */
  14477. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14478. /**
  14479. * Loads a mesh and attaches it to the controller
  14480. * @param scene the scene the mesh should be added to
  14481. * @param meshLoaded callback for when the mesh has been loaded
  14482. */
  14483. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14484. private _setButtonValue;
  14485. private _changes;
  14486. private _checkChanges;
  14487. /**
  14488. * Disposes of th webVRCOntroller
  14489. */
  14490. dispose(): void;
  14491. }
  14492. }
  14493. declare module BABYLON {
  14494. /**
  14495. * The HemisphericLight simulates the ambient environment light,
  14496. * so the passed direction is the light reflection direction, not the incoming direction.
  14497. */
  14498. export class HemisphericLight extends Light {
  14499. /**
  14500. * The groundColor is the light in the opposite direction to the one specified during creation.
  14501. * 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.
  14502. */
  14503. groundColor: Color3;
  14504. /**
  14505. * The light reflection direction, not the incoming direction.
  14506. */
  14507. direction: Vector3;
  14508. /**
  14509. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14510. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14511. * The HemisphericLight can't cast shadows.
  14512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14513. * @param name The friendly name of the light
  14514. * @param direction The direction of the light reflection
  14515. * @param scene The scene the light belongs to
  14516. */
  14517. constructor(name: string, direction: Vector3, scene: Scene);
  14518. protected _buildUniformLayout(): void;
  14519. /**
  14520. * Returns the string "HemisphericLight".
  14521. * @return The class name
  14522. */
  14523. getClassName(): string;
  14524. /**
  14525. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14526. * Returns the updated direction.
  14527. * @param target The target the direction should point to
  14528. * @return The computed direction
  14529. */
  14530. setDirectionToTarget(target: Vector3): Vector3;
  14531. /**
  14532. * Returns the shadow generator associated to the light.
  14533. * @returns Always null for hemispheric lights because it does not support shadows.
  14534. */
  14535. getShadowGenerator(): Nullable<IShadowGenerator>;
  14536. /**
  14537. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14538. * @param effect The effect to update
  14539. * @param lightIndex The index of the light in the effect to update
  14540. * @returns The hemispheric light
  14541. */
  14542. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14543. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14544. /**
  14545. * Computes the world matrix of the node
  14546. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14547. * @param useWasUpdatedFlag defines a reserved property
  14548. * @returns the world matrix
  14549. */
  14550. computeWorldMatrix(): Matrix;
  14551. /**
  14552. * Returns the integer 3.
  14553. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14554. */
  14555. getTypeID(): number;
  14556. /**
  14557. * Prepares the list of defines specific to the light type.
  14558. * @param defines the list of defines
  14559. * @param lightIndex defines the index of the light for the effect
  14560. */
  14561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14562. }
  14563. }
  14564. declare module BABYLON {
  14565. /** @hidden */
  14566. export var vrMultiviewToSingleviewPixelShader: {
  14567. name: string;
  14568. shader: string;
  14569. };
  14570. }
  14571. declare module BABYLON {
  14572. /**
  14573. * Renders to multiple views with a single draw call
  14574. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14575. */
  14576. export class MultiviewRenderTarget extends RenderTargetTexture {
  14577. /**
  14578. * Creates a multiview render target
  14579. * @param scene scene used with the render target
  14580. * @param size the size of the render target (used for each view)
  14581. */
  14582. constructor(scene: Scene, size?: number | {
  14583. width: number;
  14584. height: number;
  14585. } | {
  14586. ratio: number;
  14587. });
  14588. /**
  14589. * @hidden
  14590. * @param faceIndex the face index, if its a cube texture
  14591. */
  14592. _bindFrameBuffer(faceIndex?: number): void;
  14593. /**
  14594. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14595. * @returns the view count
  14596. */
  14597. getViewCount(): number;
  14598. }
  14599. }
  14600. declare module BABYLON {
  14601. /**
  14602. * Represents a camera frustum
  14603. */
  14604. export class Frustum {
  14605. /**
  14606. * Gets the planes representing the frustum
  14607. * @param transform matrix to be applied to the returned planes
  14608. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14609. */
  14610. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14611. /**
  14612. * Gets the near frustum plane transformed by the transform matrix
  14613. * @param transform transformation matrix to be applied to the resulting frustum plane
  14614. * @param frustumPlane the resuling frustum plane
  14615. */
  14616. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14617. /**
  14618. * Gets the far frustum plane transformed by the transform matrix
  14619. * @param transform transformation matrix to be applied to the resulting frustum plane
  14620. * @param frustumPlane the resuling frustum plane
  14621. */
  14622. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14623. /**
  14624. * Gets the left frustum plane transformed by the transform matrix
  14625. * @param transform transformation matrix to be applied to the resulting frustum plane
  14626. * @param frustumPlane the resuling frustum plane
  14627. */
  14628. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14629. /**
  14630. * Gets the right frustum plane transformed by the transform matrix
  14631. * @param transform transformation matrix to be applied to the resulting frustum plane
  14632. * @param frustumPlane the resuling frustum plane
  14633. */
  14634. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14635. /**
  14636. * Gets the top frustum plane transformed by the transform matrix
  14637. * @param transform transformation matrix to be applied to the resulting frustum plane
  14638. * @param frustumPlane the resuling frustum plane
  14639. */
  14640. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14641. /**
  14642. * Gets the bottom frustum plane transformed by the transform matrix
  14643. * @param transform transformation matrix to be applied to the resulting frustum plane
  14644. * @param frustumPlane the resuling frustum plane
  14645. */
  14646. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14647. /**
  14648. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14649. * @param transform transformation matrix to be applied to the resulting frustum planes
  14650. * @param frustumPlanes the resuling frustum planes
  14651. */
  14652. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14653. }
  14654. }
  14655. declare module BABYLON {
  14656. interface Engine {
  14657. /**
  14658. * Creates a new multiview render target
  14659. * @param width defines the width of the texture
  14660. * @param height defines the height of the texture
  14661. * @returns the created multiview texture
  14662. */
  14663. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14664. /**
  14665. * Binds a multiview framebuffer to be drawn to
  14666. * @param multiviewTexture texture to bind
  14667. */
  14668. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14669. }
  14670. interface Camera {
  14671. /**
  14672. * @hidden
  14673. * 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)
  14674. */
  14675. _useMultiviewToSingleView: boolean;
  14676. /**
  14677. * @hidden
  14678. * 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)
  14679. */
  14680. _multiviewTexture: Nullable<RenderTargetTexture>;
  14681. /**
  14682. * @hidden
  14683. * ensures the multiview texture of the camera exists and has the specified width/height
  14684. * @param width height to set on the multiview texture
  14685. * @param height width to set on the multiview texture
  14686. */
  14687. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14688. }
  14689. interface Scene {
  14690. /** @hidden */
  14691. _transformMatrixR: Matrix;
  14692. /** @hidden */
  14693. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14694. /** @hidden */
  14695. _createMultiviewUbo(): void;
  14696. /** @hidden */
  14697. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14698. /** @hidden */
  14699. _renderMultiviewToSingleView(camera: Camera): void;
  14700. }
  14701. }
  14702. declare module BABYLON {
  14703. /**
  14704. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14705. * This will not be used for webXR as it supports displaying texture arrays directly
  14706. */
  14707. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14708. /**
  14709. * Initializes a VRMultiviewToSingleview
  14710. * @param name name of the post process
  14711. * @param camera camera to be applied to
  14712. * @param scaleFactor scaling factor to the size of the output texture
  14713. */
  14714. constructor(name: string, camera: Camera, scaleFactor: number);
  14715. }
  14716. }
  14717. declare module BABYLON {
  14718. interface Engine {
  14719. /** @hidden */
  14720. _vrDisplay: any;
  14721. /** @hidden */
  14722. _vrSupported: boolean;
  14723. /** @hidden */
  14724. _oldSize: Size;
  14725. /** @hidden */
  14726. _oldHardwareScaleFactor: number;
  14727. /** @hidden */
  14728. _vrExclusivePointerMode: boolean;
  14729. /** @hidden */
  14730. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14731. /** @hidden */
  14732. _onVRDisplayPointerRestricted: () => void;
  14733. /** @hidden */
  14734. _onVRDisplayPointerUnrestricted: () => void;
  14735. /** @hidden */
  14736. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14737. /** @hidden */
  14738. _onVrDisplayDisconnect: Nullable<() => void>;
  14739. /** @hidden */
  14740. _onVrDisplayPresentChange: Nullable<() => void>;
  14741. /**
  14742. * Observable signaled when VR display mode changes
  14743. */
  14744. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14745. /**
  14746. * Observable signaled when VR request present is complete
  14747. */
  14748. onVRRequestPresentComplete: Observable<boolean>;
  14749. /**
  14750. * Observable signaled when VR request present starts
  14751. */
  14752. onVRRequestPresentStart: Observable<Engine>;
  14753. /**
  14754. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14755. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14756. */
  14757. isInVRExclusivePointerMode: boolean;
  14758. /**
  14759. * Gets a boolean indicating if a webVR device was detected
  14760. * @returns true if a webVR device was detected
  14761. */
  14762. isVRDevicePresent(): boolean;
  14763. /**
  14764. * Gets the current webVR device
  14765. * @returns the current webVR device (or null)
  14766. */
  14767. getVRDevice(): any;
  14768. /**
  14769. * Initializes a webVR display and starts listening to display change events
  14770. * The onVRDisplayChangedObservable will be notified upon these changes
  14771. * @returns A promise containing a VRDisplay and if vr is supported
  14772. */
  14773. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14774. /** @hidden */
  14775. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14776. /**
  14777. * Call this function to switch to webVR mode
  14778. * Will do nothing if webVR is not supported or if there is no webVR device
  14779. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14780. */
  14781. enableVR(): void;
  14782. /** @hidden */
  14783. _onVRFullScreenTriggered(): void;
  14784. }
  14785. }
  14786. declare module BABYLON {
  14787. /**
  14788. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14789. * IMPORTANT!! The data is right-hand data.
  14790. * @export
  14791. * @interface DevicePose
  14792. */
  14793. export interface DevicePose {
  14794. /**
  14795. * The position of the device, values in array are [x,y,z].
  14796. */
  14797. readonly position: Nullable<Float32Array>;
  14798. /**
  14799. * The linearVelocity of the device, values in array are [x,y,z].
  14800. */
  14801. readonly linearVelocity: Nullable<Float32Array>;
  14802. /**
  14803. * The linearAcceleration of the device, values in array are [x,y,z].
  14804. */
  14805. readonly linearAcceleration: Nullable<Float32Array>;
  14806. /**
  14807. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14808. */
  14809. readonly orientation: Nullable<Float32Array>;
  14810. /**
  14811. * The angularVelocity of the device, values in array are [x,y,z].
  14812. */
  14813. readonly angularVelocity: Nullable<Float32Array>;
  14814. /**
  14815. * The angularAcceleration of the device, values in array are [x,y,z].
  14816. */
  14817. readonly angularAcceleration: Nullable<Float32Array>;
  14818. }
  14819. /**
  14820. * Interface representing a pose controlled object in Babylon.
  14821. * A pose controlled object has both regular pose values as well as pose values
  14822. * from an external device such as a VR head mounted display
  14823. */
  14824. export interface PoseControlled {
  14825. /**
  14826. * The position of the object in babylon space.
  14827. */
  14828. position: Vector3;
  14829. /**
  14830. * The rotation quaternion of the object in babylon space.
  14831. */
  14832. rotationQuaternion: Quaternion;
  14833. /**
  14834. * The position of the device in babylon space.
  14835. */
  14836. devicePosition?: Vector3;
  14837. /**
  14838. * The rotation quaternion of the device in babylon space.
  14839. */
  14840. deviceRotationQuaternion: Quaternion;
  14841. /**
  14842. * The raw pose coming from the device.
  14843. */
  14844. rawPose: Nullable<DevicePose>;
  14845. /**
  14846. * The scale of the device to be used when translating from device space to babylon space.
  14847. */
  14848. deviceScaleFactor: number;
  14849. /**
  14850. * Updates the poseControlled values based on the input device pose.
  14851. * @param poseData the pose data to update the object with
  14852. */
  14853. updateFromDevice(poseData: DevicePose): void;
  14854. }
  14855. /**
  14856. * Set of options to customize the webVRCamera
  14857. */
  14858. export interface WebVROptions {
  14859. /**
  14860. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14861. */
  14862. trackPosition?: boolean;
  14863. /**
  14864. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14865. */
  14866. positionScale?: number;
  14867. /**
  14868. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14869. */
  14870. displayName?: string;
  14871. /**
  14872. * Should the native controller meshes be initialized. (default: true)
  14873. */
  14874. controllerMeshes?: boolean;
  14875. /**
  14876. * Creating a default HemiLight only on controllers. (default: true)
  14877. */
  14878. defaultLightingOnControllers?: boolean;
  14879. /**
  14880. * If you don't want to use the default VR button of the helper. (default: false)
  14881. */
  14882. useCustomVRButton?: boolean;
  14883. /**
  14884. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14885. */
  14886. customVRButton?: HTMLButtonElement;
  14887. /**
  14888. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14889. */
  14890. rayLength?: number;
  14891. /**
  14892. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14893. */
  14894. defaultHeight?: number;
  14895. /**
  14896. * If multiview should be used if availible (default: false)
  14897. */
  14898. useMultiview?: boolean;
  14899. }
  14900. /**
  14901. * This represents a WebVR camera.
  14902. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14903. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14904. */
  14905. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14906. private webVROptions;
  14907. /**
  14908. * @hidden
  14909. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14910. */
  14911. _vrDevice: any;
  14912. /**
  14913. * The rawPose of the vrDevice.
  14914. */
  14915. rawPose: Nullable<DevicePose>;
  14916. private _onVREnabled;
  14917. private _specsVersion;
  14918. private _attached;
  14919. private _frameData;
  14920. protected _descendants: Array<Node>;
  14921. private _deviceRoomPosition;
  14922. /** @hidden */
  14923. _deviceRoomRotationQuaternion: Quaternion;
  14924. private _standingMatrix;
  14925. /**
  14926. * Represents device position in babylon space.
  14927. */
  14928. devicePosition: Vector3;
  14929. /**
  14930. * Represents device rotation in babylon space.
  14931. */
  14932. deviceRotationQuaternion: Quaternion;
  14933. /**
  14934. * The scale of the device to be used when translating from device space to babylon space.
  14935. */
  14936. deviceScaleFactor: number;
  14937. private _deviceToWorld;
  14938. private _worldToDevice;
  14939. /**
  14940. * References to the webVR controllers for the vrDevice.
  14941. */
  14942. controllers: Array<WebVRController>;
  14943. /**
  14944. * Emits an event when a controller is attached.
  14945. */
  14946. onControllersAttachedObservable: Observable<WebVRController[]>;
  14947. /**
  14948. * Emits an event when a controller's mesh has been loaded;
  14949. */
  14950. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14951. /**
  14952. * Emits an event when the HMD's pose has been updated.
  14953. */
  14954. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14955. private _poseSet;
  14956. /**
  14957. * If the rig cameras be used as parent instead of this camera.
  14958. */
  14959. rigParenting: boolean;
  14960. private _lightOnControllers;
  14961. private _defaultHeight?;
  14962. /**
  14963. * Instantiates a WebVRFreeCamera.
  14964. * @param name The name of the WebVRFreeCamera
  14965. * @param position The starting anchor position for the camera
  14966. * @param scene The scene the camera belongs to
  14967. * @param webVROptions a set of customizable options for the webVRCamera
  14968. */
  14969. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14970. /**
  14971. * Gets the device distance from the ground in meters.
  14972. * @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.
  14973. */
  14974. deviceDistanceToRoomGround(): number;
  14975. /**
  14976. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14977. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14978. */
  14979. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14980. /**
  14981. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14982. * @returns A promise with a boolean set to if the standing matrix is supported.
  14983. */
  14984. useStandingMatrixAsync(): Promise<boolean>;
  14985. /**
  14986. * Disposes the camera
  14987. */
  14988. dispose(): void;
  14989. /**
  14990. * Gets a vrController by name.
  14991. * @param name The name of the controller to retreive
  14992. * @returns the controller matching the name specified or null if not found
  14993. */
  14994. getControllerByName(name: string): Nullable<WebVRController>;
  14995. private _leftController;
  14996. /**
  14997. * The controller corresponding to the users left hand.
  14998. */
  14999. readonly leftController: Nullable<WebVRController>;
  15000. private _rightController;
  15001. /**
  15002. * The controller corresponding to the users right hand.
  15003. */
  15004. readonly rightController: Nullable<WebVRController>;
  15005. /**
  15006. * Casts a ray forward from the vrCamera's gaze.
  15007. * @param length Length of the ray (default: 100)
  15008. * @returns the ray corresponding to the gaze
  15009. */
  15010. getForwardRay(length?: number): Ray;
  15011. /**
  15012. * @hidden
  15013. * Updates the camera based on device's frame data
  15014. */
  15015. _checkInputs(): void;
  15016. /**
  15017. * Updates the poseControlled values based on the input device pose.
  15018. * @param poseData Pose coming from the device
  15019. */
  15020. updateFromDevice(poseData: DevicePose): void;
  15021. private _htmlElementAttached;
  15022. private _detachIfAttached;
  15023. /**
  15024. * WebVR's attach control will start broadcasting frames to the device.
  15025. * Note that in certain browsers (chrome for example) this function must be called
  15026. * within a user-interaction callback. Example:
  15027. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15028. *
  15029. * @param element html element to attach the vrDevice to
  15030. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15031. */
  15032. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15033. /**
  15034. * Detaches the camera from the html element and disables VR
  15035. *
  15036. * @param element html element to detach from
  15037. */
  15038. detachControl(element: HTMLElement): void;
  15039. /**
  15040. * @returns the name of this class
  15041. */
  15042. getClassName(): string;
  15043. /**
  15044. * Calls resetPose on the vrDisplay
  15045. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15046. */
  15047. resetToCurrentRotation(): void;
  15048. /**
  15049. * @hidden
  15050. * Updates the rig cameras (left and right eye)
  15051. */
  15052. _updateRigCameras(): void;
  15053. private _workingVector;
  15054. private _oneVector;
  15055. private _workingMatrix;
  15056. private updateCacheCalled;
  15057. private _correctPositionIfNotTrackPosition;
  15058. /**
  15059. * @hidden
  15060. * Updates the cached values of the camera
  15061. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15062. */
  15063. _updateCache(ignoreParentClass?: boolean): void;
  15064. /**
  15065. * @hidden
  15066. * Get current device position in babylon world
  15067. */
  15068. _computeDevicePosition(): void;
  15069. /**
  15070. * Updates the current device position and rotation in the babylon world
  15071. */
  15072. update(): void;
  15073. /**
  15074. * @hidden
  15075. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15076. * @returns an identity matrix
  15077. */
  15078. _getViewMatrix(): Matrix;
  15079. private _tmpMatrix;
  15080. /**
  15081. * This function is called by the two RIG cameras.
  15082. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15083. * @hidden
  15084. */
  15085. _getWebVRViewMatrix(): Matrix;
  15086. /** @hidden */
  15087. _getWebVRProjectionMatrix(): Matrix;
  15088. private _onGamepadConnectedObserver;
  15089. private _onGamepadDisconnectedObserver;
  15090. private _updateCacheWhenTrackingDisabledObserver;
  15091. /**
  15092. * Initializes the controllers and their meshes
  15093. */
  15094. initControllers(): void;
  15095. }
  15096. }
  15097. declare module BABYLON {
  15098. /**
  15099. * Size options for a post process
  15100. */
  15101. export type PostProcessOptions = {
  15102. width: number;
  15103. height: number;
  15104. };
  15105. /**
  15106. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15107. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15108. */
  15109. export class PostProcess {
  15110. /** Name of the PostProcess. */
  15111. name: string;
  15112. /**
  15113. * Gets or sets the unique id of the post process
  15114. */
  15115. uniqueId: number;
  15116. /**
  15117. * Width of the texture to apply the post process on
  15118. */
  15119. width: number;
  15120. /**
  15121. * Height of the texture to apply the post process on
  15122. */
  15123. height: number;
  15124. /**
  15125. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15126. * @hidden
  15127. */
  15128. _outputTexture: Nullable<InternalTexture>;
  15129. /**
  15130. * Sampling mode used by the shader
  15131. * See https://doc.babylonjs.com/classes/3.1/texture
  15132. */
  15133. renderTargetSamplingMode: number;
  15134. /**
  15135. * Clear color to use when screen clearing
  15136. */
  15137. clearColor: Color4;
  15138. /**
  15139. * If the buffer needs to be cleared before applying the post process. (default: true)
  15140. * Should be set to false if shader will overwrite all previous pixels.
  15141. */
  15142. autoClear: boolean;
  15143. /**
  15144. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15145. */
  15146. alphaMode: number;
  15147. /**
  15148. * Sets the setAlphaBlendConstants of the babylon engine
  15149. */
  15150. alphaConstants: Color4;
  15151. /**
  15152. * Animations to be used for the post processing
  15153. */
  15154. animations: Animation[];
  15155. /**
  15156. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15157. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15158. */
  15159. enablePixelPerfectMode: boolean;
  15160. /**
  15161. * Force the postprocess to be applied without taking in account viewport
  15162. */
  15163. forceFullscreenViewport: boolean;
  15164. /**
  15165. * List of inspectable custom properties (used by the Inspector)
  15166. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15167. */
  15168. inspectableCustomProperties: IInspectable[];
  15169. /**
  15170. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15171. *
  15172. * | Value | Type | Description |
  15173. * | ----- | ----------------------------------- | ----------- |
  15174. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15175. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15176. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15177. *
  15178. */
  15179. scaleMode: number;
  15180. /**
  15181. * Force textures to be a power of two (default: false)
  15182. */
  15183. alwaysForcePOT: boolean;
  15184. private _samples;
  15185. /**
  15186. * Number of sample textures (default: 1)
  15187. */
  15188. samples: number;
  15189. /**
  15190. * Modify the scale of the post process to be the same as the viewport (default: false)
  15191. */
  15192. adaptScaleToCurrentViewport: boolean;
  15193. private _camera;
  15194. private _scene;
  15195. private _engine;
  15196. private _options;
  15197. private _reusable;
  15198. private _textureType;
  15199. /**
  15200. * Smart array of input and output textures for the post process.
  15201. * @hidden
  15202. */
  15203. _textures: SmartArray<InternalTexture>;
  15204. /**
  15205. * The index in _textures that corresponds to the output texture.
  15206. * @hidden
  15207. */
  15208. _currentRenderTextureInd: number;
  15209. private _effect;
  15210. private _samplers;
  15211. private _fragmentUrl;
  15212. private _vertexUrl;
  15213. private _parameters;
  15214. private _scaleRatio;
  15215. protected _indexParameters: any;
  15216. private _shareOutputWithPostProcess;
  15217. private _texelSize;
  15218. private _forcedOutputTexture;
  15219. /**
  15220. * Returns the fragment url or shader name used in the post process.
  15221. * @returns the fragment url or name in the shader store.
  15222. */
  15223. getEffectName(): string;
  15224. /**
  15225. * An event triggered when the postprocess is activated.
  15226. */
  15227. onActivateObservable: Observable<Camera>;
  15228. private _onActivateObserver;
  15229. /**
  15230. * A function that is added to the onActivateObservable
  15231. */
  15232. onActivate: Nullable<(camera: Camera) => void>;
  15233. /**
  15234. * An event triggered when the postprocess changes its size.
  15235. */
  15236. onSizeChangedObservable: Observable<PostProcess>;
  15237. private _onSizeChangedObserver;
  15238. /**
  15239. * A function that is added to the onSizeChangedObservable
  15240. */
  15241. onSizeChanged: (postProcess: PostProcess) => void;
  15242. /**
  15243. * An event triggered when the postprocess applies its effect.
  15244. */
  15245. onApplyObservable: Observable<Effect>;
  15246. private _onApplyObserver;
  15247. /**
  15248. * A function that is added to the onApplyObservable
  15249. */
  15250. onApply: (effect: Effect) => void;
  15251. /**
  15252. * An event triggered before rendering the postprocess
  15253. */
  15254. onBeforeRenderObservable: Observable<Effect>;
  15255. private _onBeforeRenderObserver;
  15256. /**
  15257. * A function that is added to the onBeforeRenderObservable
  15258. */
  15259. onBeforeRender: (effect: Effect) => void;
  15260. /**
  15261. * An event triggered after rendering the postprocess
  15262. */
  15263. onAfterRenderObservable: Observable<Effect>;
  15264. private _onAfterRenderObserver;
  15265. /**
  15266. * A function that is added to the onAfterRenderObservable
  15267. */
  15268. onAfterRender: (efect: Effect) => void;
  15269. /**
  15270. * 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
  15271. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15272. */
  15273. inputTexture: InternalTexture;
  15274. /**
  15275. * Gets the camera which post process is applied to.
  15276. * @returns The camera the post process is applied to.
  15277. */
  15278. getCamera(): Camera;
  15279. /**
  15280. * Gets the texel size of the postprocess.
  15281. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15282. */
  15283. readonly texelSize: Vector2;
  15284. /**
  15285. * Creates a new instance PostProcess
  15286. * @param name The name of the PostProcess.
  15287. * @param fragmentUrl The url of the fragment shader to be used.
  15288. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15289. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15290. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15291. * @param camera The camera to apply the render pass to.
  15292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15293. * @param engine The engine which the post process will be applied. (default: current engine)
  15294. * @param reusable If the post process can be reused on the same frame. (default: false)
  15295. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15296. * @param textureType Type of textures used when performing the post process. (default: 0)
  15297. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15298. * @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
  15299. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15300. */
  15301. constructor(
  15302. /** Name of the PostProcess. */
  15303. 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);
  15304. /**
  15305. * Gets a string idenfifying the name of the class
  15306. * @returns "PostProcess" string
  15307. */
  15308. getClassName(): string;
  15309. /**
  15310. * Gets the engine which this post process belongs to.
  15311. * @returns The engine the post process was enabled with.
  15312. */
  15313. getEngine(): Engine;
  15314. /**
  15315. * The effect that is created when initializing the post process.
  15316. * @returns The created effect corresponding the the postprocess.
  15317. */
  15318. getEffect(): Effect;
  15319. /**
  15320. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15321. * @param postProcess The post process to share the output with.
  15322. * @returns This post process.
  15323. */
  15324. shareOutputWith(postProcess: PostProcess): PostProcess;
  15325. /**
  15326. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15327. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15328. */
  15329. useOwnOutput(): void;
  15330. /**
  15331. * Updates the effect with the current post process compile time values and recompiles the shader.
  15332. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15333. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15334. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15335. * @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
  15336. * @param onCompiled Called when the shader has been compiled.
  15337. * @param onError Called if there is an error when compiling a shader.
  15338. */
  15339. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15340. /**
  15341. * The post process is reusable if it can be used multiple times within one frame.
  15342. * @returns If the post process is reusable
  15343. */
  15344. isReusable(): boolean;
  15345. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15346. markTextureDirty(): void;
  15347. /**
  15348. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15349. * 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.
  15350. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15351. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15352. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15353. * @returns The target texture that was bound to be written to.
  15354. */
  15355. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15356. /**
  15357. * If the post process is supported.
  15358. */
  15359. readonly isSupported: boolean;
  15360. /**
  15361. * The aspect ratio of the output texture.
  15362. */
  15363. readonly aspectRatio: number;
  15364. /**
  15365. * Get a value indicating if the post-process is ready to be used
  15366. * @returns true if the post-process is ready (shader is compiled)
  15367. */
  15368. isReady(): boolean;
  15369. /**
  15370. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15371. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15372. */
  15373. apply(): Nullable<Effect>;
  15374. private _disposeTextures;
  15375. /**
  15376. * Disposes the post process.
  15377. * @param camera The camera to dispose the post process on.
  15378. */
  15379. dispose(camera?: Camera): void;
  15380. }
  15381. }
  15382. declare module BABYLON {
  15383. /** @hidden */
  15384. export var kernelBlurVaryingDeclaration: {
  15385. name: string;
  15386. shader: string;
  15387. };
  15388. }
  15389. declare module BABYLON {
  15390. /** @hidden */
  15391. export var kernelBlurFragment: {
  15392. name: string;
  15393. shader: string;
  15394. };
  15395. }
  15396. declare module BABYLON {
  15397. /** @hidden */
  15398. export var kernelBlurFragment2: {
  15399. name: string;
  15400. shader: string;
  15401. };
  15402. }
  15403. declare module BABYLON {
  15404. /** @hidden */
  15405. export var kernelBlurPixelShader: {
  15406. name: string;
  15407. shader: string;
  15408. };
  15409. }
  15410. declare module BABYLON {
  15411. /** @hidden */
  15412. export var kernelBlurVertex: {
  15413. name: string;
  15414. shader: string;
  15415. };
  15416. }
  15417. declare module BABYLON {
  15418. /** @hidden */
  15419. export var kernelBlurVertexShader: {
  15420. name: string;
  15421. shader: string;
  15422. };
  15423. }
  15424. declare module BABYLON {
  15425. /**
  15426. * The Blur Post Process which blurs an image based on a kernel and direction.
  15427. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15428. */
  15429. export class BlurPostProcess extends PostProcess {
  15430. /** The direction in which to blur the image. */
  15431. direction: Vector2;
  15432. private blockCompilation;
  15433. protected _kernel: number;
  15434. protected _idealKernel: number;
  15435. protected _packedFloat: boolean;
  15436. private _staticDefines;
  15437. /**
  15438. * Sets the length in pixels of the blur sample region
  15439. */
  15440. /**
  15441. * Gets the length in pixels of the blur sample region
  15442. */
  15443. kernel: number;
  15444. /**
  15445. * Sets wether or not the blur needs to unpack/repack floats
  15446. */
  15447. /**
  15448. * Gets wether or not the blur is unpacking/repacking floats
  15449. */
  15450. packedFloat: boolean;
  15451. /**
  15452. * Creates a new instance BlurPostProcess
  15453. * @param name The name of the effect.
  15454. * @param direction The direction in which to blur the image.
  15455. * @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.
  15456. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15457. * @param camera The camera to apply the render pass to.
  15458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15459. * @param engine The engine which the post process will be applied. (default: current engine)
  15460. * @param reusable If the post process can be reused on the same frame. (default: false)
  15461. * @param textureType Type of textures used when performing the post process. (default: 0)
  15462. * @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)
  15463. */
  15464. constructor(name: string,
  15465. /** The direction in which to blur the image. */
  15466. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15467. /**
  15468. * Updates the effect with the current post process compile time values and recompiles the shader.
  15469. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15470. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15471. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15472. * @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
  15473. * @param onCompiled Called when the shader has been compiled.
  15474. * @param onError Called if there is an error when compiling a shader.
  15475. */
  15476. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15477. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15478. /**
  15479. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15480. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15481. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15482. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15483. * The gaps between physical kernels are compensated for in the weighting of the samples
  15484. * @param idealKernel Ideal blur kernel.
  15485. * @return Nearest best kernel.
  15486. */
  15487. protected _nearestBestKernel(idealKernel: number): number;
  15488. /**
  15489. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15490. * @param x The point on the Gaussian distribution to sample.
  15491. * @return the value of the Gaussian function at x.
  15492. */
  15493. protected _gaussianWeight(x: number): number;
  15494. /**
  15495. * Generates a string that can be used as a floating point number in GLSL.
  15496. * @param x Value to print.
  15497. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15498. * @return GLSL float string.
  15499. */
  15500. protected _glslFloat(x: number, decimalFigures?: number): string;
  15501. }
  15502. }
  15503. declare module BABYLON {
  15504. /**
  15505. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15506. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15507. * You can then easily use it as a reflectionTexture on a flat surface.
  15508. * In case the surface is not a plane, please consider relying on reflection probes.
  15509. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15510. */
  15511. export class MirrorTexture extends RenderTargetTexture {
  15512. private scene;
  15513. /**
  15514. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15515. * 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.
  15516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15517. */
  15518. mirrorPlane: Plane;
  15519. /**
  15520. * Define the blur ratio used to blur the reflection if needed.
  15521. */
  15522. blurRatio: number;
  15523. /**
  15524. * Define the adaptive blur kernel used to blur the reflection if needed.
  15525. * This will autocompute the closest best match for the `blurKernel`
  15526. */
  15527. adaptiveBlurKernel: number;
  15528. /**
  15529. * Define the blur kernel used to blur the reflection if needed.
  15530. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15531. */
  15532. blurKernel: number;
  15533. /**
  15534. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15535. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15536. */
  15537. blurKernelX: number;
  15538. /**
  15539. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15540. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15541. */
  15542. blurKernelY: number;
  15543. private _autoComputeBlurKernel;
  15544. protected _onRatioRescale(): void;
  15545. private _updateGammaSpace;
  15546. private _imageProcessingConfigChangeObserver;
  15547. private _transformMatrix;
  15548. private _mirrorMatrix;
  15549. private _savedViewMatrix;
  15550. private _blurX;
  15551. private _blurY;
  15552. private _adaptiveBlurKernel;
  15553. private _blurKernelX;
  15554. private _blurKernelY;
  15555. private _blurRatio;
  15556. /**
  15557. * Instantiates a Mirror Texture.
  15558. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15559. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15560. * You can then easily use it as a reflectionTexture on a flat surface.
  15561. * In case the surface is not a plane, please consider relying on reflection probes.
  15562. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15563. * @param name
  15564. * @param size
  15565. * @param scene
  15566. * @param generateMipMaps
  15567. * @param type
  15568. * @param samplingMode
  15569. * @param generateDepthBuffer
  15570. */
  15571. constructor(name: string, size: number | {
  15572. width: number;
  15573. height: number;
  15574. } | {
  15575. ratio: number;
  15576. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15577. private _preparePostProcesses;
  15578. /**
  15579. * Clone the mirror texture.
  15580. * @returns the cloned texture
  15581. */
  15582. clone(): MirrorTexture;
  15583. /**
  15584. * Serialize the texture to a JSON representation you could use in Parse later on
  15585. * @returns the serialized JSON representation
  15586. */
  15587. serialize(): any;
  15588. /**
  15589. * Dispose the texture and release its associated resources.
  15590. */
  15591. dispose(): void;
  15592. }
  15593. }
  15594. declare module BABYLON {
  15595. /**
  15596. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15597. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15598. */
  15599. export class Texture extends BaseTexture {
  15600. /**
  15601. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15602. */
  15603. static SerializeBuffers: boolean;
  15604. /** @hidden */
  15605. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15606. /** @hidden */
  15607. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15608. /** @hidden */
  15609. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15610. /** nearest is mag = nearest and min = nearest and mip = linear */
  15611. static readonly NEAREST_SAMPLINGMODE: number;
  15612. /** nearest is mag = nearest and min = nearest and mip = linear */
  15613. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15615. static readonly BILINEAR_SAMPLINGMODE: number;
  15616. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15617. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15618. /** Trilinear is mag = linear and min = linear and mip = linear */
  15619. static readonly TRILINEAR_SAMPLINGMODE: number;
  15620. /** Trilinear is mag = linear and min = linear and mip = linear */
  15621. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15622. /** mag = nearest and min = nearest and mip = nearest */
  15623. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15624. /** mag = nearest and min = linear and mip = nearest */
  15625. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15626. /** mag = nearest and min = linear and mip = linear */
  15627. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15628. /** mag = nearest and min = linear and mip = none */
  15629. static readonly NEAREST_LINEAR: number;
  15630. /** mag = nearest and min = nearest and mip = none */
  15631. static readonly NEAREST_NEAREST: number;
  15632. /** mag = linear and min = nearest and mip = nearest */
  15633. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15634. /** mag = linear and min = nearest and mip = linear */
  15635. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15636. /** mag = linear and min = linear and mip = none */
  15637. static readonly LINEAR_LINEAR: number;
  15638. /** mag = linear and min = nearest and mip = none */
  15639. static readonly LINEAR_NEAREST: number;
  15640. /** Explicit coordinates mode */
  15641. static readonly EXPLICIT_MODE: number;
  15642. /** Spherical coordinates mode */
  15643. static readonly SPHERICAL_MODE: number;
  15644. /** Planar coordinates mode */
  15645. static readonly PLANAR_MODE: number;
  15646. /** Cubic coordinates mode */
  15647. static readonly CUBIC_MODE: number;
  15648. /** Projection coordinates mode */
  15649. static readonly PROJECTION_MODE: number;
  15650. /** Inverse Cubic coordinates mode */
  15651. static readonly SKYBOX_MODE: number;
  15652. /** Inverse Cubic coordinates mode */
  15653. static readonly INVCUBIC_MODE: number;
  15654. /** Equirectangular coordinates mode */
  15655. static readonly EQUIRECTANGULAR_MODE: number;
  15656. /** Equirectangular Fixed coordinates mode */
  15657. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15658. /** Equirectangular Fixed Mirrored coordinates mode */
  15659. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15660. /** Texture is not repeating outside of 0..1 UVs */
  15661. static readonly CLAMP_ADDRESSMODE: number;
  15662. /** Texture is repeating outside of 0..1 UVs */
  15663. static readonly WRAP_ADDRESSMODE: number;
  15664. /** Texture is repeating and mirrored */
  15665. static readonly MIRROR_ADDRESSMODE: number;
  15666. /**
  15667. * 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
  15668. */
  15669. static UseSerializedUrlIfAny: boolean;
  15670. /**
  15671. * Define the url of the texture.
  15672. */
  15673. url: Nullable<string>;
  15674. /**
  15675. * Define an offset on the texture to offset the u coordinates of the UVs
  15676. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15677. */
  15678. uOffset: number;
  15679. /**
  15680. * Define an offset on the texture to offset the v coordinates of the UVs
  15681. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15682. */
  15683. vOffset: number;
  15684. /**
  15685. * Define an offset on the texture to scale the u coordinates of the UVs
  15686. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15687. */
  15688. uScale: number;
  15689. /**
  15690. * Define an offset on the texture to scale the v coordinates of the UVs
  15691. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15692. */
  15693. vScale: number;
  15694. /**
  15695. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15696. * @see http://doc.babylonjs.com/how_to/more_materials
  15697. */
  15698. uAng: number;
  15699. /**
  15700. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15701. * @see http://doc.babylonjs.com/how_to/more_materials
  15702. */
  15703. vAng: number;
  15704. /**
  15705. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15706. * @see http://doc.babylonjs.com/how_to/more_materials
  15707. */
  15708. wAng: number;
  15709. /**
  15710. * Defines the center of rotation (U)
  15711. */
  15712. uRotationCenter: number;
  15713. /**
  15714. * Defines the center of rotation (V)
  15715. */
  15716. vRotationCenter: number;
  15717. /**
  15718. * Defines the center of rotation (W)
  15719. */
  15720. wRotationCenter: number;
  15721. /**
  15722. * Are mip maps generated for this texture or not.
  15723. */
  15724. readonly noMipmap: boolean;
  15725. /**
  15726. * List of inspectable custom properties (used by the Inspector)
  15727. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15728. */
  15729. inspectableCustomProperties: Nullable<IInspectable[]>;
  15730. private _noMipmap;
  15731. /** @hidden */
  15732. _invertY: boolean;
  15733. private _rowGenerationMatrix;
  15734. private _cachedTextureMatrix;
  15735. private _projectionModeMatrix;
  15736. private _t0;
  15737. private _t1;
  15738. private _t2;
  15739. private _cachedUOffset;
  15740. private _cachedVOffset;
  15741. private _cachedUScale;
  15742. private _cachedVScale;
  15743. private _cachedUAng;
  15744. private _cachedVAng;
  15745. private _cachedWAng;
  15746. private _cachedProjectionMatrixId;
  15747. private _cachedCoordinatesMode;
  15748. /** @hidden */
  15749. protected _initialSamplingMode: number;
  15750. /** @hidden */
  15751. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15752. private _deleteBuffer;
  15753. protected _format: Nullable<number>;
  15754. private _delayedOnLoad;
  15755. private _delayedOnError;
  15756. /**
  15757. * Observable triggered once the texture has been loaded.
  15758. */
  15759. onLoadObservable: Observable<Texture>;
  15760. protected _isBlocking: boolean;
  15761. /**
  15762. * Is the texture preventing material to render while loading.
  15763. * If false, a default texture will be used instead of the loading one during the preparation step.
  15764. */
  15765. isBlocking: boolean;
  15766. /**
  15767. * Get the current sampling mode associated with the texture.
  15768. */
  15769. readonly samplingMode: number;
  15770. /**
  15771. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15772. */
  15773. readonly invertY: boolean;
  15774. /**
  15775. * Instantiates a new texture.
  15776. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15777. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15778. * @param url define the url of the picture to load as a texture
  15779. * @param scene define the scene or engine the texture will belong to
  15780. * @param noMipmap define if the texture will require mip maps or not
  15781. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15782. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15783. * @param onLoad define a callback triggered when the texture has been loaded
  15784. * @param onError define a callback triggered when an error occurred during the loading session
  15785. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15786. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15787. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15788. */
  15789. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15790. /**
  15791. * Update the url (and optional buffer) of this texture if url was null during construction.
  15792. * @param url the url of the texture
  15793. * @param buffer the buffer of the texture (defaults to null)
  15794. * @param onLoad callback called when the texture is loaded (defaults to null)
  15795. */
  15796. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15797. /**
  15798. * Finish the loading sequence of a texture flagged as delayed load.
  15799. * @hidden
  15800. */
  15801. delayLoad(): void;
  15802. private _prepareRowForTextureGeneration;
  15803. /**
  15804. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15805. * @returns the transform matrix of the texture.
  15806. */
  15807. getTextureMatrix(): Matrix;
  15808. /**
  15809. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15810. * @returns The reflection texture transform
  15811. */
  15812. getReflectionTextureMatrix(): Matrix;
  15813. /**
  15814. * Clones the texture.
  15815. * @returns the cloned texture
  15816. */
  15817. clone(): Texture;
  15818. /**
  15819. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15820. * @returns The JSON representation of the texture
  15821. */
  15822. serialize(): any;
  15823. /**
  15824. * Get the current class name of the texture useful for serialization or dynamic coding.
  15825. * @returns "Texture"
  15826. */
  15827. getClassName(): string;
  15828. /**
  15829. * Dispose the texture and release its associated resources.
  15830. */
  15831. dispose(): void;
  15832. /**
  15833. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15834. * @param parsedTexture Define the JSON representation of the texture
  15835. * @param scene Define the scene the parsed texture should be instantiated in
  15836. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15837. * @returns The parsed texture if successful
  15838. */
  15839. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15840. /**
  15841. * Creates a texture from its base 64 representation.
  15842. * @param data Define the base64 payload without the data: prefix
  15843. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15844. * @param scene Define the scene the texture should belong to
  15845. * @param noMipmap Forces the texture to not create mip map information if true
  15846. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15847. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15848. * @param onLoad define a callback triggered when the texture has been loaded
  15849. * @param onError define a callback triggered when an error occurred during the loading session
  15850. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15851. * @returns the created texture
  15852. */
  15853. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15854. /**
  15855. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15856. * @param data Define the base64 payload without the data: prefix
  15857. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15858. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15859. * @param scene Define the scene the texture should belong to
  15860. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15861. * @param noMipmap Forces the texture to not create mip map information if true
  15862. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15863. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15864. * @param onLoad define a callback triggered when the texture has been loaded
  15865. * @param onError define a callback triggered when an error occurred during the loading session
  15866. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15867. * @returns the created texture
  15868. */
  15869. 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;
  15870. }
  15871. }
  15872. declare module BABYLON {
  15873. /**
  15874. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15875. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15876. */
  15877. export class PostProcessManager {
  15878. private _scene;
  15879. private _indexBuffer;
  15880. private _vertexBuffers;
  15881. /**
  15882. * Creates a new instance PostProcess
  15883. * @param scene The scene that the post process is associated with.
  15884. */
  15885. constructor(scene: Scene);
  15886. private _prepareBuffers;
  15887. private _buildIndexBuffer;
  15888. /**
  15889. * Rebuilds the vertex buffers of the manager.
  15890. * @hidden
  15891. */
  15892. _rebuild(): void;
  15893. /**
  15894. * Prepares a frame to be run through a post process.
  15895. * @param sourceTexture The input texture to the post procesess. (default: null)
  15896. * @param postProcesses An array of post processes to be run. (default: null)
  15897. * @returns True if the post processes were able to be run.
  15898. * @hidden
  15899. */
  15900. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15901. /**
  15902. * Manually render a set of post processes to a texture.
  15903. * @param postProcesses An array of post processes to be run.
  15904. * @param targetTexture The target texture to render to.
  15905. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15906. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15907. * @param lodLevel defines which lod of the texture to render to
  15908. */
  15909. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15910. /**
  15911. * Finalize the result of the output of the postprocesses.
  15912. * @param doNotPresent If true the result will not be displayed to the screen.
  15913. * @param targetTexture The target texture to render to.
  15914. * @param faceIndex The index of the face to bind the target texture to.
  15915. * @param postProcesses The array of post processes to render.
  15916. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15917. * @hidden
  15918. */
  15919. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15920. /**
  15921. * Disposes of the post process manager.
  15922. */
  15923. dispose(): void;
  15924. }
  15925. }
  15926. declare module BABYLON {
  15927. /** Interface used by value gradients (color, factor, ...) */
  15928. export interface IValueGradient {
  15929. /**
  15930. * Gets or sets the gradient value (between 0 and 1)
  15931. */
  15932. gradient: number;
  15933. }
  15934. /** Class used to store color4 gradient */
  15935. export class ColorGradient implements IValueGradient {
  15936. /**
  15937. * Gets or sets the gradient value (between 0 and 1)
  15938. */
  15939. gradient: number;
  15940. /**
  15941. * Gets or sets first associated color
  15942. */
  15943. color1: Color4;
  15944. /**
  15945. * Gets or sets second associated color
  15946. */
  15947. color2?: Color4;
  15948. /**
  15949. * Will get a color picked randomly between color1 and color2.
  15950. * If color2 is undefined then color1 will be used
  15951. * @param result defines the target Color4 to store the result in
  15952. */
  15953. getColorToRef(result: Color4): void;
  15954. }
  15955. /** Class used to store color 3 gradient */
  15956. export class Color3Gradient implements IValueGradient {
  15957. /**
  15958. * Gets or sets the gradient value (between 0 and 1)
  15959. */
  15960. gradient: number;
  15961. /**
  15962. * Gets or sets the associated color
  15963. */
  15964. color: Color3;
  15965. }
  15966. /** Class used to store factor gradient */
  15967. export class FactorGradient implements IValueGradient {
  15968. /**
  15969. * Gets or sets the gradient value (between 0 and 1)
  15970. */
  15971. gradient: number;
  15972. /**
  15973. * Gets or sets first associated factor
  15974. */
  15975. factor1: number;
  15976. /**
  15977. * Gets or sets second associated factor
  15978. */
  15979. factor2?: number;
  15980. /**
  15981. * Will get a number picked randomly between factor1 and factor2.
  15982. * If factor2 is undefined then factor1 will be used
  15983. * @returns the picked number
  15984. */
  15985. getFactor(): number;
  15986. }
  15987. /**
  15988. * Helper used to simplify some generic gradient tasks
  15989. */
  15990. export class GradientHelper {
  15991. /**
  15992. * Gets the current gradient from an array of IValueGradient
  15993. * @param ratio defines the current ratio to get
  15994. * @param gradients defines the array of IValueGradient
  15995. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15996. */
  15997. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15998. }
  15999. }
  16000. declare module BABYLON {
  16001. /**
  16002. * A class extending Texture allowing drawing on a texture
  16003. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16004. */
  16005. export class DynamicTexture extends Texture {
  16006. private _generateMipMaps;
  16007. private _canvas;
  16008. private _context;
  16009. private _engine;
  16010. /**
  16011. * Creates a DynamicTexture
  16012. * @param name defines the name of the texture
  16013. * @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
  16014. * @param scene defines the scene where you want the texture
  16015. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16016. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16017. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16018. */
  16019. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16020. /**
  16021. * Get the current class name of the texture useful for serialization or dynamic coding.
  16022. * @returns "DynamicTexture"
  16023. */
  16024. getClassName(): string;
  16025. /**
  16026. * Gets the current state of canRescale
  16027. */
  16028. readonly canRescale: boolean;
  16029. private _recreate;
  16030. /**
  16031. * Scales the texture
  16032. * @param ratio the scale factor to apply to both width and height
  16033. */
  16034. scale(ratio: number): void;
  16035. /**
  16036. * Resizes the texture
  16037. * @param width the new width
  16038. * @param height the new height
  16039. */
  16040. scaleTo(width: number, height: number): void;
  16041. /**
  16042. * Gets the context of the canvas used by the texture
  16043. * @returns the canvas context of the dynamic texture
  16044. */
  16045. getContext(): CanvasRenderingContext2D;
  16046. /**
  16047. * Clears the texture
  16048. */
  16049. clear(): void;
  16050. /**
  16051. * Updates the texture
  16052. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16053. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16054. */
  16055. update(invertY?: boolean, premulAlpha?: boolean): void;
  16056. /**
  16057. * Draws text onto the texture
  16058. * @param text defines the text to be drawn
  16059. * @param x defines the placement of the text from the left
  16060. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16061. * @param font defines the font to be used with font-style, font-size, font-name
  16062. * @param color defines the color used for the text
  16063. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16064. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16065. * @param update defines whether texture is immediately update (default is true)
  16066. */
  16067. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16068. /**
  16069. * Clones the texture
  16070. * @returns the clone of the texture.
  16071. */
  16072. clone(): DynamicTexture;
  16073. /**
  16074. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16075. * @returns a serialized dynamic texture object
  16076. */
  16077. serialize(): any;
  16078. /** @hidden */
  16079. _rebuild(): void;
  16080. }
  16081. }
  16082. declare module BABYLON {
  16083. interface AbstractScene {
  16084. /**
  16085. * The list of procedural textures added to the scene
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16087. */
  16088. proceduralTextures: Array<ProceduralTexture>;
  16089. }
  16090. /**
  16091. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16092. * in a given scene.
  16093. */
  16094. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16095. /**
  16096. * The component name helpfull to identify the component in the list of scene components.
  16097. */
  16098. readonly name: string;
  16099. /**
  16100. * The scene the component belongs to.
  16101. */
  16102. scene: Scene;
  16103. /**
  16104. * Creates a new instance of the component for the given scene
  16105. * @param scene Defines the scene to register the component in
  16106. */
  16107. constructor(scene: Scene);
  16108. /**
  16109. * Registers the component in a given scene
  16110. */
  16111. register(): void;
  16112. /**
  16113. * Rebuilds the elements related to this component in case of
  16114. * context lost for instance.
  16115. */
  16116. rebuild(): void;
  16117. /**
  16118. * Disposes the component and the associated ressources.
  16119. */
  16120. dispose(): void;
  16121. private _beforeClear;
  16122. }
  16123. }
  16124. declare module BABYLON {
  16125. interface Engine {
  16126. /**
  16127. * Creates a new render target cube texture
  16128. * @param size defines the size of the texture
  16129. * @param options defines the options used to create the texture
  16130. * @returns a new render target cube texture stored in an InternalTexture
  16131. */
  16132. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16133. }
  16134. }
  16135. declare module BABYLON {
  16136. /** @hidden */
  16137. export var proceduralVertexShader: {
  16138. name: string;
  16139. shader: string;
  16140. };
  16141. }
  16142. declare module BABYLON {
  16143. /**
  16144. * 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.
  16145. * This is the base class of any Procedural texture and contains most of the shareable code.
  16146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16147. */
  16148. export class ProceduralTexture extends Texture {
  16149. isCube: boolean;
  16150. /**
  16151. * Define if the texture is enabled or not (disabled texture will not render)
  16152. */
  16153. isEnabled: boolean;
  16154. /**
  16155. * Define if the texture must be cleared before rendering (default is true)
  16156. */
  16157. autoClear: boolean;
  16158. /**
  16159. * Callback called when the texture is generated
  16160. */
  16161. onGenerated: () => void;
  16162. /**
  16163. * Event raised when the texture is generated
  16164. */
  16165. onGeneratedObservable: Observable<ProceduralTexture>;
  16166. /** @hidden */
  16167. _generateMipMaps: boolean;
  16168. /** @hidden **/
  16169. _effect: Effect;
  16170. /** @hidden */
  16171. _textures: {
  16172. [key: string]: Texture;
  16173. };
  16174. private _size;
  16175. private _currentRefreshId;
  16176. private _refreshRate;
  16177. private _vertexBuffers;
  16178. private _indexBuffer;
  16179. private _uniforms;
  16180. private _samplers;
  16181. private _fragment;
  16182. private _floats;
  16183. private _ints;
  16184. private _floatsArrays;
  16185. private _colors3;
  16186. private _colors4;
  16187. private _vectors2;
  16188. private _vectors3;
  16189. private _matrices;
  16190. private _fallbackTexture;
  16191. private _fallbackTextureUsed;
  16192. private _engine;
  16193. private _cachedDefines;
  16194. private _contentUpdateId;
  16195. private _contentData;
  16196. /**
  16197. * Instantiates a new procedural texture.
  16198. * 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.
  16199. * This is the base class of any Procedural texture and contains most of the shareable code.
  16200. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16201. * @param name Define the name of the texture
  16202. * @param size Define the size of the texture to create
  16203. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16204. * @param scene Define the scene the texture belongs to
  16205. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16206. * @param generateMipMaps Define if the texture should creates mip maps or not
  16207. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16208. */
  16209. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16210. /**
  16211. * The effect that is created when initializing the post process.
  16212. * @returns The created effect corresponding the the postprocess.
  16213. */
  16214. getEffect(): Effect;
  16215. /**
  16216. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16217. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16218. */
  16219. getContent(): Nullable<ArrayBufferView>;
  16220. private _createIndexBuffer;
  16221. /** @hidden */
  16222. _rebuild(): void;
  16223. /**
  16224. * Resets the texture in order to recreate its associated resources.
  16225. * This can be called in case of context loss
  16226. */
  16227. reset(): void;
  16228. protected _getDefines(): string;
  16229. /**
  16230. * Is the texture ready to be used ? (rendered at least once)
  16231. * @returns true if ready, otherwise, false.
  16232. */
  16233. isReady(): boolean;
  16234. /**
  16235. * Resets the refresh counter of the texture and start bak from scratch.
  16236. * Could be useful to regenerate the texture if it is setup to render only once.
  16237. */
  16238. resetRefreshCounter(): void;
  16239. /**
  16240. * Set the fragment shader to use in order to render the texture.
  16241. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16242. */
  16243. setFragment(fragment: any): void;
  16244. /**
  16245. * Define the refresh rate of the texture or the rendering frequency.
  16246. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16247. */
  16248. refreshRate: number;
  16249. /** @hidden */
  16250. _shouldRender(): boolean;
  16251. /**
  16252. * Get the size the texture is rendering at.
  16253. * @returns the size (texture is always squared)
  16254. */
  16255. getRenderSize(): number;
  16256. /**
  16257. * Resize the texture to new value.
  16258. * @param size Define the new size the texture should have
  16259. * @param generateMipMaps Define whether the new texture should create mip maps
  16260. */
  16261. resize(size: number, generateMipMaps: boolean): void;
  16262. private _checkUniform;
  16263. /**
  16264. * Set a texture in the shader program used to render.
  16265. * @param name Define the name of the uniform samplers as defined in the shader
  16266. * @param texture Define the texture to bind to this sampler
  16267. * @return the texture itself allowing "fluent" like uniform updates
  16268. */
  16269. setTexture(name: string, texture: Texture): ProceduralTexture;
  16270. /**
  16271. * Set a float in the shader.
  16272. * @param name Define the name of the uniform as defined in the shader
  16273. * @param value Define the value to give to the uniform
  16274. * @return the texture itself allowing "fluent" like uniform updates
  16275. */
  16276. setFloat(name: string, value: number): ProceduralTexture;
  16277. /**
  16278. * Set a int in the shader.
  16279. * @param name Define the name of the uniform as defined in the shader
  16280. * @param value Define the value to give to the uniform
  16281. * @return the texture itself allowing "fluent" like uniform updates
  16282. */
  16283. setInt(name: string, value: number): ProceduralTexture;
  16284. /**
  16285. * Set an array of floats in the shader.
  16286. * @param name Define the name of the uniform as defined in the shader
  16287. * @param value Define the value to give to the uniform
  16288. * @return the texture itself allowing "fluent" like uniform updates
  16289. */
  16290. setFloats(name: string, value: number[]): ProceduralTexture;
  16291. /**
  16292. * Set a vec3 in the shader from a Color3.
  16293. * @param name Define the name of the uniform as defined in the shader
  16294. * @param value Define the value to give to the uniform
  16295. * @return the texture itself allowing "fluent" like uniform updates
  16296. */
  16297. setColor3(name: string, value: Color3): ProceduralTexture;
  16298. /**
  16299. * Set a vec4 in the shader from a Color4.
  16300. * @param name Define the name of the uniform as defined in the shader
  16301. * @param value Define the value to give to the uniform
  16302. * @return the texture itself allowing "fluent" like uniform updates
  16303. */
  16304. setColor4(name: string, value: Color4): ProceduralTexture;
  16305. /**
  16306. * Set a vec2 in the shader from a Vector2.
  16307. * @param name Define the name of the uniform as defined in the shader
  16308. * @param value Define the value to give to the uniform
  16309. * @return the texture itself allowing "fluent" like uniform updates
  16310. */
  16311. setVector2(name: string, value: Vector2): ProceduralTexture;
  16312. /**
  16313. * Set a vec3 in the shader from a Vector3.
  16314. * @param name Define the name of the uniform as defined in the shader
  16315. * @param value Define the value to give to the uniform
  16316. * @return the texture itself allowing "fluent" like uniform updates
  16317. */
  16318. setVector3(name: string, value: Vector3): ProceduralTexture;
  16319. /**
  16320. * Set a mat4 in the shader from a MAtrix.
  16321. * @param name Define the name of the uniform as defined in the shader
  16322. * @param value Define the value to give to the uniform
  16323. * @return the texture itself allowing "fluent" like uniform updates
  16324. */
  16325. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16326. /**
  16327. * Render the texture to its associated render target.
  16328. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16329. */
  16330. render(useCameraPostProcess?: boolean): void;
  16331. /**
  16332. * Clone the texture.
  16333. * @returns the cloned texture
  16334. */
  16335. clone(): ProceduralTexture;
  16336. /**
  16337. * Dispose the texture and release its asoociated resources.
  16338. */
  16339. dispose(): void;
  16340. }
  16341. }
  16342. declare module BABYLON {
  16343. /**
  16344. * This represents the base class for particle system in Babylon.
  16345. * 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.
  16346. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16347. * @example https://doc.babylonjs.com/babylon101/particles
  16348. */
  16349. export class BaseParticleSystem {
  16350. /**
  16351. * Source color is added to the destination color without alpha affecting the result
  16352. */
  16353. static BLENDMODE_ONEONE: number;
  16354. /**
  16355. * Blend current color and particle color using particle’s alpha
  16356. */
  16357. static BLENDMODE_STANDARD: number;
  16358. /**
  16359. * Add current color and particle color multiplied by particle’s alpha
  16360. */
  16361. static BLENDMODE_ADD: number;
  16362. /**
  16363. * Multiply current color with particle color
  16364. */
  16365. static BLENDMODE_MULTIPLY: number;
  16366. /**
  16367. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16368. */
  16369. static BLENDMODE_MULTIPLYADD: number;
  16370. /**
  16371. * List of animations used by the particle system.
  16372. */
  16373. animations: Animation[];
  16374. /**
  16375. * The id of the Particle system.
  16376. */
  16377. id: string;
  16378. /**
  16379. * The friendly name of the Particle system.
  16380. */
  16381. name: string;
  16382. /**
  16383. * The rendering group used by the Particle system to chose when to render.
  16384. */
  16385. renderingGroupId: number;
  16386. /**
  16387. * The emitter represents the Mesh or position we are attaching the particle system to.
  16388. */
  16389. emitter: Nullable<AbstractMesh | Vector3>;
  16390. /**
  16391. * The maximum number of particles to emit per frame
  16392. */
  16393. emitRate: number;
  16394. /**
  16395. * If you want to launch only a few particles at once, that can be done, as well.
  16396. */
  16397. manualEmitCount: number;
  16398. /**
  16399. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16400. */
  16401. updateSpeed: number;
  16402. /**
  16403. * The amount of time the particle system is running (depends of the overall update speed).
  16404. */
  16405. targetStopDuration: number;
  16406. /**
  16407. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16408. */
  16409. disposeOnStop: boolean;
  16410. /**
  16411. * Minimum power of emitting particles.
  16412. */
  16413. minEmitPower: number;
  16414. /**
  16415. * Maximum power of emitting particles.
  16416. */
  16417. maxEmitPower: number;
  16418. /**
  16419. * Minimum life time of emitting particles.
  16420. */
  16421. minLifeTime: number;
  16422. /**
  16423. * Maximum life time of emitting particles.
  16424. */
  16425. maxLifeTime: number;
  16426. /**
  16427. * Minimum Size of emitting particles.
  16428. */
  16429. minSize: number;
  16430. /**
  16431. * Maximum Size of emitting particles.
  16432. */
  16433. maxSize: number;
  16434. /**
  16435. * Minimum scale of emitting particles on X axis.
  16436. */
  16437. minScaleX: number;
  16438. /**
  16439. * Maximum scale of emitting particles on X axis.
  16440. */
  16441. maxScaleX: number;
  16442. /**
  16443. * Minimum scale of emitting particles on Y axis.
  16444. */
  16445. minScaleY: number;
  16446. /**
  16447. * Maximum scale of emitting particles on Y axis.
  16448. */
  16449. maxScaleY: number;
  16450. /**
  16451. * Gets or sets the minimal initial rotation in radians.
  16452. */
  16453. minInitialRotation: number;
  16454. /**
  16455. * Gets or sets the maximal initial rotation in radians.
  16456. */
  16457. maxInitialRotation: number;
  16458. /**
  16459. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16460. */
  16461. minAngularSpeed: number;
  16462. /**
  16463. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16464. */
  16465. maxAngularSpeed: number;
  16466. /**
  16467. * The texture used to render each particle. (this can be a spritesheet)
  16468. */
  16469. particleTexture: Nullable<Texture>;
  16470. /**
  16471. * The layer mask we are rendering the particles through.
  16472. */
  16473. layerMask: number;
  16474. /**
  16475. * This can help using your own shader to render the particle system.
  16476. * The according effect will be created
  16477. */
  16478. customShader: any;
  16479. /**
  16480. * By default particle system starts as soon as they are created. This prevents the
  16481. * automatic start to happen and let you decide when to start emitting particles.
  16482. */
  16483. preventAutoStart: boolean;
  16484. private _noiseTexture;
  16485. /**
  16486. * Gets or sets a texture used to add random noise to particle positions
  16487. */
  16488. noiseTexture: Nullable<ProceduralTexture>;
  16489. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16490. noiseStrength: Vector3;
  16491. /**
  16492. * Callback triggered when the particle animation is ending.
  16493. */
  16494. onAnimationEnd: Nullable<() => void>;
  16495. /**
  16496. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16497. */
  16498. blendMode: number;
  16499. /**
  16500. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16501. * to override the particles.
  16502. */
  16503. forceDepthWrite: boolean;
  16504. /** 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 */
  16505. preWarmCycles: number;
  16506. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16507. preWarmStepOffset: number;
  16508. /**
  16509. * 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)
  16510. */
  16511. spriteCellChangeSpeed: number;
  16512. /**
  16513. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16514. */
  16515. startSpriteCellID: number;
  16516. /**
  16517. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16518. */
  16519. endSpriteCellID: number;
  16520. /**
  16521. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16522. */
  16523. spriteCellWidth: number;
  16524. /**
  16525. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16526. */
  16527. spriteCellHeight: number;
  16528. /**
  16529. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16530. */
  16531. spriteRandomStartCell: boolean;
  16532. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16533. translationPivot: Vector2;
  16534. /** @hidden */
  16535. protected _isAnimationSheetEnabled: boolean;
  16536. /**
  16537. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16538. */
  16539. beginAnimationOnStart: boolean;
  16540. /**
  16541. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16542. */
  16543. beginAnimationFrom: number;
  16544. /**
  16545. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16546. */
  16547. beginAnimationTo: number;
  16548. /**
  16549. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16550. */
  16551. beginAnimationLoop: boolean;
  16552. /**
  16553. * Gets or sets a world offset applied to all particles
  16554. */
  16555. worldOffset: Vector3;
  16556. /**
  16557. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16558. */
  16559. isAnimationSheetEnabled: boolean;
  16560. /**
  16561. * Get hosting scene
  16562. * @returns the scene
  16563. */
  16564. getScene(): Scene;
  16565. /**
  16566. * You can use gravity if you want to give an orientation to your particles.
  16567. */
  16568. gravity: Vector3;
  16569. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16570. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16571. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16572. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16573. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16574. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16575. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16576. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16577. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16578. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16579. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16580. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16581. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16582. /**
  16583. * Defines the delay in milliseconds before starting the system (0 by default)
  16584. */
  16585. startDelay: number;
  16586. /**
  16587. * Gets the current list of drag gradients.
  16588. * You must use addDragGradient and removeDragGradient to udpate this list
  16589. * @returns the list of drag gradients
  16590. */
  16591. getDragGradients(): Nullable<Array<FactorGradient>>;
  16592. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16593. limitVelocityDamping: number;
  16594. /**
  16595. * Gets the current list of limit velocity gradients.
  16596. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16597. * @returns the list of limit velocity gradients
  16598. */
  16599. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Gets the current list of color gradients.
  16602. * You must use addColorGradient and removeColorGradient to udpate this list
  16603. * @returns the list of color gradients
  16604. */
  16605. getColorGradients(): Nullable<Array<ColorGradient>>;
  16606. /**
  16607. * Gets the current list of size gradients.
  16608. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16609. * @returns the list of size gradients
  16610. */
  16611. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16612. /**
  16613. * Gets the current list of color remap gradients.
  16614. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16615. * @returns the list of color remap gradients
  16616. */
  16617. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16618. /**
  16619. * Gets the current list of alpha remap gradients.
  16620. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16621. * @returns the list of alpha remap gradients
  16622. */
  16623. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16624. /**
  16625. * Gets the current list of life time gradients.
  16626. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16627. * @returns the list of life time gradients
  16628. */
  16629. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Gets the current list of angular speed gradients.
  16632. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16633. * @returns the list of angular speed gradients
  16634. */
  16635. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16636. /**
  16637. * Gets the current list of velocity gradients.
  16638. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16639. * @returns the list of velocity gradients
  16640. */
  16641. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16642. /**
  16643. * Gets the current list of start size gradients.
  16644. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16645. * @returns the list of start size gradients
  16646. */
  16647. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16648. /**
  16649. * Gets the current list of emit rate gradients.
  16650. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16651. * @returns the list of emit rate gradients
  16652. */
  16653. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16654. /**
  16655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16656. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16657. */
  16658. direction1: Vector3;
  16659. /**
  16660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16661. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16662. */
  16663. direction2: Vector3;
  16664. /**
  16665. * 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.
  16666. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16667. */
  16668. minEmitBox: Vector3;
  16669. /**
  16670. * 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.
  16671. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16672. */
  16673. maxEmitBox: Vector3;
  16674. /**
  16675. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16676. */
  16677. color1: Color4;
  16678. /**
  16679. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16680. */
  16681. color2: Color4;
  16682. /**
  16683. * Color the particle will have at the end of its lifetime
  16684. */
  16685. colorDead: Color4;
  16686. /**
  16687. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16688. */
  16689. textureMask: Color4;
  16690. /**
  16691. * The particle emitter type defines the emitter used by the particle system.
  16692. * It can be for example box, sphere, or cone...
  16693. */
  16694. particleEmitterType: IParticleEmitterType;
  16695. /** @hidden */
  16696. _isSubEmitter: boolean;
  16697. /**
  16698. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16699. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16700. */
  16701. billboardMode: number;
  16702. protected _isBillboardBased: boolean;
  16703. /**
  16704. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16705. */
  16706. isBillboardBased: boolean;
  16707. /**
  16708. * The scene the particle system belongs to.
  16709. */
  16710. protected _scene: Scene;
  16711. /**
  16712. * Local cache of defines for image processing.
  16713. */
  16714. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16715. /**
  16716. * Default configuration related to image processing available in the standard Material.
  16717. */
  16718. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16719. /**
  16720. * Gets the image processing configuration used either in this material.
  16721. */
  16722. /**
  16723. * Sets the Default image processing configuration used either in the this material.
  16724. *
  16725. * If sets to null, the scene one is in use.
  16726. */
  16727. imageProcessingConfiguration: ImageProcessingConfiguration;
  16728. /**
  16729. * Attaches a new image processing configuration to the Standard Material.
  16730. * @param configuration
  16731. */
  16732. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16733. /** @hidden */
  16734. protected _reset(): void;
  16735. /** @hidden */
  16736. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16737. /**
  16738. * Instantiates a particle system.
  16739. * 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.
  16740. * @param name The name of the particle system
  16741. */
  16742. constructor(name: string);
  16743. /**
  16744. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16747. * @returns the emitter
  16748. */
  16749. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16750. /**
  16751. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16752. * @param radius The radius of the hemisphere to emit from
  16753. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16754. * @returns the emitter
  16755. */
  16756. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16757. /**
  16758. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16759. * @param radius The radius of the sphere to emit from
  16760. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16761. * @returns the emitter
  16762. */
  16763. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16764. /**
  16765. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16766. * @param radius The radius of the sphere to emit from
  16767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16769. * @returns the emitter
  16770. */
  16771. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16772. /**
  16773. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16774. * @param radius The radius of the emission cylinder
  16775. * @param height The height of the emission cylinder
  16776. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16777. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16778. * @returns the emitter
  16779. */
  16780. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16781. /**
  16782. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16783. * @param radius The radius of the cylinder to emit from
  16784. * @param height The height of the emission cylinder
  16785. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16786. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16787. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16788. * @returns the emitter
  16789. */
  16790. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16791. /**
  16792. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16793. * @param radius The radius of the cone to emit from
  16794. * @param angle The base angle of the cone
  16795. * @returns the emitter
  16796. */
  16797. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16798. /**
  16799. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16800. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16801. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16802. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16803. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16804. * @returns the emitter
  16805. */
  16806. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16807. }
  16808. }
  16809. declare module BABYLON {
  16810. /**
  16811. * Type of sub emitter
  16812. */
  16813. export enum SubEmitterType {
  16814. /**
  16815. * Attached to the particle over it's lifetime
  16816. */
  16817. ATTACHED = 0,
  16818. /**
  16819. * Created when the particle dies
  16820. */
  16821. END = 1
  16822. }
  16823. /**
  16824. * Sub emitter class used to emit particles from an existing particle
  16825. */
  16826. export class SubEmitter {
  16827. /**
  16828. * the particle system to be used by the sub emitter
  16829. */
  16830. particleSystem: ParticleSystem;
  16831. /**
  16832. * Type of the submitter (Default: END)
  16833. */
  16834. type: SubEmitterType;
  16835. /**
  16836. * 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)
  16837. * Note: This only is supported when using an emitter of type Mesh
  16838. */
  16839. inheritDirection: boolean;
  16840. /**
  16841. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16842. */
  16843. inheritedVelocityAmount: number;
  16844. /**
  16845. * Creates a sub emitter
  16846. * @param particleSystem the particle system to be used by the sub emitter
  16847. */
  16848. constructor(
  16849. /**
  16850. * the particle system to be used by the sub emitter
  16851. */
  16852. particleSystem: ParticleSystem);
  16853. /**
  16854. * Clones the sub emitter
  16855. * @returns the cloned sub emitter
  16856. */
  16857. clone(): SubEmitter;
  16858. /**
  16859. * Serialize current object to a JSON object
  16860. * @returns the serialized object
  16861. */
  16862. serialize(): any;
  16863. /** @hidden */
  16864. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16865. /**
  16866. * Creates a new SubEmitter from a serialized JSON version
  16867. * @param serializationObject defines the JSON object to read from
  16868. * @param scene defines the hosting scene
  16869. * @param rootUrl defines the rootUrl for data loading
  16870. * @returns a new SubEmitter
  16871. */
  16872. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16873. /** Release associated resources */
  16874. dispose(): void;
  16875. }
  16876. }
  16877. declare module BABYLON {
  16878. /** @hidden */
  16879. export var clipPlaneFragmentDeclaration: {
  16880. name: string;
  16881. shader: string;
  16882. };
  16883. }
  16884. declare module BABYLON {
  16885. /** @hidden */
  16886. export var imageProcessingDeclaration: {
  16887. name: string;
  16888. shader: string;
  16889. };
  16890. }
  16891. declare module BABYLON {
  16892. /** @hidden */
  16893. export var imageProcessingFunctions: {
  16894. name: string;
  16895. shader: string;
  16896. };
  16897. }
  16898. declare module BABYLON {
  16899. /** @hidden */
  16900. export var clipPlaneFragment: {
  16901. name: string;
  16902. shader: string;
  16903. };
  16904. }
  16905. declare module BABYLON {
  16906. /** @hidden */
  16907. export var particlesPixelShader: {
  16908. name: string;
  16909. shader: string;
  16910. };
  16911. }
  16912. declare module BABYLON {
  16913. /** @hidden */
  16914. export var clipPlaneVertexDeclaration: {
  16915. name: string;
  16916. shader: string;
  16917. };
  16918. }
  16919. declare module BABYLON {
  16920. /** @hidden */
  16921. export var clipPlaneVertex: {
  16922. name: string;
  16923. shader: string;
  16924. };
  16925. }
  16926. declare module BABYLON {
  16927. /** @hidden */
  16928. export var particlesVertexShader: {
  16929. name: string;
  16930. shader: string;
  16931. };
  16932. }
  16933. declare module BABYLON {
  16934. /**
  16935. * This represents a particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16941. /**
  16942. * Billboard mode will only apply to Y axis
  16943. */
  16944. static readonly BILLBOARDMODE_Y: number;
  16945. /**
  16946. * Billboard mode will apply to all axes
  16947. */
  16948. static readonly BILLBOARDMODE_ALL: number;
  16949. /**
  16950. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16951. */
  16952. static readonly BILLBOARDMODE_STRETCHED: number;
  16953. /**
  16954. * This function can be defined to provide custom update for active particles.
  16955. * This function will be called instead of regular update (age, position, color, etc.).
  16956. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16957. */
  16958. updateFunction: (particles: Particle[]) => void;
  16959. private _emitterWorldMatrix;
  16960. /**
  16961. * This function can be defined to specify initial direction for every new particle.
  16962. * It by default use the emitterType defined function
  16963. */
  16964. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16965. /**
  16966. * This function can be defined to specify initial position for every new particle.
  16967. * It by default use the emitterType defined function
  16968. */
  16969. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16970. /**
  16971. * @hidden
  16972. */
  16973. _inheritedVelocityOffset: Vector3;
  16974. /**
  16975. * An event triggered when the system is disposed
  16976. */
  16977. onDisposeObservable: Observable<ParticleSystem>;
  16978. private _onDisposeObserver;
  16979. /**
  16980. * Sets a callback that will be triggered when the system is disposed
  16981. */
  16982. onDispose: () => void;
  16983. private _particles;
  16984. private _epsilon;
  16985. private _capacity;
  16986. private _stockParticles;
  16987. private _newPartsExcess;
  16988. private _vertexData;
  16989. private _vertexBuffer;
  16990. private _vertexBuffers;
  16991. private _spriteBuffer;
  16992. private _indexBuffer;
  16993. private _effect;
  16994. private _customEffect;
  16995. private _cachedDefines;
  16996. private _scaledColorStep;
  16997. private _colorDiff;
  16998. private _scaledDirection;
  16999. private _scaledGravity;
  17000. private _currentRenderId;
  17001. private _alive;
  17002. private _useInstancing;
  17003. private _started;
  17004. private _stopped;
  17005. private _actualFrame;
  17006. private _scaledUpdateSpeed;
  17007. private _vertexBufferSize;
  17008. /** @hidden */
  17009. _currentEmitRateGradient: Nullable<FactorGradient>;
  17010. /** @hidden */
  17011. _currentEmitRate1: number;
  17012. /** @hidden */
  17013. _currentEmitRate2: number;
  17014. /** @hidden */
  17015. _currentStartSizeGradient: Nullable<FactorGradient>;
  17016. /** @hidden */
  17017. _currentStartSize1: number;
  17018. /** @hidden */
  17019. _currentStartSize2: number;
  17020. private readonly _rawTextureWidth;
  17021. private _rampGradientsTexture;
  17022. private _useRampGradients;
  17023. /** Gets or sets a boolean indicating that ramp gradients must be used
  17024. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17025. */
  17026. useRampGradients: boolean;
  17027. /**
  17028. * 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.
  17029. * 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: [])
  17030. */
  17031. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17032. private _subEmitters;
  17033. /**
  17034. * @hidden
  17035. * If the particle systems emitter should be disposed when the particle system is disposed
  17036. */
  17037. _disposeEmitterOnDispose: boolean;
  17038. /**
  17039. * The current active Sub-systems, this property is used by the root particle system only.
  17040. */
  17041. activeSubSystems: Array<ParticleSystem>;
  17042. private _rootParticleSystem;
  17043. /**
  17044. * Gets the current list of active particles
  17045. */
  17046. readonly particles: Particle[];
  17047. /**
  17048. * Returns the string "ParticleSystem"
  17049. * @returns a string containing the class name
  17050. */
  17051. getClassName(): string;
  17052. /**
  17053. * Instantiates a particle system.
  17054. * 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.
  17055. * @param name The name of the particle system
  17056. * @param capacity The max number of particles alive at the same time
  17057. * @param scene The scene the particle system belongs to
  17058. * @param customEffect a custom effect used to change the way particles are rendered by default
  17059. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17060. * @param epsilon Offset used to render the particles
  17061. */
  17062. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17063. private _addFactorGradient;
  17064. private _removeFactorGradient;
  17065. /**
  17066. * Adds a new life time gradient
  17067. * @param gradient defines the gradient to use (between 0 and 1)
  17068. * @param factor defines the life time factor to affect to the specified gradient
  17069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17070. * @returns the current particle system
  17071. */
  17072. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17073. /**
  17074. * Remove a specific life time gradient
  17075. * @param gradient defines the gradient to remove
  17076. * @returns the current particle system
  17077. */
  17078. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17079. /**
  17080. * Adds a new size gradient
  17081. * @param gradient defines the gradient to use (between 0 and 1)
  17082. * @param factor defines the size factor to affect to the specified gradient
  17083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17084. * @returns the current particle system
  17085. */
  17086. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17087. /**
  17088. * Remove a specific size gradient
  17089. * @param gradient defines the gradient to remove
  17090. * @returns the current particle system
  17091. */
  17092. removeSizeGradient(gradient: number): IParticleSystem;
  17093. /**
  17094. * Adds a new color remap gradient
  17095. * @param gradient defines the gradient to use (between 0 and 1)
  17096. * @param min defines the color remap minimal range
  17097. * @param max defines the color remap maximal range
  17098. * @returns the current particle system
  17099. */
  17100. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17101. /**
  17102. * Remove a specific color remap gradient
  17103. * @param gradient defines the gradient to remove
  17104. * @returns the current particle system
  17105. */
  17106. removeColorRemapGradient(gradient: number): IParticleSystem;
  17107. /**
  17108. * Adds a new alpha remap gradient
  17109. * @param gradient defines the gradient to use (between 0 and 1)
  17110. * @param min defines the alpha remap minimal range
  17111. * @param max defines the alpha remap maximal range
  17112. * @returns the current particle system
  17113. */
  17114. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17115. /**
  17116. * Remove a specific alpha remap gradient
  17117. * @param gradient defines the gradient to remove
  17118. * @returns the current particle system
  17119. */
  17120. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17121. /**
  17122. * Adds a new angular speed gradient
  17123. * @param gradient defines the gradient to use (between 0 and 1)
  17124. * @param factor defines the angular speed to affect to the specified gradient
  17125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17126. * @returns the current particle system
  17127. */
  17128. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17129. /**
  17130. * Remove a specific angular speed gradient
  17131. * @param gradient defines the gradient to remove
  17132. * @returns the current particle system
  17133. */
  17134. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17135. /**
  17136. * Adds a new velocity gradient
  17137. * @param gradient defines the gradient to use (between 0 and 1)
  17138. * @param factor defines the velocity to affect to the specified gradient
  17139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17140. * @returns the current particle system
  17141. */
  17142. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17143. /**
  17144. * Remove a specific velocity gradient
  17145. * @param gradient defines the gradient to remove
  17146. * @returns the current particle system
  17147. */
  17148. removeVelocityGradient(gradient: number): IParticleSystem;
  17149. /**
  17150. * Adds a new limit velocity gradient
  17151. * @param gradient defines the gradient to use (between 0 and 1)
  17152. * @param factor defines the limit velocity value to affect to the specified gradient
  17153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17154. * @returns the current particle system
  17155. */
  17156. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17157. /**
  17158. * Remove a specific limit velocity gradient
  17159. * @param gradient defines the gradient to remove
  17160. * @returns the current particle system
  17161. */
  17162. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17163. /**
  17164. * Adds a new drag gradient
  17165. * @param gradient defines the gradient to use (between 0 and 1)
  17166. * @param factor defines the drag value to affect to the specified gradient
  17167. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17168. * @returns the current particle system
  17169. */
  17170. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17171. /**
  17172. * Remove a specific drag gradient
  17173. * @param gradient defines the gradient to remove
  17174. * @returns the current particle system
  17175. */
  17176. removeDragGradient(gradient: number): IParticleSystem;
  17177. /**
  17178. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17179. * @param gradient defines the gradient to use (between 0 and 1)
  17180. * @param factor defines the emit rate value to affect to the specified gradient
  17181. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17182. * @returns the current particle system
  17183. */
  17184. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17185. /**
  17186. * Remove a specific emit rate gradient
  17187. * @param gradient defines the gradient to remove
  17188. * @returns the current particle system
  17189. */
  17190. removeEmitRateGradient(gradient: number): IParticleSystem;
  17191. /**
  17192. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17193. * @param gradient defines the gradient to use (between 0 and 1)
  17194. * @param factor defines the start size value to affect to the specified gradient
  17195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17196. * @returns the current particle system
  17197. */
  17198. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17199. /**
  17200. * Remove a specific start size gradient
  17201. * @param gradient defines the gradient to remove
  17202. * @returns the current particle system
  17203. */
  17204. removeStartSizeGradient(gradient: number): IParticleSystem;
  17205. private _createRampGradientTexture;
  17206. /**
  17207. * Gets the current list of ramp gradients.
  17208. * You must use addRampGradient and removeRampGradient to udpate this list
  17209. * @returns the list of ramp gradients
  17210. */
  17211. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17212. /**
  17213. * Adds a new ramp gradient used to remap particle colors
  17214. * @param gradient defines the gradient to use (between 0 and 1)
  17215. * @param color defines the color to affect to the specified gradient
  17216. * @returns the current particle system
  17217. */
  17218. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17219. /**
  17220. * Remove a specific ramp gradient
  17221. * @param gradient defines the gradient to remove
  17222. * @returns the current particle system
  17223. */
  17224. removeRampGradient(gradient: number): ParticleSystem;
  17225. /**
  17226. * Adds a new color gradient
  17227. * @param gradient defines the gradient to use (between 0 and 1)
  17228. * @param color1 defines the color to affect to the specified gradient
  17229. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17230. * @returns this particle system
  17231. */
  17232. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17233. /**
  17234. * Remove a specific color gradient
  17235. * @param gradient defines the gradient to remove
  17236. * @returns this particle system
  17237. */
  17238. removeColorGradient(gradient: number): IParticleSystem;
  17239. private _fetchR;
  17240. protected _reset(): void;
  17241. private _resetEffect;
  17242. private _createVertexBuffers;
  17243. private _createIndexBuffer;
  17244. /**
  17245. * Gets the maximum number of particles active at the same time.
  17246. * @returns The max number of active particles.
  17247. */
  17248. getCapacity(): number;
  17249. /**
  17250. * Gets whether there are still active particles in the system.
  17251. * @returns True if it is alive, otherwise false.
  17252. */
  17253. isAlive(): boolean;
  17254. /**
  17255. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17256. * @returns True if it has been started, otherwise false.
  17257. */
  17258. isStarted(): boolean;
  17259. private _prepareSubEmitterInternalArray;
  17260. /**
  17261. * Starts the particle system and begins to emit
  17262. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17263. */
  17264. start(delay?: number): void;
  17265. /**
  17266. * Stops the particle system.
  17267. * @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.
  17268. */
  17269. stop(stopSubEmitters?: boolean): void;
  17270. /**
  17271. * Remove all active particles
  17272. */
  17273. reset(): void;
  17274. /**
  17275. * @hidden (for internal use only)
  17276. */
  17277. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17278. /**
  17279. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17280. * Its lifetime will start back at 0.
  17281. */
  17282. recycleParticle: (particle: Particle) => void;
  17283. private _stopSubEmitters;
  17284. private _createParticle;
  17285. private _removeFromRoot;
  17286. private _emitFromParticle;
  17287. private _update;
  17288. /** @hidden */
  17289. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17290. /** @hidden */
  17291. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17292. /** @hidden */
  17293. private _getEffect;
  17294. /**
  17295. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17296. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17297. */
  17298. animate(preWarmOnly?: boolean): void;
  17299. private _appendParticleVertices;
  17300. /**
  17301. * Rebuilds the particle system.
  17302. */
  17303. rebuild(): void;
  17304. /**
  17305. * Is this system ready to be used/rendered
  17306. * @return true if the system is ready
  17307. */
  17308. isReady(): boolean;
  17309. private _render;
  17310. /**
  17311. * Renders the particle system in its current state.
  17312. * @returns the current number of particles
  17313. */
  17314. render(): number;
  17315. /**
  17316. * Disposes the particle system and free the associated resources
  17317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17318. */
  17319. dispose(disposeTexture?: boolean): void;
  17320. /**
  17321. * Clones the particle system.
  17322. * @param name The name of the cloned object
  17323. * @param newEmitter The new emitter to use
  17324. * @returns the cloned particle system
  17325. */
  17326. clone(name: string, newEmitter: any): ParticleSystem;
  17327. /**
  17328. * Serializes the particle system to a JSON object.
  17329. * @returns the JSON object
  17330. */
  17331. serialize(): any;
  17332. /** @hidden */
  17333. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17334. /** @hidden */
  17335. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17336. /**
  17337. * Parses a JSON object to create a particle system.
  17338. * @param parsedParticleSystem The JSON object to parse
  17339. * @param scene The scene to create the particle system in
  17340. * @param rootUrl The root url to use to load external dependencies like texture
  17341. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17342. * @returns the Parsed particle system
  17343. */
  17344. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17345. }
  17346. }
  17347. declare module BABYLON {
  17348. /**
  17349. * A particle represents one of the element emitted by a particle system.
  17350. * This is mainly define by its coordinates, direction, velocity and age.
  17351. */
  17352. export class Particle {
  17353. /**
  17354. * The particle system the particle belongs to.
  17355. */
  17356. particleSystem: ParticleSystem;
  17357. private static _Count;
  17358. /**
  17359. * Unique ID of the particle
  17360. */
  17361. id: number;
  17362. /**
  17363. * The world position of the particle in the scene.
  17364. */
  17365. position: Vector3;
  17366. /**
  17367. * The world direction of the particle in the scene.
  17368. */
  17369. direction: Vector3;
  17370. /**
  17371. * The color of the particle.
  17372. */
  17373. color: Color4;
  17374. /**
  17375. * The color change of the particle per step.
  17376. */
  17377. colorStep: Color4;
  17378. /**
  17379. * Defines how long will the life of the particle be.
  17380. */
  17381. lifeTime: number;
  17382. /**
  17383. * The current age of the particle.
  17384. */
  17385. age: number;
  17386. /**
  17387. * The current size of the particle.
  17388. */
  17389. size: number;
  17390. /**
  17391. * The current scale of the particle.
  17392. */
  17393. scale: Vector2;
  17394. /**
  17395. * The current angle of the particle.
  17396. */
  17397. angle: number;
  17398. /**
  17399. * Defines how fast is the angle changing.
  17400. */
  17401. angularSpeed: number;
  17402. /**
  17403. * Defines the cell index used by the particle to be rendered from a sprite.
  17404. */
  17405. cellIndex: number;
  17406. /**
  17407. * The information required to support color remapping
  17408. */
  17409. remapData: Vector4;
  17410. /** @hidden */
  17411. _randomCellOffset?: number;
  17412. /** @hidden */
  17413. _initialDirection: Nullable<Vector3>;
  17414. /** @hidden */
  17415. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17416. /** @hidden */
  17417. _initialStartSpriteCellID: number;
  17418. /** @hidden */
  17419. _initialEndSpriteCellID: number;
  17420. /** @hidden */
  17421. _currentColorGradient: Nullable<ColorGradient>;
  17422. /** @hidden */
  17423. _currentColor1: Color4;
  17424. /** @hidden */
  17425. _currentColor2: Color4;
  17426. /** @hidden */
  17427. _currentSizeGradient: Nullable<FactorGradient>;
  17428. /** @hidden */
  17429. _currentSize1: number;
  17430. /** @hidden */
  17431. _currentSize2: number;
  17432. /** @hidden */
  17433. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17434. /** @hidden */
  17435. _currentAngularSpeed1: number;
  17436. /** @hidden */
  17437. _currentAngularSpeed2: number;
  17438. /** @hidden */
  17439. _currentVelocityGradient: Nullable<FactorGradient>;
  17440. /** @hidden */
  17441. _currentVelocity1: number;
  17442. /** @hidden */
  17443. _currentVelocity2: number;
  17444. /** @hidden */
  17445. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentLimitVelocity1: number;
  17448. /** @hidden */
  17449. _currentLimitVelocity2: number;
  17450. /** @hidden */
  17451. _currentDragGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentDrag1: number;
  17454. /** @hidden */
  17455. _currentDrag2: number;
  17456. /** @hidden */
  17457. _randomNoiseCoordinates1: Vector3;
  17458. /** @hidden */
  17459. _randomNoiseCoordinates2: Vector3;
  17460. /**
  17461. * Creates a new instance Particle
  17462. * @param particleSystem the particle system the particle belongs to
  17463. */
  17464. constructor(
  17465. /**
  17466. * The particle system the particle belongs to.
  17467. */
  17468. particleSystem: ParticleSystem);
  17469. private updateCellInfoFromSystem;
  17470. /**
  17471. * Defines how the sprite cell index is updated for the particle
  17472. */
  17473. updateCellIndex(): void;
  17474. /** @hidden */
  17475. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17476. /** @hidden */
  17477. _inheritParticleInfoToSubEmitters(): void;
  17478. /** @hidden */
  17479. _reset(): void;
  17480. /**
  17481. * Copy the properties of particle to another one.
  17482. * @param other the particle to copy the information to.
  17483. */
  17484. copyTo(other: Particle): void;
  17485. }
  17486. }
  17487. declare module BABYLON {
  17488. /**
  17489. * Particle emitter represents a volume emitting particles.
  17490. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17491. */
  17492. export interface IParticleEmitterType {
  17493. /**
  17494. * Called by the particle System when the direction is computed for the created particle.
  17495. * @param worldMatrix is the world matrix of the particle system
  17496. * @param directionToUpdate is the direction vector to update with the result
  17497. * @param particle is the particle we are computed the direction for
  17498. */
  17499. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17500. /**
  17501. * Called by the particle System when the position is computed for the created particle.
  17502. * @param worldMatrix is the world matrix of the particle system
  17503. * @param positionToUpdate is the position vector to update with the result
  17504. * @param particle is the particle we are computed the position for
  17505. */
  17506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17507. /**
  17508. * Clones the current emitter and returns a copy of it
  17509. * @returns the new emitter
  17510. */
  17511. clone(): IParticleEmitterType;
  17512. /**
  17513. * Called by the GPUParticleSystem to setup the update shader
  17514. * @param effect defines the update shader
  17515. */
  17516. applyToShader(effect: Effect): void;
  17517. /**
  17518. * Returns a string to use to update the GPU particles update shader
  17519. * @returns the effect defines string
  17520. */
  17521. getEffectDefines(): string;
  17522. /**
  17523. * Returns a string representing the class name
  17524. * @returns a string containing the class name
  17525. */
  17526. getClassName(): string;
  17527. /**
  17528. * Serializes the particle system to a JSON object.
  17529. * @returns the JSON object
  17530. */
  17531. serialize(): any;
  17532. /**
  17533. * Parse properties from a JSON object
  17534. * @param serializationObject defines the JSON object
  17535. */
  17536. parse(serializationObject: any): void;
  17537. }
  17538. }
  17539. declare module BABYLON {
  17540. /**
  17541. * Particle emitter emitting particles from the inside of a box.
  17542. * It emits the particles randomly between 2 given directions.
  17543. */
  17544. export class BoxParticleEmitter implements IParticleEmitterType {
  17545. /**
  17546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17547. */
  17548. direction1: Vector3;
  17549. /**
  17550. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17551. */
  17552. direction2: Vector3;
  17553. /**
  17554. * 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.
  17555. */
  17556. minEmitBox: Vector3;
  17557. /**
  17558. * 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.
  17559. */
  17560. maxEmitBox: Vector3;
  17561. /**
  17562. * Creates a new instance BoxParticleEmitter
  17563. */
  17564. constructor();
  17565. /**
  17566. * Called by the particle System when the direction is computed for the created particle.
  17567. * @param worldMatrix is the world matrix of the particle system
  17568. * @param directionToUpdate is the direction vector to update with the result
  17569. * @param particle is the particle we are computed the direction for
  17570. */
  17571. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17572. /**
  17573. * Called by the particle System when the position is computed for the created particle.
  17574. * @param worldMatrix is the world matrix of the particle system
  17575. * @param positionToUpdate is the position vector to update with the result
  17576. * @param particle is the particle we are computed the position for
  17577. */
  17578. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17579. /**
  17580. * Clones the current emitter and returns a copy of it
  17581. * @returns the new emitter
  17582. */
  17583. clone(): BoxParticleEmitter;
  17584. /**
  17585. * Called by the GPUParticleSystem to setup the update shader
  17586. * @param effect defines the update shader
  17587. */
  17588. applyToShader(effect: Effect): void;
  17589. /**
  17590. * Returns a string to use to update the GPU particles update shader
  17591. * @returns a string containng the defines string
  17592. */
  17593. getEffectDefines(): string;
  17594. /**
  17595. * Returns the string "BoxParticleEmitter"
  17596. * @returns a string containing the class name
  17597. */
  17598. getClassName(): string;
  17599. /**
  17600. * Serializes the particle system to a JSON object.
  17601. * @returns the JSON object
  17602. */
  17603. serialize(): any;
  17604. /**
  17605. * Parse properties from a JSON object
  17606. * @param serializationObject defines the JSON object
  17607. */
  17608. parse(serializationObject: any): void;
  17609. }
  17610. }
  17611. declare module BABYLON {
  17612. /**
  17613. * Particle emitter emitting particles from the inside of a cone.
  17614. * It emits the particles alongside the cone volume from the base to the particle.
  17615. * The emission direction might be randomized.
  17616. */
  17617. export class ConeParticleEmitter implements IParticleEmitterType {
  17618. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17619. directionRandomizer: number;
  17620. private _radius;
  17621. private _angle;
  17622. private _height;
  17623. /**
  17624. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17625. */
  17626. radiusRange: number;
  17627. /**
  17628. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17629. */
  17630. heightRange: number;
  17631. /**
  17632. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17633. */
  17634. emitFromSpawnPointOnly: boolean;
  17635. /**
  17636. * Gets or sets the radius of the emission cone
  17637. */
  17638. radius: number;
  17639. /**
  17640. * Gets or sets the angle of the emission cone
  17641. */
  17642. angle: number;
  17643. private _buildHeight;
  17644. /**
  17645. * Creates a new instance ConeParticleEmitter
  17646. * @param radius the radius of the emission cone (1 by default)
  17647. * @param angle the cone base angle (PI by default)
  17648. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17649. */
  17650. constructor(radius?: number, angle?: number,
  17651. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17652. directionRandomizer?: number);
  17653. /**
  17654. * Called by the particle System when the direction is computed for the created particle.
  17655. * @param worldMatrix is the world matrix of the particle system
  17656. * @param directionToUpdate is the direction vector to update with the result
  17657. * @param particle is the particle we are computed the direction for
  17658. */
  17659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17660. /**
  17661. * Called by the particle System when the position is computed for the created particle.
  17662. * @param worldMatrix is the world matrix of the particle system
  17663. * @param positionToUpdate is the position vector to update with the result
  17664. * @param particle is the particle we are computed the position for
  17665. */
  17666. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17667. /**
  17668. * Clones the current emitter and returns a copy of it
  17669. * @returns the new emitter
  17670. */
  17671. clone(): ConeParticleEmitter;
  17672. /**
  17673. * Called by the GPUParticleSystem to setup the update shader
  17674. * @param effect defines the update shader
  17675. */
  17676. applyToShader(effect: Effect): void;
  17677. /**
  17678. * Returns a string to use to update the GPU particles update shader
  17679. * @returns a string containng the defines string
  17680. */
  17681. getEffectDefines(): string;
  17682. /**
  17683. * Returns the string "ConeParticleEmitter"
  17684. * @returns a string containing the class name
  17685. */
  17686. getClassName(): string;
  17687. /**
  17688. * Serializes the particle system to a JSON object.
  17689. * @returns the JSON object
  17690. */
  17691. serialize(): any;
  17692. /**
  17693. * Parse properties from a JSON object
  17694. * @param serializationObject defines the JSON object
  17695. */
  17696. parse(serializationObject: any): void;
  17697. }
  17698. }
  17699. declare module BABYLON {
  17700. /**
  17701. * Particle emitter emitting particles from the inside of a cylinder.
  17702. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17703. */
  17704. export class CylinderParticleEmitter implements IParticleEmitterType {
  17705. /**
  17706. * The radius of the emission cylinder.
  17707. */
  17708. radius: number;
  17709. /**
  17710. * The height of the emission cylinder.
  17711. */
  17712. height: number;
  17713. /**
  17714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17715. */
  17716. radiusRange: number;
  17717. /**
  17718. * How much to randomize the particle direction [0-1].
  17719. */
  17720. directionRandomizer: number;
  17721. /**
  17722. * Creates a new instance CylinderParticleEmitter
  17723. * @param radius the radius of the emission cylinder (1 by default)
  17724. * @param height the height of the emission cylinder (1 by default)
  17725. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17726. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17727. */
  17728. constructor(
  17729. /**
  17730. * The radius of the emission cylinder.
  17731. */
  17732. radius?: number,
  17733. /**
  17734. * The height of the emission cylinder.
  17735. */
  17736. height?: number,
  17737. /**
  17738. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17739. */
  17740. radiusRange?: number,
  17741. /**
  17742. * How much to randomize the particle direction [0-1].
  17743. */
  17744. directionRandomizer?: number);
  17745. /**
  17746. * Called by the particle System when the direction is computed for the created particle.
  17747. * @param worldMatrix is the world matrix of the particle system
  17748. * @param directionToUpdate is the direction vector to update with the result
  17749. * @param particle is the particle we are computed the direction for
  17750. */
  17751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17752. /**
  17753. * Called by the particle System when the position is computed for the created particle.
  17754. * @param worldMatrix is the world matrix of the particle system
  17755. * @param positionToUpdate is the position vector to update with the result
  17756. * @param particle is the particle we are computed the position for
  17757. */
  17758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17759. /**
  17760. * Clones the current emitter and returns a copy of it
  17761. * @returns the new emitter
  17762. */
  17763. clone(): CylinderParticleEmitter;
  17764. /**
  17765. * Called by the GPUParticleSystem to setup the update shader
  17766. * @param effect defines the update shader
  17767. */
  17768. applyToShader(effect: Effect): void;
  17769. /**
  17770. * Returns a string to use to update the GPU particles update shader
  17771. * @returns a string containng the defines string
  17772. */
  17773. getEffectDefines(): string;
  17774. /**
  17775. * Returns the string "CylinderParticleEmitter"
  17776. * @returns a string containing the class name
  17777. */
  17778. getClassName(): string;
  17779. /**
  17780. * Serializes the particle system to a JSON object.
  17781. * @returns the JSON object
  17782. */
  17783. serialize(): any;
  17784. /**
  17785. * Parse properties from a JSON object
  17786. * @param serializationObject defines the JSON object
  17787. */
  17788. parse(serializationObject: any): void;
  17789. }
  17790. /**
  17791. * Particle emitter emitting particles from the inside of a cylinder.
  17792. * It emits the particles randomly between two vectors.
  17793. */
  17794. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17795. /**
  17796. * The min limit of the emission direction.
  17797. */
  17798. direction1: Vector3;
  17799. /**
  17800. * The max limit of the emission direction.
  17801. */
  17802. direction2: Vector3;
  17803. /**
  17804. * Creates a new instance CylinderDirectedParticleEmitter
  17805. * @param radius the radius of the emission cylinder (1 by default)
  17806. * @param height the height of the emission cylinder (1 by default)
  17807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17808. * @param direction1 the min limit of the emission direction (up vector by default)
  17809. * @param direction2 the max limit of the emission direction (up vector by default)
  17810. */
  17811. constructor(radius?: number, height?: number, radiusRange?: number,
  17812. /**
  17813. * The min limit of the emission direction.
  17814. */
  17815. direction1?: Vector3,
  17816. /**
  17817. * The max limit of the emission direction.
  17818. */
  17819. direction2?: Vector3);
  17820. /**
  17821. * Called by the particle System when the direction is computed for the created particle.
  17822. * @param worldMatrix is the world matrix of the particle system
  17823. * @param directionToUpdate is the direction vector to update with the result
  17824. * @param particle is the particle we are computed the direction for
  17825. */
  17826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17827. /**
  17828. * Clones the current emitter and returns a copy of it
  17829. * @returns the new emitter
  17830. */
  17831. clone(): CylinderDirectedParticleEmitter;
  17832. /**
  17833. * Called by the GPUParticleSystem to setup the update shader
  17834. * @param effect defines the update shader
  17835. */
  17836. applyToShader(effect: Effect): void;
  17837. /**
  17838. * Returns a string to use to update the GPU particles update shader
  17839. * @returns a string containng the defines string
  17840. */
  17841. getEffectDefines(): string;
  17842. /**
  17843. * Returns the string "CylinderDirectedParticleEmitter"
  17844. * @returns a string containing the class name
  17845. */
  17846. getClassName(): string;
  17847. /**
  17848. * Serializes the particle system to a JSON object.
  17849. * @returns the JSON object
  17850. */
  17851. serialize(): any;
  17852. /**
  17853. * Parse properties from a JSON object
  17854. * @param serializationObject defines the JSON object
  17855. */
  17856. parse(serializationObject: any): void;
  17857. }
  17858. }
  17859. declare module BABYLON {
  17860. /**
  17861. * Particle emitter emitting particles from the inside of a hemisphere.
  17862. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17863. */
  17864. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17865. /**
  17866. * The radius of the emission hemisphere.
  17867. */
  17868. radius: number;
  17869. /**
  17870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17871. */
  17872. radiusRange: number;
  17873. /**
  17874. * How much to randomize the particle direction [0-1].
  17875. */
  17876. directionRandomizer: number;
  17877. /**
  17878. * Creates a new instance HemisphericParticleEmitter
  17879. * @param radius the radius of the emission hemisphere (1 by default)
  17880. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17881. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17882. */
  17883. constructor(
  17884. /**
  17885. * The radius of the emission hemisphere.
  17886. */
  17887. radius?: number,
  17888. /**
  17889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17890. */
  17891. radiusRange?: number,
  17892. /**
  17893. * How much to randomize the particle direction [0-1].
  17894. */
  17895. directionRandomizer?: number);
  17896. /**
  17897. * Called by the particle System when the direction is computed for the created particle.
  17898. * @param worldMatrix is the world matrix of the particle system
  17899. * @param directionToUpdate is the direction vector to update with the result
  17900. * @param particle is the particle we are computed the direction for
  17901. */
  17902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17903. /**
  17904. * Called by the particle System when the position is computed for the created particle.
  17905. * @param worldMatrix is the world matrix of the particle system
  17906. * @param positionToUpdate is the position vector to update with the result
  17907. * @param particle is the particle we are computed the position for
  17908. */
  17909. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17910. /**
  17911. * Clones the current emitter and returns a copy of it
  17912. * @returns the new emitter
  17913. */
  17914. clone(): HemisphericParticleEmitter;
  17915. /**
  17916. * Called by the GPUParticleSystem to setup the update shader
  17917. * @param effect defines the update shader
  17918. */
  17919. applyToShader(effect: Effect): void;
  17920. /**
  17921. * Returns a string to use to update the GPU particles update shader
  17922. * @returns a string containng the defines string
  17923. */
  17924. getEffectDefines(): string;
  17925. /**
  17926. * Returns the string "HemisphericParticleEmitter"
  17927. * @returns a string containing the class name
  17928. */
  17929. getClassName(): string;
  17930. /**
  17931. * Serializes the particle system to a JSON object.
  17932. * @returns the JSON object
  17933. */
  17934. serialize(): any;
  17935. /**
  17936. * Parse properties from a JSON object
  17937. * @param serializationObject defines the JSON object
  17938. */
  17939. parse(serializationObject: any): void;
  17940. }
  17941. }
  17942. declare module BABYLON {
  17943. /**
  17944. * Particle emitter emitting particles from a point.
  17945. * It emits the particles randomly between 2 given directions.
  17946. */
  17947. export class PointParticleEmitter implements IParticleEmitterType {
  17948. /**
  17949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17950. */
  17951. direction1: Vector3;
  17952. /**
  17953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17954. */
  17955. direction2: Vector3;
  17956. /**
  17957. * Creates a new instance PointParticleEmitter
  17958. */
  17959. constructor();
  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(): PointParticleEmitter;
  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 "PointParticleEmitter"
  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 the inside of a sphere.
  18009. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18010. */
  18011. export class SphereParticleEmitter implements IParticleEmitterType {
  18012. /**
  18013. * The radius of the emission sphere.
  18014. */
  18015. radius: number;
  18016. /**
  18017. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18018. */
  18019. radiusRange: number;
  18020. /**
  18021. * How much to randomize the particle direction [0-1].
  18022. */
  18023. directionRandomizer: number;
  18024. /**
  18025. * Creates a new instance SphereParticleEmitter
  18026. * @param radius the radius of the emission sphere (1 by default)
  18027. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18028. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18029. */
  18030. constructor(
  18031. /**
  18032. * The radius of the emission sphere.
  18033. */
  18034. radius?: number,
  18035. /**
  18036. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18037. */
  18038. radiusRange?: number,
  18039. /**
  18040. * How much to randomize the particle direction [0-1].
  18041. */
  18042. directionRandomizer?: number);
  18043. /**
  18044. * Called by the particle System when the direction is computed for the created particle.
  18045. * @param worldMatrix is the world matrix of the particle system
  18046. * @param directionToUpdate is the direction vector to update with the result
  18047. * @param particle is the particle we are computed the direction for
  18048. */
  18049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18050. /**
  18051. * Called by the particle System when the position is computed for the created particle.
  18052. * @param worldMatrix is the world matrix of the particle system
  18053. * @param positionToUpdate is the position vector to update with the result
  18054. * @param particle is the particle we are computed the position for
  18055. */
  18056. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18057. /**
  18058. * Clones the current emitter and returns a copy of it
  18059. * @returns the new emitter
  18060. */
  18061. clone(): SphereParticleEmitter;
  18062. /**
  18063. * Called by the GPUParticleSystem to setup the update shader
  18064. * @param effect defines the update shader
  18065. */
  18066. applyToShader(effect: Effect): void;
  18067. /**
  18068. * Returns a string to use to update the GPU particles update shader
  18069. * @returns a string containng the defines string
  18070. */
  18071. getEffectDefines(): string;
  18072. /**
  18073. * Returns the string "SphereParticleEmitter"
  18074. * @returns a string containing the class name
  18075. */
  18076. getClassName(): string;
  18077. /**
  18078. * Serializes the particle system to a JSON object.
  18079. * @returns the JSON object
  18080. */
  18081. serialize(): any;
  18082. /**
  18083. * Parse properties from a JSON object
  18084. * @param serializationObject defines the JSON object
  18085. */
  18086. parse(serializationObject: any): void;
  18087. }
  18088. /**
  18089. * Particle emitter emitting particles from the inside of a sphere.
  18090. * It emits the particles randomly between two vectors.
  18091. */
  18092. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18093. /**
  18094. * The min limit of the emission direction.
  18095. */
  18096. direction1: Vector3;
  18097. /**
  18098. * The max limit of the emission direction.
  18099. */
  18100. direction2: Vector3;
  18101. /**
  18102. * Creates a new instance SphereDirectedParticleEmitter
  18103. * @param radius the radius of the emission sphere (1 by default)
  18104. * @param direction1 the min limit of the emission direction (up vector by default)
  18105. * @param direction2 the max limit of the emission direction (up vector by default)
  18106. */
  18107. constructor(radius?: number,
  18108. /**
  18109. * The min limit of the emission direction.
  18110. */
  18111. direction1?: Vector3,
  18112. /**
  18113. * The max limit of the emission direction.
  18114. */
  18115. direction2?: Vector3);
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Clones the current emitter and returns a copy of it
  18125. * @returns the new emitter
  18126. */
  18127. clone(): SphereDirectedParticleEmitter;
  18128. /**
  18129. * Called by the GPUParticleSystem to setup the update shader
  18130. * @param effect defines the update shader
  18131. */
  18132. applyToShader(effect: Effect): void;
  18133. /**
  18134. * Returns a string to use to update the GPU particles update shader
  18135. * @returns a string containng the defines string
  18136. */
  18137. getEffectDefines(): string;
  18138. /**
  18139. * Returns the string "SphereDirectedParticleEmitter"
  18140. * @returns a string containing the class name
  18141. */
  18142. getClassName(): string;
  18143. /**
  18144. * Serializes the particle system to a JSON object.
  18145. * @returns the JSON object
  18146. */
  18147. serialize(): any;
  18148. /**
  18149. * Parse properties from a JSON object
  18150. * @param serializationObject defines the JSON object
  18151. */
  18152. parse(serializationObject: any): void;
  18153. }
  18154. }
  18155. declare module BABYLON {
  18156. /**
  18157. * Interface representing a particle system in Babylon.js.
  18158. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18159. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18160. */
  18161. export interface IParticleSystem {
  18162. /**
  18163. * List of animations used by the particle system.
  18164. */
  18165. animations: Animation[];
  18166. /**
  18167. * The id of the Particle system.
  18168. */
  18169. id: string;
  18170. /**
  18171. * The name of the Particle system.
  18172. */
  18173. name: string;
  18174. /**
  18175. * The emitter represents the Mesh or position we are attaching the particle system to.
  18176. */
  18177. emitter: Nullable<AbstractMesh | Vector3>;
  18178. /**
  18179. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18180. */
  18181. isBillboardBased: boolean;
  18182. /**
  18183. * The rendering group used by the Particle system to chose when to render.
  18184. */
  18185. renderingGroupId: number;
  18186. /**
  18187. * The layer mask we are rendering the particles through.
  18188. */
  18189. layerMask: number;
  18190. /**
  18191. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18192. */
  18193. updateSpeed: number;
  18194. /**
  18195. * The amount of time the particle system is running (depends of the overall update speed).
  18196. */
  18197. targetStopDuration: number;
  18198. /**
  18199. * The texture used to render each particle. (this can be a spritesheet)
  18200. */
  18201. particleTexture: Nullable<Texture>;
  18202. /**
  18203. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18204. */
  18205. blendMode: number;
  18206. /**
  18207. * Minimum life time of emitting particles.
  18208. */
  18209. minLifeTime: number;
  18210. /**
  18211. * Maximum life time of emitting particles.
  18212. */
  18213. maxLifeTime: number;
  18214. /**
  18215. * Minimum Size of emitting particles.
  18216. */
  18217. minSize: number;
  18218. /**
  18219. * Maximum Size of emitting particles.
  18220. */
  18221. maxSize: number;
  18222. /**
  18223. * Minimum scale of emitting particles on X axis.
  18224. */
  18225. minScaleX: number;
  18226. /**
  18227. * Maximum scale of emitting particles on X axis.
  18228. */
  18229. maxScaleX: number;
  18230. /**
  18231. * Minimum scale of emitting particles on Y axis.
  18232. */
  18233. minScaleY: number;
  18234. /**
  18235. * Maximum scale of emitting particles on Y axis.
  18236. */
  18237. maxScaleY: number;
  18238. /**
  18239. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18240. */
  18241. color1: Color4;
  18242. /**
  18243. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18244. */
  18245. color2: Color4;
  18246. /**
  18247. * Color the particle will have at the end of its lifetime.
  18248. */
  18249. colorDead: Color4;
  18250. /**
  18251. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18252. */
  18253. emitRate: number;
  18254. /**
  18255. * You can use gravity if you want to give an orientation to your particles.
  18256. */
  18257. gravity: Vector3;
  18258. /**
  18259. * Minimum power of emitting particles.
  18260. */
  18261. minEmitPower: number;
  18262. /**
  18263. * Maximum power of emitting particles.
  18264. */
  18265. maxEmitPower: number;
  18266. /**
  18267. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18268. */
  18269. minAngularSpeed: number;
  18270. /**
  18271. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18272. */
  18273. maxAngularSpeed: number;
  18274. /**
  18275. * Gets or sets the minimal initial rotation in radians.
  18276. */
  18277. minInitialRotation: number;
  18278. /**
  18279. * Gets or sets the maximal initial rotation in radians.
  18280. */
  18281. maxInitialRotation: number;
  18282. /**
  18283. * The particle emitter type defines the emitter used by the particle system.
  18284. * It can be for example box, sphere, or cone...
  18285. */
  18286. particleEmitterType: Nullable<IParticleEmitterType>;
  18287. /**
  18288. * Defines the delay in milliseconds before starting the system (0 by default)
  18289. */
  18290. startDelay: number;
  18291. /**
  18292. * 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
  18293. */
  18294. preWarmCycles: number;
  18295. /**
  18296. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18297. */
  18298. preWarmStepOffset: number;
  18299. /**
  18300. * 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)
  18301. */
  18302. spriteCellChangeSpeed: number;
  18303. /**
  18304. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18305. */
  18306. startSpriteCellID: number;
  18307. /**
  18308. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18309. */
  18310. endSpriteCellID: number;
  18311. /**
  18312. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18313. */
  18314. spriteCellWidth: number;
  18315. /**
  18316. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18317. */
  18318. spriteCellHeight: number;
  18319. /**
  18320. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18321. */
  18322. spriteRandomStartCell: boolean;
  18323. /**
  18324. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18325. */
  18326. isAnimationSheetEnabled: boolean;
  18327. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18328. translationPivot: Vector2;
  18329. /**
  18330. * Gets or sets a texture used to add random noise to particle positions
  18331. */
  18332. noiseTexture: Nullable<BaseTexture>;
  18333. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18334. noiseStrength: Vector3;
  18335. /**
  18336. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18337. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18338. */
  18339. billboardMode: number;
  18340. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18341. limitVelocityDamping: number;
  18342. /**
  18343. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18344. */
  18345. beginAnimationOnStart: boolean;
  18346. /**
  18347. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18348. */
  18349. beginAnimationFrom: number;
  18350. /**
  18351. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18352. */
  18353. beginAnimationTo: number;
  18354. /**
  18355. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18356. */
  18357. beginAnimationLoop: boolean;
  18358. /**
  18359. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18360. */
  18361. disposeOnStop: boolean;
  18362. /**
  18363. * Gets the maximum number of particles active at the same time.
  18364. * @returns The max number of active particles.
  18365. */
  18366. getCapacity(): number;
  18367. /**
  18368. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18369. * @returns True if it has been started, otherwise false.
  18370. */
  18371. isStarted(): boolean;
  18372. /**
  18373. * Animates the particle system for this frame.
  18374. */
  18375. animate(): void;
  18376. /**
  18377. * Renders the particle system in its current state.
  18378. * @returns the current number of particles
  18379. */
  18380. render(): number;
  18381. /**
  18382. * Dispose the particle system and frees its associated resources.
  18383. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18384. */
  18385. dispose(disposeTexture?: boolean): void;
  18386. /**
  18387. * Clones the particle system.
  18388. * @param name The name of the cloned object
  18389. * @param newEmitter The new emitter to use
  18390. * @returns the cloned particle system
  18391. */
  18392. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Rebuild the particle system
  18400. */
  18401. rebuild(): void;
  18402. /**
  18403. * Starts the particle system and begins to emit
  18404. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18405. */
  18406. start(delay?: number): void;
  18407. /**
  18408. * Stops the particle system.
  18409. */
  18410. stop(): void;
  18411. /**
  18412. * Remove all active particles
  18413. */
  18414. reset(): void;
  18415. /**
  18416. * Is this system ready to be used/rendered
  18417. * @return true if the system is ready
  18418. */
  18419. isReady(): boolean;
  18420. /**
  18421. * Adds a new color gradient
  18422. * @param gradient defines the gradient to use (between 0 and 1)
  18423. * @param color1 defines the color to affect to the specified gradient
  18424. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18425. * @returns the current particle system
  18426. */
  18427. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18428. /**
  18429. * Remove a specific color gradient
  18430. * @param gradient defines the gradient to remove
  18431. * @returns the current particle system
  18432. */
  18433. removeColorGradient(gradient: number): IParticleSystem;
  18434. /**
  18435. * Adds a new size gradient
  18436. * @param gradient defines the gradient to use (between 0 and 1)
  18437. * @param factor defines the size factor to affect to the specified gradient
  18438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18439. * @returns the current particle system
  18440. */
  18441. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18442. /**
  18443. * Remove a specific size gradient
  18444. * @param gradient defines the gradient to remove
  18445. * @returns the current particle system
  18446. */
  18447. removeSizeGradient(gradient: number): IParticleSystem;
  18448. /**
  18449. * Gets the current list of color gradients.
  18450. * You must use addColorGradient and removeColorGradient to udpate this list
  18451. * @returns the list of color gradients
  18452. */
  18453. getColorGradients(): Nullable<Array<ColorGradient>>;
  18454. /**
  18455. * Gets the current list of size gradients.
  18456. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18457. * @returns the list of size gradients
  18458. */
  18459. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18460. /**
  18461. * Gets the current list of angular speed gradients.
  18462. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18463. * @returns the list of angular speed gradients
  18464. */
  18465. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18466. /**
  18467. * Adds a new angular speed gradient
  18468. * @param gradient defines the gradient to use (between 0 and 1)
  18469. * @param factor defines the angular speed to affect to the specified gradient
  18470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18471. * @returns the current particle system
  18472. */
  18473. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18474. /**
  18475. * Remove a specific angular speed gradient
  18476. * @param gradient defines the gradient to remove
  18477. * @returns the current particle system
  18478. */
  18479. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18480. /**
  18481. * Gets the current list of velocity gradients.
  18482. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18483. * @returns the list of velocity gradients
  18484. */
  18485. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18486. /**
  18487. * Adds a new velocity gradient
  18488. * @param gradient defines the gradient to use (between 0 and 1)
  18489. * @param factor defines the velocity to affect to the specified gradient
  18490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18491. * @returns the current particle system
  18492. */
  18493. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18494. /**
  18495. * Remove a specific velocity gradient
  18496. * @param gradient defines the gradient to remove
  18497. * @returns the current particle system
  18498. */
  18499. removeVelocityGradient(gradient: number): IParticleSystem;
  18500. /**
  18501. * Gets the current list of limit velocity gradients.
  18502. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18503. * @returns the list of limit velocity gradients
  18504. */
  18505. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18506. /**
  18507. * Adds a new limit velocity gradient
  18508. * @param gradient defines the gradient to use (between 0 and 1)
  18509. * @param factor defines the limit velocity to affect to the specified gradient
  18510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18511. * @returns the current particle system
  18512. */
  18513. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18514. /**
  18515. * Remove a specific limit velocity gradient
  18516. * @param gradient defines the gradient to remove
  18517. * @returns the current particle system
  18518. */
  18519. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18520. /**
  18521. * Adds a new drag gradient
  18522. * @param gradient defines the gradient to use (between 0 and 1)
  18523. * @param factor defines the drag to affect to the specified gradient
  18524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18525. * @returns the current particle system
  18526. */
  18527. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18528. /**
  18529. * Remove a specific drag gradient
  18530. * @param gradient defines the gradient to remove
  18531. * @returns the current particle system
  18532. */
  18533. removeDragGradient(gradient: number): IParticleSystem;
  18534. /**
  18535. * Gets the current list of drag gradients.
  18536. * You must use addDragGradient and removeDragGradient to udpate this list
  18537. * @returns the list of drag gradients
  18538. */
  18539. getDragGradients(): Nullable<Array<FactorGradient>>;
  18540. /**
  18541. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18542. * @param gradient defines the gradient to use (between 0 and 1)
  18543. * @param factor defines the emit rate to affect to the specified gradient
  18544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18545. * @returns the current particle system
  18546. */
  18547. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18548. /**
  18549. * Remove a specific emit rate gradient
  18550. * @param gradient defines the gradient to remove
  18551. * @returns the current particle system
  18552. */
  18553. removeEmitRateGradient(gradient: number): IParticleSystem;
  18554. /**
  18555. * Gets the current list of emit rate gradients.
  18556. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18557. * @returns the list of emit rate gradients
  18558. */
  18559. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18560. /**
  18561. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18562. * @param gradient defines the gradient to use (between 0 and 1)
  18563. * @param factor defines the start size to affect to the specified gradient
  18564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18565. * @returns the current particle system
  18566. */
  18567. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18568. /**
  18569. * Remove a specific start size gradient
  18570. * @param gradient defines the gradient to remove
  18571. * @returns the current particle system
  18572. */
  18573. removeStartSizeGradient(gradient: number): IParticleSystem;
  18574. /**
  18575. * Gets the current list of start size gradients.
  18576. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18577. * @returns the list of start size gradients
  18578. */
  18579. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18580. /**
  18581. * Adds a new life time gradient
  18582. * @param gradient defines the gradient to use (between 0 and 1)
  18583. * @param factor defines the life time factor to affect to the specified gradient
  18584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18585. * @returns the current particle system
  18586. */
  18587. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18588. /**
  18589. * Remove a specific life time gradient
  18590. * @param gradient defines the gradient to remove
  18591. * @returns the current particle system
  18592. */
  18593. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18594. /**
  18595. * Gets the current list of life time gradients.
  18596. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18597. * @returns the list of life time gradients
  18598. */
  18599. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18600. /**
  18601. * Gets the current list of color gradients.
  18602. * You must use addColorGradient and removeColorGradient to udpate this list
  18603. * @returns the list of color gradients
  18604. */
  18605. getColorGradients(): Nullable<Array<ColorGradient>>;
  18606. /**
  18607. * Adds a new ramp gradient used to remap particle colors
  18608. * @param gradient defines the gradient to use (between 0 and 1)
  18609. * @param color defines the color to affect to the specified gradient
  18610. * @returns the current particle system
  18611. */
  18612. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18613. /**
  18614. * Gets the current list of ramp gradients.
  18615. * You must use addRampGradient and removeRampGradient to udpate this list
  18616. * @returns the list of ramp gradients
  18617. */
  18618. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18619. /** Gets or sets a boolean indicating that ramp gradients must be used
  18620. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18621. */
  18622. useRampGradients: boolean;
  18623. /**
  18624. * Adds a new color remap gradient
  18625. * @param gradient defines the gradient to use (between 0 and 1)
  18626. * @param min defines the color remap minimal range
  18627. * @param max defines the color remap maximal range
  18628. * @returns the current particle system
  18629. */
  18630. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18631. /**
  18632. * Gets the current list of color remap gradients.
  18633. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18634. * @returns the list of color remap gradients
  18635. */
  18636. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18637. /**
  18638. * Adds a new alpha remap gradient
  18639. * @param gradient defines the gradient to use (between 0 and 1)
  18640. * @param min defines the alpha remap minimal range
  18641. * @param max defines the alpha remap maximal range
  18642. * @returns the current particle system
  18643. */
  18644. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18645. /**
  18646. * Gets the current list of alpha remap gradients.
  18647. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18648. * @returns the list of alpha remap gradients
  18649. */
  18650. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18651. /**
  18652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18655. * @returns the emitter
  18656. */
  18657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18658. /**
  18659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18660. * @param radius The radius of the hemisphere to emit from
  18661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18662. * @returns the emitter
  18663. */
  18664. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18665. /**
  18666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18667. * @param radius The radius of the sphere to emit from
  18668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18669. * @returns the emitter
  18670. */
  18671. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18672. /**
  18673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18674. * @param radius The radius of the sphere to emit from
  18675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18677. * @returns the emitter
  18678. */
  18679. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18680. /**
  18681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18682. * @param radius The radius of the emission cylinder
  18683. * @param height The height of the emission cylinder
  18684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18686. * @returns the emitter
  18687. */
  18688. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18689. /**
  18690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18691. * @param radius The radius of the cylinder to emit from
  18692. * @param height The height of the emission cylinder
  18693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18696. * @returns the emitter
  18697. */
  18698. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18699. /**
  18700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18701. * @param radius The radius of the cone to emit from
  18702. * @param angle The base angle of the cone
  18703. * @returns the emitter
  18704. */
  18705. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18706. /**
  18707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18712. * @returns the emitter
  18713. */
  18714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18715. /**
  18716. * Get hosting scene
  18717. * @returns the scene
  18718. */
  18719. getScene(): Scene;
  18720. }
  18721. }
  18722. declare module BABYLON {
  18723. /**
  18724. * Creates an instance based on a source mesh.
  18725. */
  18726. export class InstancedMesh extends AbstractMesh {
  18727. private _sourceMesh;
  18728. private _currentLOD;
  18729. /** @hidden */
  18730. _indexInSourceMeshInstanceArray: number;
  18731. constructor(name: string, source: Mesh);
  18732. /**
  18733. * Returns the string "InstancedMesh".
  18734. */
  18735. getClassName(): string;
  18736. /** Gets the list of lights affecting that mesh */
  18737. readonly lightSources: Light[];
  18738. _resyncLightSources(): void;
  18739. _resyncLighSource(light: Light): void;
  18740. _removeLightSource(light: Light, dispose: boolean): void;
  18741. /**
  18742. * If the source mesh receives shadows
  18743. */
  18744. readonly receiveShadows: boolean;
  18745. /**
  18746. * The material of the source mesh
  18747. */
  18748. readonly material: Nullable<Material>;
  18749. /**
  18750. * Visibility of the source mesh
  18751. */
  18752. readonly visibility: number;
  18753. /**
  18754. * Skeleton of the source mesh
  18755. */
  18756. readonly skeleton: Nullable<Skeleton>;
  18757. /**
  18758. * Rendering ground id of the source mesh
  18759. */
  18760. renderingGroupId: number;
  18761. /**
  18762. * Returns the total number of vertices (integer).
  18763. */
  18764. getTotalVertices(): number;
  18765. /**
  18766. * Returns a positive integer : the total number of indices in this mesh geometry.
  18767. * @returns the numner of indices or zero if the mesh has no geometry.
  18768. */
  18769. getTotalIndices(): number;
  18770. /**
  18771. * The source mesh of the instance
  18772. */
  18773. readonly sourceMesh: Mesh;
  18774. /**
  18775. * Is this node ready to be used/rendered
  18776. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18777. * @return {boolean} is it ready
  18778. */
  18779. isReady(completeCheck?: boolean): boolean;
  18780. /**
  18781. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18782. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18783. * @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.
  18784. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18785. */
  18786. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18787. /**
  18788. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18789. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18790. * The `data` are either a numeric array either a Float32Array.
  18791. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18792. * 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).
  18793. * Note that a new underlying VertexBuffer object is created each call.
  18794. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18795. *
  18796. * Possible `kind` values :
  18797. * - VertexBuffer.PositionKind
  18798. * - VertexBuffer.UVKind
  18799. * - VertexBuffer.UV2Kind
  18800. * - VertexBuffer.UV3Kind
  18801. * - VertexBuffer.UV4Kind
  18802. * - VertexBuffer.UV5Kind
  18803. * - VertexBuffer.UV6Kind
  18804. * - VertexBuffer.ColorKind
  18805. * - VertexBuffer.MatricesIndicesKind
  18806. * - VertexBuffer.MatricesIndicesExtraKind
  18807. * - VertexBuffer.MatricesWeightsKind
  18808. * - VertexBuffer.MatricesWeightsExtraKind
  18809. *
  18810. * Returns the Mesh.
  18811. */
  18812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18813. /**
  18814. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18815. * If the mesh has no geometry, it is simply returned as it is.
  18816. * The `data` are either a numeric array either a Float32Array.
  18817. * No new underlying VertexBuffer object is created.
  18818. * 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.
  18819. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18820. *
  18821. * Possible `kind` values :
  18822. * - VertexBuffer.PositionKind
  18823. * - VertexBuffer.UVKind
  18824. * - VertexBuffer.UV2Kind
  18825. * - VertexBuffer.UV3Kind
  18826. * - VertexBuffer.UV4Kind
  18827. * - VertexBuffer.UV5Kind
  18828. * - VertexBuffer.UV6Kind
  18829. * - VertexBuffer.ColorKind
  18830. * - VertexBuffer.MatricesIndicesKind
  18831. * - VertexBuffer.MatricesIndicesExtraKind
  18832. * - VertexBuffer.MatricesWeightsKind
  18833. * - VertexBuffer.MatricesWeightsExtraKind
  18834. *
  18835. * Returns the Mesh.
  18836. */
  18837. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18838. /**
  18839. * Sets the mesh indices.
  18840. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18841. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18842. * This method creates a new index buffer each call.
  18843. * Returns the Mesh.
  18844. */
  18845. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18846. /**
  18847. * Boolean : True if the mesh owns the requested kind of data.
  18848. */
  18849. isVerticesDataPresent(kind: string): boolean;
  18850. /**
  18851. * Returns an array of indices (IndicesArray).
  18852. */
  18853. getIndices(): Nullable<IndicesArray>;
  18854. readonly _positions: Nullable<Vector3[]>;
  18855. /**
  18856. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18857. * This means the mesh underlying bounding box and sphere are recomputed.
  18858. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18859. * @returns the current mesh
  18860. */
  18861. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18862. /** @hidden */
  18863. _preActivate(): InstancedMesh;
  18864. /** @hidden */
  18865. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18866. /** @hidden */
  18867. _postActivate(): void;
  18868. getWorldMatrix(): Matrix;
  18869. readonly isAnInstance: boolean;
  18870. /**
  18871. * Returns the current associated LOD AbstractMesh.
  18872. */
  18873. getLOD(camera: Camera): AbstractMesh;
  18874. /** @hidden */
  18875. _syncSubMeshes(): InstancedMesh;
  18876. /** @hidden */
  18877. _generatePointsArray(): boolean;
  18878. /**
  18879. * Creates a new InstancedMesh from the current mesh.
  18880. * - name (string) : the cloned mesh name
  18881. * - newParent (optional Node) : the optional Node to parent the clone to.
  18882. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18883. *
  18884. * Returns the clone.
  18885. */
  18886. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18887. /**
  18888. * Disposes the InstancedMesh.
  18889. * Returns nothing.
  18890. */
  18891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18892. }
  18893. }
  18894. declare module BABYLON {
  18895. /**
  18896. * Defines the options associated with the creation of a shader material.
  18897. */
  18898. export interface IShaderMaterialOptions {
  18899. /**
  18900. * Does the material work in alpha blend mode
  18901. */
  18902. needAlphaBlending: boolean;
  18903. /**
  18904. * Does the material work in alpha test mode
  18905. */
  18906. needAlphaTesting: boolean;
  18907. /**
  18908. * The list of attribute names used in the shader
  18909. */
  18910. attributes: string[];
  18911. /**
  18912. * The list of unifrom names used in the shader
  18913. */
  18914. uniforms: string[];
  18915. /**
  18916. * The list of UBO names used in the shader
  18917. */
  18918. uniformBuffers: string[];
  18919. /**
  18920. * The list of sampler names used in the shader
  18921. */
  18922. samplers: string[];
  18923. /**
  18924. * The list of defines used in the shader
  18925. */
  18926. defines: string[];
  18927. }
  18928. /**
  18929. * 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.
  18930. *
  18931. * This returned material effects how the mesh will look based on the code in the shaders.
  18932. *
  18933. * @see http://doc.babylonjs.com/how_to/shader_material
  18934. */
  18935. export class ShaderMaterial extends Material {
  18936. private _shaderPath;
  18937. private _options;
  18938. private _textures;
  18939. private _textureArrays;
  18940. private _floats;
  18941. private _ints;
  18942. private _floatsArrays;
  18943. private _colors3;
  18944. private _colors3Arrays;
  18945. private _colors4;
  18946. private _colors4Arrays;
  18947. private _vectors2;
  18948. private _vectors3;
  18949. private _vectors4;
  18950. private _matrices;
  18951. private _matrices3x3;
  18952. private _matrices2x2;
  18953. private _vectors2Arrays;
  18954. private _vectors3Arrays;
  18955. private _vectors4Arrays;
  18956. private _cachedWorldViewMatrix;
  18957. private _cachedWorldViewProjectionMatrix;
  18958. private _renderId;
  18959. /**
  18960. * Instantiate a new shader material.
  18961. * 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.
  18962. * This returned material effects how the mesh will look based on the code in the shaders.
  18963. * @see http://doc.babylonjs.com/how_to/shader_material
  18964. * @param name Define the name of the material in the scene
  18965. * @param scene Define the scene the material belongs to
  18966. * @param shaderPath Defines the route to the shader code in one of three ways:
  18967. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18968. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18969. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18970. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18971. * @param options Define the options used to create the shader
  18972. */
  18973. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18974. /**
  18975. * Gets the options used to compile the shader.
  18976. * They can be modified to trigger a new compilation
  18977. */
  18978. readonly options: IShaderMaterialOptions;
  18979. /**
  18980. * Gets the current class name of the material e.g. "ShaderMaterial"
  18981. * Mainly use in serialization.
  18982. * @returns the class name
  18983. */
  18984. getClassName(): string;
  18985. /**
  18986. * Specifies if the material will require alpha blending
  18987. * @returns a boolean specifying if alpha blending is needed
  18988. */
  18989. needAlphaBlending(): boolean;
  18990. /**
  18991. * Specifies if this material should be rendered in alpha test mode
  18992. * @returns a boolean specifying if an alpha test is needed.
  18993. */
  18994. needAlphaTesting(): boolean;
  18995. private _checkUniform;
  18996. /**
  18997. * Set a texture in the shader.
  18998. * @param name Define the name of the uniform samplers as defined in the shader
  18999. * @param texture Define the texture to bind to this sampler
  19000. * @return the material itself allowing "fluent" like uniform updates
  19001. */
  19002. setTexture(name: string, texture: Texture): ShaderMaterial;
  19003. /**
  19004. * Set a texture array in the shader.
  19005. * @param name Define the name of the uniform sampler array as defined in the shader
  19006. * @param textures Define the list of textures to bind to this sampler
  19007. * @return the material itself allowing "fluent" like uniform updates
  19008. */
  19009. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19010. /**
  19011. * Set a float in the shader.
  19012. * @param name Define the name of the uniform as defined in the shader
  19013. * @param value Define the value to give to the uniform
  19014. * @return the material itself allowing "fluent" like uniform updates
  19015. */
  19016. setFloat(name: string, value: number): ShaderMaterial;
  19017. /**
  19018. * Set a int in the shader.
  19019. * @param name Define the name of the uniform as defined in the shader
  19020. * @param value Define the value to give to the uniform
  19021. * @return the material itself allowing "fluent" like uniform updates
  19022. */
  19023. setInt(name: string, value: number): ShaderMaterial;
  19024. /**
  19025. * Set an array of floats in the shader.
  19026. * @param name Define the name of the uniform as defined in the shader
  19027. * @param value Define the value to give to the uniform
  19028. * @return the material itself allowing "fluent" like uniform updates
  19029. */
  19030. setFloats(name: string, value: number[]): ShaderMaterial;
  19031. /**
  19032. * Set a vec3 in the shader from a Color3.
  19033. * @param name Define the name of the uniform as defined in the shader
  19034. * @param value Define the value to give to the uniform
  19035. * @return the material itself allowing "fluent" like uniform updates
  19036. */
  19037. setColor3(name: string, value: Color3): ShaderMaterial;
  19038. /**
  19039. * Set a vec3 array in the shader from a Color3 array.
  19040. * @param name Define the name of the uniform as defined in the shader
  19041. * @param value Define the value to give to the uniform
  19042. * @return the material itself allowing "fluent" like uniform updates
  19043. */
  19044. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19045. /**
  19046. * Set a vec4 in the shader from a Color4.
  19047. * @param name Define the name of the uniform as defined in the shader
  19048. * @param value Define the value to give to the uniform
  19049. * @return the material itself allowing "fluent" like uniform updates
  19050. */
  19051. setColor4(name: string, value: Color4): ShaderMaterial;
  19052. /**
  19053. * Set a vec4 array in the shader from a Color4 array.
  19054. * @param name Define the name of the uniform as defined in the shader
  19055. * @param value Define the value to give to the uniform
  19056. * @return the material itself allowing "fluent" like uniform updates
  19057. */
  19058. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19059. /**
  19060. * Set a vec2 in the shader from a Vector2.
  19061. * @param name Define the name of the uniform as defined in the shader
  19062. * @param value Define the value to give to the uniform
  19063. * @return the material itself allowing "fluent" like uniform updates
  19064. */
  19065. setVector2(name: string, value: Vector2): ShaderMaterial;
  19066. /**
  19067. * Set a vec3 in the shader from a Vector3.
  19068. * @param name Define the name of the uniform as defined in the shader
  19069. * @param value Define the value to give to the uniform
  19070. * @return the material itself allowing "fluent" like uniform updates
  19071. */
  19072. setVector3(name: string, value: Vector3): ShaderMaterial;
  19073. /**
  19074. * Set a vec4 in the shader from a Vector4.
  19075. * @param name Define the name of the uniform as defined in the shader
  19076. * @param value Define the value to give to the uniform
  19077. * @return the material itself allowing "fluent" like uniform updates
  19078. */
  19079. setVector4(name: string, value: Vector4): ShaderMaterial;
  19080. /**
  19081. * Set a mat4 in the shader from a Matrix.
  19082. * @param name Define the name of the uniform as defined in the shader
  19083. * @param value Define the value to give to the uniform
  19084. * @return the material itself allowing "fluent" like uniform updates
  19085. */
  19086. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19087. /**
  19088. * Set a mat3 in the shader from a Float32Array.
  19089. * @param name Define the name of the uniform as defined in the shader
  19090. * @param value Define the value to give to the uniform
  19091. * @return the material itself allowing "fluent" like uniform updates
  19092. */
  19093. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19094. /**
  19095. * Set a mat2 in the shader from a Float32Array.
  19096. * @param name Define the name of the uniform as defined in the shader
  19097. * @param value Define the value to give to the uniform
  19098. * @return the material itself allowing "fluent" like uniform updates
  19099. */
  19100. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19101. /**
  19102. * Set a vec2 array in the shader from a number array.
  19103. * @param name Define the name of the uniform as defined in the shader
  19104. * @param value Define the value to give to the uniform
  19105. * @return the material itself allowing "fluent" like uniform updates
  19106. */
  19107. setArray2(name: string, value: number[]): ShaderMaterial;
  19108. /**
  19109. * Set a vec3 array in the shader from a number array.
  19110. * @param name Define the name of the uniform as defined in the shader
  19111. * @param value Define the value to give to the uniform
  19112. * @return the material itself allowing "fluent" like uniform updates
  19113. */
  19114. setArray3(name: string, value: number[]): ShaderMaterial;
  19115. /**
  19116. * Set a vec4 array in the shader from a number array.
  19117. * @param name Define the name of the uniform as defined in the shader
  19118. * @param value Define the value to give to the uniform
  19119. * @return the material itself allowing "fluent" like uniform updates
  19120. */
  19121. setArray4(name: string, value: number[]): ShaderMaterial;
  19122. private _checkCache;
  19123. /**
  19124. * Specifies that the submesh is ready to be used
  19125. * @param mesh defines the mesh to check
  19126. * @param subMesh defines which submesh to check
  19127. * @param useInstances specifies that instances should be used
  19128. * @returns a boolean indicating that the submesh is ready or not
  19129. */
  19130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19131. /**
  19132. * Checks if the material is ready to render the requested mesh
  19133. * @param mesh Define the mesh to render
  19134. * @param useInstances Define whether or not the material is used with instances
  19135. * @returns true if ready, otherwise false
  19136. */
  19137. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19138. /**
  19139. * Binds the world matrix to the material
  19140. * @param world defines the world transformation matrix
  19141. */
  19142. bindOnlyWorldMatrix(world: Matrix): void;
  19143. /**
  19144. * Binds the material to the mesh
  19145. * @param world defines the world transformation matrix
  19146. * @param mesh defines the mesh to bind the material to
  19147. */
  19148. bind(world: Matrix, mesh?: Mesh): void;
  19149. /**
  19150. * Gets the active textures from the material
  19151. * @returns an array of textures
  19152. */
  19153. getActiveTextures(): BaseTexture[];
  19154. /**
  19155. * Specifies if the material uses a texture
  19156. * @param texture defines the texture to check against the material
  19157. * @returns a boolean specifying if the material uses the texture
  19158. */
  19159. hasTexture(texture: BaseTexture): boolean;
  19160. /**
  19161. * Makes a duplicate of the material, and gives it a new name
  19162. * @param name defines the new name for the duplicated material
  19163. * @returns the cloned material
  19164. */
  19165. clone(name: string): ShaderMaterial;
  19166. /**
  19167. * Disposes the material
  19168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19171. */
  19172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19173. /**
  19174. * Serializes this material in a JSON representation
  19175. * @returns the serialized material object
  19176. */
  19177. serialize(): any;
  19178. /**
  19179. * Creates a shader material from parsed shader material data
  19180. * @param source defines the JSON represnetation of the material
  19181. * @param scene defines the hosting scene
  19182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19183. * @returns a new material
  19184. */
  19185. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19186. }
  19187. }
  19188. declare module BABYLON {
  19189. /** @hidden */
  19190. export var colorPixelShader: {
  19191. name: string;
  19192. shader: string;
  19193. };
  19194. }
  19195. declare module BABYLON {
  19196. /** @hidden */
  19197. export var colorVertexShader: {
  19198. name: string;
  19199. shader: string;
  19200. };
  19201. }
  19202. declare module BABYLON {
  19203. /**
  19204. * Line mesh
  19205. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19206. */
  19207. export class LinesMesh extends Mesh {
  19208. /**
  19209. * If vertex color should be applied to the mesh
  19210. */
  19211. readonly useVertexColor?: boolean | undefined;
  19212. /**
  19213. * If vertex alpha should be applied to the mesh
  19214. */
  19215. readonly useVertexAlpha?: boolean | undefined;
  19216. /**
  19217. * Color of the line (Default: White)
  19218. */
  19219. color: Color3;
  19220. /**
  19221. * Alpha of the line (Default: 1)
  19222. */
  19223. alpha: number;
  19224. /**
  19225. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19226. * This margin is expressed in world space coordinates, so its value may vary.
  19227. * Default value is 0.1
  19228. */
  19229. intersectionThreshold: number;
  19230. private _colorShader;
  19231. private color4;
  19232. /**
  19233. * Creates a new LinesMesh
  19234. * @param name defines the name
  19235. * @param scene defines the hosting scene
  19236. * @param parent defines the parent mesh if any
  19237. * @param source defines the optional source LinesMesh used to clone data from
  19238. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19239. * When false, achieved by calling a clone(), also passing False.
  19240. * This will make creation of children, recursive.
  19241. * @param useVertexColor defines if this LinesMesh supports vertex color
  19242. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19243. */
  19244. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19245. /**
  19246. * If vertex color should be applied to the mesh
  19247. */
  19248. useVertexColor?: boolean | undefined,
  19249. /**
  19250. * If vertex alpha should be applied to the mesh
  19251. */
  19252. useVertexAlpha?: boolean | undefined);
  19253. private _addClipPlaneDefine;
  19254. private _removeClipPlaneDefine;
  19255. isReady(): boolean;
  19256. /**
  19257. * Returns the string "LineMesh"
  19258. */
  19259. getClassName(): string;
  19260. /**
  19261. * @hidden
  19262. */
  19263. /**
  19264. * @hidden
  19265. */
  19266. material: Material;
  19267. /**
  19268. * @hidden
  19269. */
  19270. readonly checkCollisions: boolean;
  19271. /** @hidden */
  19272. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19273. /** @hidden */
  19274. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19275. /**
  19276. * Disposes of the line mesh
  19277. * @param doNotRecurse If children should be disposed
  19278. */
  19279. dispose(doNotRecurse?: boolean): void;
  19280. /**
  19281. * Returns a new LineMesh object cloned from the current one.
  19282. */
  19283. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19284. /**
  19285. * Creates a new InstancedLinesMesh object from the mesh model.
  19286. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19287. * @param name defines the name of the new instance
  19288. * @returns a new InstancedLinesMesh
  19289. */
  19290. createInstance(name: string): InstancedLinesMesh;
  19291. }
  19292. /**
  19293. * Creates an instance based on a source LinesMesh
  19294. */
  19295. export class InstancedLinesMesh extends InstancedMesh {
  19296. /**
  19297. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19298. * This margin is expressed in world space coordinates, so its value may vary.
  19299. * Initilized with the intersectionThreshold value of the source LinesMesh
  19300. */
  19301. intersectionThreshold: number;
  19302. constructor(name: string, source: LinesMesh);
  19303. /**
  19304. * Returns the string "InstancedLinesMesh".
  19305. */
  19306. getClassName(): string;
  19307. }
  19308. }
  19309. declare module BABYLON {
  19310. /** @hidden */
  19311. export var linePixelShader: {
  19312. name: string;
  19313. shader: string;
  19314. };
  19315. }
  19316. declare module BABYLON {
  19317. /** @hidden */
  19318. export var lineVertexShader: {
  19319. name: string;
  19320. shader: string;
  19321. };
  19322. }
  19323. declare module BABYLON {
  19324. interface AbstractMesh {
  19325. /**
  19326. * Gets the edgesRenderer associated with the mesh
  19327. */
  19328. edgesRenderer: Nullable<EdgesRenderer>;
  19329. }
  19330. interface LinesMesh {
  19331. /**
  19332. * Enables the edge rendering mode on the mesh.
  19333. * This mode makes the mesh edges visible
  19334. * @param epsilon defines the maximal distance between two angles to detect a face
  19335. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19336. * @returns the currentAbstractMesh
  19337. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19338. */
  19339. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19340. }
  19341. interface InstancedLinesMesh {
  19342. /**
  19343. * Enables the edge rendering mode on the mesh.
  19344. * This mode makes the mesh edges visible
  19345. * @param epsilon defines the maximal distance between two angles to detect a face
  19346. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19347. * @returns the current InstancedLinesMesh
  19348. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19349. */
  19350. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19351. }
  19352. /**
  19353. * Defines the minimum contract an Edges renderer should follow.
  19354. */
  19355. export interface IEdgesRenderer extends IDisposable {
  19356. /**
  19357. * Gets or sets a boolean indicating if the edgesRenderer is active
  19358. */
  19359. isEnabled: boolean;
  19360. /**
  19361. * Renders the edges of the attached mesh,
  19362. */
  19363. render(): void;
  19364. /**
  19365. * Checks wether or not the edges renderer is ready to render.
  19366. * @return true if ready, otherwise false.
  19367. */
  19368. isReady(): boolean;
  19369. }
  19370. /**
  19371. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19372. */
  19373. export class EdgesRenderer implements IEdgesRenderer {
  19374. /**
  19375. * Define the size of the edges with an orthographic camera
  19376. */
  19377. edgesWidthScalerForOrthographic: number;
  19378. /**
  19379. * Define the size of the edges with a perspective camera
  19380. */
  19381. edgesWidthScalerForPerspective: number;
  19382. protected _source: AbstractMesh;
  19383. protected _linesPositions: number[];
  19384. protected _linesNormals: number[];
  19385. protected _linesIndices: number[];
  19386. protected _epsilon: number;
  19387. protected _indicesCount: number;
  19388. protected _lineShader: ShaderMaterial;
  19389. protected _ib: DataBuffer;
  19390. protected _buffers: {
  19391. [key: string]: Nullable<VertexBuffer>;
  19392. };
  19393. protected _checkVerticesInsteadOfIndices: boolean;
  19394. private _meshRebuildObserver;
  19395. private _meshDisposeObserver;
  19396. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19397. isEnabled: boolean;
  19398. /**
  19399. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19400. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19401. * @param source Mesh used to create edges
  19402. * @param epsilon sum of angles in adjacency to check for edge
  19403. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19404. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19405. */
  19406. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19407. protected _prepareRessources(): void;
  19408. /** @hidden */
  19409. _rebuild(): void;
  19410. /**
  19411. * Releases the required resources for the edges renderer
  19412. */
  19413. dispose(): void;
  19414. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19415. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19416. /**
  19417. * Checks if the pair of p0 and p1 is en edge
  19418. * @param faceIndex
  19419. * @param edge
  19420. * @param faceNormals
  19421. * @param p0
  19422. * @param p1
  19423. * @private
  19424. */
  19425. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19426. /**
  19427. * push line into the position, normal and index buffer
  19428. * @protected
  19429. */
  19430. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19431. /**
  19432. * Generates lines edges from adjacencjes
  19433. * @private
  19434. */
  19435. _generateEdgesLines(): void;
  19436. /**
  19437. * Checks wether or not the edges renderer is ready to render.
  19438. * @return true if ready, otherwise false.
  19439. */
  19440. isReady(): boolean;
  19441. /**
  19442. * Renders the edges of the attached mesh,
  19443. */
  19444. render(): void;
  19445. }
  19446. /**
  19447. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19448. */
  19449. export class LineEdgesRenderer extends EdgesRenderer {
  19450. /**
  19451. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19452. * @param source LineMesh used to generate edges
  19453. * @param epsilon not important (specified angle for edge detection)
  19454. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19455. */
  19456. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19457. /**
  19458. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19459. */
  19460. _generateEdgesLines(): void;
  19461. }
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * This represents the object necessary to create a rendering group.
  19466. * This is exclusively used and created by the rendering manager.
  19467. * To modify the behavior, you use the available helpers in your scene or meshes.
  19468. * @hidden
  19469. */
  19470. export class RenderingGroup {
  19471. index: number;
  19472. private static _zeroVector;
  19473. private _scene;
  19474. private _opaqueSubMeshes;
  19475. private _transparentSubMeshes;
  19476. private _alphaTestSubMeshes;
  19477. private _depthOnlySubMeshes;
  19478. private _particleSystems;
  19479. private _spriteManagers;
  19480. private _opaqueSortCompareFn;
  19481. private _alphaTestSortCompareFn;
  19482. private _transparentSortCompareFn;
  19483. private _renderOpaque;
  19484. private _renderAlphaTest;
  19485. private _renderTransparent;
  19486. /** @hidden */
  19487. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19488. onBeforeTransparentRendering: () => void;
  19489. /**
  19490. * Set the opaque sort comparison function.
  19491. * If null the sub meshes will be render in the order they were created
  19492. */
  19493. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19494. /**
  19495. * Set the alpha test sort comparison function.
  19496. * If null the sub meshes will be render in the order they were created
  19497. */
  19498. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19499. /**
  19500. * Set the transparent sort comparison function.
  19501. * If null the sub meshes will be render in the order they were created
  19502. */
  19503. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19504. /**
  19505. * Creates a new rendering group.
  19506. * @param index The rendering group index
  19507. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19508. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19509. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19510. */
  19511. 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>);
  19512. /**
  19513. * Render all the sub meshes contained in the group.
  19514. * @param customRenderFunction Used to override the default render behaviour of the group.
  19515. * @returns true if rendered some submeshes.
  19516. */
  19517. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19518. /**
  19519. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19520. * @param subMeshes The submeshes to render
  19521. */
  19522. private renderOpaqueSorted;
  19523. /**
  19524. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19525. * @param subMeshes The submeshes to render
  19526. */
  19527. private renderAlphaTestSorted;
  19528. /**
  19529. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19530. * @param subMeshes The submeshes to render
  19531. */
  19532. private renderTransparentSorted;
  19533. /**
  19534. * Renders the submeshes in a specified order.
  19535. * @param subMeshes The submeshes to sort before render
  19536. * @param sortCompareFn The comparison function use to sort
  19537. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19538. * @param transparent Specifies to activate blending if true
  19539. */
  19540. private static renderSorted;
  19541. /**
  19542. * Renders the submeshes in the order they were dispatched (no sort applied).
  19543. * @param subMeshes The submeshes to render
  19544. */
  19545. private static renderUnsorted;
  19546. /**
  19547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19548. * are rendered back to front if in the same alpha index.
  19549. *
  19550. * @param a The first submesh
  19551. * @param b The second submesh
  19552. * @returns The result of the comparison
  19553. */
  19554. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19555. /**
  19556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19557. * are rendered back to front.
  19558. *
  19559. * @param a The first submesh
  19560. * @param b The second submesh
  19561. * @returns The result of the comparison
  19562. */
  19563. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19564. /**
  19565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19566. * are rendered front to back (prevent overdraw).
  19567. *
  19568. * @param a The first submesh
  19569. * @param b The second submesh
  19570. * @returns The result of the comparison
  19571. */
  19572. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19573. /**
  19574. * Resets the different lists of submeshes to prepare a new frame.
  19575. */
  19576. prepare(): void;
  19577. dispose(): void;
  19578. /**
  19579. * Inserts the submesh in its correct queue depending on its material.
  19580. * @param subMesh The submesh to dispatch
  19581. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19582. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19583. */
  19584. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19585. dispatchSprites(spriteManager: ISpriteManager): void;
  19586. dispatchParticles(particleSystem: IParticleSystem): void;
  19587. private _renderParticles;
  19588. private _renderSprites;
  19589. }
  19590. }
  19591. declare module BABYLON {
  19592. /**
  19593. * Interface describing the different options available in the rendering manager
  19594. * regarding Auto Clear between groups.
  19595. */
  19596. export interface IRenderingManagerAutoClearSetup {
  19597. /**
  19598. * Defines whether or not autoclear is enable.
  19599. */
  19600. autoClear: boolean;
  19601. /**
  19602. * Defines whether or not to autoclear the depth buffer.
  19603. */
  19604. depth: boolean;
  19605. /**
  19606. * Defines whether or not to autoclear the stencil buffer.
  19607. */
  19608. stencil: boolean;
  19609. }
  19610. /**
  19611. * This class is used by the onRenderingGroupObservable
  19612. */
  19613. export class RenderingGroupInfo {
  19614. /**
  19615. * The Scene that being rendered
  19616. */
  19617. scene: Scene;
  19618. /**
  19619. * The camera currently used for the rendering pass
  19620. */
  19621. camera: Nullable<Camera>;
  19622. /**
  19623. * The ID of the renderingGroup being processed
  19624. */
  19625. renderingGroupId: number;
  19626. }
  19627. /**
  19628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19629. * It is enable to manage the different groups as well as the different necessary sort functions.
  19630. * This should not be used directly aside of the few static configurations
  19631. */
  19632. export class RenderingManager {
  19633. /**
  19634. * The max id used for rendering groups (not included)
  19635. */
  19636. static MAX_RENDERINGGROUPS: number;
  19637. /**
  19638. * The min id used for rendering groups (included)
  19639. */
  19640. static MIN_RENDERINGGROUPS: number;
  19641. /**
  19642. * Used to globally prevent autoclearing scenes.
  19643. */
  19644. static AUTOCLEAR: boolean;
  19645. /**
  19646. * @hidden
  19647. */
  19648. _useSceneAutoClearSetup: boolean;
  19649. private _scene;
  19650. private _renderingGroups;
  19651. private _depthStencilBufferAlreadyCleaned;
  19652. private _autoClearDepthStencil;
  19653. private _customOpaqueSortCompareFn;
  19654. private _customAlphaTestSortCompareFn;
  19655. private _customTransparentSortCompareFn;
  19656. private _renderingGroupInfo;
  19657. /**
  19658. * Instantiates a new rendering group for a particular scene
  19659. * @param scene Defines the scene the groups belongs to
  19660. */
  19661. constructor(scene: Scene);
  19662. private _clearDepthStencilBuffer;
  19663. /**
  19664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19665. * @hidden
  19666. */
  19667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19668. /**
  19669. * Resets the different information of the group to prepare a new frame
  19670. * @hidden
  19671. */
  19672. reset(): void;
  19673. /**
  19674. * Dispose and release the group and its associated resources.
  19675. * @hidden
  19676. */
  19677. dispose(): void;
  19678. /**
  19679. * Clear the info related to rendering groups preventing retention points during dispose.
  19680. */
  19681. freeRenderingGroups(): void;
  19682. private _prepareRenderingGroup;
  19683. /**
  19684. * Add a sprite manager to the rendering manager in order to render it this frame.
  19685. * @param spriteManager Define the sprite manager to render
  19686. */
  19687. dispatchSprites(spriteManager: ISpriteManager): void;
  19688. /**
  19689. * Add a particle system to the rendering manager in order to render it this frame.
  19690. * @param particleSystem Define the particle system to render
  19691. */
  19692. dispatchParticles(particleSystem: IParticleSystem): void;
  19693. /**
  19694. * Add a submesh to the manager in order to render it this frame
  19695. * @param subMesh The submesh to dispatch
  19696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19698. */
  19699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19700. /**
  19701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19702. * This allowed control for front to back rendering or reversly depending of the special needs.
  19703. *
  19704. * @param renderingGroupId The rendering group id corresponding to its index
  19705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19708. */
  19709. 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;
  19710. /**
  19711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19712. *
  19713. * @param renderingGroupId The rendering group id corresponding to its index
  19714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19717. */
  19718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19719. /**
  19720. * Gets the current auto clear configuration for one rendering group of the rendering
  19721. * manager.
  19722. * @param index the rendering group index to get the information for
  19723. * @returns The auto clear setup for the requested rendering group
  19724. */
  19725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19726. }
  19727. }
  19728. declare module BABYLON {
  19729. /**
  19730. * This Helps creating a texture that will be created from a camera in your scene.
  19731. * It is basically a dynamic texture that could be used to create special effects for instance.
  19732. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19733. */
  19734. export class RenderTargetTexture extends Texture {
  19735. isCube: boolean;
  19736. /**
  19737. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19738. */
  19739. static readonly REFRESHRATE_RENDER_ONCE: number;
  19740. /**
  19741. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19742. */
  19743. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19744. /**
  19745. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19746. * the central point of your effect and can save a lot of performances.
  19747. */
  19748. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19749. /**
  19750. * Use this predicate to dynamically define the list of mesh you want to render.
  19751. * If set, the renderList property will be overwritten.
  19752. */
  19753. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19754. private _renderList;
  19755. /**
  19756. * Use this list to define the list of mesh you want to render.
  19757. */
  19758. renderList: Nullable<Array<AbstractMesh>>;
  19759. private _hookArray;
  19760. /**
  19761. * Define if particles should be rendered in your texture.
  19762. */
  19763. renderParticles: boolean;
  19764. /**
  19765. * Define if sprites should be rendered in your texture.
  19766. */
  19767. renderSprites: boolean;
  19768. /**
  19769. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19770. */
  19771. coordinatesMode: number;
  19772. /**
  19773. * Define the camera used to render the texture.
  19774. */
  19775. activeCamera: Nullable<Camera>;
  19776. /**
  19777. * Override the render function of the texture with your own one.
  19778. */
  19779. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19780. /**
  19781. * Define if camera post processes should be use while rendering the texture.
  19782. */
  19783. useCameraPostProcesses: boolean;
  19784. /**
  19785. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19786. */
  19787. ignoreCameraViewport: boolean;
  19788. private _postProcessManager;
  19789. private _postProcesses;
  19790. private _resizeObserver;
  19791. /**
  19792. * An event triggered when the texture is unbind.
  19793. */
  19794. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19795. /**
  19796. * An event triggered when the texture is unbind.
  19797. */
  19798. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19799. private _onAfterUnbindObserver;
  19800. /**
  19801. * Set a after unbind callback in the texture.
  19802. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19803. */
  19804. onAfterUnbind: () => void;
  19805. /**
  19806. * An event triggered before rendering the texture
  19807. */
  19808. onBeforeRenderObservable: Observable<number>;
  19809. private _onBeforeRenderObserver;
  19810. /**
  19811. * Set a before render callback in the texture.
  19812. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19813. */
  19814. onBeforeRender: (faceIndex: number) => void;
  19815. /**
  19816. * An event triggered after rendering the texture
  19817. */
  19818. onAfterRenderObservable: Observable<number>;
  19819. private _onAfterRenderObserver;
  19820. /**
  19821. * Set a after render callback in the texture.
  19822. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19823. */
  19824. onAfterRender: (faceIndex: number) => void;
  19825. /**
  19826. * An event triggered after the texture clear
  19827. */
  19828. onClearObservable: Observable<Engine>;
  19829. private _onClearObserver;
  19830. /**
  19831. * Set a clear callback in the texture.
  19832. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19833. */
  19834. onClear: (Engine: Engine) => void;
  19835. /**
  19836. * An event triggered when the texture is resized.
  19837. */
  19838. onResizeObservable: Observable<RenderTargetTexture>;
  19839. /**
  19840. * Define the clear color of the Render Target if it should be different from the scene.
  19841. */
  19842. clearColor: Color4;
  19843. protected _size: number | {
  19844. width: number;
  19845. height: number;
  19846. };
  19847. protected _initialSizeParameter: number | {
  19848. width: number;
  19849. height: number;
  19850. } | {
  19851. ratio: number;
  19852. };
  19853. protected _sizeRatio: Nullable<number>;
  19854. /** @hidden */
  19855. _generateMipMaps: boolean;
  19856. protected _renderingManager: RenderingManager;
  19857. /** @hidden */
  19858. _waitingRenderList: string[];
  19859. protected _doNotChangeAspectRatio: boolean;
  19860. protected _currentRefreshId: number;
  19861. protected _refreshRate: number;
  19862. protected _textureMatrix: Matrix;
  19863. protected _samples: number;
  19864. protected _renderTargetOptions: RenderTargetCreationOptions;
  19865. /**
  19866. * Gets render target creation options that were used.
  19867. */
  19868. readonly renderTargetOptions: RenderTargetCreationOptions;
  19869. protected _engine: Engine;
  19870. protected _onRatioRescale(): void;
  19871. /**
  19872. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19873. * It must define where the camera used to render the texture is set
  19874. */
  19875. boundingBoxPosition: Vector3;
  19876. private _boundingBoxSize;
  19877. /**
  19878. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19879. * When defined, the cubemap will switch to local mode
  19880. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19881. * @example https://www.babylonjs-playground.com/#RNASML
  19882. */
  19883. boundingBoxSize: Vector3;
  19884. /**
  19885. * In case the RTT has been created with a depth texture, get the associated
  19886. * depth texture.
  19887. * Otherwise, return null.
  19888. */
  19889. depthStencilTexture: Nullable<InternalTexture>;
  19890. /**
  19891. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19892. * or used a shadow, depth texture...
  19893. * @param name The friendly name of the texture
  19894. * @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)
  19895. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19896. * @param generateMipMaps True if mip maps need to be generated after render.
  19897. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19898. * @param type The type of the buffer in the RTT (int, half float, float...)
  19899. * @param isCube True if a cube texture needs to be created
  19900. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19901. * @param generateDepthBuffer True to generate a depth buffer
  19902. * @param generateStencilBuffer True to generate a stencil buffer
  19903. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19904. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19905. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19906. */
  19907. constructor(name: string, size: number | {
  19908. width: number;
  19909. height: number;
  19910. } | {
  19911. ratio: number;
  19912. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19913. /**
  19914. * Creates a depth stencil texture.
  19915. * This is only available in WebGL 2 or with the depth texture extension available.
  19916. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19917. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19918. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19919. */
  19920. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19921. private _processSizeParameter;
  19922. /**
  19923. * Define the number of samples to use in case of MSAA.
  19924. * It defaults to one meaning no MSAA has been enabled.
  19925. */
  19926. samples: number;
  19927. /**
  19928. * Resets the refresh counter of the texture and start bak from scratch.
  19929. * Could be useful to regenerate the texture if it is setup to render only once.
  19930. */
  19931. resetRefreshCounter(): void;
  19932. /**
  19933. * Define the refresh rate of the texture or the rendering frequency.
  19934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19935. */
  19936. refreshRate: number;
  19937. /**
  19938. * Adds a post process to the render target rendering passes.
  19939. * @param postProcess define the post process to add
  19940. */
  19941. addPostProcess(postProcess: PostProcess): void;
  19942. /**
  19943. * Clear all the post processes attached to the render target
  19944. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19945. */
  19946. clearPostProcesses(dispose?: boolean): void;
  19947. /**
  19948. * Remove one of the post process from the list of attached post processes to the texture
  19949. * @param postProcess define the post process to remove from the list
  19950. */
  19951. removePostProcess(postProcess: PostProcess): void;
  19952. /** @hidden */
  19953. _shouldRender(): boolean;
  19954. /**
  19955. * Gets the actual render size of the texture.
  19956. * @returns the width of the render size
  19957. */
  19958. getRenderSize(): number;
  19959. /**
  19960. * Gets the actual render width of the texture.
  19961. * @returns the width of the render size
  19962. */
  19963. getRenderWidth(): number;
  19964. /**
  19965. * Gets the actual render height of the texture.
  19966. * @returns the height of the render size
  19967. */
  19968. getRenderHeight(): number;
  19969. /**
  19970. * Get if the texture can be rescaled or not.
  19971. */
  19972. readonly canRescale: boolean;
  19973. /**
  19974. * Resize the texture using a ratio.
  19975. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19976. */
  19977. scale(ratio: number): void;
  19978. /**
  19979. * Get the texture reflection matrix used to rotate/transform the reflection.
  19980. * @returns the reflection matrix
  19981. */
  19982. getReflectionTextureMatrix(): Matrix;
  19983. /**
  19984. * Resize the texture to a new desired size.
  19985. * Be carrefull as it will recreate all the data in the new texture.
  19986. * @param size Define the new size. It can be:
  19987. * - a number for squared texture,
  19988. * - an object containing { width: number, height: number }
  19989. * - or an object containing a ratio { ratio: number }
  19990. */
  19991. resize(size: number | {
  19992. width: number;
  19993. height: number;
  19994. } | {
  19995. ratio: number;
  19996. }): void;
  19997. /**
  19998. * Renders all the objects from the render list into the texture.
  19999. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20000. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20001. */
  20002. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20003. private _bestReflectionRenderTargetDimension;
  20004. /**
  20005. * @hidden
  20006. * @param faceIndex face index to bind to if this is a cubetexture
  20007. */
  20008. _bindFrameBuffer(faceIndex?: number): void;
  20009. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20010. private renderToTarget;
  20011. /**
  20012. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20013. * This allowed control for front to back rendering or reversly depending of the special needs.
  20014. *
  20015. * @param renderingGroupId The rendering group id corresponding to its index
  20016. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20017. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20018. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20019. */
  20020. 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;
  20021. /**
  20022. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20023. *
  20024. * @param renderingGroupId The rendering group id corresponding to its index
  20025. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20026. */
  20027. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20028. /**
  20029. * Clones the texture.
  20030. * @returns the cloned texture
  20031. */
  20032. clone(): RenderTargetTexture;
  20033. /**
  20034. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20035. * @returns The JSON representation of the texture
  20036. */
  20037. serialize(): any;
  20038. /**
  20039. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20040. */
  20041. disposeFramebufferObjects(): void;
  20042. /**
  20043. * Dispose the texture and release its associated resources.
  20044. */
  20045. dispose(): void;
  20046. /** @hidden */
  20047. _rebuild(): void;
  20048. /**
  20049. * Clear the info related to rendering groups preventing retention point in material dispose.
  20050. */
  20051. freeRenderingGroups(): void;
  20052. /**
  20053. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20054. * @returns the view count
  20055. */
  20056. getViewCount(): number;
  20057. }
  20058. }
  20059. declare module BABYLON {
  20060. /**
  20061. * Base class for the main features of a material in Babylon.js
  20062. */
  20063. export class Material implements IAnimatable {
  20064. /**
  20065. * Returns the triangle fill mode
  20066. */
  20067. static readonly TriangleFillMode: number;
  20068. /**
  20069. * Returns the wireframe mode
  20070. */
  20071. static readonly WireFrameFillMode: number;
  20072. /**
  20073. * Returns the point fill mode
  20074. */
  20075. static readonly PointFillMode: number;
  20076. /**
  20077. * Returns the point list draw mode
  20078. */
  20079. static readonly PointListDrawMode: number;
  20080. /**
  20081. * Returns the line list draw mode
  20082. */
  20083. static readonly LineListDrawMode: number;
  20084. /**
  20085. * Returns the line loop draw mode
  20086. */
  20087. static readonly LineLoopDrawMode: number;
  20088. /**
  20089. * Returns the line strip draw mode
  20090. */
  20091. static readonly LineStripDrawMode: number;
  20092. /**
  20093. * Returns the triangle strip draw mode
  20094. */
  20095. static readonly TriangleStripDrawMode: number;
  20096. /**
  20097. * Returns the triangle fan draw mode
  20098. */
  20099. static readonly TriangleFanDrawMode: number;
  20100. /**
  20101. * Stores the clock-wise side orientation
  20102. */
  20103. static readonly ClockWiseSideOrientation: number;
  20104. /**
  20105. * Stores the counter clock-wise side orientation
  20106. */
  20107. static readonly CounterClockWiseSideOrientation: number;
  20108. /**
  20109. * The dirty texture flag value
  20110. */
  20111. static readonly TextureDirtyFlag: number;
  20112. /**
  20113. * The dirty light flag value
  20114. */
  20115. static readonly LightDirtyFlag: number;
  20116. /**
  20117. * The dirty fresnel flag value
  20118. */
  20119. static readonly FresnelDirtyFlag: number;
  20120. /**
  20121. * The dirty attribute flag value
  20122. */
  20123. static readonly AttributesDirtyFlag: number;
  20124. /**
  20125. * The dirty misc flag value
  20126. */
  20127. static readonly MiscDirtyFlag: number;
  20128. /**
  20129. * The all dirty flag value
  20130. */
  20131. static readonly AllDirtyFlag: number;
  20132. /**
  20133. * The ID of the material
  20134. */
  20135. id: string;
  20136. /**
  20137. * Gets or sets the unique id of the material
  20138. */
  20139. uniqueId: number;
  20140. /**
  20141. * The name of the material
  20142. */
  20143. name: string;
  20144. /**
  20145. * Gets or sets user defined metadata
  20146. */
  20147. metadata: any;
  20148. /**
  20149. * For internal use only. Please do not use.
  20150. */
  20151. reservedDataStore: any;
  20152. /**
  20153. * Specifies if the ready state should be checked on each call
  20154. */
  20155. checkReadyOnEveryCall: boolean;
  20156. /**
  20157. * Specifies if the ready state should be checked once
  20158. */
  20159. checkReadyOnlyOnce: boolean;
  20160. /**
  20161. * The state of the material
  20162. */
  20163. state: string;
  20164. /**
  20165. * The alpha value of the material
  20166. */
  20167. protected _alpha: number;
  20168. /**
  20169. * List of inspectable custom properties (used by the Inspector)
  20170. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20171. */
  20172. inspectableCustomProperties: IInspectable[];
  20173. /**
  20174. * Sets the alpha value of the material
  20175. */
  20176. /**
  20177. * Gets the alpha value of the material
  20178. */
  20179. alpha: number;
  20180. /**
  20181. * Specifies if back face culling is enabled
  20182. */
  20183. protected _backFaceCulling: boolean;
  20184. /**
  20185. * Sets the back-face culling state
  20186. */
  20187. /**
  20188. * Gets the back-face culling state
  20189. */
  20190. backFaceCulling: boolean;
  20191. /**
  20192. * Stores the value for side orientation
  20193. */
  20194. sideOrientation: number;
  20195. /**
  20196. * Callback triggered when the material is compiled
  20197. */
  20198. onCompiled: Nullable<(effect: Effect) => void>;
  20199. /**
  20200. * Callback triggered when an error occurs
  20201. */
  20202. onError: Nullable<(effect: Effect, errors: string) => void>;
  20203. /**
  20204. * Callback triggered to get the render target textures
  20205. */
  20206. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20207. /**
  20208. * Gets a boolean indicating that current material needs to register RTT
  20209. */
  20210. readonly hasRenderTargetTextures: boolean;
  20211. /**
  20212. * Specifies if the material should be serialized
  20213. */
  20214. doNotSerialize: boolean;
  20215. /**
  20216. * @hidden
  20217. */
  20218. _storeEffectOnSubMeshes: boolean;
  20219. /**
  20220. * Stores the animations for the material
  20221. */
  20222. animations: Nullable<Array<Animation>>;
  20223. /**
  20224. * An event triggered when the material is disposed
  20225. */
  20226. onDisposeObservable: Observable<Material>;
  20227. /**
  20228. * An observer which watches for dispose events
  20229. */
  20230. private _onDisposeObserver;
  20231. private _onUnBindObservable;
  20232. /**
  20233. * Called during a dispose event
  20234. */
  20235. onDispose: () => void;
  20236. private _onBindObservable;
  20237. /**
  20238. * An event triggered when the material is bound
  20239. */
  20240. readonly onBindObservable: Observable<AbstractMesh>;
  20241. /**
  20242. * An observer which watches for bind events
  20243. */
  20244. private _onBindObserver;
  20245. /**
  20246. * Called during a bind event
  20247. */
  20248. onBind: (Mesh: AbstractMesh) => void;
  20249. /**
  20250. * An event triggered when the material is unbound
  20251. */
  20252. readonly onUnBindObservable: Observable<Material>;
  20253. /**
  20254. * Stores the value of the alpha mode
  20255. */
  20256. private _alphaMode;
  20257. /**
  20258. * Sets the value of the alpha mode.
  20259. *
  20260. * | Value | Type | Description |
  20261. * | --- | --- | --- |
  20262. * | 0 | ALPHA_DISABLE | |
  20263. * | 1 | ALPHA_ADD | |
  20264. * | 2 | ALPHA_COMBINE | |
  20265. * | 3 | ALPHA_SUBTRACT | |
  20266. * | 4 | ALPHA_MULTIPLY | |
  20267. * | 5 | ALPHA_MAXIMIZED | |
  20268. * | 6 | ALPHA_ONEONE | |
  20269. * | 7 | ALPHA_PREMULTIPLIED | |
  20270. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20271. * | 9 | ALPHA_INTERPOLATE | |
  20272. * | 10 | ALPHA_SCREENMODE | |
  20273. *
  20274. */
  20275. /**
  20276. * Gets the value of the alpha mode
  20277. */
  20278. alphaMode: number;
  20279. /**
  20280. * Stores the state of the need depth pre-pass value
  20281. */
  20282. private _needDepthPrePass;
  20283. /**
  20284. * Sets the need depth pre-pass value
  20285. */
  20286. /**
  20287. * Gets the depth pre-pass value
  20288. */
  20289. needDepthPrePass: boolean;
  20290. /**
  20291. * Specifies if depth writing should be disabled
  20292. */
  20293. disableDepthWrite: boolean;
  20294. /**
  20295. * Specifies if depth writing should be forced
  20296. */
  20297. forceDepthWrite: boolean;
  20298. /**
  20299. * Specifies if there should be a separate pass for culling
  20300. */
  20301. separateCullingPass: boolean;
  20302. /**
  20303. * Stores the state specifing if fog should be enabled
  20304. */
  20305. private _fogEnabled;
  20306. /**
  20307. * Sets the state for enabling fog
  20308. */
  20309. /**
  20310. * Gets the value of the fog enabled state
  20311. */
  20312. fogEnabled: boolean;
  20313. /**
  20314. * Stores the size of points
  20315. */
  20316. pointSize: number;
  20317. /**
  20318. * Stores the z offset value
  20319. */
  20320. zOffset: number;
  20321. /**
  20322. * Gets a value specifying if wireframe mode is enabled
  20323. */
  20324. /**
  20325. * Sets the state of wireframe mode
  20326. */
  20327. wireframe: boolean;
  20328. /**
  20329. * Gets the value specifying if point clouds are enabled
  20330. */
  20331. /**
  20332. * Sets the state of point cloud mode
  20333. */
  20334. pointsCloud: boolean;
  20335. /**
  20336. * Gets the material fill mode
  20337. */
  20338. /**
  20339. * Sets the material fill mode
  20340. */
  20341. fillMode: number;
  20342. /**
  20343. * @hidden
  20344. * Stores the effects for the material
  20345. */
  20346. _effect: Nullable<Effect>;
  20347. /**
  20348. * @hidden
  20349. * Specifies if the material was previously ready
  20350. */
  20351. _wasPreviouslyReady: boolean;
  20352. /**
  20353. * Specifies if uniform buffers should be used
  20354. */
  20355. private _useUBO;
  20356. /**
  20357. * Stores a reference to the scene
  20358. */
  20359. private _scene;
  20360. /**
  20361. * Stores the fill mode state
  20362. */
  20363. private _fillMode;
  20364. /**
  20365. * Specifies if the depth write state should be cached
  20366. */
  20367. private _cachedDepthWriteState;
  20368. /**
  20369. * Stores the uniform buffer
  20370. */
  20371. protected _uniformBuffer: UniformBuffer;
  20372. /** @hidden */
  20373. _indexInSceneMaterialArray: number;
  20374. /** @hidden */
  20375. meshMap: Nullable<{
  20376. [id: string]: AbstractMesh | undefined;
  20377. }>;
  20378. /**
  20379. * Creates a material instance
  20380. * @param name defines the name of the material
  20381. * @param scene defines the scene to reference
  20382. * @param doNotAdd specifies if the material should be added to the scene
  20383. */
  20384. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20385. /**
  20386. * Returns a string representation of the current material
  20387. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20388. * @returns a string with material information
  20389. */
  20390. toString(fullDetails?: boolean): string;
  20391. /**
  20392. * Gets the class name of the material
  20393. * @returns a string with the class name of the material
  20394. */
  20395. getClassName(): string;
  20396. /**
  20397. * Specifies if updates for the material been locked
  20398. */
  20399. readonly isFrozen: boolean;
  20400. /**
  20401. * Locks updates for the material
  20402. */
  20403. freeze(): void;
  20404. /**
  20405. * Unlocks updates for the material
  20406. */
  20407. unfreeze(): void;
  20408. /**
  20409. * Specifies if the material is ready to be used
  20410. * @param mesh defines the mesh to check
  20411. * @param useInstances specifies if instances should be used
  20412. * @returns a boolean indicating if the material is ready to be used
  20413. */
  20414. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20415. /**
  20416. * Specifies that the submesh is ready to be used
  20417. * @param mesh defines the mesh to check
  20418. * @param subMesh defines which submesh to check
  20419. * @param useInstances specifies that instances should be used
  20420. * @returns a boolean indicating that the submesh is ready or not
  20421. */
  20422. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20423. /**
  20424. * Returns the material effect
  20425. * @returns the effect associated with the material
  20426. */
  20427. getEffect(): Nullable<Effect>;
  20428. /**
  20429. * Returns the current scene
  20430. * @returns a Scene
  20431. */
  20432. getScene(): Scene;
  20433. /**
  20434. * Specifies if the material will require alpha blending
  20435. * @returns a boolean specifying if alpha blending is needed
  20436. */
  20437. needAlphaBlending(): boolean;
  20438. /**
  20439. * Specifies if the mesh will require alpha blending
  20440. * @param mesh defines the mesh to check
  20441. * @returns a boolean specifying if alpha blending is needed for the mesh
  20442. */
  20443. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20444. /**
  20445. * Specifies if this material should be rendered in alpha test mode
  20446. * @returns a boolean specifying if an alpha test is needed.
  20447. */
  20448. needAlphaTesting(): boolean;
  20449. /**
  20450. * Gets the texture used for the alpha test
  20451. * @returns the texture to use for alpha testing
  20452. */
  20453. getAlphaTestTexture(): Nullable<BaseTexture>;
  20454. /**
  20455. * Marks the material to indicate that it needs to be re-calculated
  20456. */
  20457. markDirty(): void;
  20458. /** @hidden */
  20459. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20460. /**
  20461. * Binds the material to the mesh
  20462. * @param world defines the world transformation matrix
  20463. * @param mesh defines the mesh to bind the material to
  20464. */
  20465. bind(world: Matrix, mesh?: Mesh): void;
  20466. /**
  20467. * Binds the submesh to the material
  20468. * @param world defines the world transformation matrix
  20469. * @param mesh defines the mesh containing the submesh
  20470. * @param subMesh defines the submesh to bind the material to
  20471. */
  20472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20473. /**
  20474. * Binds the world matrix to the material
  20475. * @param world defines the world transformation matrix
  20476. */
  20477. bindOnlyWorldMatrix(world: Matrix): void;
  20478. /**
  20479. * Binds the scene's uniform buffer to the effect.
  20480. * @param effect defines the effect to bind to the scene uniform buffer
  20481. * @param sceneUbo defines the uniform buffer storing scene data
  20482. */
  20483. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20484. /**
  20485. * Binds the view matrix to the effect
  20486. * @param effect defines the effect to bind the view matrix to
  20487. */
  20488. bindView(effect: Effect): void;
  20489. /**
  20490. * Binds the view projection matrix to the effect
  20491. * @param effect defines the effect to bind the view projection matrix to
  20492. */
  20493. bindViewProjection(effect: Effect): void;
  20494. /**
  20495. * Specifies if material alpha testing should be turned on for the mesh
  20496. * @param mesh defines the mesh to check
  20497. */
  20498. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20499. /**
  20500. * Processes to execute after binding the material to a mesh
  20501. * @param mesh defines the rendered mesh
  20502. */
  20503. protected _afterBind(mesh?: Mesh): void;
  20504. /**
  20505. * Unbinds the material from the mesh
  20506. */
  20507. unbind(): void;
  20508. /**
  20509. * Gets the active textures from the material
  20510. * @returns an array of textures
  20511. */
  20512. getActiveTextures(): BaseTexture[];
  20513. /**
  20514. * Specifies if the material uses a texture
  20515. * @param texture defines the texture to check against the material
  20516. * @returns a boolean specifying if the material uses the texture
  20517. */
  20518. hasTexture(texture: BaseTexture): boolean;
  20519. /**
  20520. * Makes a duplicate of the material, and gives it a new name
  20521. * @param name defines the new name for the duplicated material
  20522. * @returns the cloned material
  20523. */
  20524. clone(name: string): Nullable<Material>;
  20525. /**
  20526. * Gets the meshes bound to the material
  20527. * @returns an array of meshes bound to the material
  20528. */
  20529. getBindedMeshes(): AbstractMesh[];
  20530. /**
  20531. * Force shader compilation
  20532. * @param mesh defines the mesh associated with this material
  20533. * @param onCompiled defines a function to execute once the material is compiled
  20534. * @param options defines the options to configure the compilation
  20535. */
  20536. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20537. clipPlane: boolean;
  20538. }>): void;
  20539. /**
  20540. * Force shader compilation
  20541. * @param mesh defines the mesh that will use this material
  20542. * @param options defines additional options for compiling the shaders
  20543. * @returns a promise that resolves when the compilation completes
  20544. */
  20545. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20546. clipPlane: boolean;
  20547. }>): Promise<void>;
  20548. private static readonly _AllDirtyCallBack;
  20549. private static readonly _ImageProcessingDirtyCallBack;
  20550. private static readonly _TextureDirtyCallBack;
  20551. private static readonly _FresnelDirtyCallBack;
  20552. private static readonly _MiscDirtyCallBack;
  20553. private static readonly _LightsDirtyCallBack;
  20554. private static readonly _AttributeDirtyCallBack;
  20555. private static _FresnelAndMiscDirtyCallBack;
  20556. private static _TextureAndMiscDirtyCallBack;
  20557. private static readonly _DirtyCallbackArray;
  20558. private static readonly _RunDirtyCallBacks;
  20559. /**
  20560. * Marks a define in the material to indicate that it needs to be re-computed
  20561. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20562. */
  20563. markAsDirty(flag: number): void;
  20564. /**
  20565. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20566. * @param func defines a function which checks material defines against the submeshes
  20567. */
  20568. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20569. /**
  20570. * Indicates that we need to re-calculated for all submeshes
  20571. */
  20572. protected _markAllSubMeshesAsAllDirty(): void;
  20573. /**
  20574. * Indicates that image processing needs to be re-calculated for all submeshes
  20575. */
  20576. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20577. /**
  20578. * Indicates that textures need to be re-calculated for all submeshes
  20579. */
  20580. protected _markAllSubMeshesAsTexturesDirty(): void;
  20581. /**
  20582. * Indicates that fresnel needs to be re-calculated for all submeshes
  20583. */
  20584. protected _markAllSubMeshesAsFresnelDirty(): void;
  20585. /**
  20586. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20587. */
  20588. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20589. /**
  20590. * Indicates that lights need to be re-calculated for all submeshes
  20591. */
  20592. protected _markAllSubMeshesAsLightsDirty(): void;
  20593. /**
  20594. * Indicates that attributes need to be re-calculated for all submeshes
  20595. */
  20596. protected _markAllSubMeshesAsAttributesDirty(): void;
  20597. /**
  20598. * Indicates that misc needs to be re-calculated for all submeshes
  20599. */
  20600. protected _markAllSubMeshesAsMiscDirty(): void;
  20601. /**
  20602. * Indicates that textures and misc need to be re-calculated for all submeshes
  20603. */
  20604. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20605. /**
  20606. * Disposes the material
  20607. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20608. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20609. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20610. */
  20611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20612. /** @hidden */
  20613. private releaseVertexArrayObject;
  20614. /**
  20615. * Serializes this material
  20616. * @returns the serialized material object
  20617. */
  20618. serialize(): any;
  20619. /**
  20620. * Creates a material from parsed material data
  20621. * @param parsedMaterial defines parsed material data
  20622. * @param scene defines the hosting scene
  20623. * @param rootUrl defines the root URL to use to load textures
  20624. * @returns a new material
  20625. */
  20626. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20627. }
  20628. }
  20629. declare module BABYLON {
  20630. /**
  20631. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20632. * separate meshes. This can be use to improve performances.
  20633. * @see http://doc.babylonjs.com/how_to/multi_materials
  20634. */
  20635. export class MultiMaterial extends Material {
  20636. private _subMaterials;
  20637. /**
  20638. * Gets or Sets the list of Materials used within the multi material.
  20639. * They need to be ordered according to the submeshes order in the associated mesh
  20640. */
  20641. subMaterials: Nullable<Material>[];
  20642. /**
  20643. * Function used to align with Node.getChildren()
  20644. * @returns the list of Materials used within the multi material
  20645. */
  20646. getChildren(): Nullable<Material>[];
  20647. /**
  20648. * Instantiates a new Multi Material
  20649. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20650. * separate meshes. This can be use to improve performances.
  20651. * @see http://doc.babylonjs.com/how_to/multi_materials
  20652. * @param name Define the name in the scene
  20653. * @param scene Define the scene the material belongs to
  20654. */
  20655. constructor(name: string, scene: Scene);
  20656. private _hookArray;
  20657. /**
  20658. * Get one of the submaterial by its index in the submaterials array
  20659. * @param index The index to look the sub material at
  20660. * @returns The Material if the index has been defined
  20661. */
  20662. getSubMaterial(index: number): Nullable<Material>;
  20663. /**
  20664. * Get the list of active textures for the whole sub materials list.
  20665. * @returns All the textures that will be used during the rendering
  20666. */
  20667. getActiveTextures(): BaseTexture[];
  20668. /**
  20669. * Gets the current class name of the material e.g. "MultiMaterial"
  20670. * Mainly use in serialization.
  20671. * @returns the class name
  20672. */
  20673. getClassName(): string;
  20674. /**
  20675. * Checks if the material is ready to render the requested sub mesh
  20676. * @param mesh Define the mesh the submesh belongs to
  20677. * @param subMesh Define the sub mesh to look readyness for
  20678. * @param useInstances Define whether or not the material is used with instances
  20679. * @returns true if ready, otherwise false
  20680. */
  20681. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20682. /**
  20683. * Clones the current material and its related sub materials
  20684. * @param name Define the name of the newly cloned material
  20685. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20686. * @returns the cloned material
  20687. */
  20688. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20689. /**
  20690. * Serializes the materials into a JSON representation.
  20691. * @returns the JSON representation
  20692. */
  20693. serialize(): any;
  20694. /**
  20695. * Dispose the material and release its associated resources
  20696. * @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)
  20697. * @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)
  20698. * @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)
  20699. */
  20700. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20701. /**
  20702. * Creates a MultiMaterial from parsed MultiMaterial data.
  20703. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20704. * @param scene defines the hosting scene
  20705. * @returns a new MultiMaterial
  20706. */
  20707. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20708. }
  20709. }
  20710. declare module BABYLON {
  20711. /**
  20712. * Base class for submeshes
  20713. */
  20714. export class BaseSubMesh {
  20715. /** @hidden */
  20716. _materialDefines: Nullable<MaterialDefines>;
  20717. /** @hidden */
  20718. _materialEffect: Nullable<Effect>;
  20719. /**
  20720. * Gets associated effect
  20721. */
  20722. readonly effect: Nullable<Effect>;
  20723. /**
  20724. * Sets associated effect (effect used to render this submesh)
  20725. * @param effect defines the effect to associate with
  20726. * @param defines defines the set of defines used to compile this effect
  20727. */
  20728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20729. }
  20730. /**
  20731. * Defines a subdivision inside a mesh
  20732. */
  20733. export class SubMesh extends BaseSubMesh implements ICullable {
  20734. /** the material index to use */
  20735. materialIndex: number;
  20736. /** vertex index start */
  20737. verticesStart: number;
  20738. /** vertices count */
  20739. verticesCount: number;
  20740. /** index start */
  20741. indexStart: number;
  20742. /** indices count */
  20743. indexCount: number;
  20744. /** @hidden */
  20745. _linesIndexCount: number;
  20746. private _mesh;
  20747. private _renderingMesh;
  20748. private _boundingInfo;
  20749. private _linesIndexBuffer;
  20750. /** @hidden */
  20751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20752. /** @hidden */
  20753. _trianglePlanes: Plane[];
  20754. /** @hidden */
  20755. _lastColliderTransformMatrix: Nullable<Matrix>;
  20756. /** @hidden */
  20757. _renderId: number;
  20758. /** @hidden */
  20759. _alphaIndex: number;
  20760. /** @hidden */
  20761. _distanceToCamera: number;
  20762. /** @hidden */
  20763. _id: number;
  20764. private _currentMaterial;
  20765. /**
  20766. * Add a new submesh to a mesh
  20767. * @param materialIndex defines the material index to use
  20768. * @param verticesStart defines vertex index start
  20769. * @param verticesCount defines vertices count
  20770. * @param indexStart defines index start
  20771. * @param indexCount defines indices count
  20772. * @param mesh defines the parent mesh
  20773. * @param renderingMesh defines an optional rendering mesh
  20774. * @param createBoundingBox defines if bounding box should be created for this submesh
  20775. * @returns the new submesh
  20776. */
  20777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20778. /**
  20779. * Creates a new submesh
  20780. * @param materialIndex defines the material index to use
  20781. * @param verticesStart defines vertex index start
  20782. * @param verticesCount defines vertices count
  20783. * @param indexStart defines index start
  20784. * @param indexCount defines indices count
  20785. * @param mesh defines the parent mesh
  20786. * @param renderingMesh defines an optional rendering mesh
  20787. * @param createBoundingBox defines if bounding box should be created for this submesh
  20788. */
  20789. constructor(
  20790. /** the material index to use */
  20791. materialIndex: number,
  20792. /** vertex index start */
  20793. verticesStart: number,
  20794. /** vertices count */
  20795. verticesCount: number,
  20796. /** index start */
  20797. indexStart: number,
  20798. /** indices count */
  20799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20800. /**
  20801. * Returns true if this submesh covers the entire parent mesh
  20802. * @ignorenaming
  20803. */
  20804. readonly IsGlobal: boolean;
  20805. /**
  20806. * Returns the submesh BoudingInfo object
  20807. * @returns current bounding info (or mesh's one if the submesh is global)
  20808. */
  20809. getBoundingInfo(): BoundingInfo;
  20810. /**
  20811. * Sets the submesh BoundingInfo
  20812. * @param boundingInfo defines the new bounding info to use
  20813. * @returns the SubMesh
  20814. */
  20815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20816. /**
  20817. * Returns the mesh of the current submesh
  20818. * @return the parent mesh
  20819. */
  20820. getMesh(): AbstractMesh;
  20821. /**
  20822. * Returns the rendering mesh of the submesh
  20823. * @returns the rendering mesh (could be different from parent mesh)
  20824. */
  20825. getRenderingMesh(): Mesh;
  20826. /**
  20827. * Returns the submesh material
  20828. * @returns null or the current material
  20829. */
  20830. getMaterial(): Nullable<Material>;
  20831. /**
  20832. * Sets a new updated BoundingInfo object to the submesh
  20833. * @param data defines an optional position array to use to determine the bounding info
  20834. * @returns the SubMesh
  20835. */
  20836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20837. /** @hidden */
  20838. _checkCollision(collider: Collider): boolean;
  20839. /**
  20840. * Updates the submesh BoundingInfo
  20841. * @param world defines the world matrix to use to update the bounding info
  20842. * @returns the submesh
  20843. */
  20844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20845. /**
  20846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20847. * @param frustumPlanes defines the frustum planes
  20848. * @returns true if the submesh is intersecting with the frustum
  20849. */
  20850. isInFrustum(frustumPlanes: Plane[]): boolean;
  20851. /**
  20852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20853. * @param frustumPlanes defines the frustum planes
  20854. * @returns true if the submesh is inside the frustum
  20855. */
  20856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20857. /**
  20858. * Renders the submesh
  20859. * @param enableAlphaMode defines if alpha needs to be used
  20860. * @returns the submesh
  20861. */
  20862. render(enableAlphaMode: boolean): SubMesh;
  20863. /**
  20864. * @hidden
  20865. */
  20866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20867. /**
  20868. * Checks if the submesh intersects with a ray
  20869. * @param ray defines the ray to test
  20870. * @returns true is the passed ray intersects the submesh bounding box
  20871. */
  20872. canIntersects(ray: Ray): boolean;
  20873. /**
  20874. * Intersects current submesh with a ray
  20875. * @param ray defines the ray to test
  20876. * @param positions defines mesh's positions array
  20877. * @param indices defines mesh's indices array
  20878. * @param fastCheck defines if only bounding info should be used
  20879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20880. * @returns intersection info or null if no intersection
  20881. */
  20882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20883. /** @hidden */
  20884. private _intersectLines;
  20885. /** @hidden */
  20886. private _intersectUnIndexedLines;
  20887. /** @hidden */
  20888. private _intersectTriangles;
  20889. /** @hidden */
  20890. private _intersectUnIndexedTriangles;
  20891. /** @hidden */
  20892. _rebuild(): void;
  20893. /**
  20894. * Creates a new submesh from the passed mesh
  20895. * @param newMesh defines the new hosting mesh
  20896. * @param newRenderingMesh defines an optional rendering mesh
  20897. * @returns the new submesh
  20898. */
  20899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20900. /**
  20901. * Release associated resources
  20902. */
  20903. dispose(): void;
  20904. /**
  20905. * Gets the class name
  20906. * @returns the string "SubMesh".
  20907. */
  20908. getClassName(): string;
  20909. /**
  20910. * Creates a new submesh from indices data
  20911. * @param materialIndex the index of the main mesh material
  20912. * @param startIndex the index where to start the copy in the mesh indices array
  20913. * @param indexCount the number of indices to copy then from the startIndex
  20914. * @param mesh the main mesh to create the submesh from
  20915. * @param renderingMesh the optional rendering mesh
  20916. * @returns a new submesh
  20917. */
  20918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20919. }
  20920. }
  20921. declare module BABYLON {
  20922. /**
  20923. * Class used to represent data loading progression
  20924. */
  20925. export class SceneLoaderFlags {
  20926. private static _ForceFullSceneLoadingForIncremental;
  20927. private static _ShowLoadingScreen;
  20928. private static _CleanBoneMatrixWeights;
  20929. private static _loggingLevel;
  20930. /**
  20931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20932. */
  20933. static ForceFullSceneLoadingForIncremental: boolean;
  20934. /**
  20935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20936. */
  20937. static ShowLoadingScreen: boolean;
  20938. /**
  20939. * Defines the current logging level (while loading the scene)
  20940. * @ignorenaming
  20941. */
  20942. static loggingLevel: number;
  20943. /**
  20944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20945. */
  20946. static CleanBoneMatrixWeights: boolean;
  20947. }
  20948. }
  20949. declare module BABYLON {
  20950. /**
  20951. * Class used to store geometry data (vertex buffers + index buffer)
  20952. */
  20953. export class Geometry implements IGetSetVerticesData {
  20954. /**
  20955. * Gets or sets the ID of the geometry
  20956. */
  20957. id: string;
  20958. /**
  20959. * Gets or sets the unique ID of the geometry
  20960. */
  20961. uniqueId: number;
  20962. /**
  20963. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20964. */
  20965. delayLoadState: number;
  20966. /**
  20967. * Gets the file containing the data to load when running in delay load state
  20968. */
  20969. delayLoadingFile: Nullable<string>;
  20970. /**
  20971. * Callback called when the geometry is updated
  20972. */
  20973. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20974. private _scene;
  20975. private _engine;
  20976. private _meshes;
  20977. private _totalVertices;
  20978. /** @hidden */
  20979. _indices: IndicesArray;
  20980. /** @hidden */
  20981. _vertexBuffers: {
  20982. [key: string]: VertexBuffer;
  20983. };
  20984. private _isDisposed;
  20985. private _extend;
  20986. private _boundingBias;
  20987. /** @hidden */
  20988. _delayInfo: Array<string>;
  20989. private _indexBuffer;
  20990. private _indexBufferIsUpdatable;
  20991. /** @hidden */
  20992. _boundingInfo: Nullable<BoundingInfo>;
  20993. /** @hidden */
  20994. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20995. /** @hidden */
  20996. _softwareSkinningFrameId: number;
  20997. private _vertexArrayObjects;
  20998. private _updatable;
  20999. /** @hidden */
  21000. _positions: Nullable<Vector3[]>;
  21001. /**
  21002. * 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
  21003. */
  21004. /**
  21005. * 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
  21006. */
  21007. boundingBias: Vector2;
  21008. /**
  21009. * Static function used to attach a new empty geometry to a mesh
  21010. * @param mesh defines the mesh to attach the geometry to
  21011. * @returns the new Geometry
  21012. */
  21013. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21014. /**
  21015. * Creates a new geometry
  21016. * @param id defines the unique ID
  21017. * @param scene defines the hosting scene
  21018. * @param vertexData defines the VertexData used to get geometry data
  21019. * @param updatable defines if geometry must be updatable (false by default)
  21020. * @param mesh defines the mesh that will be associated with the geometry
  21021. */
  21022. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21023. /**
  21024. * Gets the current extend of the geometry
  21025. */
  21026. readonly extend: {
  21027. minimum: Vector3;
  21028. maximum: Vector3;
  21029. };
  21030. /**
  21031. * Gets the hosting scene
  21032. * @returns the hosting Scene
  21033. */
  21034. getScene(): Scene;
  21035. /**
  21036. * Gets the hosting engine
  21037. * @returns the hosting Engine
  21038. */
  21039. getEngine(): Engine;
  21040. /**
  21041. * Defines if the geometry is ready to use
  21042. * @returns true if the geometry is ready to be used
  21043. */
  21044. isReady(): boolean;
  21045. /**
  21046. * Gets a value indicating that the geometry should not be serialized
  21047. */
  21048. readonly doNotSerialize: boolean;
  21049. /** @hidden */
  21050. _rebuild(): void;
  21051. /**
  21052. * Affects all geometry data in one call
  21053. * @param vertexData defines the geometry data
  21054. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21055. */
  21056. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21057. /**
  21058. * Set specific vertex data
  21059. * @param kind defines the data kind (Position, normal, etc...)
  21060. * @param data defines the vertex data to use
  21061. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21062. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21063. */
  21064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21065. /**
  21066. * Removes a specific vertex data
  21067. * @param kind defines the data kind (Position, normal, etc...)
  21068. */
  21069. removeVerticesData(kind: string): void;
  21070. /**
  21071. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21072. * @param buffer defines the vertex buffer to use
  21073. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21074. */
  21075. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21076. /**
  21077. * Update a specific vertex buffer
  21078. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21079. * It will do nothing if the buffer is not updatable
  21080. * @param kind defines the data kind (Position, normal, etc...)
  21081. * @param data defines the data to use
  21082. * @param offset defines the offset in the target buffer where to store the data
  21083. * @param useBytes set to true if the offset is in bytes
  21084. */
  21085. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21086. /**
  21087. * Update a specific vertex buffer
  21088. * This function will create a new buffer if the current one is not updatable
  21089. * @param kind defines the data kind (Position, normal, etc...)
  21090. * @param data defines the data to use
  21091. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21092. */
  21093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21094. private _updateBoundingInfo;
  21095. /** @hidden */
  21096. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21097. /**
  21098. * Gets total number of vertices
  21099. * @returns the total number of vertices
  21100. */
  21101. getTotalVertices(): number;
  21102. /**
  21103. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21104. * @param kind defines the data kind (Position, normal, etc...)
  21105. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21106. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21107. * @returns a float array containing vertex data
  21108. */
  21109. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21110. /**
  21111. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21112. * @param kind defines the data kind (Position, normal, etc...)
  21113. * @returns true if the vertex buffer with the specified kind is updatable
  21114. */
  21115. isVertexBufferUpdatable(kind: string): boolean;
  21116. /**
  21117. * Gets a specific vertex buffer
  21118. * @param kind defines the data kind (Position, normal, etc...)
  21119. * @returns a VertexBuffer
  21120. */
  21121. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21122. /**
  21123. * Returns all vertex buffers
  21124. * @return an object holding all vertex buffers indexed by kind
  21125. */
  21126. getVertexBuffers(): Nullable<{
  21127. [key: string]: VertexBuffer;
  21128. }>;
  21129. /**
  21130. * Gets a boolean indicating if specific vertex buffer is present
  21131. * @param kind defines the data kind (Position, normal, etc...)
  21132. * @returns true if data is present
  21133. */
  21134. isVerticesDataPresent(kind: string): boolean;
  21135. /**
  21136. * Gets a list of all attached data kinds (Position, normal, etc...)
  21137. * @returns a list of string containing all kinds
  21138. */
  21139. getVerticesDataKinds(): string[];
  21140. /**
  21141. * Update index buffer
  21142. * @param indices defines the indices to store in the index buffer
  21143. * @param offset defines the offset in the target buffer where to store the data
  21144. * @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)
  21145. */
  21146. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21147. /**
  21148. * Creates a new index buffer
  21149. * @param indices defines the indices to store in the index buffer
  21150. * @param totalVertices defines the total number of vertices (could be null)
  21151. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21152. */
  21153. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21154. /**
  21155. * Return the total number of indices
  21156. * @returns the total number of indices
  21157. */
  21158. getTotalIndices(): number;
  21159. /**
  21160. * Gets the index buffer array
  21161. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21162. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21163. * @returns the index buffer array
  21164. */
  21165. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21166. /**
  21167. * Gets the index buffer
  21168. * @return the index buffer
  21169. */
  21170. getIndexBuffer(): Nullable<DataBuffer>;
  21171. /** @hidden */
  21172. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21173. /**
  21174. * Release the associated resources for a specific mesh
  21175. * @param mesh defines the source mesh
  21176. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21177. */
  21178. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21179. /**
  21180. * Apply current geometry to a given mesh
  21181. * @param mesh defines the mesh to apply geometry to
  21182. */
  21183. applyToMesh(mesh: Mesh): void;
  21184. private _updateExtend;
  21185. private _applyToMesh;
  21186. private notifyUpdate;
  21187. /**
  21188. * Load the geometry if it was flagged as delay loaded
  21189. * @param scene defines the hosting scene
  21190. * @param onLoaded defines a callback called when the geometry is loaded
  21191. */
  21192. load(scene: Scene, onLoaded?: () => void): void;
  21193. private _queueLoad;
  21194. /**
  21195. * Invert the geometry to move from a right handed system to a left handed one.
  21196. */
  21197. toLeftHanded(): void;
  21198. /** @hidden */
  21199. _resetPointsArrayCache(): void;
  21200. /** @hidden */
  21201. _generatePointsArray(): boolean;
  21202. /**
  21203. * Gets a value indicating if the geometry is disposed
  21204. * @returns true if the geometry was disposed
  21205. */
  21206. isDisposed(): boolean;
  21207. private _disposeVertexArrayObjects;
  21208. /**
  21209. * Free all associated resources
  21210. */
  21211. dispose(): void;
  21212. /**
  21213. * Clone the current geometry into a new geometry
  21214. * @param id defines the unique ID of the new geometry
  21215. * @returns a new geometry object
  21216. */
  21217. copy(id: string): Geometry;
  21218. /**
  21219. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21220. * @return a JSON representation of the current geometry data (without the vertices data)
  21221. */
  21222. serialize(): any;
  21223. private toNumberArray;
  21224. /**
  21225. * Serialize all vertices data into a JSON oject
  21226. * @returns a JSON representation of the current geometry data
  21227. */
  21228. serializeVerticeData(): any;
  21229. /**
  21230. * Extracts a clone of a mesh geometry
  21231. * @param mesh defines the source mesh
  21232. * @param id defines the unique ID of the new geometry object
  21233. * @returns the new geometry object
  21234. */
  21235. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21236. /**
  21237. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21238. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21239. * Be aware Math.random() could cause collisions, but:
  21240. * "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"
  21241. * @returns a string containing a new GUID
  21242. */
  21243. static RandomId(): string;
  21244. /** @hidden */
  21245. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21246. private static _CleanMatricesWeights;
  21247. /**
  21248. * Create a new geometry from persisted data (Using .babylon file format)
  21249. * @param parsedVertexData defines the persisted data
  21250. * @param scene defines the hosting scene
  21251. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21252. * @returns the new geometry object
  21253. */
  21254. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21255. }
  21256. }
  21257. declare module BABYLON {
  21258. /**
  21259. * Define an interface for all classes that will get and set the data on vertices
  21260. */
  21261. export interface IGetSetVerticesData {
  21262. /**
  21263. * Gets a boolean indicating if specific vertex data is present
  21264. * @param kind defines the vertex data kind to use
  21265. * @returns true is data kind is present
  21266. */
  21267. isVerticesDataPresent(kind: string): boolean;
  21268. /**
  21269. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21270. * @param kind defines the data kind (Position, normal, etc...)
  21271. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21272. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21273. * @returns a float array containing vertex data
  21274. */
  21275. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21276. /**
  21277. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21278. * @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.
  21279. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21280. * @returns the indices array or an empty array if the mesh has no geometry
  21281. */
  21282. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21283. /**
  21284. * Set specific vertex data
  21285. * @param kind defines the data kind (Position, normal, etc...)
  21286. * @param data defines the vertex data to use
  21287. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21288. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21289. */
  21290. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21291. /**
  21292. * Update a specific associated vertex buffer
  21293. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21294. * - VertexBuffer.PositionKind
  21295. * - VertexBuffer.UVKind
  21296. * - VertexBuffer.UV2Kind
  21297. * - VertexBuffer.UV3Kind
  21298. * - VertexBuffer.UV4Kind
  21299. * - VertexBuffer.UV5Kind
  21300. * - VertexBuffer.UV6Kind
  21301. * - VertexBuffer.ColorKind
  21302. * - VertexBuffer.MatricesIndicesKind
  21303. * - VertexBuffer.MatricesIndicesExtraKind
  21304. * - VertexBuffer.MatricesWeightsKind
  21305. * - VertexBuffer.MatricesWeightsExtraKind
  21306. * @param data defines the data source
  21307. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21308. * @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)
  21309. */
  21310. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21311. /**
  21312. * Creates a new index buffer
  21313. * @param indices defines the indices to store in the index buffer
  21314. * @param totalVertices defines the total number of vertices (could be null)
  21315. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21316. */
  21317. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21318. }
  21319. /**
  21320. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21321. */
  21322. export class VertexData {
  21323. /**
  21324. * Mesh side orientation : usually the external or front surface
  21325. */
  21326. static readonly FRONTSIDE: number;
  21327. /**
  21328. * Mesh side orientation : usually the internal or back surface
  21329. */
  21330. static readonly BACKSIDE: number;
  21331. /**
  21332. * Mesh side orientation : both internal and external or front and back surfaces
  21333. */
  21334. static readonly DOUBLESIDE: number;
  21335. /**
  21336. * Mesh side orientation : by default, `FRONTSIDE`
  21337. */
  21338. static readonly DEFAULTSIDE: number;
  21339. /**
  21340. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21341. */
  21342. positions: Nullable<FloatArray>;
  21343. /**
  21344. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21345. */
  21346. normals: Nullable<FloatArray>;
  21347. /**
  21348. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21349. */
  21350. tangents: Nullable<FloatArray>;
  21351. /**
  21352. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21353. */
  21354. uvs: Nullable<FloatArray>;
  21355. /**
  21356. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21357. */
  21358. uvs2: Nullable<FloatArray>;
  21359. /**
  21360. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21361. */
  21362. uvs3: Nullable<FloatArray>;
  21363. /**
  21364. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21365. */
  21366. uvs4: Nullable<FloatArray>;
  21367. /**
  21368. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21369. */
  21370. uvs5: Nullable<FloatArray>;
  21371. /**
  21372. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21373. */
  21374. uvs6: Nullable<FloatArray>;
  21375. /**
  21376. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21377. */
  21378. colors: Nullable<FloatArray>;
  21379. /**
  21380. * 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).
  21381. */
  21382. matricesIndices: Nullable<FloatArray>;
  21383. /**
  21384. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21385. */
  21386. matricesWeights: Nullable<FloatArray>;
  21387. /**
  21388. * An array extending the number of possible indices
  21389. */
  21390. matricesIndicesExtra: Nullable<FloatArray>;
  21391. /**
  21392. * An array extending the number of possible weights when the number of indices is extended
  21393. */
  21394. matricesWeightsExtra: Nullable<FloatArray>;
  21395. /**
  21396. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21397. */
  21398. indices: Nullable<IndicesArray>;
  21399. /**
  21400. * Uses the passed data array to set the set the values for the specified kind of data
  21401. * @param data a linear array of floating numbers
  21402. * @param kind the type of data that is being set, eg positions, colors etc
  21403. */
  21404. set(data: FloatArray, kind: string): void;
  21405. /**
  21406. * Associates the vertexData to the passed Mesh.
  21407. * Sets it as updatable or not (default `false`)
  21408. * @param mesh the mesh the vertexData is applied to
  21409. * @param updatable when used and having the value true allows new data to update the vertexData
  21410. * @returns the VertexData
  21411. */
  21412. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21413. /**
  21414. * Associates the vertexData to the passed Geometry.
  21415. * Sets it as updatable or not (default `false`)
  21416. * @param geometry the geometry the vertexData is applied to
  21417. * @param updatable when used and having the value true allows new data to update the vertexData
  21418. * @returns VertexData
  21419. */
  21420. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21421. /**
  21422. * Updates the associated mesh
  21423. * @param mesh the mesh to be updated
  21424. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21425. * @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
  21426. * @returns VertexData
  21427. */
  21428. updateMesh(mesh: Mesh): VertexData;
  21429. /**
  21430. * Updates the associated geometry
  21431. * @param geometry the geometry to be updated
  21432. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21433. * @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
  21434. * @returns VertexData.
  21435. */
  21436. updateGeometry(geometry: Geometry): VertexData;
  21437. private _applyTo;
  21438. private _update;
  21439. /**
  21440. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21441. * @param matrix the transforming matrix
  21442. * @returns the VertexData
  21443. */
  21444. transform(matrix: Matrix): VertexData;
  21445. /**
  21446. * Merges the passed VertexData into the current one
  21447. * @param other the VertexData to be merged into the current one
  21448. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21449. * @returns the modified VertexData
  21450. */
  21451. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21452. private _mergeElement;
  21453. private _validate;
  21454. /**
  21455. * Serializes the VertexData
  21456. * @returns a serialized object
  21457. */
  21458. serialize(): any;
  21459. /**
  21460. * Extracts the vertexData from a mesh
  21461. * @param mesh the mesh from which to extract the VertexData
  21462. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21463. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21464. * @returns the object VertexData associated to the passed mesh
  21465. */
  21466. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21467. /**
  21468. * Extracts the vertexData from the geometry
  21469. * @param geometry the geometry from which to extract the VertexData
  21470. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21471. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21472. * @returns the object VertexData associated to the passed mesh
  21473. */
  21474. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21475. private static _ExtractFrom;
  21476. /**
  21477. * Creates the VertexData for a Ribbon
  21478. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21479. * * pathArray array of paths, each of which an array of successive Vector3
  21480. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21481. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21482. * * 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
  21483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21484. * * 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)
  21485. * * 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)
  21486. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21487. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21488. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21489. * @returns the VertexData of the ribbon
  21490. */
  21491. static CreateRibbon(options: {
  21492. pathArray: Vector3[][];
  21493. closeArray?: boolean;
  21494. closePath?: boolean;
  21495. offset?: number;
  21496. sideOrientation?: number;
  21497. frontUVs?: Vector4;
  21498. backUVs?: Vector4;
  21499. invertUV?: boolean;
  21500. uvs?: Vector2[];
  21501. colors?: Color4[];
  21502. }): VertexData;
  21503. /**
  21504. * Creates the VertexData for a box
  21505. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21506. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21507. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21508. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21509. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21510. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21511. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21513. * * 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)
  21514. * * 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)
  21515. * @returns the VertexData of the box
  21516. */
  21517. static CreateBox(options: {
  21518. size?: number;
  21519. width?: number;
  21520. height?: number;
  21521. depth?: number;
  21522. faceUV?: Vector4[];
  21523. faceColors?: Color4[];
  21524. sideOrientation?: number;
  21525. frontUVs?: Vector4;
  21526. backUVs?: Vector4;
  21527. }): VertexData;
  21528. /**
  21529. * Creates the VertexData for a tiled box
  21530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21531. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21532. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21533. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21535. * @returns the VertexData of the box
  21536. */
  21537. static CreateTiledBox(options: {
  21538. pattern?: number;
  21539. width?: number;
  21540. height?: number;
  21541. depth?: number;
  21542. tileSize?: number;
  21543. tileWidth?: number;
  21544. tileHeight?: number;
  21545. alignHorizontal?: number;
  21546. alignVertical?: number;
  21547. faceUV?: Vector4[];
  21548. faceColors?: Color4[];
  21549. sideOrientation?: number;
  21550. }): VertexData;
  21551. /**
  21552. * Creates the VertexData for a tiled plane
  21553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21554. * * pattern a limited pattern arrangement depending on the number
  21555. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21556. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21557. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21559. * * 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)
  21560. * * 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)
  21561. * @returns the VertexData of the tiled plane
  21562. */
  21563. static CreateTiledPlane(options: {
  21564. pattern?: number;
  21565. tileSize?: number;
  21566. tileWidth?: number;
  21567. tileHeight?: number;
  21568. size?: number;
  21569. width?: number;
  21570. height?: number;
  21571. alignHorizontal?: number;
  21572. alignVertical?: number;
  21573. sideOrientation?: number;
  21574. frontUVs?: Vector4;
  21575. backUVs?: Vector4;
  21576. }): VertexData;
  21577. /**
  21578. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21580. * * segments sets the number of horizontal strips optional, default 32
  21581. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21582. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21583. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21584. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21585. * * 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
  21586. * * 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
  21587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21588. * * 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)
  21589. * * 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)
  21590. * @returns the VertexData of the ellipsoid
  21591. */
  21592. static CreateSphere(options: {
  21593. segments?: number;
  21594. diameter?: number;
  21595. diameterX?: number;
  21596. diameterY?: number;
  21597. diameterZ?: number;
  21598. arc?: number;
  21599. slice?: number;
  21600. sideOrientation?: number;
  21601. frontUVs?: Vector4;
  21602. backUVs?: Vector4;
  21603. }): VertexData;
  21604. /**
  21605. * Creates the VertexData for a cylinder, cone or prism
  21606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21607. * * height sets the height (y direction) of the cylinder, optional, default 2
  21608. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21609. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21610. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21611. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21612. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21613. * * 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
  21614. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21615. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21616. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21617. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21619. * * 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)
  21620. * * 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)
  21621. * @returns the VertexData of the cylinder, cone or prism
  21622. */
  21623. static CreateCylinder(options: {
  21624. height?: number;
  21625. diameterTop?: number;
  21626. diameterBottom?: number;
  21627. diameter?: number;
  21628. tessellation?: number;
  21629. subdivisions?: number;
  21630. arc?: number;
  21631. faceColors?: Color4[];
  21632. faceUV?: Vector4[];
  21633. hasRings?: boolean;
  21634. enclose?: boolean;
  21635. sideOrientation?: number;
  21636. frontUVs?: Vector4;
  21637. backUVs?: Vector4;
  21638. }): VertexData;
  21639. /**
  21640. * Creates the VertexData for a torus
  21641. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21642. * * diameter the diameter of the torus, optional default 1
  21643. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21644. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21646. * * 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)
  21647. * * 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)
  21648. * @returns the VertexData of the torus
  21649. */
  21650. static CreateTorus(options: {
  21651. diameter?: number;
  21652. thickness?: number;
  21653. tessellation?: number;
  21654. sideOrientation?: number;
  21655. frontUVs?: Vector4;
  21656. backUVs?: Vector4;
  21657. }): VertexData;
  21658. /**
  21659. * Creates the VertexData of the LineSystem
  21660. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21661. * - lines an array of lines, each line being an array of successive Vector3
  21662. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21663. * @returns the VertexData of the LineSystem
  21664. */
  21665. static CreateLineSystem(options: {
  21666. lines: Vector3[][];
  21667. colors?: Nullable<Color4[][]>;
  21668. }): VertexData;
  21669. /**
  21670. * Create the VertexData for a DashedLines
  21671. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21672. * - points an array successive Vector3
  21673. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21674. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21675. * - dashNb the intended total number of dashes, optional, default 200
  21676. * @returns the VertexData for the DashedLines
  21677. */
  21678. static CreateDashedLines(options: {
  21679. points: Vector3[];
  21680. dashSize?: number;
  21681. gapSize?: number;
  21682. dashNb?: number;
  21683. }): VertexData;
  21684. /**
  21685. * Creates the VertexData for a Ground
  21686. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21687. * - width the width (x direction) of the ground, optional, default 1
  21688. * - height the height (z direction) of the ground, optional, default 1
  21689. * - subdivisions the number of subdivisions per side, optional, default 1
  21690. * @returns the VertexData of the Ground
  21691. */
  21692. static CreateGround(options: {
  21693. width?: number;
  21694. height?: number;
  21695. subdivisions?: number;
  21696. subdivisionsX?: number;
  21697. subdivisionsY?: number;
  21698. }): VertexData;
  21699. /**
  21700. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21702. * * xmin the ground minimum X coordinate, optional, default -1
  21703. * * zmin the ground minimum Z coordinate, optional, default -1
  21704. * * xmax the ground maximum X coordinate, optional, default 1
  21705. * * zmax the ground maximum Z coordinate, optional, default 1
  21706. * * 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}
  21707. * * 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}
  21708. * @returns the VertexData of the TiledGround
  21709. */
  21710. static CreateTiledGround(options: {
  21711. xmin: number;
  21712. zmin: number;
  21713. xmax: number;
  21714. zmax: number;
  21715. subdivisions?: {
  21716. w: number;
  21717. h: number;
  21718. };
  21719. precision?: {
  21720. w: number;
  21721. h: number;
  21722. };
  21723. }): VertexData;
  21724. /**
  21725. * Creates the VertexData of the Ground designed from a heightmap
  21726. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21727. * * width the width (x direction) of the ground
  21728. * * height the height (z direction) of the ground
  21729. * * subdivisions the number of subdivisions per side
  21730. * * minHeight the minimum altitude on the ground, optional, default 0
  21731. * * maxHeight the maximum altitude on the ground, optional default 1
  21732. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21733. * * buffer the array holding the image color data
  21734. * * bufferWidth the width of image
  21735. * * bufferHeight the height of image
  21736. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21737. * @returns the VertexData of the Ground designed from a heightmap
  21738. */
  21739. static CreateGroundFromHeightMap(options: {
  21740. width: number;
  21741. height: number;
  21742. subdivisions: number;
  21743. minHeight: number;
  21744. maxHeight: number;
  21745. colorFilter: Color3;
  21746. buffer: Uint8Array;
  21747. bufferWidth: number;
  21748. bufferHeight: number;
  21749. alphaFilter: number;
  21750. }): VertexData;
  21751. /**
  21752. * Creates the VertexData for a Plane
  21753. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21754. * * size sets the width and height of the plane to the value of size, optional default 1
  21755. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21756. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21758. * * 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)
  21759. * * 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)
  21760. * @returns the VertexData of the box
  21761. */
  21762. static CreatePlane(options: {
  21763. size?: number;
  21764. width?: number;
  21765. height?: number;
  21766. sideOrientation?: number;
  21767. frontUVs?: Vector4;
  21768. backUVs?: Vector4;
  21769. }): VertexData;
  21770. /**
  21771. * Creates the VertexData of the Disc or regular Polygon
  21772. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21773. * * radius the radius of the disc, optional default 0.5
  21774. * * tessellation the number of polygon sides, optional, default 64
  21775. * * 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
  21776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21777. * * 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)
  21778. * * 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)
  21779. * @returns the VertexData of the box
  21780. */
  21781. static CreateDisc(options: {
  21782. radius?: number;
  21783. tessellation?: number;
  21784. arc?: number;
  21785. sideOrientation?: number;
  21786. frontUVs?: Vector4;
  21787. backUVs?: Vector4;
  21788. }): VertexData;
  21789. /**
  21790. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21791. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21792. * @param polygon a mesh built from polygonTriangulation.build()
  21793. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21794. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21795. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21796. * @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)
  21797. * @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)
  21798. * @returns the VertexData of the Polygon
  21799. */
  21800. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21801. /**
  21802. * Creates the VertexData of the IcoSphere
  21803. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21804. * * radius the radius of the IcoSphere, optional default 1
  21805. * * radiusX allows stretching in the x direction, optional, default radius
  21806. * * radiusY allows stretching in the y direction, optional, default radius
  21807. * * radiusZ allows stretching in the z direction, optional, default radius
  21808. * * flat when true creates a flat shaded mesh, optional, default true
  21809. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21811. * * 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)
  21812. * * 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)
  21813. * @returns the VertexData of the IcoSphere
  21814. */
  21815. static CreateIcoSphere(options: {
  21816. radius?: number;
  21817. radiusX?: number;
  21818. radiusY?: number;
  21819. radiusZ?: number;
  21820. flat?: boolean;
  21821. subdivisions?: number;
  21822. sideOrientation?: number;
  21823. frontUVs?: Vector4;
  21824. backUVs?: Vector4;
  21825. }): VertexData;
  21826. /**
  21827. * Creates the VertexData for a Polyhedron
  21828. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21829. * * type provided types are:
  21830. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21831. * * 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)
  21832. * * size the size of the IcoSphere, optional default 1
  21833. * * sizeX allows stretching in the x direction, optional, default size
  21834. * * sizeY allows stretching in the y direction, optional, default size
  21835. * * sizeZ allows stretching in the z direction, optional, default size
  21836. * * 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
  21837. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21838. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21839. * * flat when true creates a flat shaded mesh, optional, default true
  21840. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21841. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21842. * * 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)
  21843. * * 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)
  21844. * @returns the VertexData of the Polyhedron
  21845. */
  21846. static CreatePolyhedron(options: {
  21847. type?: number;
  21848. size?: number;
  21849. sizeX?: number;
  21850. sizeY?: number;
  21851. sizeZ?: number;
  21852. custom?: any;
  21853. faceUV?: Vector4[];
  21854. faceColors?: Color4[];
  21855. flat?: boolean;
  21856. sideOrientation?: number;
  21857. frontUVs?: Vector4;
  21858. backUVs?: Vector4;
  21859. }): VertexData;
  21860. /**
  21861. * Creates the VertexData for a TorusKnot
  21862. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21863. * * radius the radius of the torus knot, optional, default 2
  21864. * * tube the thickness of the tube, optional, default 0.5
  21865. * * radialSegments the number of sides on each tube segments, optional, default 32
  21866. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21867. * * p the number of windings around the z axis, optional, default 2
  21868. * * q the number of windings around the x axis, optional, default 3
  21869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21870. * * 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)
  21871. * * 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)
  21872. * @returns the VertexData of the Torus Knot
  21873. */
  21874. static CreateTorusKnot(options: {
  21875. radius?: number;
  21876. tube?: number;
  21877. radialSegments?: number;
  21878. tubularSegments?: number;
  21879. p?: number;
  21880. q?: number;
  21881. sideOrientation?: number;
  21882. frontUVs?: Vector4;
  21883. backUVs?: Vector4;
  21884. }): VertexData;
  21885. /**
  21886. * Compute normals for given positions and indices
  21887. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21888. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21889. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21890. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21891. * * facetNormals : optional array of facet normals (vector3)
  21892. * * facetPositions : optional array of facet positions (vector3)
  21893. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21894. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21895. * * bInfo : optional bounding info, required for facetPartitioning computation
  21896. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21897. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21898. * * useRightHandedSystem: optional boolean to for right handed system computation
  21899. * * depthSort : optional boolean to enable the facet depth sort computation
  21900. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21901. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21902. */
  21903. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21904. facetNormals?: any;
  21905. facetPositions?: any;
  21906. facetPartitioning?: any;
  21907. ratio?: number;
  21908. bInfo?: any;
  21909. bbSize?: Vector3;
  21910. subDiv?: any;
  21911. useRightHandedSystem?: boolean;
  21912. depthSort?: boolean;
  21913. distanceTo?: Vector3;
  21914. depthSortedFacets?: any;
  21915. }): void;
  21916. /** @hidden */
  21917. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21918. /**
  21919. * Applies VertexData created from the imported parameters to the geometry
  21920. * @param parsedVertexData the parsed data from an imported file
  21921. * @param geometry the geometry to apply the VertexData to
  21922. */
  21923. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21924. }
  21925. }
  21926. declare module BABYLON {
  21927. /**
  21928. * Defines a target to use with MorphTargetManager
  21929. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21930. */
  21931. export class MorphTarget implements IAnimatable {
  21932. /** defines the name of the target */
  21933. name: string;
  21934. /**
  21935. * Gets or sets the list of animations
  21936. */
  21937. animations: Animation[];
  21938. private _scene;
  21939. private _positions;
  21940. private _normals;
  21941. private _tangents;
  21942. private _uvs;
  21943. private _influence;
  21944. /**
  21945. * Observable raised when the influence changes
  21946. */
  21947. onInfluenceChanged: Observable<boolean>;
  21948. /** @hidden */
  21949. _onDataLayoutChanged: Observable<void>;
  21950. /**
  21951. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21952. */
  21953. influence: number;
  21954. /**
  21955. * Gets or sets the id of the morph Target
  21956. */
  21957. id: string;
  21958. private _animationPropertiesOverride;
  21959. /**
  21960. * Gets or sets the animation properties override
  21961. */
  21962. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21963. /**
  21964. * Creates a new MorphTarget
  21965. * @param name defines the name of the target
  21966. * @param influence defines the influence to use
  21967. * @param scene defines the scene the morphtarget belongs to
  21968. */
  21969. constructor(
  21970. /** defines the name of the target */
  21971. name: string, influence?: number, scene?: Nullable<Scene>);
  21972. /**
  21973. * Gets a boolean defining if the target contains position data
  21974. */
  21975. readonly hasPositions: boolean;
  21976. /**
  21977. * Gets a boolean defining if the target contains normal data
  21978. */
  21979. readonly hasNormals: boolean;
  21980. /**
  21981. * Gets a boolean defining if the target contains tangent data
  21982. */
  21983. readonly hasTangents: boolean;
  21984. /**
  21985. * Gets a boolean defining if the target contains texture coordinates data
  21986. */
  21987. readonly hasUVs: boolean;
  21988. /**
  21989. * Affects position data to this target
  21990. * @param data defines the position data to use
  21991. */
  21992. setPositions(data: Nullable<FloatArray>): void;
  21993. /**
  21994. * Gets the position data stored in this target
  21995. * @returns a FloatArray containing the position data (or null if not present)
  21996. */
  21997. getPositions(): Nullable<FloatArray>;
  21998. /**
  21999. * Affects normal data to this target
  22000. * @param data defines the normal data to use
  22001. */
  22002. setNormals(data: Nullable<FloatArray>): void;
  22003. /**
  22004. * Gets the normal data stored in this target
  22005. * @returns a FloatArray containing the normal data (or null if not present)
  22006. */
  22007. getNormals(): Nullable<FloatArray>;
  22008. /**
  22009. * Affects tangent data to this target
  22010. * @param data defines the tangent data to use
  22011. */
  22012. setTangents(data: Nullable<FloatArray>): void;
  22013. /**
  22014. * Gets the tangent data stored in this target
  22015. * @returns a FloatArray containing the tangent data (or null if not present)
  22016. */
  22017. getTangents(): Nullable<FloatArray>;
  22018. /**
  22019. * Affects texture coordinates data to this target
  22020. * @param data defines the texture coordinates data to use
  22021. */
  22022. setUVs(data: Nullable<FloatArray>): void;
  22023. /**
  22024. * Gets the texture coordinates data stored in this target
  22025. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22026. */
  22027. getUVs(): Nullable<FloatArray>;
  22028. /**
  22029. * Serializes the current target into a Serialization object
  22030. * @returns the serialized object
  22031. */
  22032. serialize(): any;
  22033. /**
  22034. * Returns the string "MorphTarget"
  22035. * @returns "MorphTarget"
  22036. */
  22037. getClassName(): string;
  22038. /**
  22039. * Creates a new target from serialized data
  22040. * @param serializationObject defines the serialized data to use
  22041. * @returns a new MorphTarget
  22042. */
  22043. static Parse(serializationObject: any): MorphTarget;
  22044. /**
  22045. * Creates a MorphTarget from mesh data
  22046. * @param mesh defines the source mesh
  22047. * @param name defines the name to use for the new target
  22048. * @param influence defines the influence to attach to the target
  22049. * @returns a new MorphTarget
  22050. */
  22051. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22052. }
  22053. }
  22054. declare module BABYLON {
  22055. /**
  22056. * This class is used to deform meshes using morphing between different targets
  22057. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22058. */
  22059. export class MorphTargetManager {
  22060. private _targets;
  22061. private _targetInfluenceChangedObservers;
  22062. private _targetDataLayoutChangedObservers;
  22063. private _activeTargets;
  22064. private _scene;
  22065. private _influences;
  22066. private _supportsNormals;
  22067. private _supportsTangents;
  22068. private _supportsUVs;
  22069. private _vertexCount;
  22070. private _uniqueId;
  22071. private _tempInfluences;
  22072. /**
  22073. * Gets or sets a boolean indicating if normals must be morphed
  22074. */
  22075. enableNormalMorphing: boolean;
  22076. /**
  22077. * Gets or sets a boolean indicating if tangents must be morphed
  22078. */
  22079. enableTangentMorphing: boolean;
  22080. /**
  22081. * Gets or sets a boolean indicating if UV must be morphed
  22082. */
  22083. enableUVMorphing: boolean;
  22084. /**
  22085. * Creates a new MorphTargetManager
  22086. * @param scene defines the current scene
  22087. */
  22088. constructor(scene?: Nullable<Scene>);
  22089. /**
  22090. * Gets the unique ID of this manager
  22091. */
  22092. readonly uniqueId: number;
  22093. /**
  22094. * Gets the number of vertices handled by this manager
  22095. */
  22096. readonly vertexCount: number;
  22097. /**
  22098. * Gets a boolean indicating if this manager supports morphing of normals
  22099. */
  22100. readonly supportsNormals: boolean;
  22101. /**
  22102. * Gets a boolean indicating if this manager supports morphing of tangents
  22103. */
  22104. readonly supportsTangents: boolean;
  22105. /**
  22106. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22107. */
  22108. readonly supportsUVs: boolean;
  22109. /**
  22110. * Gets the number of targets stored in this manager
  22111. */
  22112. readonly numTargets: number;
  22113. /**
  22114. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22115. */
  22116. readonly numInfluencers: number;
  22117. /**
  22118. * Gets the list of influences (one per target)
  22119. */
  22120. readonly influences: Float32Array;
  22121. /**
  22122. * Gets the active target at specified index. An active target is a target with an influence > 0
  22123. * @param index defines the index to check
  22124. * @returns the requested target
  22125. */
  22126. getActiveTarget(index: number): MorphTarget;
  22127. /**
  22128. * Gets the target at specified index
  22129. * @param index defines the index to check
  22130. * @returns the requested target
  22131. */
  22132. getTarget(index: number): MorphTarget;
  22133. /**
  22134. * Add a new target to this manager
  22135. * @param target defines the target to add
  22136. */
  22137. addTarget(target: MorphTarget): void;
  22138. /**
  22139. * Removes a target from the manager
  22140. * @param target defines the target to remove
  22141. */
  22142. removeTarget(target: MorphTarget): void;
  22143. /**
  22144. * Serializes the current manager into a Serialization object
  22145. * @returns the serialized object
  22146. */
  22147. serialize(): any;
  22148. private _syncActiveTargets;
  22149. /**
  22150. * Syncrhonize the targets with all the meshes using this morph target manager
  22151. */
  22152. synchronize(): void;
  22153. /**
  22154. * Creates a new MorphTargetManager from serialized data
  22155. * @param serializationObject defines the serialized data
  22156. * @param scene defines the hosting scene
  22157. * @returns the new MorphTargetManager
  22158. */
  22159. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22160. }
  22161. }
  22162. declare module BABYLON {
  22163. /**
  22164. * Class used to represent a specific level of detail of a mesh
  22165. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22166. */
  22167. export class MeshLODLevel {
  22168. /** Defines the distance where this level should start being displayed */
  22169. distance: number;
  22170. /** Defines the mesh to use to render this level */
  22171. mesh: Nullable<Mesh>;
  22172. /**
  22173. * Creates a new LOD level
  22174. * @param distance defines the distance where this level should star being displayed
  22175. * @param mesh defines the mesh to use to render this level
  22176. */
  22177. constructor(
  22178. /** Defines the distance where this level should start being displayed */
  22179. distance: number,
  22180. /** Defines the mesh to use to render this level */
  22181. mesh: Nullable<Mesh>);
  22182. }
  22183. }
  22184. declare module BABYLON {
  22185. /**
  22186. * Mesh representing the gorund
  22187. */
  22188. export class GroundMesh extends Mesh {
  22189. /** If octree should be generated */
  22190. generateOctree: boolean;
  22191. private _heightQuads;
  22192. /** @hidden */
  22193. _subdivisionsX: number;
  22194. /** @hidden */
  22195. _subdivisionsY: number;
  22196. /** @hidden */
  22197. _width: number;
  22198. /** @hidden */
  22199. _height: number;
  22200. /** @hidden */
  22201. _minX: number;
  22202. /** @hidden */
  22203. _maxX: number;
  22204. /** @hidden */
  22205. _minZ: number;
  22206. /** @hidden */
  22207. _maxZ: number;
  22208. constructor(name: string, scene: Scene);
  22209. /**
  22210. * "GroundMesh"
  22211. * @returns "GroundMesh"
  22212. */
  22213. getClassName(): string;
  22214. /**
  22215. * The minimum of x and y subdivisions
  22216. */
  22217. readonly subdivisions: number;
  22218. /**
  22219. * X subdivisions
  22220. */
  22221. readonly subdivisionsX: number;
  22222. /**
  22223. * Y subdivisions
  22224. */
  22225. readonly subdivisionsY: number;
  22226. /**
  22227. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22228. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22229. * @param chunksCount the number of subdivisions for x and y
  22230. * @param octreeBlocksSize (Default: 32)
  22231. */
  22232. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22233. /**
  22234. * Returns a height (y) value in the Worl system :
  22235. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22236. * @param x x coordinate
  22237. * @param z z coordinate
  22238. * @returns the ground y position if (x, z) are outside the ground surface.
  22239. */
  22240. getHeightAtCoordinates(x: number, z: number): number;
  22241. /**
  22242. * Returns a normalized vector (Vector3) orthogonal to the ground
  22243. * at the ground coordinates (x, z) expressed in the World system.
  22244. * @param x x coordinate
  22245. * @param z z coordinate
  22246. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22247. */
  22248. getNormalAtCoordinates(x: number, z: number): Vector3;
  22249. /**
  22250. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22251. * at the ground coordinates (x, z) expressed in the World system.
  22252. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22253. * @param x x coordinate
  22254. * @param z z coordinate
  22255. * @param ref vector to store the result
  22256. * @returns the GroundMesh.
  22257. */
  22258. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22259. /**
  22260. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22261. * if the ground has been updated.
  22262. * This can be used in the render loop.
  22263. * @returns the GroundMesh.
  22264. */
  22265. updateCoordinateHeights(): GroundMesh;
  22266. private _getFacetAt;
  22267. private _initHeightQuads;
  22268. private _computeHeightQuads;
  22269. /**
  22270. * Serializes this ground mesh
  22271. * @param serializationObject object to write serialization to
  22272. */
  22273. serialize(serializationObject: any): void;
  22274. /**
  22275. * Parses a serialized ground mesh
  22276. * @param parsedMesh the serialized mesh
  22277. * @param scene the scene to create the ground mesh in
  22278. * @returns the created ground mesh
  22279. */
  22280. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22281. }
  22282. }
  22283. declare module BABYLON {
  22284. /**
  22285. * Interface for Physics-Joint data
  22286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22287. */
  22288. export interface PhysicsJointData {
  22289. /**
  22290. * The main pivot of the joint
  22291. */
  22292. mainPivot?: Vector3;
  22293. /**
  22294. * The connected pivot of the joint
  22295. */
  22296. connectedPivot?: Vector3;
  22297. /**
  22298. * The main axis of the joint
  22299. */
  22300. mainAxis?: Vector3;
  22301. /**
  22302. * The connected axis of the joint
  22303. */
  22304. connectedAxis?: Vector3;
  22305. /**
  22306. * The collision of the joint
  22307. */
  22308. collision?: boolean;
  22309. /**
  22310. * Native Oimo/Cannon/Energy data
  22311. */
  22312. nativeParams?: any;
  22313. }
  22314. /**
  22315. * This is a holder class for the physics joint created by the physics plugin
  22316. * It holds a set of functions to control the underlying joint
  22317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22318. */
  22319. export class PhysicsJoint {
  22320. /**
  22321. * The type of the physics joint
  22322. */
  22323. type: number;
  22324. /**
  22325. * The data for the physics joint
  22326. */
  22327. jointData: PhysicsJointData;
  22328. private _physicsJoint;
  22329. protected _physicsPlugin: IPhysicsEnginePlugin;
  22330. /**
  22331. * Initializes the physics joint
  22332. * @param type The type of the physics joint
  22333. * @param jointData The data for the physics joint
  22334. */
  22335. constructor(
  22336. /**
  22337. * The type of the physics joint
  22338. */
  22339. type: number,
  22340. /**
  22341. * The data for the physics joint
  22342. */
  22343. jointData: PhysicsJointData);
  22344. /**
  22345. * Gets the physics joint
  22346. */
  22347. /**
  22348. * Sets the physics joint
  22349. */
  22350. physicsJoint: any;
  22351. /**
  22352. * Sets the physics plugin
  22353. */
  22354. physicsPlugin: IPhysicsEnginePlugin;
  22355. /**
  22356. * Execute a function that is physics-plugin specific.
  22357. * @param {Function} func the function that will be executed.
  22358. * It accepts two parameters: the physics world and the physics joint
  22359. */
  22360. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22361. /**
  22362. * Distance-Joint type
  22363. */
  22364. static DistanceJoint: number;
  22365. /**
  22366. * Hinge-Joint type
  22367. */
  22368. static HingeJoint: number;
  22369. /**
  22370. * Ball-and-Socket joint type
  22371. */
  22372. static BallAndSocketJoint: number;
  22373. /**
  22374. * Wheel-Joint type
  22375. */
  22376. static WheelJoint: number;
  22377. /**
  22378. * Slider-Joint type
  22379. */
  22380. static SliderJoint: number;
  22381. /**
  22382. * Prismatic-Joint type
  22383. */
  22384. static PrismaticJoint: number;
  22385. /**
  22386. * Universal-Joint type
  22387. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22388. */
  22389. static UniversalJoint: number;
  22390. /**
  22391. * Hinge-Joint 2 type
  22392. */
  22393. static Hinge2Joint: number;
  22394. /**
  22395. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22396. */
  22397. static PointToPointJoint: number;
  22398. /**
  22399. * Spring-Joint type
  22400. */
  22401. static SpringJoint: number;
  22402. /**
  22403. * Lock-Joint type
  22404. */
  22405. static LockJoint: number;
  22406. }
  22407. /**
  22408. * A class representing a physics distance joint
  22409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22410. */
  22411. export class DistanceJoint extends PhysicsJoint {
  22412. /**
  22413. *
  22414. * @param jointData The data for the Distance-Joint
  22415. */
  22416. constructor(jointData: DistanceJointData);
  22417. /**
  22418. * Update the predefined distance.
  22419. * @param maxDistance The maximum preferred distance
  22420. * @param minDistance The minimum preferred distance
  22421. */
  22422. updateDistance(maxDistance: number, minDistance?: number): void;
  22423. }
  22424. /**
  22425. * Represents a Motor-Enabled Joint
  22426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22427. */
  22428. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22429. /**
  22430. * Initializes the Motor-Enabled Joint
  22431. * @param type The type of the joint
  22432. * @param jointData The physica joint data for the joint
  22433. */
  22434. constructor(type: number, jointData: PhysicsJointData);
  22435. /**
  22436. * Set the motor values.
  22437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22438. * @param force the force to apply
  22439. * @param maxForce max force for this motor.
  22440. */
  22441. setMotor(force?: number, maxForce?: number): void;
  22442. /**
  22443. * Set the motor's limits.
  22444. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22445. * @param upperLimit The upper limit of the motor
  22446. * @param lowerLimit The lower limit of the motor
  22447. */
  22448. setLimit(upperLimit: number, lowerLimit?: number): void;
  22449. }
  22450. /**
  22451. * This class represents a single physics Hinge-Joint
  22452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22453. */
  22454. export class HingeJoint extends MotorEnabledJoint {
  22455. /**
  22456. * Initializes the Hinge-Joint
  22457. * @param jointData The joint data for the Hinge-Joint
  22458. */
  22459. constructor(jointData: PhysicsJointData);
  22460. /**
  22461. * Set the motor values.
  22462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22463. * @param {number} force the force to apply
  22464. * @param {number} maxForce max force for this motor.
  22465. */
  22466. setMotor(force?: number, maxForce?: number): void;
  22467. /**
  22468. * Set the motor's limits.
  22469. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22470. * @param upperLimit The upper limit of the motor
  22471. * @param lowerLimit The lower limit of the motor
  22472. */
  22473. setLimit(upperLimit: number, lowerLimit?: number): void;
  22474. }
  22475. /**
  22476. * This class represents a dual hinge physics joint (same as wheel joint)
  22477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22478. */
  22479. export class Hinge2Joint extends MotorEnabledJoint {
  22480. /**
  22481. * Initializes the Hinge2-Joint
  22482. * @param jointData The joint data for the Hinge2-Joint
  22483. */
  22484. constructor(jointData: PhysicsJointData);
  22485. /**
  22486. * Set the motor values.
  22487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22488. * @param {number} targetSpeed the speed the motor is to reach
  22489. * @param {number} maxForce max force for this motor.
  22490. * @param {motorIndex} the motor's index, 0 or 1.
  22491. */
  22492. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22493. /**
  22494. * Set the motor limits.
  22495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22496. * @param {number} upperLimit the upper limit
  22497. * @param {number} lowerLimit lower limit
  22498. * @param {motorIndex} the motor's index, 0 or 1.
  22499. */
  22500. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22501. }
  22502. /**
  22503. * Interface for a motor enabled joint
  22504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22505. */
  22506. export interface IMotorEnabledJoint {
  22507. /**
  22508. * Physics joint
  22509. */
  22510. physicsJoint: any;
  22511. /**
  22512. * Sets the motor of the motor-enabled joint
  22513. * @param force The force of the motor
  22514. * @param maxForce The maximum force of the motor
  22515. * @param motorIndex The index of the motor
  22516. */
  22517. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22518. /**
  22519. * Sets the limit of the motor
  22520. * @param upperLimit The upper limit of the motor
  22521. * @param lowerLimit The lower limit of the motor
  22522. * @param motorIndex The index of the motor
  22523. */
  22524. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22525. }
  22526. /**
  22527. * Joint data for a Distance-Joint
  22528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22529. */
  22530. export interface DistanceJointData extends PhysicsJointData {
  22531. /**
  22532. * Max distance the 2 joint objects can be apart
  22533. */
  22534. maxDistance: number;
  22535. }
  22536. /**
  22537. * Joint data from a spring joint
  22538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22539. */
  22540. export interface SpringJointData extends PhysicsJointData {
  22541. /**
  22542. * Length of the spring
  22543. */
  22544. length: number;
  22545. /**
  22546. * Stiffness of the spring
  22547. */
  22548. stiffness: number;
  22549. /**
  22550. * Damping of the spring
  22551. */
  22552. damping: number;
  22553. /** this callback will be called when applying the force to the impostors. */
  22554. forceApplicationCallback: () => void;
  22555. }
  22556. }
  22557. declare module BABYLON {
  22558. /**
  22559. * Holds the data for the raycast result
  22560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22561. */
  22562. export class PhysicsRaycastResult {
  22563. private _hasHit;
  22564. private _hitDistance;
  22565. private _hitNormalWorld;
  22566. private _hitPointWorld;
  22567. private _rayFromWorld;
  22568. private _rayToWorld;
  22569. /**
  22570. * Gets if there was a hit
  22571. */
  22572. readonly hasHit: boolean;
  22573. /**
  22574. * Gets the distance from the hit
  22575. */
  22576. readonly hitDistance: number;
  22577. /**
  22578. * Gets the hit normal/direction in the world
  22579. */
  22580. readonly hitNormalWorld: Vector3;
  22581. /**
  22582. * Gets the hit point in the world
  22583. */
  22584. readonly hitPointWorld: Vector3;
  22585. /**
  22586. * Gets the ray "start point" of the ray in the world
  22587. */
  22588. readonly rayFromWorld: Vector3;
  22589. /**
  22590. * Gets the ray "end point" of the ray in the world
  22591. */
  22592. readonly rayToWorld: Vector3;
  22593. /**
  22594. * Sets the hit data (normal & point in world space)
  22595. * @param hitNormalWorld defines the normal in world space
  22596. * @param hitPointWorld defines the point in world space
  22597. */
  22598. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22599. /**
  22600. * Sets the distance from the start point to the hit point
  22601. * @param distance
  22602. */
  22603. setHitDistance(distance: number): void;
  22604. /**
  22605. * Calculates the distance manually
  22606. */
  22607. calculateHitDistance(): void;
  22608. /**
  22609. * Resets all the values to default
  22610. * @param from The from point on world space
  22611. * @param to The to point on world space
  22612. */
  22613. reset(from?: Vector3, to?: Vector3): void;
  22614. }
  22615. /**
  22616. * Interface for the size containing width and height
  22617. */
  22618. interface IXYZ {
  22619. /**
  22620. * X
  22621. */
  22622. x: number;
  22623. /**
  22624. * Y
  22625. */
  22626. y: number;
  22627. /**
  22628. * Z
  22629. */
  22630. z: number;
  22631. }
  22632. }
  22633. declare module BABYLON {
  22634. /**
  22635. * Interface used to describe a physics joint
  22636. */
  22637. export interface PhysicsImpostorJoint {
  22638. /** Defines the main impostor to which the joint is linked */
  22639. mainImpostor: PhysicsImpostor;
  22640. /** Defines the impostor that is connected to the main impostor using this joint */
  22641. connectedImpostor: PhysicsImpostor;
  22642. /** Defines the joint itself */
  22643. joint: PhysicsJoint;
  22644. }
  22645. /** @hidden */
  22646. export interface IPhysicsEnginePlugin {
  22647. world: any;
  22648. name: string;
  22649. setGravity(gravity: Vector3): void;
  22650. setTimeStep(timeStep: number): void;
  22651. getTimeStep(): number;
  22652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22656. removePhysicsBody(impostor: PhysicsImpostor): void;
  22657. generateJoint(joint: PhysicsImpostorJoint): void;
  22658. removeJoint(joint: PhysicsImpostorJoint): void;
  22659. isSupported(): boolean;
  22660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22667. getBodyMass(impostor: PhysicsImpostor): number;
  22668. getBodyFriction(impostor: PhysicsImpostor): number;
  22669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22670. getBodyRestitution(impostor: PhysicsImpostor): number;
  22671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22672. getBodyPressure?(impostor: PhysicsImpostor): number;
  22673. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22674. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22675. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22676. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22677. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22678. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22679. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22680. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22681. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22682. sleepBody(impostor: PhysicsImpostor): void;
  22683. wakeUpBody(impostor: PhysicsImpostor): void;
  22684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22688. getRadius(impostor: PhysicsImpostor): number;
  22689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22691. dispose(): void;
  22692. }
  22693. /**
  22694. * Interface used to define a physics engine
  22695. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22696. */
  22697. export interface IPhysicsEngine {
  22698. /**
  22699. * Gets the gravity vector used by the simulation
  22700. */
  22701. gravity: Vector3;
  22702. /**
  22703. * Sets the gravity vector used by the simulation
  22704. * @param gravity defines the gravity vector to use
  22705. */
  22706. setGravity(gravity: Vector3): void;
  22707. /**
  22708. * Set the time step of the physics engine.
  22709. * Default is 1/60.
  22710. * To slow it down, enter 1/600 for example.
  22711. * To speed it up, 1/30
  22712. * @param newTimeStep the new timestep to apply to this world.
  22713. */
  22714. setTimeStep(newTimeStep: number): void;
  22715. /**
  22716. * Get the time step of the physics engine.
  22717. * @returns the current time step
  22718. */
  22719. getTimeStep(): number;
  22720. /**
  22721. * Release all resources
  22722. */
  22723. dispose(): void;
  22724. /**
  22725. * Gets the name of the current physics plugin
  22726. * @returns the name of the plugin
  22727. */
  22728. getPhysicsPluginName(): string;
  22729. /**
  22730. * Adding a new impostor for the impostor tracking.
  22731. * This will be done by the impostor itself.
  22732. * @param impostor the impostor to add
  22733. */
  22734. addImpostor(impostor: PhysicsImpostor): void;
  22735. /**
  22736. * Remove an impostor from the engine.
  22737. * This impostor and its mesh will not longer be updated by the physics engine.
  22738. * @param impostor the impostor to remove
  22739. */
  22740. removeImpostor(impostor: PhysicsImpostor): void;
  22741. /**
  22742. * Add a joint to the physics engine
  22743. * @param mainImpostor defines the main impostor to which the joint is added.
  22744. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22745. * @param joint defines the joint that will connect both impostors.
  22746. */
  22747. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22748. /**
  22749. * Removes a joint from the simulation
  22750. * @param mainImpostor defines the impostor used with the joint
  22751. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22752. * @param joint defines the joint to remove
  22753. */
  22754. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22755. /**
  22756. * Gets the current plugin used to run the simulation
  22757. * @returns current plugin
  22758. */
  22759. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22760. /**
  22761. * Gets the list of physic impostors
  22762. * @returns an array of PhysicsImpostor
  22763. */
  22764. getImpostors(): Array<PhysicsImpostor>;
  22765. /**
  22766. * Gets the impostor for a physics enabled object
  22767. * @param object defines the object impersonated by the impostor
  22768. * @returns the PhysicsImpostor or null if not found
  22769. */
  22770. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22771. /**
  22772. * Gets the impostor for a physics body object
  22773. * @param body defines physics body used by the impostor
  22774. * @returns the PhysicsImpostor or null if not found
  22775. */
  22776. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22777. /**
  22778. * Does a raycast in the physics world
  22779. * @param from when should the ray start?
  22780. * @param to when should the ray end?
  22781. * @returns PhysicsRaycastResult
  22782. */
  22783. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22784. /**
  22785. * Called by the scene. No need to call it.
  22786. * @param delta defines the timespam between frames
  22787. */
  22788. _step(delta: number): void;
  22789. }
  22790. }
  22791. declare module BABYLON {
  22792. /**
  22793. * The interface for the physics imposter parameters
  22794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22795. */
  22796. export interface PhysicsImpostorParameters {
  22797. /**
  22798. * The mass of the physics imposter
  22799. */
  22800. mass: number;
  22801. /**
  22802. * The friction of the physics imposter
  22803. */
  22804. friction?: number;
  22805. /**
  22806. * The coefficient of restitution of the physics imposter
  22807. */
  22808. restitution?: number;
  22809. /**
  22810. * The native options of the physics imposter
  22811. */
  22812. nativeOptions?: any;
  22813. /**
  22814. * Specifies if the parent should be ignored
  22815. */
  22816. ignoreParent?: boolean;
  22817. /**
  22818. * Specifies if bi-directional transformations should be disabled
  22819. */
  22820. disableBidirectionalTransformation?: boolean;
  22821. /**
  22822. * The pressure inside the physics imposter, soft object only
  22823. */
  22824. pressure?: number;
  22825. /**
  22826. * The stiffness the physics imposter, soft object only
  22827. */
  22828. stiffness?: number;
  22829. /**
  22830. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22831. */
  22832. velocityIterations?: number;
  22833. /**
  22834. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22835. */
  22836. positionIterations?: number;
  22837. /**
  22838. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22839. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22840. * Add to fix multiple points
  22841. */
  22842. fixedPoints?: number;
  22843. /**
  22844. * The collision margin around a soft object
  22845. */
  22846. margin?: number;
  22847. /**
  22848. * The collision margin around a soft object
  22849. */
  22850. damping?: number;
  22851. /**
  22852. * The path for a rope based on an extrusion
  22853. */
  22854. path?: any;
  22855. /**
  22856. * The shape of an extrusion used for a rope based on an extrusion
  22857. */
  22858. shape?: any;
  22859. }
  22860. /**
  22861. * Interface for a physics-enabled object
  22862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22863. */
  22864. export interface IPhysicsEnabledObject {
  22865. /**
  22866. * The position of the physics-enabled object
  22867. */
  22868. position: Vector3;
  22869. /**
  22870. * The rotation of the physics-enabled object
  22871. */
  22872. rotationQuaternion: Nullable<Quaternion>;
  22873. /**
  22874. * The scale of the physics-enabled object
  22875. */
  22876. scaling: Vector3;
  22877. /**
  22878. * The rotation of the physics-enabled object
  22879. */
  22880. rotation?: Vector3;
  22881. /**
  22882. * The parent of the physics-enabled object
  22883. */
  22884. parent?: any;
  22885. /**
  22886. * The bounding info of the physics-enabled object
  22887. * @returns The bounding info of the physics-enabled object
  22888. */
  22889. getBoundingInfo(): BoundingInfo;
  22890. /**
  22891. * Computes the world matrix
  22892. * @param force Specifies if the world matrix should be computed by force
  22893. * @returns A world matrix
  22894. */
  22895. computeWorldMatrix(force: boolean): Matrix;
  22896. /**
  22897. * Gets the world matrix
  22898. * @returns A world matrix
  22899. */
  22900. getWorldMatrix?(): Matrix;
  22901. /**
  22902. * Gets the child meshes
  22903. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22904. * @returns An array of abstract meshes
  22905. */
  22906. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22907. /**
  22908. * Gets the vertex data
  22909. * @param kind The type of vertex data
  22910. * @returns A nullable array of numbers, or a float32 array
  22911. */
  22912. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22913. /**
  22914. * Gets the indices from the mesh
  22915. * @returns A nullable array of index arrays
  22916. */
  22917. getIndices?(): Nullable<IndicesArray>;
  22918. /**
  22919. * Gets the scene from the mesh
  22920. * @returns the indices array or null
  22921. */
  22922. getScene?(): Scene;
  22923. /**
  22924. * Gets the absolute position from the mesh
  22925. * @returns the absolute position
  22926. */
  22927. getAbsolutePosition(): Vector3;
  22928. /**
  22929. * Gets the absolute pivot point from the mesh
  22930. * @returns the absolute pivot point
  22931. */
  22932. getAbsolutePivotPoint(): Vector3;
  22933. /**
  22934. * Rotates the mesh
  22935. * @param axis The axis of rotation
  22936. * @param amount The amount of rotation
  22937. * @param space The space of the rotation
  22938. * @returns The rotation transform node
  22939. */
  22940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22941. /**
  22942. * Translates the mesh
  22943. * @param axis The axis of translation
  22944. * @param distance The distance of translation
  22945. * @param space The space of the translation
  22946. * @returns The transform node
  22947. */
  22948. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22949. /**
  22950. * Sets the absolute position of the mesh
  22951. * @param absolutePosition The absolute position of the mesh
  22952. * @returns The transform node
  22953. */
  22954. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22955. /**
  22956. * Gets the class name of the mesh
  22957. * @returns The class name
  22958. */
  22959. getClassName(): string;
  22960. }
  22961. /**
  22962. * Represents a physics imposter
  22963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22964. */
  22965. export class PhysicsImpostor {
  22966. /**
  22967. * The physics-enabled object used as the physics imposter
  22968. */
  22969. object: IPhysicsEnabledObject;
  22970. /**
  22971. * The type of the physics imposter
  22972. */
  22973. type: number;
  22974. private _options;
  22975. private _scene?;
  22976. /**
  22977. * The default object size of the imposter
  22978. */
  22979. static DEFAULT_OBJECT_SIZE: Vector3;
  22980. /**
  22981. * The identity quaternion of the imposter
  22982. */
  22983. static IDENTITY_QUATERNION: Quaternion;
  22984. /** @hidden */
  22985. _pluginData: any;
  22986. private _physicsEngine;
  22987. private _physicsBody;
  22988. private _bodyUpdateRequired;
  22989. private _onBeforePhysicsStepCallbacks;
  22990. private _onAfterPhysicsStepCallbacks;
  22991. /** @hidden */
  22992. _onPhysicsCollideCallbacks: Array<{
  22993. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22994. otherImpostors: Array<PhysicsImpostor>;
  22995. }>;
  22996. private _deltaPosition;
  22997. private _deltaRotation;
  22998. private _deltaRotationConjugated;
  22999. /** @hidden */
  23000. _isFromLine: boolean;
  23001. private _parent;
  23002. private _isDisposed;
  23003. private static _tmpVecs;
  23004. private static _tmpQuat;
  23005. /**
  23006. * Specifies if the physics imposter is disposed
  23007. */
  23008. readonly isDisposed: boolean;
  23009. /**
  23010. * Gets the mass of the physics imposter
  23011. */
  23012. mass: number;
  23013. /**
  23014. * Gets the coefficient of friction
  23015. */
  23016. /**
  23017. * Sets the coefficient of friction
  23018. */
  23019. friction: number;
  23020. /**
  23021. * Gets the coefficient of restitution
  23022. */
  23023. /**
  23024. * Sets the coefficient of restitution
  23025. */
  23026. restitution: number;
  23027. /**
  23028. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23029. */
  23030. /**
  23031. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23032. */
  23033. pressure: number;
  23034. /**
  23035. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23036. */
  23037. /**
  23038. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23039. */
  23040. stiffness: number;
  23041. /**
  23042. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23043. */
  23044. /**
  23045. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23046. */
  23047. velocityIterations: number;
  23048. /**
  23049. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23050. */
  23051. /**
  23052. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23053. */
  23054. positionIterations: number;
  23055. /**
  23056. * The unique id of the physics imposter
  23057. * set by the physics engine when adding this impostor to the array
  23058. */
  23059. uniqueId: number;
  23060. /**
  23061. * @hidden
  23062. */
  23063. soft: boolean;
  23064. /**
  23065. * @hidden
  23066. */
  23067. segments: number;
  23068. private _joints;
  23069. /**
  23070. * Initializes the physics imposter
  23071. * @param object The physics-enabled object used as the physics imposter
  23072. * @param type The type of the physics imposter
  23073. * @param _options The options for the physics imposter
  23074. * @param _scene The Babylon scene
  23075. */
  23076. constructor(
  23077. /**
  23078. * The physics-enabled object used as the physics imposter
  23079. */
  23080. object: IPhysicsEnabledObject,
  23081. /**
  23082. * The type of the physics imposter
  23083. */
  23084. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23085. /**
  23086. * This function will completly initialize this impostor.
  23087. * It will create a new body - but only if this mesh has no parent.
  23088. * If it has, this impostor will not be used other than to define the impostor
  23089. * of the child mesh.
  23090. * @hidden
  23091. */
  23092. _init(): void;
  23093. private _getPhysicsParent;
  23094. /**
  23095. * Should a new body be generated.
  23096. * @returns boolean specifying if body initialization is required
  23097. */
  23098. isBodyInitRequired(): boolean;
  23099. /**
  23100. * Sets the updated scaling
  23101. * @param updated Specifies if the scaling is updated
  23102. */
  23103. setScalingUpdated(): void;
  23104. /**
  23105. * Force a regeneration of this or the parent's impostor's body.
  23106. * Use under cautious - This will remove all joints already implemented.
  23107. */
  23108. forceUpdate(): void;
  23109. /**
  23110. * Gets the body that holds this impostor. Either its own, or its parent.
  23111. */
  23112. /**
  23113. * Set the physics body. Used mainly by the physics engine/plugin
  23114. */
  23115. physicsBody: any;
  23116. /**
  23117. * Get the parent of the physics imposter
  23118. * @returns Physics imposter or null
  23119. */
  23120. /**
  23121. * Sets the parent of the physics imposter
  23122. */
  23123. parent: Nullable<PhysicsImpostor>;
  23124. /**
  23125. * Resets the update flags
  23126. */
  23127. resetUpdateFlags(): void;
  23128. /**
  23129. * Gets the object extend size
  23130. * @returns the object extend size
  23131. */
  23132. getObjectExtendSize(): Vector3;
  23133. /**
  23134. * Gets the object center
  23135. * @returns The object center
  23136. */
  23137. getObjectCenter(): Vector3;
  23138. /**
  23139. * Get a specific parametes from the options parameter
  23140. * @param paramName The object parameter name
  23141. * @returns The object parameter
  23142. */
  23143. getParam(paramName: string): any;
  23144. /**
  23145. * Sets a specific parameter in the options given to the physics plugin
  23146. * @param paramName The parameter name
  23147. * @param value The value of the parameter
  23148. */
  23149. setParam(paramName: string, value: number): void;
  23150. /**
  23151. * Specifically change the body's mass option. Won't recreate the physics body object
  23152. * @param mass The mass of the physics imposter
  23153. */
  23154. setMass(mass: number): void;
  23155. /**
  23156. * Gets the linear velocity
  23157. * @returns linear velocity or null
  23158. */
  23159. getLinearVelocity(): Nullable<Vector3>;
  23160. /**
  23161. * Sets the linear velocity
  23162. * @param velocity linear velocity or null
  23163. */
  23164. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23165. /**
  23166. * Gets the angular velocity
  23167. * @returns angular velocity or null
  23168. */
  23169. getAngularVelocity(): Nullable<Vector3>;
  23170. /**
  23171. * Sets the angular velocity
  23172. * @param velocity The velocity or null
  23173. */
  23174. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23175. /**
  23176. * Execute a function with the physics plugin native code
  23177. * Provide a function the will have two variables - the world object and the physics body object
  23178. * @param func The function to execute with the physics plugin native code
  23179. */
  23180. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23181. /**
  23182. * Register a function that will be executed before the physics world is stepping forward
  23183. * @param func The function to execute before the physics world is stepped forward
  23184. */
  23185. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23186. /**
  23187. * Unregister a function that will be executed before the physics world is stepping forward
  23188. * @param func The function to execute before the physics world is stepped forward
  23189. */
  23190. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23191. /**
  23192. * Register a function that will be executed after the physics step
  23193. * @param func The function to execute after physics step
  23194. */
  23195. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23196. /**
  23197. * Unregisters a function that will be executed after the physics step
  23198. * @param func The function to execute after physics step
  23199. */
  23200. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23201. /**
  23202. * register a function that will be executed when this impostor collides against a different body
  23203. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23204. * @param func Callback that is executed on collision
  23205. */
  23206. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23207. /**
  23208. * Unregisters the physics imposter on contact
  23209. * @param collideAgainst The physics object to collide against
  23210. * @param func Callback to execute on collision
  23211. */
  23212. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23213. private _tmpQuat;
  23214. private _tmpQuat2;
  23215. /**
  23216. * Get the parent rotation
  23217. * @returns The parent rotation
  23218. */
  23219. getParentsRotation(): Quaternion;
  23220. /**
  23221. * this function is executed by the physics engine.
  23222. */
  23223. beforeStep: () => void;
  23224. /**
  23225. * this function is executed by the physics engine
  23226. */
  23227. afterStep: () => void;
  23228. /**
  23229. * Legacy collision detection event support
  23230. */
  23231. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23232. /**
  23233. * event and body object due to cannon's event-based architecture.
  23234. */
  23235. onCollide: (e: {
  23236. body: any;
  23237. }) => void;
  23238. /**
  23239. * Apply a force
  23240. * @param force The force to apply
  23241. * @param contactPoint The contact point for the force
  23242. * @returns The physics imposter
  23243. */
  23244. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23245. /**
  23246. * Apply an impulse
  23247. * @param force The impulse force
  23248. * @param contactPoint The contact point for the impulse force
  23249. * @returns The physics imposter
  23250. */
  23251. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23252. /**
  23253. * A help function to create a joint
  23254. * @param otherImpostor A physics imposter used to create a joint
  23255. * @param jointType The type of joint
  23256. * @param jointData The data for the joint
  23257. * @returns The physics imposter
  23258. */
  23259. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23260. /**
  23261. * Add a joint to this impostor with a different impostor
  23262. * @param otherImpostor A physics imposter used to add a joint
  23263. * @param joint The joint to add
  23264. * @returns The physics imposter
  23265. */
  23266. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23267. /**
  23268. * Add an anchor to a cloth impostor
  23269. * @param otherImpostor rigid impostor to anchor to
  23270. * @param width ratio across width from 0 to 1
  23271. * @param height ratio up height from 0 to 1
  23272. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23273. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23274. * @returns impostor the soft imposter
  23275. */
  23276. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23277. /**
  23278. * Add a hook to a rope impostor
  23279. * @param otherImpostor rigid impostor to anchor to
  23280. * @param length ratio across rope from 0 to 1
  23281. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23282. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23283. * @returns impostor the rope imposter
  23284. */
  23285. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23286. /**
  23287. * Will keep this body still, in a sleep mode.
  23288. * @returns the physics imposter
  23289. */
  23290. sleep(): PhysicsImpostor;
  23291. /**
  23292. * Wake the body up.
  23293. * @returns The physics imposter
  23294. */
  23295. wakeUp(): PhysicsImpostor;
  23296. /**
  23297. * Clones the physics imposter
  23298. * @param newObject The physics imposter clones to this physics-enabled object
  23299. * @returns A nullable physics imposter
  23300. */
  23301. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23302. /**
  23303. * Disposes the physics imposter
  23304. */
  23305. dispose(): void;
  23306. /**
  23307. * Sets the delta position
  23308. * @param position The delta position amount
  23309. */
  23310. setDeltaPosition(position: Vector3): void;
  23311. /**
  23312. * Sets the delta rotation
  23313. * @param rotation The delta rotation amount
  23314. */
  23315. setDeltaRotation(rotation: Quaternion): void;
  23316. /**
  23317. * Gets the box size of the physics imposter and stores the result in the input parameter
  23318. * @param result Stores the box size
  23319. * @returns The physics imposter
  23320. */
  23321. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23322. /**
  23323. * Gets the radius of the physics imposter
  23324. * @returns Radius of the physics imposter
  23325. */
  23326. getRadius(): number;
  23327. /**
  23328. * Sync a bone with this impostor
  23329. * @param bone The bone to sync to the impostor.
  23330. * @param boneMesh The mesh that the bone is influencing.
  23331. * @param jointPivot The pivot of the joint / bone in local space.
  23332. * @param distToJoint Optional distance from the impostor to the joint.
  23333. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23334. */
  23335. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23336. /**
  23337. * Sync impostor to a bone
  23338. * @param bone The bone that the impostor will be synced to.
  23339. * @param boneMesh The mesh that the bone is influencing.
  23340. * @param jointPivot The pivot of the joint / bone in local space.
  23341. * @param distToJoint Optional distance from the impostor to the joint.
  23342. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23343. * @param boneAxis Optional vector3 axis the bone is aligned with
  23344. */
  23345. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23346. /**
  23347. * No-Imposter type
  23348. */
  23349. static NoImpostor: number;
  23350. /**
  23351. * Sphere-Imposter type
  23352. */
  23353. static SphereImpostor: number;
  23354. /**
  23355. * Box-Imposter type
  23356. */
  23357. static BoxImpostor: number;
  23358. /**
  23359. * Plane-Imposter type
  23360. */
  23361. static PlaneImpostor: number;
  23362. /**
  23363. * Mesh-imposter type
  23364. */
  23365. static MeshImpostor: number;
  23366. /**
  23367. * Capsule-Impostor type (Ammo.js plugin only)
  23368. */
  23369. static CapsuleImpostor: number;
  23370. /**
  23371. * Cylinder-Imposter type
  23372. */
  23373. static CylinderImpostor: number;
  23374. /**
  23375. * Particle-Imposter type
  23376. */
  23377. static ParticleImpostor: number;
  23378. /**
  23379. * Heightmap-Imposter type
  23380. */
  23381. static HeightmapImpostor: number;
  23382. /**
  23383. * ConvexHull-Impostor type (Ammo.js plugin only)
  23384. */
  23385. static ConvexHullImpostor: number;
  23386. /**
  23387. * Rope-Imposter type
  23388. */
  23389. static RopeImpostor: number;
  23390. /**
  23391. * Cloth-Imposter type
  23392. */
  23393. static ClothImpostor: number;
  23394. /**
  23395. * Softbody-Imposter type
  23396. */
  23397. static SoftbodyImpostor: number;
  23398. }
  23399. }
  23400. declare module BABYLON {
  23401. /**
  23402. * @hidden
  23403. **/
  23404. export class _CreationDataStorage {
  23405. closePath?: boolean;
  23406. closeArray?: boolean;
  23407. idx: number[];
  23408. dashSize: number;
  23409. gapSize: number;
  23410. path3D: Path3D;
  23411. pathArray: Vector3[][];
  23412. arc: number;
  23413. radius: number;
  23414. cap: number;
  23415. tessellation: number;
  23416. }
  23417. /**
  23418. * @hidden
  23419. **/
  23420. class _InstanceDataStorage {
  23421. visibleInstances: any;
  23422. batchCache: _InstancesBatch;
  23423. instancesBufferSize: number;
  23424. instancesBuffer: Nullable<Buffer>;
  23425. instancesData: Float32Array;
  23426. overridenInstanceCount: number;
  23427. isFrozen: boolean;
  23428. previousBatch: Nullable<_InstancesBatch>;
  23429. hardwareInstancedRendering: boolean;
  23430. sideOrientation: number;
  23431. }
  23432. /**
  23433. * @hidden
  23434. **/
  23435. export class _InstancesBatch {
  23436. mustReturn: boolean;
  23437. visibleInstances: Nullable<InstancedMesh[]>[];
  23438. renderSelf: boolean[];
  23439. hardwareInstancedRendering: boolean[];
  23440. }
  23441. /**
  23442. * Class used to represent renderable models
  23443. */
  23444. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23445. /**
  23446. * Mesh side orientation : usually the external or front surface
  23447. */
  23448. static readonly FRONTSIDE: number;
  23449. /**
  23450. * Mesh side orientation : usually the internal or back surface
  23451. */
  23452. static readonly BACKSIDE: number;
  23453. /**
  23454. * Mesh side orientation : both internal and external or front and back surfaces
  23455. */
  23456. static readonly DOUBLESIDE: number;
  23457. /**
  23458. * Mesh side orientation : by default, `FRONTSIDE`
  23459. */
  23460. static readonly DEFAULTSIDE: number;
  23461. /**
  23462. * Mesh cap setting : no cap
  23463. */
  23464. static readonly NO_CAP: number;
  23465. /**
  23466. * Mesh cap setting : one cap at the beginning of the mesh
  23467. */
  23468. static readonly CAP_START: number;
  23469. /**
  23470. * Mesh cap setting : one cap at the end of the mesh
  23471. */
  23472. static readonly CAP_END: number;
  23473. /**
  23474. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23475. */
  23476. static readonly CAP_ALL: number;
  23477. /**
  23478. * Mesh pattern setting : no flip or rotate
  23479. */
  23480. static readonly NO_FLIP: number;
  23481. /**
  23482. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23483. */
  23484. static readonly FLIP_TILE: number;
  23485. /**
  23486. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23487. */
  23488. static readonly ROTATE_TILE: number;
  23489. /**
  23490. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23491. */
  23492. static readonly FLIP_ROW: number;
  23493. /**
  23494. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23495. */
  23496. static readonly ROTATE_ROW: number;
  23497. /**
  23498. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23499. */
  23500. static readonly FLIP_N_ROTATE_TILE: number;
  23501. /**
  23502. * Mesh pattern setting : rotate pattern and rotate
  23503. */
  23504. static readonly FLIP_N_ROTATE_ROW: number;
  23505. /**
  23506. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23507. */
  23508. static readonly CENTER: number;
  23509. /**
  23510. * Mesh tile positioning : part tiles on left
  23511. */
  23512. static readonly LEFT: number;
  23513. /**
  23514. * Mesh tile positioning : part tiles on right
  23515. */
  23516. static readonly RIGHT: number;
  23517. /**
  23518. * Mesh tile positioning : part tiles on top
  23519. */
  23520. static readonly TOP: number;
  23521. /**
  23522. * Mesh tile positioning : part tiles on bottom
  23523. */
  23524. static readonly BOTTOM: number;
  23525. /**
  23526. * Gets the default side orientation.
  23527. * @param orientation the orientation to value to attempt to get
  23528. * @returns the default orientation
  23529. * @hidden
  23530. */
  23531. static _GetDefaultSideOrientation(orientation?: number): number;
  23532. private _internalMeshDataInfo;
  23533. /**
  23534. * An event triggered before rendering the mesh
  23535. */
  23536. readonly onBeforeRenderObservable: Observable<Mesh>;
  23537. /**
  23538. * An event triggered before binding the mesh
  23539. */
  23540. readonly onBeforeBindObservable: Observable<Mesh>;
  23541. /**
  23542. * An event triggered after rendering the mesh
  23543. */
  23544. readonly onAfterRenderObservable: Observable<Mesh>;
  23545. /**
  23546. * An event triggered before drawing the mesh
  23547. */
  23548. readonly onBeforeDrawObservable: Observable<Mesh>;
  23549. private _onBeforeDrawObserver;
  23550. /**
  23551. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23552. */
  23553. onBeforeDraw: () => void;
  23554. readonly hasInstances: boolean;
  23555. /**
  23556. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23557. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23558. */
  23559. delayLoadState: number;
  23560. /**
  23561. * Gets the list of instances created from this mesh
  23562. * it is not supposed to be modified manually.
  23563. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23564. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23565. */
  23566. instances: InstancedMesh[];
  23567. /**
  23568. * Gets the file containing delay loading data for this mesh
  23569. */
  23570. delayLoadingFile: string;
  23571. /** @hidden */
  23572. _binaryInfo: any;
  23573. /**
  23574. * User defined function used to change how LOD level selection is done
  23575. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23576. */
  23577. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23578. /**
  23579. * Gets or sets the morph target manager
  23580. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23581. */
  23582. morphTargetManager: Nullable<MorphTargetManager>;
  23583. /** @hidden */
  23584. _creationDataStorage: Nullable<_CreationDataStorage>;
  23585. /** @hidden */
  23586. _geometry: Nullable<Geometry>;
  23587. /** @hidden */
  23588. _delayInfo: Array<string>;
  23589. /** @hidden */
  23590. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23591. /** @hidden */
  23592. _instanceDataStorage: _InstanceDataStorage;
  23593. private _effectiveMaterial;
  23594. /** @hidden */
  23595. _shouldGenerateFlatShading: boolean;
  23596. /** @hidden */
  23597. _originalBuilderSideOrientation: number;
  23598. /**
  23599. * Use this property to change the original side orientation defined at construction time
  23600. */
  23601. overrideMaterialSideOrientation: Nullable<number>;
  23602. /**
  23603. * Gets the source mesh (the one used to clone this one from)
  23604. */
  23605. readonly source: Nullable<Mesh>;
  23606. /**
  23607. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23608. */
  23609. isUnIndexed: boolean;
  23610. /**
  23611. * @constructor
  23612. * @param name The value used by scene.getMeshByName() to do a lookup.
  23613. * @param scene The scene to add this mesh to.
  23614. * @param parent The parent of this mesh, if it has one
  23615. * @param source An optional Mesh from which geometry is shared, cloned.
  23616. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23617. * When false, achieved by calling a clone(), also passing False.
  23618. * This will make creation of children, recursive.
  23619. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23620. */
  23621. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23622. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23623. /**
  23624. * Gets the class name
  23625. * @returns the string "Mesh".
  23626. */
  23627. getClassName(): string;
  23628. /** @hidden */
  23629. readonly _isMesh: boolean;
  23630. /**
  23631. * Returns a description of this mesh
  23632. * @param fullDetails define if full details about this mesh must be used
  23633. * @returns a descriptive string representing this mesh
  23634. */
  23635. toString(fullDetails?: boolean): string;
  23636. /** @hidden */
  23637. _unBindEffect(): void;
  23638. /**
  23639. * Gets a boolean indicating if this mesh has LOD
  23640. */
  23641. readonly hasLODLevels: boolean;
  23642. /**
  23643. * Gets the list of MeshLODLevel associated with the current mesh
  23644. * @returns an array of MeshLODLevel
  23645. */
  23646. getLODLevels(): MeshLODLevel[];
  23647. private _sortLODLevels;
  23648. /**
  23649. * Add a mesh as LOD level triggered at the given distance.
  23650. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23651. * @param distance The distance from the center of the object to show this level
  23652. * @param mesh The mesh to be added as LOD level (can be null)
  23653. * @return This mesh (for chaining)
  23654. */
  23655. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23656. /**
  23657. * Returns the LOD level mesh at the passed distance or null if not found.
  23658. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23659. * @param distance The distance from the center of the object to show this level
  23660. * @returns a Mesh or `null`
  23661. */
  23662. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23663. /**
  23664. * Remove a mesh from the LOD array
  23665. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23666. * @param mesh defines the mesh to be removed
  23667. * @return This mesh (for chaining)
  23668. */
  23669. removeLODLevel(mesh: Mesh): Mesh;
  23670. /**
  23671. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23672. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23673. * @param camera defines the camera to use to compute distance
  23674. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23675. * @return This mesh (for chaining)
  23676. */
  23677. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23678. /**
  23679. * Gets the mesh internal Geometry object
  23680. */
  23681. readonly geometry: Nullable<Geometry>;
  23682. /**
  23683. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23684. * @returns the total number of vertices
  23685. */
  23686. getTotalVertices(): number;
  23687. /**
  23688. * Returns the content of an associated vertex buffer
  23689. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23690. * - VertexBuffer.PositionKind
  23691. * - VertexBuffer.UVKind
  23692. * - VertexBuffer.UV2Kind
  23693. * - VertexBuffer.UV3Kind
  23694. * - VertexBuffer.UV4Kind
  23695. * - VertexBuffer.UV5Kind
  23696. * - VertexBuffer.UV6Kind
  23697. * - VertexBuffer.ColorKind
  23698. * - VertexBuffer.MatricesIndicesKind
  23699. * - VertexBuffer.MatricesIndicesExtraKind
  23700. * - VertexBuffer.MatricesWeightsKind
  23701. * - VertexBuffer.MatricesWeightsExtraKind
  23702. * @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
  23703. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23704. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23705. */
  23706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23707. /**
  23708. * Returns the mesh VertexBuffer object from the requested `kind`
  23709. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23710. * - VertexBuffer.PositionKind
  23711. * - VertexBuffer.NormalKind
  23712. * - VertexBuffer.UVKind
  23713. * - VertexBuffer.UV2Kind
  23714. * - VertexBuffer.UV3Kind
  23715. * - VertexBuffer.UV4Kind
  23716. * - VertexBuffer.UV5Kind
  23717. * - VertexBuffer.UV6Kind
  23718. * - VertexBuffer.ColorKind
  23719. * - VertexBuffer.MatricesIndicesKind
  23720. * - VertexBuffer.MatricesIndicesExtraKind
  23721. * - VertexBuffer.MatricesWeightsKind
  23722. * - VertexBuffer.MatricesWeightsExtraKind
  23723. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23724. */
  23725. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23726. /**
  23727. * Tests if a specific vertex buffer is associated with this mesh
  23728. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23729. * - VertexBuffer.PositionKind
  23730. * - VertexBuffer.NormalKind
  23731. * - VertexBuffer.UVKind
  23732. * - VertexBuffer.UV2Kind
  23733. * - VertexBuffer.UV3Kind
  23734. * - VertexBuffer.UV4Kind
  23735. * - VertexBuffer.UV5Kind
  23736. * - VertexBuffer.UV6Kind
  23737. * - VertexBuffer.ColorKind
  23738. * - VertexBuffer.MatricesIndicesKind
  23739. * - VertexBuffer.MatricesIndicesExtraKind
  23740. * - VertexBuffer.MatricesWeightsKind
  23741. * - VertexBuffer.MatricesWeightsExtraKind
  23742. * @returns a boolean
  23743. */
  23744. isVerticesDataPresent(kind: string): boolean;
  23745. /**
  23746. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23747. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23748. * - VertexBuffer.PositionKind
  23749. * - VertexBuffer.UVKind
  23750. * - VertexBuffer.UV2Kind
  23751. * - VertexBuffer.UV3Kind
  23752. * - VertexBuffer.UV4Kind
  23753. * - VertexBuffer.UV5Kind
  23754. * - VertexBuffer.UV6Kind
  23755. * - VertexBuffer.ColorKind
  23756. * - VertexBuffer.MatricesIndicesKind
  23757. * - VertexBuffer.MatricesIndicesExtraKind
  23758. * - VertexBuffer.MatricesWeightsKind
  23759. * - VertexBuffer.MatricesWeightsExtraKind
  23760. * @returns a boolean
  23761. */
  23762. isVertexBufferUpdatable(kind: string): boolean;
  23763. /**
  23764. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23765. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23766. * - VertexBuffer.PositionKind
  23767. * - VertexBuffer.NormalKind
  23768. * - VertexBuffer.UVKind
  23769. * - VertexBuffer.UV2Kind
  23770. * - VertexBuffer.UV3Kind
  23771. * - VertexBuffer.UV4Kind
  23772. * - VertexBuffer.UV5Kind
  23773. * - VertexBuffer.UV6Kind
  23774. * - VertexBuffer.ColorKind
  23775. * - VertexBuffer.MatricesIndicesKind
  23776. * - VertexBuffer.MatricesIndicesExtraKind
  23777. * - VertexBuffer.MatricesWeightsKind
  23778. * - VertexBuffer.MatricesWeightsExtraKind
  23779. * @returns an array of strings
  23780. */
  23781. getVerticesDataKinds(): string[];
  23782. /**
  23783. * Returns a positive integer : the total number of indices in this mesh geometry.
  23784. * @returns the numner of indices or zero if the mesh has no geometry.
  23785. */
  23786. getTotalIndices(): number;
  23787. /**
  23788. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23789. * @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.
  23790. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23791. * @returns the indices array or an empty array if the mesh has no geometry
  23792. */
  23793. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23794. readonly isBlocked: boolean;
  23795. /**
  23796. * Determine if the current mesh is ready to be rendered
  23797. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23798. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23799. * @returns true if all associated assets are ready (material, textures, shaders)
  23800. */
  23801. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23802. /**
  23803. * 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.
  23804. */
  23805. readonly areNormalsFrozen: boolean;
  23806. /**
  23807. * 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.
  23808. * @returns the current mesh
  23809. */
  23810. freezeNormals(): Mesh;
  23811. /**
  23812. * 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
  23813. * @returns the current mesh
  23814. */
  23815. unfreezeNormals(): Mesh;
  23816. /**
  23817. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23818. */
  23819. overridenInstanceCount: number;
  23820. /** @hidden */
  23821. _preActivate(): Mesh;
  23822. /** @hidden */
  23823. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23824. /** @hidden */
  23825. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23826. /**
  23827. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23828. * This means the mesh underlying bounding box and sphere are recomputed.
  23829. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23830. * @returns the current mesh
  23831. */
  23832. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23833. /** @hidden */
  23834. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23835. /**
  23836. * This function will subdivide the mesh into multiple submeshes
  23837. * @param count defines the expected number of submeshes
  23838. */
  23839. subdivide(count: number): void;
  23840. /**
  23841. * Copy a FloatArray into a specific associated vertex buffer
  23842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23843. * - VertexBuffer.PositionKind
  23844. * - VertexBuffer.UVKind
  23845. * - VertexBuffer.UV2Kind
  23846. * - VertexBuffer.UV3Kind
  23847. * - VertexBuffer.UV4Kind
  23848. * - VertexBuffer.UV5Kind
  23849. * - VertexBuffer.UV6Kind
  23850. * - VertexBuffer.ColorKind
  23851. * - VertexBuffer.MatricesIndicesKind
  23852. * - VertexBuffer.MatricesIndicesExtraKind
  23853. * - VertexBuffer.MatricesWeightsKind
  23854. * - VertexBuffer.MatricesWeightsExtraKind
  23855. * @param data defines the data source
  23856. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23857. * @param stride defines the data stride size (can be null)
  23858. * @returns the current mesh
  23859. */
  23860. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23861. /**
  23862. * Flags an associated vertex buffer as updatable
  23863. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23864. * - VertexBuffer.PositionKind
  23865. * - VertexBuffer.UVKind
  23866. * - VertexBuffer.UV2Kind
  23867. * - VertexBuffer.UV3Kind
  23868. * - VertexBuffer.UV4Kind
  23869. * - VertexBuffer.UV5Kind
  23870. * - VertexBuffer.UV6Kind
  23871. * - VertexBuffer.ColorKind
  23872. * - VertexBuffer.MatricesIndicesKind
  23873. * - VertexBuffer.MatricesIndicesExtraKind
  23874. * - VertexBuffer.MatricesWeightsKind
  23875. * - VertexBuffer.MatricesWeightsExtraKind
  23876. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23877. */
  23878. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23879. /**
  23880. * Sets the mesh global Vertex Buffer
  23881. * @param buffer defines the buffer to use
  23882. * @returns the current mesh
  23883. */
  23884. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23885. /**
  23886. * Update a specific associated vertex buffer
  23887. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23888. * - VertexBuffer.PositionKind
  23889. * - VertexBuffer.UVKind
  23890. * - VertexBuffer.UV2Kind
  23891. * - VertexBuffer.UV3Kind
  23892. * - VertexBuffer.UV4Kind
  23893. * - VertexBuffer.UV5Kind
  23894. * - VertexBuffer.UV6Kind
  23895. * - VertexBuffer.ColorKind
  23896. * - VertexBuffer.MatricesIndicesKind
  23897. * - VertexBuffer.MatricesIndicesExtraKind
  23898. * - VertexBuffer.MatricesWeightsKind
  23899. * - VertexBuffer.MatricesWeightsExtraKind
  23900. * @param data defines the data source
  23901. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23902. * @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)
  23903. * @returns the current mesh
  23904. */
  23905. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23906. /**
  23907. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23908. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23909. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23910. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23911. * @returns the current mesh
  23912. */
  23913. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23914. /**
  23915. * Creates a un-shared specific occurence of the geometry for the mesh.
  23916. * @returns the current mesh
  23917. */
  23918. makeGeometryUnique(): Mesh;
  23919. /**
  23920. * Set the index buffer of this mesh
  23921. * @param indices defines the source data
  23922. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23923. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23924. * @returns the current mesh
  23925. */
  23926. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23927. /**
  23928. * Update the current index buffer
  23929. * @param indices defines the source data
  23930. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23931. * @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)
  23932. * @returns the current mesh
  23933. */
  23934. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23935. /**
  23936. * Invert the geometry to move from a right handed system to a left handed one.
  23937. * @returns the current mesh
  23938. */
  23939. toLeftHanded(): Mesh;
  23940. /** @hidden */
  23941. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23942. /** @hidden */
  23943. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23944. /**
  23945. * Registers for this mesh a javascript function called just before the rendering process
  23946. * @param func defines the function to call before rendering this mesh
  23947. * @returns the current mesh
  23948. */
  23949. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23950. /**
  23951. * Disposes a previously registered javascript function called before the rendering
  23952. * @param func defines the function to remove
  23953. * @returns the current mesh
  23954. */
  23955. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23956. /**
  23957. * Registers for this mesh a javascript function called just after the rendering is complete
  23958. * @param func defines the function to call after rendering this mesh
  23959. * @returns the current mesh
  23960. */
  23961. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23962. /**
  23963. * Disposes a previously registered javascript function called after the rendering.
  23964. * @param func defines the function to remove
  23965. * @returns the current mesh
  23966. */
  23967. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23968. /** @hidden */
  23969. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23970. /** @hidden */
  23971. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23972. /** @hidden */
  23973. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23974. /** @hidden */
  23975. _rebuild(): void;
  23976. /** @hidden */
  23977. _freeze(): void;
  23978. /** @hidden */
  23979. _unFreeze(): void;
  23980. /**
  23981. * 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
  23982. * @param subMesh defines the subMesh to render
  23983. * @param enableAlphaMode defines if alpha mode can be changed
  23984. * @returns the current mesh
  23985. */
  23986. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23987. private _onBeforeDraw;
  23988. /**
  23989. * Renormalize the mesh and patch it up if there are no weights
  23990. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23991. * However in the case of zero weights then we set just a single influence to 1.
  23992. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23993. */
  23994. cleanMatrixWeights(): void;
  23995. private normalizeSkinFourWeights;
  23996. private normalizeSkinWeightsAndExtra;
  23997. /**
  23998. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23999. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24000. * the user know there was an issue with importing the mesh
  24001. * @returns a validation object with skinned, valid and report string
  24002. */
  24003. validateSkinning(): {
  24004. skinned: boolean;
  24005. valid: boolean;
  24006. report: string;
  24007. };
  24008. /** @hidden */
  24009. _checkDelayState(): Mesh;
  24010. private _queueLoad;
  24011. /**
  24012. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24013. * A mesh is in the frustum if its bounding box intersects the frustum
  24014. * @param frustumPlanes defines the frustum to test
  24015. * @returns true if the mesh is in the frustum planes
  24016. */
  24017. isInFrustum(frustumPlanes: Plane[]): boolean;
  24018. /**
  24019. * Sets the mesh material by the material or multiMaterial `id` property
  24020. * @param id is a string identifying the material or the multiMaterial
  24021. * @returns the current mesh
  24022. */
  24023. setMaterialByID(id: string): Mesh;
  24024. /**
  24025. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24026. * @returns an array of IAnimatable
  24027. */
  24028. getAnimatables(): IAnimatable[];
  24029. /**
  24030. * Modifies the mesh geometry according to the passed transformation matrix.
  24031. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24032. * The mesh normals are modified using the same transformation.
  24033. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24034. * @param transform defines the transform matrix to use
  24035. * @see http://doc.babylonjs.com/resources/baking_transformations
  24036. * @returns the current mesh
  24037. */
  24038. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24039. /**
  24040. * Modifies the mesh geometry according to its own current World Matrix.
  24041. * The mesh World Matrix is then reset.
  24042. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24043. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24044. * @see http://doc.babylonjs.com/resources/baking_transformations
  24045. * @returns the current mesh
  24046. */
  24047. bakeCurrentTransformIntoVertices(): Mesh;
  24048. /** @hidden */
  24049. readonly _positions: Nullable<Vector3[]>;
  24050. /** @hidden */
  24051. _resetPointsArrayCache(): Mesh;
  24052. /** @hidden */
  24053. _generatePointsArray(): boolean;
  24054. /**
  24055. * Returns a new Mesh object generated from the current mesh properties.
  24056. * This method must not get confused with createInstance()
  24057. * @param name is a string, the name given to the new mesh
  24058. * @param newParent can be any Node object (default `null`)
  24059. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24060. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24061. * @returns a new mesh
  24062. */
  24063. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24064. /**
  24065. * Releases resources associated with this mesh.
  24066. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24067. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24068. */
  24069. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24070. /**
  24071. * Modifies the mesh geometry according to a displacement map.
  24072. * 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.
  24073. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24074. * @param url is a string, the URL from the image file is to be downloaded.
  24075. * @param minHeight is the lower limit of the displacement.
  24076. * @param maxHeight is the upper limit of the displacement.
  24077. * @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.
  24078. * @param uvOffset is an optional vector2 used to offset UV.
  24079. * @param uvScale is an optional vector2 used to scale UV.
  24080. * @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.
  24081. * @returns the Mesh.
  24082. */
  24083. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24084. /**
  24085. * Modifies the mesh geometry according to a displacementMap buffer.
  24086. * 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.
  24087. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24088. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24089. * @param heightMapWidth is the width of the buffer image.
  24090. * @param heightMapHeight is the height of the buffer image.
  24091. * @param minHeight is the lower limit of the displacement.
  24092. * @param maxHeight is the upper limit of the displacement.
  24093. * @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.
  24094. * @param uvOffset is an optional vector2 used to offset UV.
  24095. * @param uvScale is an optional vector2 used to scale UV.
  24096. * @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.
  24097. * @returns the Mesh.
  24098. */
  24099. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24100. /**
  24101. * Modify the mesh to get a flat shading rendering.
  24102. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24103. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24104. * @returns current mesh
  24105. */
  24106. convertToFlatShadedMesh(): Mesh;
  24107. /**
  24108. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24109. * In other words, more vertices, no more indices and a single bigger VBO.
  24110. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24111. * @returns current mesh
  24112. */
  24113. convertToUnIndexedMesh(): Mesh;
  24114. /**
  24115. * Inverses facet orientations.
  24116. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24117. * @param flipNormals will also inverts the normals
  24118. * @returns current mesh
  24119. */
  24120. flipFaces(flipNormals?: boolean): Mesh;
  24121. /**
  24122. * Increase the number of facets and hence vertices in a mesh
  24123. * Vertex normals are interpolated from existing vertex normals
  24124. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24125. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24126. */
  24127. increaseVertices(numberPerEdge: number): void;
  24128. /**
  24129. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24130. * This will undo any application of covertToFlatShadedMesh
  24131. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24132. */
  24133. forceSharedVertices(): void;
  24134. /** @hidden */
  24135. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24136. /** @hidden */
  24137. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24138. /**
  24139. * Creates a new InstancedMesh object from the mesh model.
  24140. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24141. * @param name defines the name of the new instance
  24142. * @returns a new InstancedMesh
  24143. */
  24144. createInstance(name: string): InstancedMesh;
  24145. /**
  24146. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24147. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24148. * @returns the current mesh
  24149. */
  24150. synchronizeInstances(): Mesh;
  24151. /**
  24152. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24153. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24154. * This should be used together with the simplification to avoid disappearing triangles.
  24155. * @param successCallback an optional success callback to be called after the optimization finished.
  24156. * @returns the current mesh
  24157. */
  24158. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24159. /**
  24160. * Serialize current mesh
  24161. * @param serializationObject defines the object which will receive the serialization data
  24162. */
  24163. serialize(serializationObject: any): void;
  24164. /** @hidden */
  24165. _syncGeometryWithMorphTargetManager(): void;
  24166. /** @hidden */
  24167. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24168. /**
  24169. * Returns a new Mesh object parsed from the source provided.
  24170. * @param parsedMesh is the source
  24171. * @param scene defines the hosting scene
  24172. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24173. * @returns a new Mesh
  24174. */
  24175. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24176. /**
  24177. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24178. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24179. * @param name defines the name of the mesh to create
  24180. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24181. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24182. * @param closePath creates a seam between the first and the last points of each path of the path array
  24183. * @param offset is taken in account only if the `pathArray` is containing a single path
  24184. * @param scene defines the hosting scene
  24185. * @param updatable defines if the mesh must be flagged as updatable
  24186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24187. * @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)
  24188. * @returns a new Mesh
  24189. */
  24190. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24191. /**
  24192. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24193. * @param name defines the name of the mesh to create
  24194. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24195. * @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
  24196. * @param scene defines the hosting scene
  24197. * @param updatable defines if the mesh must be flagged as updatable
  24198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24199. * @returns a new Mesh
  24200. */
  24201. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24202. /**
  24203. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24204. * @param name defines the name of the mesh to create
  24205. * @param size sets the size (float) of each box side (default 1)
  24206. * @param scene defines the hosting scene
  24207. * @param updatable defines if the mesh must be flagged as updatable
  24208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24209. * @returns a new Mesh
  24210. */
  24211. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24212. /**
  24213. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24214. * @param name defines the name of the mesh to create
  24215. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24216. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24217. * @param scene defines the hosting scene
  24218. * @param updatable defines if the mesh must be flagged as updatable
  24219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24220. * @returns a new Mesh
  24221. */
  24222. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24223. /**
  24224. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24225. * @param name defines the name of the mesh to create
  24226. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24227. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24228. * @param scene defines the hosting scene
  24229. * @returns a new Mesh
  24230. */
  24231. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24232. /**
  24233. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24234. * @param name defines the name of the mesh to create
  24235. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24236. * @param diameterTop set the top cap diameter (floats, default 1)
  24237. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24238. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24239. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24240. * @param scene defines the hosting scene
  24241. * @param updatable defines if the mesh must be flagged as updatable
  24242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24243. * @returns a new Mesh
  24244. */
  24245. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24246. /**
  24247. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24248. * @param name defines the name of the mesh to create
  24249. * @param diameter sets the diameter size (float) of the torus (default 1)
  24250. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24251. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24252. * @param scene defines the hosting scene
  24253. * @param updatable defines if the mesh must be flagged as updatable
  24254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24255. * @returns a new Mesh
  24256. */
  24257. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24258. /**
  24259. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24260. * @param name defines the name of the mesh to create
  24261. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24262. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24263. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24264. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24265. * @param p the number of windings on X axis (positive integers, default 2)
  24266. * @param q the number of windings on Y axis (positive integers, default 3)
  24267. * @param scene defines the hosting scene
  24268. * @param updatable defines if the mesh must be flagged as updatable
  24269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24270. * @returns a new Mesh
  24271. */
  24272. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24273. /**
  24274. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24275. * @param name defines the name of the mesh to create
  24276. * @param points is an array successive Vector3
  24277. * @param scene defines the hosting scene
  24278. * @param updatable defines if the mesh must be flagged as updatable
  24279. * @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).
  24280. * @returns a new Mesh
  24281. */
  24282. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24283. /**
  24284. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24285. * @param name defines the name of the mesh to create
  24286. * @param points is an array successive Vector3
  24287. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24288. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24289. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24290. * @param scene defines the hosting scene
  24291. * @param updatable defines if the mesh must be flagged as updatable
  24292. * @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)
  24293. * @returns a new Mesh
  24294. */
  24295. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24296. /**
  24297. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24298. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24299. * 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.
  24300. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24301. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24302. * Remember you can only change the shape positions, not their number when updating a polygon.
  24303. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24304. * @param name defines the name of the mesh to create
  24305. * @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
  24306. * @param scene defines the hosting scene
  24307. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24308. * @param updatable defines if the mesh must be flagged as updatable
  24309. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24310. * @param earcutInjection can be used to inject your own earcut reference
  24311. * @returns a new Mesh
  24312. */
  24313. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24314. /**
  24315. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24316. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24317. * @param name defines the name of the mesh to create
  24318. * @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
  24319. * @param depth defines the height of extrusion
  24320. * @param scene defines the hosting scene
  24321. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24322. * @param updatable defines if the mesh must be flagged as updatable
  24323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24324. * @param earcutInjection can be used to inject your own earcut reference
  24325. * @returns a new Mesh
  24326. */
  24327. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24328. /**
  24329. * Creates an extruded shape mesh.
  24330. * 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
  24331. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24332. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24333. * @param name defines the name of the mesh to create
  24334. * @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
  24335. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24336. * @param scale is the value to scale the shape
  24337. * @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
  24338. * @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
  24339. * @param scene defines the hosting scene
  24340. * @param updatable defines if the mesh must be flagged as updatable
  24341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24342. * @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)
  24343. * @returns a new Mesh
  24344. */
  24345. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24346. /**
  24347. * Creates an custom extruded shape mesh.
  24348. * The custom extrusion is a parametric shape.
  24349. * It has no predefined shape. Its final shape will depend on the input parameters.
  24350. * Please consider using the same method from the MeshBuilder class instead
  24351. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24352. * @param name defines the name of the mesh to create
  24353. * @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
  24354. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24355. * @param scaleFunction is a custom Javascript function called on each path point
  24356. * @param rotationFunction is a custom Javascript function called on each path point
  24357. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24358. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24359. * @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
  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. * @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)
  24364. * @returns a new Mesh
  24365. */
  24366. 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;
  24367. /**
  24368. * Creates lathe mesh.
  24369. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24370. * Please consider using the same method from the MeshBuilder class instead
  24371. * @param name defines the name of the mesh to create
  24372. * @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
  24373. * @param radius is the radius value of the lathe
  24374. * @param tessellation is the side number of the lathe.
  24375. * @param scene defines the hosting scene
  24376. * @param updatable defines if the mesh must be flagged as updatable
  24377. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24378. * @returns a new Mesh
  24379. */
  24380. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24381. /**
  24382. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24383. * @param name defines the name of the mesh to create
  24384. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24385. * @param scene defines the hosting scene
  24386. * @param updatable defines if the mesh must be flagged as updatable
  24387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24388. * @returns a new Mesh
  24389. */
  24390. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24391. /**
  24392. * Creates a ground mesh.
  24393. * Please consider using the same method from the MeshBuilder class instead
  24394. * @param name defines the name of the mesh to create
  24395. * @param width set the width of the ground
  24396. * @param height set the height of the ground
  24397. * @param subdivisions sets the number of subdivisions per side
  24398. * @param scene defines the hosting scene
  24399. * @param updatable defines if the mesh must be flagged as updatable
  24400. * @returns a new Mesh
  24401. */
  24402. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24403. /**
  24404. * Creates a tiled ground mesh.
  24405. * Please consider using the same method from the MeshBuilder class instead
  24406. * @param name defines the name of the mesh to create
  24407. * @param xmin set the ground minimum X coordinate
  24408. * @param zmin set the ground minimum Y coordinate
  24409. * @param xmax set the ground maximum X coordinate
  24410. * @param zmax set the ground maximum Z coordinate
  24411. * @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
  24412. * @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
  24413. * @param scene defines the hosting scene
  24414. * @param updatable defines if the mesh must be flagged as updatable
  24415. * @returns a new Mesh
  24416. */
  24417. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24418. w: number;
  24419. h: number;
  24420. }, precision: {
  24421. w: number;
  24422. h: number;
  24423. }, scene: Scene, updatable?: boolean): Mesh;
  24424. /**
  24425. * Creates a ground mesh from a height map.
  24426. * Please consider using the same method from the MeshBuilder class instead
  24427. * @see http://doc.babylonjs.com/babylon101/height_map
  24428. * @param name defines the name of the mesh to create
  24429. * @param url sets the URL of the height map image resource
  24430. * @param width set the ground width size
  24431. * @param height set the ground height size
  24432. * @param subdivisions sets the number of subdivision per side
  24433. * @param minHeight is the minimum altitude on the ground
  24434. * @param maxHeight is the maximum altitude on the ground
  24435. * @param scene defines the hosting scene
  24436. * @param updatable defines if the mesh must be flagged as updatable
  24437. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24438. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24439. * @returns a new Mesh
  24440. */
  24441. 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;
  24442. /**
  24443. * Creates a tube mesh.
  24444. * The tube is a parametric shape.
  24445. * It has no predefined shape. Its final shape will depend on the input parameters.
  24446. * Please consider using the same method from the MeshBuilder class instead
  24447. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24448. * @param name defines the name of the mesh to create
  24449. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24450. * @param radius sets the tube radius size
  24451. * @param tessellation is the number of sides on the tubular surface
  24452. * @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
  24453. * @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
  24454. * @param scene defines the hosting scene
  24455. * @param updatable defines if the mesh must be flagged as updatable
  24456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24457. * @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)
  24458. * @returns a new Mesh
  24459. */
  24460. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24461. (i: number, distance: number): number;
  24462. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24463. /**
  24464. * Creates a polyhedron mesh.
  24465. * Please consider using the same method from the MeshBuilder class instead.
  24466. * * 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
  24467. * * The parameter `size` (positive float, default 1) sets the polygon size
  24468. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24469. * * 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`
  24470. * * 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
  24471. * * 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)`)
  24472. * * 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
  24473. * * 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
  24474. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24475. * * 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
  24476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24477. * @param name defines the name of the mesh to create
  24478. * @param options defines the options used to create the mesh
  24479. * @param scene defines the hosting scene
  24480. * @returns a new Mesh
  24481. */
  24482. static CreatePolyhedron(name: string, options: {
  24483. type?: number;
  24484. size?: number;
  24485. sizeX?: number;
  24486. sizeY?: number;
  24487. sizeZ?: number;
  24488. custom?: any;
  24489. faceUV?: Vector4[];
  24490. faceColors?: Color4[];
  24491. updatable?: boolean;
  24492. sideOrientation?: number;
  24493. }, scene: Scene): Mesh;
  24494. /**
  24495. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24496. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24497. * * 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`)
  24498. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24499. * * 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
  24500. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24501. * * 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
  24502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24503. * @param name defines the name of the mesh
  24504. * @param options defines the options used to create the mesh
  24505. * @param scene defines the hosting scene
  24506. * @returns a new Mesh
  24507. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24508. */
  24509. static CreateIcoSphere(name: string, options: {
  24510. radius?: number;
  24511. flat?: boolean;
  24512. subdivisions?: number;
  24513. sideOrientation?: number;
  24514. updatable?: boolean;
  24515. }, scene: Scene): Mesh;
  24516. /**
  24517. * Creates a decal mesh.
  24518. * Please consider using the same method from the MeshBuilder class instead.
  24519. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24520. * @param name defines the name of the mesh
  24521. * @param sourceMesh defines the mesh receiving the decal
  24522. * @param position sets the position of the decal in world coordinates
  24523. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24524. * @param size sets the decal scaling
  24525. * @param angle sets the angle to rotate the decal
  24526. * @returns a new Mesh
  24527. */
  24528. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24529. /**
  24530. * Prepare internal position array for software CPU skinning
  24531. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24532. */
  24533. setPositionsForCPUSkinning(): Float32Array;
  24534. /**
  24535. * Prepare internal normal array for software CPU skinning
  24536. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24537. */
  24538. setNormalsForCPUSkinning(): Float32Array;
  24539. /**
  24540. * Updates the vertex buffer by applying transformation from the bones
  24541. * @param skeleton defines the skeleton to apply to current mesh
  24542. * @returns the current mesh
  24543. */
  24544. applySkeleton(skeleton: Skeleton): Mesh;
  24545. /**
  24546. * 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
  24547. * @param meshes defines the list of meshes to scan
  24548. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24549. */
  24550. static MinMax(meshes: AbstractMesh[]): {
  24551. min: Vector3;
  24552. max: Vector3;
  24553. };
  24554. /**
  24555. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24556. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24557. * @returns a vector3
  24558. */
  24559. static Center(meshesOrMinMaxVector: {
  24560. min: Vector3;
  24561. max: Vector3;
  24562. } | AbstractMesh[]): Vector3;
  24563. /**
  24564. * Merge the array of meshes into a single mesh for performance reasons.
  24565. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24566. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24567. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24568. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24569. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24570. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24571. * @returns a new mesh
  24572. */
  24573. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24574. /** @hidden */
  24575. addInstance(instance: InstancedMesh): void;
  24576. /** @hidden */
  24577. removeInstance(instance: InstancedMesh): void;
  24578. }
  24579. }
  24580. declare module BABYLON {
  24581. /**
  24582. * This is the base class of all the camera used in the application.
  24583. * @see http://doc.babylonjs.com/features/cameras
  24584. */
  24585. export class Camera extends Node {
  24586. /** @hidden */
  24587. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24588. /**
  24589. * This is the default projection mode used by the cameras.
  24590. * It helps recreating a feeling of perspective and better appreciate depth.
  24591. * This is the best way to simulate real life cameras.
  24592. */
  24593. static readonly PERSPECTIVE_CAMERA: number;
  24594. /**
  24595. * This helps creating camera with an orthographic mode.
  24596. * 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.
  24597. */
  24598. static readonly ORTHOGRAPHIC_CAMERA: number;
  24599. /**
  24600. * This is the default FOV mode for perspective cameras.
  24601. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24602. */
  24603. static readonly FOVMODE_VERTICAL_FIXED: number;
  24604. /**
  24605. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24606. */
  24607. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24608. /**
  24609. * This specifies ther is no need for a camera rig.
  24610. * Basically only one eye is rendered corresponding to the camera.
  24611. */
  24612. static readonly RIG_MODE_NONE: number;
  24613. /**
  24614. * Simulates a camera Rig with one blue eye and one red eye.
  24615. * This can be use with 3d blue and red glasses.
  24616. */
  24617. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24618. /**
  24619. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24620. */
  24621. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24622. /**
  24623. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24624. */
  24625. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24626. /**
  24627. * Defines that both eyes of the camera will be rendered over under each other.
  24628. */
  24629. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24630. /**
  24631. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24632. */
  24633. static readonly RIG_MODE_VR: number;
  24634. /**
  24635. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24636. */
  24637. static readonly RIG_MODE_WEBVR: number;
  24638. /**
  24639. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24640. */
  24641. static readonly RIG_MODE_CUSTOM: number;
  24642. /**
  24643. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24644. */
  24645. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24646. /**
  24647. * Define the input manager associated with the camera.
  24648. */
  24649. inputs: CameraInputsManager<Camera>;
  24650. /** @hidden */
  24651. _position: Vector3;
  24652. /**
  24653. * Define the current local position of the camera in the scene
  24654. */
  24655. position: Vector3;
  24656. /**
  24657. * The vector the camera should consider as up.
  24658. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24659. */
  24660. upVector: Vector3;
  24661. /**
  24662. * Define the current limit on the left side for an orthographic camera
  24663. * In scene unit
  24664. */
  24665. orthoLeft: Nullable<number>;
  24666. /**
  24667. * Define the current limit on the right side for an orthographic camera
  24668. * In scene unit
  24669. */
  24670. orthoRight: Nullable<number>;
  24671. /**
  24672. * Define the current limit on the bottom side for an orthographic camera
  24673. * In scene unit
  24674. */
  24675. orthoBottom: Nullable<number>;
  24676. /**
  24677. * Define the current limit on the top side for an orthographic camera
  24678. * In scene unit
  24679. */
  24680. orthoTop: Nullable<number>;
  24681. /**
  24682. * Field Of View is set in Radians. (default is 0.8)
  24683. */
  24684. fov: number;
  24685. /**
  24686. * Define the minimum distance the camera can see from.
  24687. * This is important to note that the depth buffer are not infinite and the closer it starts
  24688. * the more your scene might encounter depth fighting issue.
  24689. */
  24690. minZ: number;
  24691. /**
  24692. * Define the maximum distance the camera can see to.
  24693. * This is important to note that the depth buffer are not infinite and the further it end
  24694. * the more your scene might encounter depth fighting issue.
  24695. */
  24696. maxZ: number;
  24697. /**
  24698. * Define the default inertia of the camera.
  24699. * This helps giving a smooth feeling to the camera movement.
  24700. */
  24701. inertia: number;
  24702. /**
  24703. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24704. */
  24705. mode: number;
  24706. /**
  24707. * Define wether the camera is intermediate.
  24708. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24709. */
  24710. isIntermediate: boolean;
  24711. /**
  24712. * Define the viewport of the camera.
  24713. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24714. */
  24715. viewport: Viewport;
  24716. /**
  24717. * Restricts the camera to viewing objects with the same layerMask.
  24718. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24719. */
  24720. layerMask: number;
  24721. /**
  24722. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24723. */
  24724. fovMode: number;
  24725. /**
  24726. * Rig mode of the camera.
  24727. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24728. * This is normally controlled byt the camera themselves as internal use.
  24729. */
  24730. cameraRigMode: number;
  24731. /**
  24732. * Defines the distance between both "eyes" in case of a RIG
  24733. */
  24734. interaxialDistance: number;
  24735. /**
  24736. * Defines if stereoscopic rendering is done side by side or over under.
  24737. */
  24738. isStereoscopicSideBySide: boolean;
  24739. /**
  24740. * 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
  24741. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24742. * else in the scene. (Eg. security camera)
  24743. *
  24744. * 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)
  24745. */
  24746. customRenderTargets: RenderTargetTexture[];
  24747. /**
  24748. * When set, the camera will render to this render target instead of the default canvas
  24749. *
  24750. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24751. */
  24752. outputRenderTarget: Nullable<RenderTargetTexture>;
  24753. /**
  24754. * Observable triggered when the camera view matrix has changed.
  24755. */
  24756. onViewMatrixChangedObservable: Observable<Camera>;
  24757. /**
  24758. * Observable triggered when the camera Projection matrix has changed.
  24759. */
  24760. onProjectionMatrixChangedObservable: Observable<Camera>;
  24761. /**
  24762. * Observable triggered when the inputs have been processed.
  24763. */
  24764. onAfterCheckInputsObservable: Observable<Camera>;
  24765. /**
  24766. * Observable triggered when reset has been called and applied to the camera.
  24767. */
  24768. onRestoreStateObservable: Observable<Camera>;
  24769. /** @hidden */
  24770. _cameraRigParams: any;
  24771. /** @hidden */
  24772. _rigCameras: Camera[];
  24773. /** @hidden */
  24774. _rigPostProcess: Nullable<PostProcess>;
  24775. protected _webvrViewMatrix: Matrix;
  24776. /** @hidden */
  24777. _skipRendering: boolean;
  24778. /** @hidden */
  24779. _projectionMatrix: Matrix;
  24780. /** @hidden */
  24781. _postProcesses: Nullable<PostProcess>[];
  24782. /** @hidden */
  24783. _activeMeshes: SmartArray<AbstractMesh>;
  24784. protected _globalPosition: Vector3;
  24785. /** @hidden */
  24786. _computedViewMatrix: Matrix;
  24787. private _doNotComputeProjectionMatrix;
  24788. private _transformMatrix;
  24789. private _frustumPlanes;
  24790. private _refreshFrustumPlanes;
  24791. private _storedFov;
  24792. private _stateStored;
  24793. /**
  24794. * Instantiates a new camera object.
  24795. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24796. * @see http://doc.babylonjs.com/features/cameras
  24797. * @param name Defines the name of the camera in the scene
  24798. * @param position Defines the position of the camera
  24799. * @param scene Defines the scene the camera belongs too
  24800. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24801. */
  24802. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24803. /**
  24804. * Store current camera state (fov, position, etc..)
  24805. * @returns the camera
  24806. */
  24807. storeState(): Camera;
  24808. /**
  24809. * Restores the camera state values if it has been stored. You must call storeState() first
  24810. */
  24811. protected _restoreStateValues(): boolean;
  24812. /**
  24813. * Restored camera state. You must call storeState() first.
  24814. * @returns true if restored and false otherwise
  24815. */
  24816. restoreState(): boolean;
  24817. /**
  24818. * Gets the class name of the camera.
  24819. * @returns the class name
  24820. */
  24821. getClassName(): string;
  24822. /** @hidden */
  24823. readonly _isCamera: boolean;
  24824. /**
  24825. * Gets a string representation of the camera useful for debug purpose.
  24826. * @param fullDetails Defines that a more verboe level of logging is required
  24827. * @returns the string representation
  24828. */
  24829. toString(fullDetails?: boolean): string;
  24830. /**
  24831. * Gets the current world space position of the camera.
  24832. */
  24833. readonly globalPosition: Vector3;
  24834. /**
  24835. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24836. * @returns the active meshe list
  24837. */
  24838. getActiveMeshes(): SmartArray<AbstractMesh>;
  24839. /**
  24840. * Check wether a mesh is part of the current active mesh list of the camera
  24841. * @param mesh Defines the mesh to check
  24842. * @returns true if active, false otherwise
  24843. */
  24844. isActiveMesh(mesh: Mesh): boolean;
  24845. /**
  24846. * Is this camera ready to be used/rendered
  24847. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24848. * @return true if the camera is ready
  24849. */
  24850. isReady(completeCheck?: boolean): boolean;
  24851. /** @hidden */
  24852. _initCache(): void;
  24853. /** @hidden */
  24854. _updateCache(ignoreParentClass?: boolean): void;
  24855. /** @hidden */
  24856. _isSynchronized(): boolean;
  24857. /** @hidden */
  24858. _isSynchronizedViewMatrix(): boolean;
  24859. /** @hidden */
  24860. _isSynchronizedProjectionMatrix(): boolean;
  24861. /**
  24862. * Attach the input controls to a specific dom element to get the input from.
  24863. * @param element Defines the element the controls should be listened from
  24864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24865. */
  24866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24867. /**
  24868. * Detach the current controls from the specified dom element.
  24869. * @param element Defines the element to stop listening the inputs from
  24870. */
  24871. detachControl(element: HTMLElement): void;
  24872. /**
  24873. * Update the camera state according to the different inputs gathered during the frame.
  24874. */
  24875. update(): void;
  24876. /** @hidden */
  24877. _checkInputs(): void;
  24878. /** @hidden */
  24879. readonly rigCameras: Camera[];
  24880. /**
  24881. * Gets the post process used by the rig cameras
  24882. */
  24883. readonly rigPostProcess: Nullable<PostProcess>;
  24884. /**
  24885. * Internal, gets the first post proces.
  24886. * @returns the first post process to be run on this camera.
  24887. */
  24888. _getFirstPostProcess(): Nullable<PostProcess>;
  24889. private _cascadePostProcessesToRigCams;
  24890. /**
  24891. * Attach a post process to the camera.
  24892. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24893. * @param postProcess The post process to attach to the camera
  24894. * @param insertAt The position of the post process in case several of them are in use in the scene
  24895. * @returns the position the post process has been inserted at
  24896. */
  24897. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24898. /**
  24899. * Detach a post process to the camera.
  24900. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24901. * @param postProcess The post process to detach from the camera
  24902. */
  24903. detachPostProcess(postProcess: PostProcess): void;
  24904. /**
  24905. * Gets the current world matrix of the camera
  24906. */
  24907. getWorldMatrix(): Matrix;
  24908. /** @hidden */
  24909. _getViewMatrix(): Matrix;
  24910. /**
  24911. * Gets the current view matrix of the camera.
  24912. * @param force forces the camera to recompute the matrix without looking at the cached state
  24913. * @returns the view matrix
  24914. */
  24915. getViewMatrix(force?: boolean): Matrix;
  24916. /**
  24917. * Freeze the projection matrix.
  24918. * It will prevent the cache check of the camera projection compute and can speed up perf
  24919. * if no parameter of the camera are meant to change
  24920. * @param projection Defines manually a projection if necessary
  24921. */
  24922. freezeProjectionMatrix(projection?: Matrix): void;
  24923. /**
  24924. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24925. */
  24926. unfreezeProjectionMatrix(): void;
  24927. /**
  24928. * Gets the current projection matrix of the camera.
  24929. * @param force forces the camera to recompute the matrix without looking at the cached state
  24930. * @returns the projection matrix
  24931. */
  24932. getProjectionMatrix(force?: boolean): Matrix;
  24933. /**
  24934. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24935. * @returns a Matrix
  24936. */
  24937. getTransformationMatrix(): Matrix;
  24938. private _updateFrustumPlanes;
  24939. /**
  24940. * Checks if a cullable object (mesh...) is in the camera frustum
  24941. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24942. * @param target The object to check
  24943. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24944. * @returns true if the object is in frustum otherwise false
  24945. */
  24946. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24947. /**
  24948. * Checks if a cullable object (mesh...) is in the camera frustum
  24949. * Unlike isInFrustum this cheks the full bounding box
  24950. * @param target The object to check
  24951. * @returns true if the object is in frustum otherwise false
  24952. */
  24953. isCompletelyInFrustum(target: ICullable): boolean;
  24954. /**
  24955. * Gets a ray in the forward direction from the camera.
  24956. * @param length Defines the length of the ray to create
  24957. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24958. * @param origin Defines the start point of the ray which defaults to the camera position
  24959. * @returns the forward ray
  24960. */
  24961. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24962. /**
  24963. * Releases resources associated with this node.
  24964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24966. */
  24967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24968. /** @hidden */
  24969. _isLeftCamera: boolean;
  24970. /**
  24971. * Gets the left camera of a rig setup in case of Rigged Camera
  24972. */
  24973. readonly isLeftCamera: boolean;
  24974. /** @hidden */
  24975. _isRightCamera: boolean;
  24976. /**
  24977. * Gets the right camera of a rig setup in case of Rigged Camera
  24978. */
  24979. readonly isRightCamera: boolean;
  24980. /**
  24981. * Gets the left camera of a rig setup in case of Rigged Camera
  24982. */
  24983. readonly leftCamera: Nullable<FreeCamera>;
  24984. /**
  24985. * Gets the right camera of a rig setup in case of Rigged Camera
  24986. */
  24987. readonly rightCamera: Nullable<FreeCamera>;
  24988. /**
  24989. * Gets the left camera target of a rig setup in case of Rigged Camera
  24990. * @returns the target position
  24991. */
  24992. getLeftTarget(): Nullable<Vector3>;
  24993. /**
  24994. * Gets the right camera target of a rig setup in case of Rigged Camera
  24995. * @returns the target position
  24996. */
  24997. getRightTarget(): Nullable<Vector3>;
  24998. /**
  24999. * @hidden
  25000. */
  25001. setCameraRigMode(mode: number, rigParams: any): void;
  25002. /** @hidden */
  25003. static _setStereoscopicRigMode(camera: Camera): void;
  25004. /** @hidden */
  25005. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25006. /** @hidden */
  25007. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25008. /** @hidden */
  25009. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25010. /** @hidden */
  25011. _getVRProjectionMatrix(): Matrix;
  25012. protected _updateCameraRotationMatrix(): void;
  25013. protected _updateWebVRCameraRotationMatrix(): void;
  25014. /**
  25015. * This function MUST be overwritten by the different WebVR cameras available.
  25016. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25017. * @hidden
  25018. */
  25019. _getWebVRProjectionMatrix(): Matrix;
  25020. /**
  25021. * This function MUST be overwritten by the different WebVR cameras available.
  25022. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25023. * @hidden
  25024. */
  25025. _getWebVRViewMatrix(): Matrix;
  25026. /** @hidden */
  25027. setCameraRigParameter(name: string, value: any): void;
  25028. /**
  25029. * needs to be overridden by children so sub has required properties to be copied
  25030. * @hidden
  25031. */
  25032. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25033. /**
  25034. * May need to be overridden by children
  25035. * @hidden
  25036. */
  25037. _updateRigCameras(): void;
  25038. /** @hidden */
  25039. _setupInputs(): void;
  25040. /**
  25041. * Serialiaze the camera setup to a json represention
  25042. * @returns the JSON representation
  25043. */
  25044. serialize(): any;
  25045. /**
  25046. * Clones the current camera.
  25047. * @param name The cloned camera name
  25048. * @returns the cloned camera
  25049. */
  25050. clone(name: string): Camera;
  25051. /**
  25052. * Gets the direction of the camera relative to a given local axis.
  25053. * @param localAxis Defines the reference axis to provide a relative direction.
  25054. * @return the direction
  25055. */
  25056. getDirection(localAxis: Vector3): Vector3;
  25057. /**
  25058. * Returns the current camera absolute rotation
  25059. */
  25060. readonly absoluteRotation: Quaternion;
  25061. /**
  25062. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25063. * @param localAxis Defines the reference axis to provide a relative direction.
  25064. * @param result Defines the vector to store the result in
  25065. */
  25066. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25067. /**
  25068. * Gets a camera constructor for a given camera type
  25069. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25070. * @param name The name of the camera the result will be able to instantiate
  25071. * @param scene The scene the result will construct the camera in
  25072. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25073. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25074. * @returns a factory method to construc the camera
  25075. */
  25076. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25077. /**
  25078. * Compute the world matrix of the camera.
  25079. * @returns the camera workd matrix
  25080. */
  25081. computeWorldMatrix(): Matrix;
  25082. /**
  25083. * Parse a JSON and creates the camera from the parsed information
  25084. * @param parsedCamera The JSON to parse
  25085. * @param scene The scene to instantiate the camera in
  25086. * @returns the newly constructed camera
  25087. */
  25088. static Parse(parsedCamera: any, scene: Scene): Camera;
  25089. }
  25090. }
  25091. declare module BABYLON {
  25092. /**
  25093. * Class containing static functions to help procedurally build meshes
  25094. */
  25095. export class DiscBuilder {
  25096. /**
  25097. * Creates a plane polygonal mesh. By default, this is a disc
  25098. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25099. * * 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
  25100. * * 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
  25101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25102. * * 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
  25103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25104. * @param name defines the name of the mesh
  25105. * @param options defines the options used to create the mesh
  25106. * @param scene defines the hosting scene
  25107. * @returns the plane polygonal mesh
  25108. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25109. */
  25110. static CreateDisc(name: string, options: {
  25111. radius?: number;
  25112. tessellation?: number;
  25113. arc?: number;
  25114. updatable?: boolean;
  25115. sideOrientation?: number;
  25116. frontUVs?: Vector4;
  25117. backUVs?: Vector4;
  25118. }, scene?: Nullable<Scene>): Mesh;
  25119. }
  25120. }
  25121. declare module BABYLON {
  25122. /**
  25123. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25124. *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.
  25125. * The SPS is also a particle system. It provides some methods to manage the particles.
  25126. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25127. *
  25128. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25129. */
  25130. export class SolidParticleSystem implements IDisposable {
  25131. /**
  25132. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25133. * Example : var p = SPS.particles[i];
  25134. */
  25135. particles: SolidParticle[];
  25136. /**
  25137. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25138. */
  25139. nbParticles: number;
  25140. /**
  25141. * If the particles must ever face the camera (default false). Useful for planar particles.
  25142. */
  25143. billboard: boolean;
  25144. /**
  25145. * Recompute normals when adding a shape
  25146. */
  25147. recomputeNormals: boolean;
  25148. /**
  25149. * This a counter ofr your own usage. It's not set by any SPS functions.
  25150. */
  25151. counter: number;
  25152. /**
  25153. * The SPS name. This name is also given to the underlying mesh.
  25154. */
  25155. name: string;
  25156. /**
  25157. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25158. */
  25159. mesh: Mesh;
  25160. /**
  25161. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25162. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25163. */
  25164. vars: any;
  25165. /**
  25166. * This array is populated when the SPS is set as 'pickable'.
  25167. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25168. * Each element of this array is an object `{idx: int, faceId: int}`.
  25169. * `idx` is the picked particle index in the `SPS.particles` array
  25170. * `faceId` is the picked face index counted within this particle.
  25171. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25172. */
  25173. pickedParticles: {
  25174. idx: number;
  25175. faceId: number;
  25176. }[];
  25177. /**
  25178. * This array is populated when `enableDepthSort` is set to true.
  25179. * Each element of this array is an instance of the class DepthSortedParticle.
  25180. */
  25181. depthSortedParticles: DepthSortedParticle[];
  25182. /**
  25183. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25184. * @hidden
  25185. */
  25186. _bSphereOnly: boolean;
  25187. /**
  25188. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25189. * @hidden
  25190. */
  25191. _bSphereRadiusFactor: number;
  25192. private _scene;
  25193. private _positions;
  25194. private _indices;
  25195. private _normals;
  25196. private _colors;
  25197. private _uvs;
  25198. private _indices32;
  25199. private _positions32;
  25200. private _normals32;
  25201. private _fixedNormal32;
  25202. private _colors32;
  25203. private _uvs32;
  25204. private _index;
  25205. private _updatable;
  25206. private _pickable;
  25207. private _isVisibilityBoxLocked;
  25208. private _alwaysVisible;
  25209. private _depthSort;
  25210. private _shapeCounter;
  25211. private _copy;
  25212. private _color;
  25213. private _computeParticleColor;
  25214. private _computeParticleTexture;
  25215. private _computeParticleRotation;
  25216. private _computeParticleVertex;
  25217. private _computeBoundingBox;
  25218. private _depthSortParticles;
  25219. private _camera;
  25220. private _mustUnrotateFixedNormals;
  25221. private _particlesIntersect;
  25222. private _needs32Bits;
  25223. /**
  25224. * Creates a SPS (Solid Particle System) object.
  25225. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25226. * @param scene (Scene) is the scene in which the SPS is added.
  25227. * @param options defines the options of the sps e.g.
  25228. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25229. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25230. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25231. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25232. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25233. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25234. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25235. */
  25236. constructor(name: string, scene: Scene, options?: {
  25237. updatable?: boolean;
  25238. isPickable?: boolean;
  25239. enableDepthSort?: boolean;
  25240. particleIntersection?: boolean;
  25241. boundingSphereOnly?: boolean;
  25242. bSphereRadiusFactor?: number;
  25243. });
  25244. /**
  25245. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25246. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25247. * @returns the created mesh
  25248. */
  25249. buildMesh(): Mesh;
  25250. /**
  25251. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25252. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25253. * Thus the particles generated from `digest()` have their property `position` set yet.
  25254. * @param mesh ( Mesh ) is the mesh to be digested
  25255. * @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
  25256. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25257. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25258. * @returns the current SPS
  25259. */
  25260. digest(mesh: Mesh, options?: {
  25261. facetNb?: number;
  25262. number?: number;
  25263. delta?: number;
  25264. }): SolidParticleSystem;
  25265. private _unrotateFixedNormals;
  25266. private _resetCopy;
  25267. private _meshBuilder;
  25268. private _posToShape;
  25269. private _uvsToShapeUV;
  25270. private _addParticle;
  25271. /**
  25272. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25273. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25274. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25275. * @param nb (positive integer) the number of particles to be created from this model
  25276. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25277. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25278. * @returns the number of shapes in the system
  25279. */
  25280. addShape(mesh: Mesh, nb: number, options?: {
  25281. positionFunction?: any;
  25282. vertexFunction?: any;
  25283. }): number;
  25284. private _rebuildParticle;
  25285. /**
  25286. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25287. * @returns the SPS.
  25288. */
  25289. rebuildMesh(): SolidParticleSystem;
  25290. /**
  25291. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25292. * This method calls `updateParticle()` for each particle of the SPS.
  25293. * For an animated SPS, it is usually called within the render loop.
  25294. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25295. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25296. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25297. * @returns the SPS.
  25298. */
  25299. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25300. /**
  25301. * Disposes the SPS.
  25302. */
  25303. dispose(): void;
  25304. /**
  25305. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25306. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25307. * @returns the SPS.
  25308. */
  25309. refreshVisibleSize(): SolidParticleSystem;
  25310. /**
  25311. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25312. * @param size the size (float) of the visibility box
  25313. * note : this doesn't lock the SPS mesh bounding box.
  25314. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25315. */
  25316. setVisibilityBox(size: number): void;
  25317. /**
  25318. * Gets whether the SPS as always visible or not
  25319. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25320. */
  25321. /**
  25322. * Sets the SPS as always visible or not
  25323. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25324. */
  25325. isAlwaysVisible: boolean;
  25326. /**
  25327. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25328. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25329. */
  25330. /**
  25331. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25332. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25333. */
  25334. isVisibilityBoxLocked: boolean;
  25335. /**
  25336. * Tells to `setParticles()` to compute the particle rotations or not.
  25337. * Default value : true. The SPS is faster when it's set to false.
  25338. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25339. */
  25340. /**
  25341. * Gets if `setParticles()` computes the particle rotations or not.
  25342. * Default value : true. The SPS is faster when it's set to false.
  25343. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25344. */
  25345. computeParticleRotation: boolean;
  25346. /**
  25347. * Tells to `setParticles()` to compute the particle colors or not.
  25348. * Default value : true. The SPS is faster when it's set to false.
  25349. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25350. */
  25351. /**
  25352. * Gets if `setParticles()` computes the particle colors or not.
  25353. * Default value : true. The SPS is faster when it's set to false.
  25354. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25355. */
  25356. computeParticleColor: boolean;
  25357. /**
  25358. * Gets if `setParticles()` computes the particle textures or not.
  25359. * Default value : true. The SPS is faster when it's set to false.
  25360. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25361. */
  25362. computeParticleTexture: boolean;
  25363. /**
  25364. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25365. * Default value : false. The SPS is faster when it's set to false.
  25366. * Note : the particle custom vertex positions aren't stored values.
  25367. */
  25368. /**
  25369. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25370. * Default value : false. The SPS is faster when it's set to false.
  25371. * Note : the particle custom vertex positions aren't stored values.
  25372. */
  25373. computeParticleVertex: boolean;
  25374. /**
  25375. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25376. */
  25377. /**
  25378. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25379. */
  25380. computeBoundingBox: boolean;
  25381. /**
  25382. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25383. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25384. * Default : `true`
  25385. */
  25386. /**
  25387. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25388. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25389. * Default : `true`
  25390. */
  25391. depthSortParticles: boolean;
  25392. /**
  25393. * This function does nothing. It may be overwritten to set all the particle first values.
  25394. * The SPS doesn't call this function, you may have to call it by your own.
  25395. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25396. */
  25397. initParticles(): void;
  25398. /**
  25399. * This function does nothing. It may be overwritten to recycle a particle.
  25400. * The SPS doesn't call this function, you may have to call it by your own.
  25401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25402. * @param particle The particle to recycle
  25403. * @returns the recycled particle
  25404. */
  25405. recycleParticle(particle: SolidParticle): SolidParticle;
  25406. /**
  25407. * Updates a particle : this function should be overwritten by the user.
  25408. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25409. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25410. * @example : just set a particle position or velocity and recycle conditions
  25411. * @param particle The particle to update
  25412. * @returns the updated particle
  25413. */
  25414. updateParticle(particle: SolidParticle): SolidParticle;
  25415. /**
  25416. * Updates a vertex of a particle : it can be overwritten by the user.
  25417. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25418. * @param particle the current particle
  25419. * @param vertex the current index of the current particle
  25420. * @param pt the index of the current vertex in the particle shape
  25421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25422. * @example : just set a vertex particle position
  25423. * @returns the updated vertex
  25424. */
  25425. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25426. /**
  25427. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25428. * This does nothing and may be overwritten by the user.
  25429. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25430. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25431. * @param update the boolean update value actually passed to setParticles()
  25432. */
  25433. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25434. /**
  25435. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25436. * This will be passed three parameters.
  25437. * This does nothing and may be overwritten by the user.
  25438. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25439. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25440. * @param update the boolean update value actually passed to setParticles()
  25441. */
  25442. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25443. }
  25444. }
  25445. declare module BABYLON {
  25446. /**
  25447. * Represents one particle of a solid particle system.
  25448. */
  25449. export class SolidParticle {
  25450. /**
  25451. * particle global index
  25452. */
  25453. idx: number;
  25454. /**
  25455. * The color of the particle
  25456. */
  25457. color: Nullable<Color4>;
  25458. /**
  25459. * The world space position of the particle.
  25460. */
  25461. position: Vector3;
  25462. /**
  25463. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25464. */
  25465. rotation: Vector3;
  25466. /**
  25467. * The world space rotation quaternion of the particle.
  25468. */
  25469. rotationQuaternion: Nullable<Quaternion>;
  25470. /**
  25471. * The scaling of the particle.
  25472. */
  25473. scaling: Vector3;
  25474. /**
  25475. * The uvs of the particle.
  25476. */
  25477. uvs: Vector4;
  25478. /**
  25479. * The current speed of the particle.
  25480. */
  25481. velocity: Vector3;
  25482. /**
  25483. * The pivot point in the particle local space.
  25484. */
  25485. pivot: Vector3;
  25486. /**
  25487. * Must the particle be translated from its pivot point in its local space ?
  25488. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25489. * Default : false
  25490. */
  25491. translateFromPivot: boolean;
  25492. /**
  25493. * Is the particle active or not ?
  25494. */
  25495. alive: boolean;
  25496. /**
  25497. * Is the particle visible or not ?
  25498. */
  25499. isVisible: boolean;
  25500. /**
  25501. * Index of this particle in the global "positions" array (Internal use)
  25502. * @hidden
  25503. */
  25504. _pos: number;
  25505. /**
  25506. * @hidden Index of this particle in the global "indices" array (Internal use)
  25507. */
  25508. _ind: number;
  25509. /**
  25510. * @hidden ModelShape of this particle (Internal use)
  25511. */
  25512. _model: ModelShape;
  25513. /**
  25514. * ModelShape id of this particle
  25515. */
  25516. shapeId: number;
  25517. /**
  25518. * Index of the particle in its shape id
  25519. */
  25520. idxInShape: number;
  25521. /**
  25522. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25523. */
  25524. _modelBoundingInfo: BoundingInfo;
  25525. /**
  25526. * @hidden Particle BoundingInfo object (Internal use)
  25527. */
  25528. _boundingInfo: BoundingInfo;
  25529. /**
  25530. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25531. */
  25532. _sps: SolidParticleSystem;
  25533. /**
  25534. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25535. */
  25536. _stillInvisible: boolean;
  25537. /**
  25538. * @hidden Last computed particle rotation matrix
  25539. */
  25540. _rotationMatrix: number[];
  25541. /**
  25542. * Parent particle Id, if any.
  25543. * Default null.
  25544. */
  25545. parentId: Nullable<number>;
  25546. /**
  25547. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25548. * The possible values are :
  25549. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25550. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25551. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25552. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25553. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25554. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25555. * */
  25556. cullingStrategy: number;
  25557. /**
  25558. * @hidden Internal global position in the SPS.
  25559. */
  25560. _globalPosition: Vector3;
  25561. /**
  25562. * Creates a Solid Particle object.
  25563. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25564. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25565. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25566. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25567. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25568. * @param shapeId (integer) is the model shape identifier in the SPS.
  25569. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25570. * @param sps defines the sps it is associated to
  25571. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25572. */
  25573. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25574. /**
  25575. * Legacy support, changed scale to scaling
  25576. */
  25577. /**
  25578. * Legacy support, changed scale to scaling
  25579. */
  25580. scale: Vector3;
  25581. /**
  25582. * Legacy support, changed quaternion to rotationQuaternion
  25583. */
  25584. /**
  25585. * Legacy support, changed quaternion to rotationQuaternion
  25586. */
  25587. quaternion: Nullable<Quaternion>;
  25588. /**
  25589. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25590. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25591. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25592. * @returns true if it intersects
  25593. */
  25594. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25595. /**
  25596. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25597. * A particle is in the frustum if its bounding box intersects the frustum
  25598. * @param frustumPlanes defines the frustum to test
  25599. * @returns true if the particle is in the frustum planes
  25600. */
  25601. isInFrustum(frustumPlanes: Plane[]): boolean;
  25602. /**
  25603. * get the rotation matrix of the particle
  25604. * @hidden
  25605. */
  25606. getRotationMatrix(m: Matrix): void;
  25607. }
  25608. /**
  25609. * Represents the shape of the model used by one particle of a solid particle system.
  25610. * SPS internal tool, don't use it manually.
  25611. */
  25612. export class ModelShape {
  25613. /**
  25614. * The shape id
  25615. * @hidden
  25616. */
  25617. shapeID: number;
  25618. /**
  25619. * flat array of model positions (internal use)
  25620. * @hidden
  25621. */
  25622. _shape: Vector3[];
  25623. /**
  25624. * flat array of model UVs (internal use)
  25625. * @hidden
  25626. */
  25627. _shapeUV: number[];
  25628. /**
  25629. * length of the shape in the model indices array (internal use)
  25630. * @hidden
  25631. */
  25632. _indicesLength: number;
  25633. /**
  25634. * Custom position function (internal use)
  25635. * @hidden
  25636. */
  25637. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25638. /**
  25639. * Custom vertex function (internal use)
  25640. * @hidden
  25641. */
  25642. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25643. /**
  25644. * 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.
  25645. * SPS internal tool, don't use it manually.
  25646. * @hidden
  25647. */
  25648. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25649. }
  25650. /**
  25651. * Represents a Depth Sorted Particle in the solid particle system.
  25652. */
  25653. export class DepthSortedParticle {
  25654. /**
  25655. * Index of the particle in the "indices" array
  25656. */
  25657. ind: number;
  25658. /**
  25659. * Length of the particle shape in the "indices" array
  25660. */
  25661. indicesLength: number;
  25662. /**
  25663. * Squared distance from the particle to the camera
  25664. */
  25665. sqDistance: number;
  25666. }
  25667. }
  25668. declare module BABYLON {
  25669. /**
  25670. * @hidden
  25671. */
  25672. export class _MeshCollisionData {
  25673. _checkCollisions: boolean;
  25674. _collisionMask: number;
  25675. _collisionGroup: number;
  25676. _collider: Nullable<Collider>;
  25677. _oldPositionForCollisions: Vector3;
  25678. _diffPositionForCollisions: Vector3;
  25679. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25680. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25681. }
  25682. }
  25683. declare module BABYLON {
  25684. /** @hidden */
  25685. class _FacetDataStorage {
  25686. facetPositions: Vector3[];
  25687. facetNormals: Vector3[];
  25688. facetPartitioning: number[][];
  25689. facetNb: number;
  25690. partitioningSubdivisions: number;
  25691. partitioningBBoxRatio: number;
  25692. facetDataEnabled: boolean;
  25693. facetParameters: any;
  25694. bbSize: Vector3;
  25695. subDiv: {
  25696. max: number;
  25697. X: number;
  25698. Y: number;
  25699. Z: number;
  25700. };
  25701. facetDepthSort: boolean;
  25702. facetDepthSortEnabled: boolean;
  25703. depthSortedIndices: IndicesArray;
  25704. depthSortedFacets: {
  25705. ind: number;
  25706. sqDistance: number;
  25707. }[];
  25708. facetDepthSortFunction: (f1: {
  25709. ind: number;
  25710. sqDistance: number;
  25711. }, f2: {
  25712. ind: number;
  25713. sqDistance: number;
  25714. }) => number;
  25715. facetDepthSortFrom: Vector3;
  25716. facetDepthSortOrigin: Vector3;
  25717. invertedMatrix: Matrix;
  25718. }
  25719. /**
  25720. * @hidden
  25721. **/
  25722. class _InternalAbstractMeshDataInfo {
  25723. _hasVertexAlpha: boolean;
  25724. _useVertexColors: boolean;
  25725. _numBoneInfluencers: number;
  25726. _applyFog: boolean;
  25727. _receiveShadows: boolean;
  25728. _facetData: _FacetDataStorage;
  25729. _visibility: number;
  25730. _skeleton: Nullable<Skeleton>;
  25731. _layerMask: number;
  25732. _computeBonesUsingShaders: boolean;
  25733. _isActive: boolean;
  25734. _onlyForInstances: boolean;
  25735. _isActiveIntermediate: boolean;
  25736. _onlyForInstancesIntermediate: boolean;
  25737. }
  25738. /**
  25739. * Class used to store all common mesh properties
  25740. */
  25741. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25742. /** No occlusion */
  25743. static OCCLUSION_TYPE_NONE: number;
  25744. /** Occlusion set to optimisitic */
  25745. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25746. /** Occlusion set to strict */
  25747. static OCCLUSION_TYPE_STRICT: number;
  25748. /** Use an accurante occlusion algorithm */
  25749. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25750. /** Use a conservative occlusion algorithm */
  25751. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25752. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25753. * Test order :
  25754. * Is the bounding sphere outside the frustum ?
  25755. * If not, are the bounding box vertices outside the frustum ?
  25756. * It not, then the cullable object is in the frustum.
  25757. */
  25758. static readonly CULLINGSTRATEGY_STANDARD: number;
  25759. /** Culling strategy : Bounding Sphere Only.
  25760. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25761. * It's also less accurate than the standard because some not visible objects can still be selected.
  25762. * Test : is the bounding sphere outside the frustum ?
  25763. * If not, then the cullable object is in the frustum.
  25764. */
  25765. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25766. /** Culling strategy : Optimistic Inclusion.
  25767. * This in an inclusion test first, then the standard exclusion test.
  25768. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25769. * 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.
  25770. * Anyway, it's as accurate as the standard strategy.
  25771. * Test :
  25772. * Is the cullable object bounding sphere center in the frustum ?
  25773. * If not, apply the default culling strategy.
  25774. */
  25775. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25776. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25777. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25778. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25779. * 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.
  25780. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25781. * Test :
  25782. * Is the cullable object bounding sphere center in the frustum ?
  25783. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25784. */
  25785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25786. /**
  25787. * No billboard
  25788. */
  25789. static readonly BILLBOARDMODE_NONE: number;
  25790. /** Billboard on X axis */
  25791. static readonly BILLBOARDMODE_X: number;
  25792. /** Billboard on Y axis */
  25793. static readonly BILLBOARDMODE_Y: number;
  25794. /** Billboard on Z axis */
  25795. static readonly BILLBOARDMODE_Z: number;
  25796. /** Billboard on all axes */
  25797. static readonly BILLBOARDMODE_ALL: number;
  25798. /** Billboard on using position instead of orientation */
  25799. static readonly BILLBOARDMODE_USE_POSITION: number;
  25800. /** @hidden */
  25801. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25802. /**
  25803. * The culling strategy to use to check whether the mesh must be rendered or not.
  25804. * This value can be changed at any time and will be used on the next render mesh selection.
  25805. * The possible values are :
  25806. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25807. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25810. * Please read each static variable documentation to get details about the culling process.
  25811. * */
  25812. cullingStrategy: number;
  25813. /**
  25814. * Gets the number of facets in the mesh
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25816. */
  25817. readonly facetNb: number;
  25818. /**
  25819. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25821. */
  25822. partitioningSubdivisions: number;
  25823. /**
  25824. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25825. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25827. */
  25828. partitioningBBoxRatio: number;
  25829. /**
  25830. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25831. * Works only for updatable meshes.
  25832. * Doesn't work with multi-materials
  25833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25834. */
  25835. mustDepthSortFacets: boolean;
  25836. /**
  25837. * The location (Vector3) where the facet depth sort must be computed from.
  25838. * By default, the active camera position.
  25839. * Used only when facet depth sort is enabled
  25840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25841. */
  25842. facetDepthSortFrom: Vector3;
  25843. /**
  25844. * gets a boolean indicating if facetData is enabled
  25845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25846. */
  25847. readonly isFacetDataEnabled: boolean;
  25848. /** @hidden */
  25849. _updateNonUniformScalingState(value: boolean): boolean;
  25850. /**
  25851. * An event triggered when this mesh collides with another one
  25852. */
  25853. onCollideObservable: Observable<AbstractMesh>;
  25854. /** Set a function to call when this mesh collides with another one */
  25855. onCollide: () => void;
  25856. /**
  25857. * An event triggered when the collision's position changes
  25858. */
  25859. onCollisionPositionChangeObservable: Observable<Vector3>;
  25860. /** Set a function to call when the collision's position changes */
  25861. onCollisionPositionChange: () => void;
  25862. /**
  25863. * An event triggered when material is changed
  25864. */
  25865. onMaterialChangedObservable: Observable<AbstractMesh>;
  25866. /**
  25867. * Gets or sets the orientation for POV movement & rotation
  25868. */
  25869. definedFacingForward: boolean;
  25870. /** @hidden */
  25871. _occlusionQuery: Nullable<WebGLQuery>;
  25872. /** @hidden */
  25873. _renderingGroup: Nullable<RenderingGroup>;
  25874. /**
  25875. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25876. */
  25877. /**
  25878. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25879. */
  25880. visibility: number;
  25881. /** Gets or sets the alpha index used to sort transparent meshes
  25882. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25883. */
  25884. alphaIndex: number;
  25885. /**
  25886. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25887. */
  25888. isVisible: boolean;
  25889. /**
  25890. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25891. */
  25892. isPickable: boolean;
  25893. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25894. showSubMeshesBoundingBox: boolean;
  25895. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25897. */
  25898. isBlocker: boolean;
  25899. /**
  25900. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25901. */
  25902. enablePointerMoveEvents: boolean;
  25903. /**
  25904. * Specifies the rendering group id for this mesh (0 by default)
  25905. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25906. */
  25907. renderingGroupId: number;
  25908. private _material;
  25909. /** Gets or sets current material */
  25910. material: Nullable<Material>;
  25911. /**
  25912. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25913. * @see http://doc.babylonjs.com/babylon101/shadows
  25914. */
  25915. receiveShadows: boolean;
  25916. /** Defines color to use when rendering outline */
  25917. outlineColor: Color3;
  25918. /** Define width to use when rendering outline */
  25919. outlineWidth: number;
  25920. /** Defines color to use when rendering overlay */
  25921. overlayColor: Color3;
  25922. /** Defines alpha to use when rendering overlay */
  25923. overlayAlpha: number;
  25924. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25925. hasVertexAlpha: boolean;
  25926. /** 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) */
  25927. useVertexColors: boolean;
  25928. /**
  25929. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25930. */
  25931. computeBonesUsingShaders: boolean;
  25932. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25933. numBoneInfluencers: number;
  25934. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25935. applyFog: boolean;
  25936. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25937. useOctreeForRenderingSelection: boolean;
  25938. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25939. useOctreeForPicking: boolean;
  25940. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25941. useOctreeForCollisions: boolean;
  25942. /**
  25943. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25944. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25945. */
  25946. layerMask: number;
  25947. /**
  25948. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25949. */
  25950. alwaysSelectAsActiveMesh: boolean;
  25951. /**
  25952. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25953. */
  25954. doNotSyncBoundingInfo: boolean;
  25955. /**
  25956. * Gets or sets the current action manager
  25957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25958. */
  25959. actionManager: Nullable<AbstractActionManager>;
  25960. private _meshCollisionData;
  25961. /**
  25962. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25964. */
  25965. ellipsoid: Vector3;
  25966. /**
  25967. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25969. */
  25970. ellipsoidOffset: Vector3;
  25971. /**
  25972. * Gets or sets a collision mask used to mask collisions (default is -1).
  25973. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25974. */
  25975. collisionMask: number;
  25976. /**
  25977. * Gets or sets the current collision group mask (-1 by default).
  25978. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25979. */
  25980. collisionGroup: number;
  25981. /**
  25982. * Defines edge width used when edgesRenderer is enabled
  25983. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25984. */
  25985. edgesWidth: number;
  25986. /**
  25987. * Defines edge color used when edgesRenderer is enabled
  25988. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25989. */
  25990. edgesColor: Color4;
  25991. /** @hidden */
  25992. _edgesRenderer: Nullable<IEdgesRenderer>;
  25993. /** @hidden */
  25994. _masterMesh: Nullable<AbstractMesh>;
  25995. /** @hidden */
  25996. _boundingInfo: Nullable<BoundingInfo>;
  25997. /** @hidden */
  25998. _renderId: number;
  25999. /**
  26000. * Gets or sets the list of subMeshes
  26001. * @see http://doc.babylonjs.com/how_to/multi_materials
  26002. */
  26003. subMeshes: SubMesh[];
  26004. /** @hidden */
  26005. _intersectionsInProgress: AbstractMesh[];
  26006. /** @hidden */
  26007. _unIndexed: boolean;
  26008. /** @hidden */
  26009. _lightSources: Light[];
  26010. /** Gets the list of lights affecting that mesh */
  26011. readonly lightSources: Light[];
  26012. /** @hidden */
  26013. readonly _positions: Nullable<Vector3[]>;
  26014. /** @hidden */
  26015. _waitingData: {
  26016. lods: Nullable<any>;
  26017. actions: Nullable<any>;
  26018. freezeWorldMatrix: Nullable<boolean>;
  26019. };
  26020. /** @hidden */
  26021. _bonesTransformMatrices: Nullable<Float32Array>;
  26022. /** @hidden */
  26023. _transformMatrixTexture: Nullable<RawTexture>;
  26024. /**
  26025. * Gets or sets a skeleton to apply skining transformations
  26026. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26027. */
  26028. skeleton: Nullable<Skeleton>;
  26029. /**
  26030. * An event triggered when the mesh is rebuilt.
  26031. */
  26032. onRebuildObservable: Observable<AbstractMesh>;
  26033. /**
  26034. * Creates a new AbstractMesh
  26035. * @param name defines the name of the mesh
  26036. * @param scene defines the hosting scene
  26037. */
  26038. constructor(name: string, scene?: Nullable<Scene>);
  26039. /**
  26040. * Returns the string "AbstractMesh"
  26041. * @returns "AbstractMesh"
  26042. */
  26043. getClassName(): string;
  26044. /**
  26045. * Gets a string representation of the current mesh
  26046. * @param fullDetails defines a boolean indicating if full details must be included
  26047. * @returns a string representation of the current mesh
  26048. */
  26049. toString(fullDetails?: boolean): string;
  26050. /**
  26051. * @hidden
  26052. */
  26053. protected _getEffectiveParent(): Nullable<Node>;
  26054. /** @hidden */
  26055. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26056. /** @hidden */
  26057. _rebuild(): void;
  26058. /** @hidden */
  26059. _resyncLightSources(): void;
  26060. /** @hidden */
  26061. _resyncLighSource(light: Light): void;
  26062. /** @hidden */
  26063. _unBindEffect(): void;
  26064. /** @hidden */
  26065. _removeLightSource(light: Light, dispose: boolean): void;
  26066. private _markSubMeshesAsDirty;
  26067. /** @hidden */
  26068. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26069. /** @hidden */
  26070. _markSubMeshesAsAttributesDirty(): void;
  26071. /** @hidden */
  26072. _markSubMeshesAsMiscDirty(): void;
  26073. /**
  26074. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26075. */
  26076. scaling: Vector3;
  26077. /**
  26078. * Returns true if the mesh is blocked. Implemented by child classes
  26079. */
  26080. readonly isBlocked: boolean;
  26081. /**
  26082. * Returns the mesh itself by default. Implemented by child classes
  26083. * @param camera defines the camera to use to pick the right LOD level
  26084. * @returns the currentAbstractMesh
  26085. */
  26086. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26087. /**
  26088. * Returns 0 by default. Implemented by child classes
  26089. * @returns an integer
  26090. */
  26091. getTotalVertices(): number;
  26092. /**
  26093. * Returns a positive integer : the total number of indices in this mesh geometry.
  26094. * @returns the numner of indices or zero if the mesh has no geometry.
  26095. */
  26096. getTotalIndices(): number;
  26097. /**
  26098. * Returns null by default. Implemented by child classes
  26099. * @returns null
  26100. */
  26101. getIndices(): Nullable<IndicesArray>;
  26102. /**
  26103. * Returns the array of the requested vertex data kind. Implemented by child classes
  26104. * @param kind defines the vertex data kind to use
  26105. * @returns null
  26106. */
  26107. getVerticesData(kind: string): Nullable<FloatArray>;
  26108. /**
  26109. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26110. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26111. * Note that a new underlying VertexBuffer object is created each call.
  26112. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26113. * @param kind defines vertex data kind:
  26114. * * VertexBuffer.PositionKind
  26115. * * VertexBuffer.UVKind
  26116. * * VertexBuffer.UV2Kind
  26117. * * VertexBuffer.UV3Kind
  26118. * * VertexBuffer.UV4Kind
  26119. * * VertexBuffer.UV5Kind
  26120. * * VertexBuffer.UV6Kind
  26121. * * VertexBuffer.ColorKind
  26122. * * VertexBuffer.MatricesIndicesKind
  26123. * * VertexBuffer.MatricesIndicesExtraKind
  26124. * * VertexBuffer.MatricesWeightsKind
  26125. * * VertexBuffer.MatricesWeightsExtraKind
  26126. * @param data defines the data source
  26127. * @param updatable defines if the data must be flagged as updatable (or static)
  26128. * @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
  26129. * @returns the current mesh
  26130. */
  26131. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26132. /**
  26133. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26134. * If the mesh has no geometry, it is simply returned as it is.
  26135. * @param kind defines vertex data kind:
  26136. * * VertexBuffer.PositionKind
  26137. * * VertexBuffer.UVKind
  26138. * * VertexBuffer.UV2Kind
  26139. * * VertexBuffer.UV3Kind
  26140. * * VertexBuffer.UV4Kind
  26141. * * VertexBuffer.UV5Kind
  26142. * * VertexBuffer.UV6Kind
  26143. * * VertexBuffer.ColorKind
  26144. * * VertexBuffer.MatricesIndicesKind
  26145. * * VertexBuffer.MatricesIndicesExtraKind
  26146. * * VertexBuffer.MatricesWeightsKind
  26147. * * VertexBuffer.MatricesWeightsExtraKind
  26148. * @param data defines the data source
  26149. * @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
  26150. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26151. * @returns the current mesh
  26152. */
  26153. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26154. /**
  26155. * Sets the mesh indices,
  26156. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26157. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26158. * @param totalVertices Defines the total number of vertices
  26159. * @returns the current mesh
  26160. */
  26161. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26162. /**
  26163. * Gets a boolean indicating if specific vertex data is present
  26164. * @param kind defines the vertex data kind to use
  26165. * @returns true is data kind is present
  26166. */
  26167. isVerticesDataPresent(kind: string): boolean;
  26168. /**
  26169. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26170. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26171. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26172. * @returns a BoundingInfo
  26173. */
  26174. getBoundingInfo(): BoundingInfo;
  26175. /**
  26176. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26177. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26178. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26179. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26180. * @returns the current mesh
  26181. */
  26182. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26183. /**
  26184. * Overwrite the current bounding info
  26185. * @param boundingInfo defines the new bounding info
  26186. * @returns the current mesh
  26187. */
  26188. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26189. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26190. readonly useBones: boolean;
  26191. /** @hidden */
  26192. _preActivate(): void;
  26193. /** @hidden */
  26194. _preActivateForIntermediateRendering(renderId: number): void;
  26195. /** @hidden */
  26196. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26197. /** @hidden */
  26198. _postActivate(): void;
  26199. /** @hidden */
  26200. _freeze(): void;
  26201. /** @hidden */
  26202. _unFreeze(): void;
  26203. /**
  26204. * Gets the current world matrix
  26205. * @returns a Matrix
  26206. */
  26207. getWorldMatrix(): Matrix;
  26208. /** @hidden */
  26209. _getWorldMatrixDeterminant(): number;
  26210. /**
  26211. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26212. */
  26213. readonly isAnInstance: boolean;
  26214. /**
  26215. * Gets a boolean indicating if this mesh has instances
  26216. */
  26217. readonly hasInstances: boolean;
  26218. /**
  26219. * Perform relative position change from the point of view of behind the front of the mesh.
  26220. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26221. * Supports definition of mesh facing forward or backward
  26222. * @param amountRight defines the distance on the right axis
  26223. * @param amountUp defines the distance on the up axis
  26224. * @param amountForward defines the distance on the forward axis
  26225. * @returns the current mesh
  26226. */
  26227. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26228. /**
  26229. * Calculate relative position change from the point of view of behind the front of the mesh.
  26230. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26231. * Supports definition of mesh facing forward or backward
  26232. * @param amountRight defines the distance on the right axis
  26233. * @param amountUp defines the distance on the up axis
  26234. * @param amountForward defines the distance on the forward axis
  26235. * @returns the new displacement vector
  26236. */
  26237. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26238. /**
  26239. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26240. * Supports definition of mesh facing forward or backward
  26241. * @param flipBack defines the flip
  26242. * @param twirlClockwise defines the twirl
  26243. * @param tiltRight defines the tilt
  26244. * @returns the current mesh
  26245. */
  26246. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26247. /**
  26248. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26249. * Supports definition of mesh facing forward or backward.
  26250. * @param flipBack defines the flip
  26251. * @param twirlClockwise defines the twirl
  26252. * @param tiltRight defines the tilt
  26253. * @returns the new rotation vector
  26254. */
  26255. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26256. /**
  26257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26258. * This means the mesh underlying bounding box and sphere are recomputed.
  26259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26260. * @returns the current mesh
  26261. */
  26262. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26263. /** @hidden */
  26264. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26265. /** @hidden */
  26266. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26267. /** @hidden */
  26268. _updateBoundingInfo(): AbstractMesh;
  26269. /** @hidden */
  26270. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26271. /** @hidden */
  26272. protected _afterComputeWorldMatrix(): void;
  26273. /** @hidden */
  26274. readonly _effectiveMesh: AbstractMesh;
  26275. /**
  26276. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26277. * A mesh is in the frustum if its bounding box intersects the frustum
  26278. * @param frustumPlanes defines the frustum to test
  26279. * @returns true if the mesh is in the frustum planes
  26280. */
  26281. isInFrustum(frustumPlanes: Plane[]): boolean;
  26282. /**
  26283. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26284. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26285. * @param frustumPlanes defines the frustum to test
  26286. * @returns true if the mesh is completely in the frustum planes
  26287. */
  26288. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26289. /**
  26290. * True if the mesh intersects another mesh or a SolidParticle object
  26291. * @param mesh defines a target mesh or SolidParticle to test
  26292. * @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)
  26293. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26294. * @returns true if there is an intersection
  26295. */
  26296. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26297. /**
  26298. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26299. * @param point defines the point to test
  26300. * @returns true if there is an intersection
  26301. */
  26302. intersectsPoint(point: Vector3): boolean;
  26303. /**
  26304. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26306. */
  26307. checkCollisions: boolean;
  26308. /**
  26309. * Gets Collider object used to compute collisions (not physics)
  26310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26311. */
  26312. readonly collider: Nullable<Collider>;
  26313. /**
  26314. * Move the mesh using collision engine
  26315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26316. * @param displacement defines the requested displacement vector
  26317. * @returns the current mesh
  26318. */
  26319. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26320. private _onCollisionPositionChange;
  26321. /** @hidden */
  26322. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26323. /** @hidden */
  26324. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26325. /** @hidden */
  26326. _checkCollision(collider: Collider): AbstractMesh;
  26327. /** @hidden */
  26328. _generatePointsArray(): boolean;
  26329. /**
  26330. * Checks if the passed Ray intersects with the mesh
  26331. * @param ray defines the ray to use
  26332. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26333. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26334. * @returns the picking info
  26335. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26336. */
  26337. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26338. /**
  26339. * Clones the current mesh
  26340. * @param name defines the mesh name
  26341. * @param newParent defines the new mesh parent
  26342. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26343. * @returns the new mesh
  26344. */
  26345. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26346. /**
  26347. * Disposes all the submeshes of the current meshnp
  26348. * @returns the current mesh
  26349. */
  26350. releaseSubMeshes(): AbstractMesh;
  26351. /**
  26352. * Releases resources associated with this abstract mesh.
  26353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26355. */
  26356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26357. /**
  26358. * Adds the passed mesh as a child to the current mesh
  26359. * @param mesh defines the child mesh
  26360. * @returns the current mesh
  26361. */
  26362. addChild(mesh: AbstractMesh): AbstractMesh;
  26363. /**
  26364. * Removes the passed mesh from the current mesh children list
  26365. * @param mesh defines the child mesh
  26366. * @returns the current mesh
  26367. */
  26368. removeChild(mesh: AbstractMesh): AbstractMesh;
  26369. /** @hidden */
  26370. private _initFacetData;
  26371. /**
  26372. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26373. * This method can be called within the render loop.
  26374. * 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
  26375. * @returns the current mesh
  26376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26377. */
  26378. updateFacetData(): AbstractMesh;
  26379. /**
  26380. * Returns the facetLocalNormals array.
  26381. * The normals are expressed in the mesh local spac
  26382. * @returns an array of Vector3
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26384. */
  26385. getFacetLocalNormals(): Vector3[];
  26386. /**
  26387. * Returns the facetLocalPositions array.
  26388. * The facet positions are expressed in the mesh local space
  26389. * @returns an array of Vector3
  26390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26391. */
  26392. getFacetLocalPositions(): Vector3[];
  26393. /**
  26394. * Returns the facetLocalPartioning array
  26395. * @returns an array of array of numbers
  26396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26397. */
  26398. getFacetLocalPartitioning(): number[][];
  26399. /**
  26400. * Returns the i-th facet position in the world system.
  26401. * This method allocates a new Vector3 per call
  26402. * @param i defines the facet index
  26403. * @returns a new Vector3
  26404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26405. */
  26406. getFacetPosition(i: number): Vector3;
  26407. /**
  26408. * Sets the reference Vector3 with the i-th facet position in the world system
  26409. * @param i defines the facet index
  26410. * @param ref defines the target vector
  26411. * @returns the current mesh
  26412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26413. */
  26414. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26415. /**
  26416. * Returns the i-th facet normal in the world system.
  26417. * This method allocates a new Vector3 per call
  26418. * @param i defines the facet index
  26419. * @returns a new Vector3
  26420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26421. */
  26422. getFacetNormal(i: number): Vector3;
  26423. /**
  26424. * Sets the reference Vector3 with the i-th facet normal in the world system
  26425. * @param i defines the facet index
  26426. * @param ref defines the target vector
  26427. * @returns the current mesh
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26429. */
  26430. getFacetNormalToRef(i: number, ref: Vector3): this;
  26431. /**
  26432. * 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)
  26433. * @param x defines x coordinate
  26434. * @param y defines y coordinate
  26435. * @param z defines z coordinate
  26436. * @returns the array of facet indexes
  26437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26438. */
  26439. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26440. /**
  26441. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26442. * @param projected sets as the (x,y,z) world projection on the facet
  26443. * @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
  26444. * @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
  26445. * @param x defines x coordinate
  26446. * @param y defines y coordinate
  26447. * @param z defines z coordinate
  26448. * @returns the face index if found (or null instead)
  26449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26450. */
  26451. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26452. /**
  26453. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26454. * @param projected sets as the (x,y,z) local projection on the facet
  26455. * @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
  26456. * @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
  26457. * @param x defines x coordinate
  26458. * @param y defines y coordinate
  26459. * @param z defines z coordinate
  26460. * @returns the face index if found (or null instead)
  26461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26462. */
  26463. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26464. /**
  26465. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26466. * @returns the parameters
  26467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26468. */
  26469. getFacetDataParameters(): any;
  26470. /**
  26471. * Disables the feature FacetData and frees the related memory
  26472. * @returns the current mesh
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26474. */
  26475. disableFacetData(): AbstractMesh;
  26476. /**
  26477. * Updates the AbstractMesh indices array
  26478. * @param indices defines the data source
  26479. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26480. * @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)
  26481. * @returns the current mesh
  26482. */
  26483. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26484. /**
  26485. * Creates new normals data for the mesh
  26486. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26487. * @returns the current mesh
  26488. */
  26489. createNormals(updatable: boolean): AbstractMesh;
  26490. /**
  26491. * Align the mesh with a normal
  26492. * @param normal defines the normal to use
  26493. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26494. * @returns the current mesh
  26495. */
  26496. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26497. /** @hidden */
  26498. _checkOcclusionQuery(): boolean;
  26499. /**
  26500. * Disables the mesh edge rendering mode
  26501. * @returns the currentAbstractMesh
  26502. */
  26503. disableEdgesRendering(): AbstractMesh;
  26504. /**
  26505. * Enables the edge rendering mode on the mesh.
  26506. * This mode makes the mesh edges visible
  26507. * @param epsilon defines the maximal distance between two angles to detect a face
  26508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26509. * @returns the currentAbstractMesh
  26510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26511. */
  26512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26513. }
  26514. }
  26515. declare module BABYLON {
  26516. /**
  26517. * Interface used to define ActionEvent
  26518. */
  26519. export interface IActionEvent {
  26520. /** The mesh or sprite that triggered the action */
  26521. source: any;
  26522. /** The X mouse cursor position at the time of the event */
  26523. pointerX: number;
  26524. /** The Y mouse cursor position at the time of the event */
  26525. pointerY: number;
  26526. /** The mesh that is currently pointed at (can be null) */
  26527. meshUnderPointer: Nullable<AbstractMesh>;
  26528. /** the original (browser) event that triggered the ActionEvent */
  26529. sourceEvent?: any;
  26530. /** additional data for the event */
  26531. additionalData?: any;
  26532. }
  26533. /**
  26534. * ActionEvent is the event being sent when an action is triggered.
  26535. */
  26536. export class ActionEvent implements IActionEvent {
  26537. /** The mesh or sprite that triggered the action */
  26538. source: any;
  26539. /** The X mouse cursor position at the time of the event */
  26540. pointerX: number;
  26541. /** The Y mouse cursor position at the time of the event */
  26542. pointerY: number;
  26543. /** The mesh that is currently pointed at (can be null) */
  26544. meshUnderPointer: Nullable<AbstractMesh>;
  26545. /** the original (browser) event that triggered the ActionEvent */
  26546. sourceEvent?: any;
  26547. /** additional data for the event */
  26548. additionalData?: any;
  26549. /**
  26550. * Creates a new ActionEvent
  26551. * @param source The mesh or sprite that triggered the action
  26552. * @param pointerX The X mouse cursor position at the time of the event
  26553. * @param pointerY The Y mouse cursor position at the time of the event
  26554. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26555. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26556. * @param additionalData additional data for the event
  26557. */
  26558. constructor(
  26559. /** The mesh or sprite that triggered the action */
  26560. source: any,
  26561. /** The X mouse cursor position at the time of the event */
  26562. pointerX: number,
  26563. /** The Y mouse cursor position at the time of the event */
  26564. pointerY: number,
  26565. /** The mesh that is currently pointed at (can be null) */
  26566. meshUnderPointer: Nullable<AbstractMesh>,
  26567. /** the original (browser) event that triggered the ActionEvent */
  26568. sourceEvent?: any,
  26569. /** additional data for the event */
  26570. additionalData?: any);
  26571. /**
  26572. * Helper function to auto-create an ActionEvent from a source mesh.
  26573. * @param source The source mesh that triggered the event
  26574. * @param evt The original (browser) event
  26575. * @param additionalData additional data for the event
  26576. * @returns the new ActionEvent
  26577. */
  26578. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26579. /**
  26580. * Helper function to auto-create an ActionEvent from a source sprite
  26581. * @param source The source sprite that triggered the event
  26582. * @param scene Scene associated with the sprite
  26583. * @param evt The original (browser) event
  26584. * @param additionalData additional data for the event
  26585. * @returns the new ActionEvent
  26586. */
  26587. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26588. /**
  26589. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26590. * @param scene the scene where the event occurred
  26591. * @param evt The original (browser) event
  26592. * @returns the new ActionEvent
  26593. */
  26594. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26595. /**
  26596. * Helper function to auto-create an ActionEvent from a primitive
  26597. * @param prim defines the target primitive
  26598. * @param pointerPos defines the pointer position
  26599. * @param evt The original (browser) event
  26600. * @param additionalData additional data for the event
  26601. * @returns the new ActionEvent
  26602. */
  26603. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26604. }
  26605. }
  26606. declare module BABYLON {
  26607. /**
  26608. * Abstract class used to decouple action Manager from scene and meshes.
  26609. * Do not instantiate.
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26611. */
  26612. export abstract class AbstractActionManager implements IDisposable {
  26613. /** Gets the list of active triggers */
  26614. static Triggers: {
  26615. [key: string]: number;
  26616. };
  26617. /** Gets the cursor to use when hovering items */
  26618. hoverCursor: string;
  26619. /** Gets the list of actions */
  26620. actions: IAction[];
  26621. /**
  26622. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26623. */
  26624. isRecursive: boolean;
  26625. /**
  26626. * Releases all associated resources
  26627. */
  26628. abstract dispose(): void;
  26629. /**
  26630. * Does this action manager has pointer triggers
  26631. */
  26632. abstract readonly hasPointerTriggers: boolean;
  26633. /**
  26634. * Does this action manager has pick triggers
  26635. */
  26636. abstract readonly hasPickTriggers: boolean;
  26637. /**
  26638. * Process a specific trigger
  26639. * @param trigger defines the trigger to process
  26640. * @param evt defines the event details to be processed
  26641. */
  26642. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26643. /**
  26644. * Does this action manager handles actions of any of the given triggers
  26645. * @param triggers defines the triggers to be tested
  26646. * @return a boolean indicating whether one (or more) of the triggers is handled
  26647. */
  26648. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26649. /**
  26650. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26651. * speed.
  26652. * @param triggerA defines the trigger to be tested
  26653. * @param triggerB defines the trigger to be tested
  26654. * @return a boolean indicating whether one (or more) of the triggers is handled
  26655. */
  26656. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26657. /**
  26658. * Does this action manager handles actions of a given trigger
  26659. * @param trigger defines the trigger to be tested
  26660. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26661. * @return whether the trigger is handled
  26662. */
  26663. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26664. /**
  26665. * Serialize this manager to a JSON object
  26666. * @param name defines the property name to store this manager
  26667. * @returns a JSON representation of this manager
  26668. */
  26669. abstract serialize(name: string): any;
  26670. /**
  26671. * Registers an action to this action manager
  26672. * @param action defines the action to be registered
  26673. * @return the action amended (prepared) after registration
  26674. */
  26675. abstract registerAction(action: IAction): Nullable<IAction>;
  26676. /**
  26677. * Unregisters an action to this action manager
  26678. * @param action defines the action to be unregistered
  26679. * @return a boolean indicating whether the action has been unregistered
  26680. */
  26681. abstract unregisterAction(action: IAction): Boolean;
  26682. /**
  26683. * Does exist one action manager with at least one trigger
  26684. **/
  26685. static readonly HasTriggers: boolean;
  26686. /**
  26687. * Does exist one action manager with at least one pick trigger
  26688. **/
  26689. static readonly HasPickTriggers: boolean;
  26690. /**
  26691. * Does exist one action manager that handles actions of a given trigger
  26692. * @param trigger defines the trigger to be tested
  26693. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26694. **/
  26695. static HasSpecificTrigger(trigger: number): boolean;
  26696. }
  26697. }
  26698. declare module BABYLON {
  26699. /**
  26700. * Defines how a node can be built from a string name.
  26701. */
  26702. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26703. /**
  26704. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26705. */
  26706. export class Node implements IBehaviorAware<Node> {
  26707. /** @hidden */
  26708. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26709. private static _NodeConstructors;
  26710. /**
  26711. * Add a new node constructor
  26712. * @param type defines the type name of the node to construct
  26713. * @param constructorFunc defines the constructor function
  26714. */
  26715. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26716. /**
  26717. * Returns a node constructor based on type name
  26718. * @param type defines the type name
  26719. * @param name defines the new node name
  26720. * @param scene defines the hosting scene
  26721. * @param options defines optional options to transmit to constructors
  26722. * @returns the new constructor or null
  26723. */
  26724. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26725. /**
  26726. * Gets or sets the name of the node
  26727. */
  26728. name: string;
  26729. /**
  26730. * Gets or sets the id of the node
  26731. */
  26732. id: string;
  26733. /**
  26734. * Gets or sets the unique id of the node
  26735. */
  26736. uniqueId: number;
  26737. /**
  26738. * Gets or sets a string used to store user defined state for the node
  26739. */
  26740. state: string;
  26741. /**
  26742. * Gets or sets an object used to store user defined information for the node
  26743. */
  26744. metadata: any;
  26745. /**
  26746. * For internal use only. Please do not use.
  26747. */
  26748. reservedDataStore: any;
  26749. /**
  26750. * List of inspectable custom properties (used by the Inspector)
  26751. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26752. */
  26753. inspectableCustomProperties: IInspectable[];
  26754. /**
  26755. * Gets or sets a boolean used to define if the node must be serialized
  26756. */
  26757. doNotSerialize: boolean;
  26758. /** @hidden */
  26759. _isDisposed: boolean;
  26760. /**
  26761. * Gets a list of Animations associated with the node
  26762. */
  26763. animations: Animation[];
  26764. protected _ranges: {
  26765. [name: string]: Nullable<AnimationRange>;
  26766. };
  26767. /**
  26768. * Callback raised when the node is ready to be used
  26769. */
  26770. onReady: Nullable<(node: Node) => void>;
  26771. private _isEnabled;
  26772. private _isParentEnabled;
  26773. private _isReady;
  26774. /** @hidden */
  26775. _currentRenderId: number;
  26776. private _parentUpdateId;
  26777. /** @hidden */
  26778. _childUpdateId: number;
  26779. /** @hidden */
  26780. _waitingParentId: Nullable<string>;
  26781. /** @hidden */
  26782. _scene: Scene;
  26783. /** @hidden */
  26784. _cache: any;
  26785. private _parentNode;
  26786. private _children;
  26787. /** @hidden */
  26788. _worldMatrix: Matrix;
  26789. /** @hidden */
  26790. _worldMatrixDeterminant: number;
  26791. /** @hidden */
  26792. _worldMatrixDeterminantIsDirty: boolean;
  26793. /** @hidden */
  26794. private _sceneRootNodesIndex;
  26795. /**
  26796. * Gets a boolean indicating if the node has been disposed
  26797. * @returns true if the node was disposed
  26798. */
  26799. isDisposed(): boolean;
  26800. /**
  26801. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26802. * @see https://doc.babylonjs.com/how_to/parenting
  26803. */
  26804. parent: Nullable<Node>;
  26805. private addToSceneRootNodes;
  26806. private removeFromSceneRootNodes;
  26807. private _animationPropertiesOverride;
  26808. /**
  26809. * Gets or sets the animation properties override
  26810. */
  26811. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26812. /**
  26813. * Gets a string idenfifying the name of the class
  26814. * @returns "Node" string
  26815. */
  26816. getClassName(): string;
  26817. /** @hidden */
  26818. readonly _isNode: boolean;
  26819. /**
  26820. * An event triggered when the mesh is disposed
  26821. */
  26822. onDisposeObservable: Observable<Node>;
  26823. private _onDisposeObserver;
  26824. /**
  26825. * Sets a callback that will be raised when the node will be disposed
  26826. */
  26827. onDispose: () => void;
  26828. /**
  26829. * Creates a new Node
  26830. * @param name the name and id to be given to this node
  26831. * @param scene the scene this node will be added to
  26832. * @param addToRootNodes the node will be added to scene.rootNodes
  26833. */
  26834. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26835. /**
  26836. * Gets the scene of the node
  26837. * @returns a scene
  26838. */
  26839. getScene(): Scene;
  26840. /**
  26841. * Gets the engine of the node
  26842. * @returns a Engine
  26843. */
  26844. getEngine(): Engine;
  26845. private _behaviors;
  26846. /**
  26847. * Attach a behavior to the node
  26848. * @see http://doc.babylonjs.com/features/behaviour
  26849. * @param behavior defines the behavior to attach
  26850. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26851. * @returns the current Node
  26852. */
  26853. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26854. /**
  26855. * Remove an attached behavior
  26856. * @see http://doc.babylonjs.com/features/behaviour
  26857. * @param behavior defines the behavior to attach
  26858. * @returns the current Node
  26859. */
  26860. removeBehavior(behavior: Behavior<Node>): Node;
  26861. /**
  26862. * Gets the list of attached behaviors
  26863. * @see http://doc.babylonjs.com/features/behaviour
  26864. */
  26865. readonly behaviors: Behavior<Node>[];
  26866. /**
  26867. * Gets an attached behavior by name
  26868. * @param name defines the name of the behavior to look for
  26869. * @see http://doc.babylonjs.com/features/behaviour
  26870. * @returns null if behavior was not found else the requested behavior
  26871. */
  26872. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26873. /**
  26874. * Returns the latest update of the World matrix
  26875. * @returns a Matrix
  26876. */
  26877. getWorldMatrix(): Matrix;
  26878. /** @hidden */
  26879. _getWorldMatrixDeterminant(): number;
  26880. /**
  26881. * Returns directly the latest state of the mesh World matrix.
  26882. * A Matrix is returned.
  26883. */
  26884. readonly worldMatrixFromCache: Matrix;
  26885. /** @hidden */
  26886. _initCache(): void;
  26887. /** @hidden */
  26888. updateCache(force?: boolean): void;
  26889. /** @hidden */
  26890. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26891. /** @hidden */
  26892. _updateCache(ignoreParentClass?: boolean): void;
  26893. /** @hidden */
  26894. _isSynchronized(): boolean;
  26895. /** @hidden */
  26896. _markSyncedWithParent(): void;
  26897. /** @hidden */
  26898. isSynchronizedWithParent(): boolean;
  26899. /** @hidden */
  26900. isSynchronized(): boolean;
  26901. /**
  26902. * Is this node ready to be used/rendered
  26903. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26904. * @return true if the node is ready
  26905. */
  26906. isReady(completeCheck?: boolean): boolean;
  26907. /**
  26908. * Is this node enabled?
  26909. * 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
  26910. * @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
  26911. * @return whether this node (and its parent) is enabled
  26912. */
  26913. isEnabled(checkAncestors?: boolean): boolean;
  26914. /** @hidden */
  26915. protected _syncParentEnabledState(): void;
  26916. /**
  26917. * Set the enabled state of this node
  26918. * @param value defines the new enabled state
  26919. */
  26920. setEnabled(value: boolean): void;
  26921. /**
  26922. * Is this node a descendant of the given node?
  26923. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26924. * @param ancestor defines the parent node to inspect
  26925. * @returns a boolean indicating if this node is a descendant of the given node
  26926. */
  26927. isDescendantOf(ancestor: Node): boolean;
  26928. /** @hidden */
  26929. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26930. /**
  26931. * Will return all nodes that have this node as ascendant
  26932. * @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
  26933. * @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
  26934. * @return all children nodes of all types
  26935. */
  26936. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26937. /**
  26938. * Get all child-meshes of this node
  26939. * @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)
  26940. * @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
  26941. * @returns an array of AbstractMesh
  26942. */
  26943. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26944. /**
  26945. * Get all direct children of this node
  26946. * @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
  26947. * @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)
  26948. * @returns an array of Node
  26949. */
  26950. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26951. /** @hidden */
  26952. _setReady(state: boolean): void;
  26953. /**
  26954. * Get an animation by name
  26955. * @param name defines the name of the animation to look for
  26956. * @returns null if not found else the requested animation
  26957. */
  26958. getAnimationByName(name: string): Nullable<Animation>;
  26959. /**
  26960. * Creates an animation range for this node
  26961. * @param name defines the name of the range
  26962. * @param from defines the starting key
  26963. * @param to defines the end key
  26964. */
  26965. createAnimationRange(name: string, from: number, to: number): void;
  26966. /**
  26967. * Delete a specific animation range
  26968. * @param name defines the name of the range to delete
  26969. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26970. */
  26971. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26972. /**
  26973. * Get an animation range by name
  26974. * @param name defines the name of the animation range to look for
  26975. * @returns null if not found else the requested animation range
  26976. */
  26977. getAnimationRange(name: string): Nullable<AnimationRange>;
  26978. /**
  26979. * Gets the list of all animation ranges defined on this node
  26980. * @returns an array
  26981. */
  26982. getAnimationRanges(): Nullable<AnimationRange>[];
  26983. /**
  26984. * Will start the animation sequence
  26985. * @param name defines the range frames for animation sequence
  26986. * @param loop defines if the animation should loop (false by default)
  26987. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26988. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26989. * @returns the object created for this animation. If range does not exist, it will return null
  26990. */
  26991. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26992. /**
  26993. * Serialize animation ranges into a JSON compatible object
  26994. * @returns serialization object
  26995. */
  26996. serializeAnimationRanges(): any;
  26997. /**
  26998. * Computes the world matrix of the node
  26999. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27000. * @returns the world matrix
  27001. */
  27002. computeWorldMatrix(force?: boolean): Matrix;
  27003. /**
  27004. * Releases resources associated with this node.
  27005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27007. */
  27008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27009. /**
  27010. * Parse animation range data from a serialization object and store them into a given node
  27011. * @param node defines where to store the animation ranges
  27012. * @param parsedNode defines the serialization object to read data from
  27013. * @param scene defines the hosting scene
  27014. */
  27015. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27016. /**
  27017. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27018. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27019. * @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
  27020. * @returns the new bounding vectors
  27021. */
  27022. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27023. min: Vector3;
  27024. max: Vector3;
  27025. };
  27026. }
  27027. }
  27028. declare module BABYLON {
  27029. /**
  27030. * @hidden
  27031. */
  27032. export class _IAnimationState {
  27033. key: number;
  27034. repeatCount: number;
  27035. workValue?: any;
  27036. loopMode?: number;
  27037. offsetValue?: any;
  27038. highLimitValue?: any;
  27039. }
  27040. /**
  27041. * Class used to store any kind of animation
  27042. */
  27043. export class Animation {
  27044. /**Name of the animation */
  27045. name: string;
  27046. /**Property to animate */
  27047. targetProperty: string;
  27048. /**The frames per second of the animation */
  27049. framePerSecond: number;
  27050. /**The data type of the animation */
  27051. dataType: number;
  27052. /**The loop mode of the animation */
  27053. loopMode?: number | undefined;
  27054. /**Specifies if blending should be enabled */
  27055. enableBlending?: boolean | undefined;
  27056. /**
  27057. * Use matrix interpolation instead of using direct key value when animating matrices
  27058. */
  27059. static AllowMatricesInterpolation: boolean;
  27060. /**
  27061. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27062. */
  27063. static AllowMatrixDecomposeForInterpolation: boolean;
  27064. /**
  27065. * Stores the key frames of the animation
  27066. */
  27067. private _keys;
  27068. /**
  27069. * Stores the easing function of the animation
  27070. */
  27071. private _easingFunction;
  27072. /**
  27073. * @hidden Internal use only
  27074. */
  27075. _runtimeAnimations: RuntimeAnimation[];
  27076. /**
  27077. * The set of event that will be linked to this animation
  27078. */
  27079. private _events;
  27080. /**
  27081. * Stores an array of target property paths
  27082. */
  27083. targetPropertyPath: string[];
  27084. /**
  27085. * Stores the blending speed of the animation
  27086. */
  27087. blendingSpeed: number;
  27088. /**
  27089. * Stores the animation ranges for the animation
  27090. */
  27091. private _ranges;
  27092. /**
  27093. * @hidden Internal use
  27094. */
  27095. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27096. /**
  27097. * Sets up an animation
  27098. * @param property The property to animate
  27099. * @param animationType The animation type to apply
  27100. * @param framePerSecond The frames per second of the animation
  27101. * @param easingFunction The easing function used in the animation
  27102. * @returns The created animation
  27103. */
  27104. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27105. /**
  27106. * Create and start an animation on a node
  27107. * @param name defines the name of the global animation that will be run on all nodes
  27108. * @param node defines the root node where the animation will take place
  27109. * @param targetProperty defines property to animate
  27110. * @param framePerSecond defines the number of frame per second yo use
  27111. * @param totalFrame defines the number of frames in total
  27112. * @param from defines the initial value
  27113. * @param to defines the final value
  27114. * @param loopMode defines which loop mode you want to use (off by default)
  27115. * @param easingFunction defines the easing function to use (linear by default)
  27116. * @param onAnimationEnd defines the callback to call when animation end
  27117. * @returns the animatable created for this animation
  27118. */
  27119. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27120. /**
  27121. * Create and start an animation on a node and its descendants
  27122. * @param name defines the name of the global animation that will be run on all nodes
  27123. * @param node defines the root node where the animation will take place
  27124. * @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
  27125. * @param targetProperty defines property to animate
  27126. * @param framePerSecond defines the number of frame per second to use
  27127. * @param totalFrame defines the number of frames in total
  27128. * @param from defines the initial value
  27129. * @param to defines the final value
  27130. * @param loopMode defines which loop mode you want to use (off by default)
  27131. * @param easingFunction defines the easing function to use (linear by default)
  27132. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27133. * @returns the list of animatables created for all nodes
  27134. * @example https://www.babylonjs-playground.com/#MH0VLI
  27135. */
  27136. 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[]>;
  27137. /**
  27138. * Creates a new animation, merges it with the existing animations and starts it
  27139. * @param name Name of the animation
  27140. * @param node Node which contains the scene that begins the animations
  27141. * @param targetProperty Specifies which property to animate
  27142. * @param framePerSecond The frames per second of the animation
  27143. * @param totalFrame The total number of frames
  27144. * @param from The frame at the beginning of the animation
  27145. * @param to The frame at the end of the animation
  27146. * @param loopMode Specifies the loop mode of the animation
  27147. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27148. * @param onAnimationEnd Callback to run once the animation is complete
  27149. * @returns Nullable animation
  27150. */
  27151. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27152. /**
  27153. * Transition property of an host to the target Value
  27154. * @param property The property to transition
  27155. * @param targetValue The target Value of the property
  27156. * @param host The object where the property to animate belongs
  27157. * @param scene Scene used to run the animation
  27158. * @param frameRate Framerate (in frame/s) to use
  27159. * @param transition The transition type we want to use
  27160. * @param duration The duration of the animation, in milliseconds
  27161. * @param onAnimationEnd Callback trigger at the end of the animation
  27162. * @returns Nullable animation
  27163. */
  27164. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27165. /**
  27166. * Return the array of runtime animations currently using this animation
  27167. */
  27168. readonly runtimeAnimations: RuntimeAnimation[];
  27169. /**
  27170. * Specifies if any of the runtime animations are currently running
  27171. */
  27172. readonly hasRunningRuntimeAnimations: boolean;
  27173. /**
  27174. * Initializes the animation
  27175. * @param name Name of the animation
  27176. * @param targetProperty Property to animate
  27177. * @param framePerSecond The frames per second of the animation
  27178. * @param dataType The data type of the animation
  27179. * @param loopMode The loop mode of the animation
  27180. * @param enableBlending Specifies if blending should be enabled
  27181. */
  27182. constructor(
  27183. /**Name of the animation */
  27184. name: string,
  27185. /**Property to animate */
  27186. targetProperty: string,
  27187. /**The frames per second of the animation */
  27188. framePerSecond: number,
  27189. /**The data type of the animation */
  27190. dataType: number,
  27191. /**The loop mode of the animation */
  27192. loopMode?: number | undefined,
  27193. /**Specifies if blending should be enabled */
  27194. enableBlending?: boolean | undefined);
  27195. /**
  27196. * Converts the animation to a string
  27197. * @param fullDetails support for multiple levels of logging within scene loading
  27198. * @returns String form of the animation
  27199. */
  27200. toString(fullDetails?: boolean): string;
  27201. /**
  27202. * Add an event to this animation
  27203. * @param event Event to add
  27204. */
  27205. addEvent(event: AnimationEvent): void;
  27206. /**
  27207. * Remove all events found at the given frame
  27208. * @param frame The frame to remove events from
  27209. */
  27210. removeEvents(frame: number): void;
  27211. /**
  27212. * Retrieves all the events from the animation
  27213. * @returns Events from the animation
  27214. */
  27215. getEvents(): AnimationEvent[];
  27216. /**
  27217. * Creates an animation range
  27218. * @param name Name of the animation range
  27219. * @param from Starting frame of the animation range
  27220. * @param to Ending frame of the animation
  27221. */
  27222. createRange(name: string, from: number, to: number): void;
  27223. /**
  27224. * Deletes an animation range by name
  27225. * @param name Name of the animation range to delete
  27226. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27227. */
  27228. deleteRange(name: string, deleteFrames?: boolean): void;
  27229. /**
  27230. * Gets the animation range by name, or null if not defined
  27231. * @param name Name of the animation range
  27232. * @returns Nullable animation range
  27233. */
  27234. getRange(name: string): Nullable<AnimationRange>;
  27235. /**
  27236. * Gets the key frames from the animation
  27237. * @returns The key frames of the animation
  27238. */
  27239. getKeys(): Array<IAnimationKey>;
  27240. /**
  27241. * Gets the highest frame rate of the animation
  27242. * @returns Highest frame rate of the animation
  27243. */
  27244. getHighestFrame(): number;
  27245. /**
  27246. * Gets the easing function of the animation
  27247. * @returns Easing function of the animation
  27248. */
  27249. getEasingFunction(): IEasingFunction;
  27250. /**
  27251. * Sets the easing function of the animation
  27252. * @param easingFunction A custom mathematical formula for animation
  27253. */
  27254. setEasingFunction(easingFunction: EasingFunction): void;
  27255. /**
  27256. * Interpolates a scalar linearly
  27257. * @param startValue Start value of the animation curve
  27258. * @param endValue End value of the animation curve
  27259. * @param gradient Scalar amount to interpolate
  27260. * @returns Interpolated scalar value
  27261. */
  27262. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27263. /**
  27264. * Interpolates a scalar cubically
  27265. * @param startValue Start value of the animation curve
  27266. * @param outTangent End tangent of the animation
  27267. * @param endValue End value of the animation curve
  27268. * @param inTangent Start tangent of the animation curve
  27269. * @param gradient Scalar amount to interpolate
  27270. * @returns Interpolated scalar value
  27271. */
  27272. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27273. /**
  27274. * Interpolates a quaternion using a spherical linear interpolation
  27275. * @param startValue Start value of the animation curve
  27276. * @param endValue End value of the animation curve
  27277. * @param gradient Scalar amount to interpolate
  27278. * @returns Interpolated quaternion value
  27279. */
  27280. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27281. /**
  27282. * Interpolates a quaternion cubically
  27283. * @param startValue Start value of the animation curve
  27284. * @param outTangent End tangent of the animation curve
  27285. * @param endValue End value of the animation curve
  27286. * @param inTangent Start tangent of the animation curve
  27287. * @param gradient Scalar amount to interpolate
  27288. * @returns Interpolated quaternion value
  27289. */
  27290. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27291. /**
  27292. * Interpolates a Vector3 linearl
  27293. * @param startValue Start value of the animation curve
  27294. * @param endValue End value of the animation curve
  27295. * @param gradient Scalar amount to interpolate
  27296. * @returns Interpolated scalar value
  27297. */
  27298. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27299. /**
  27300. * Interpolates a Vector3 cubically
  27301. * @param startValue Start value of the animation curve
  27302. * @param outTangent End tangent of the animation
  27303. * @param endValue End value of the animation curve
  27304. * @param inTangent Start tangent of the animation curve
  27305. * @param gradient Scalar amount to interpolate
  27306. * @returns InterpolatedVector3 value
  27307. */
  27308. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27309. /**
  27310. * Interpolates a Vector2 linearly
  27311. * @param startValue Start value of the animation curve
  27312. * @param endValue End value of the animation curve
  27313. * @param gradient Scalar amount to interpolate
  27314. * @returns Interpolated Vector2 value
  27315. */
  27316. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27317. /**
  27318. * Interpolates a Vector2 cubically
  27319. * @param startValue Start value of the animation curve
  27320. * @param outTangent End tangent of the animation
  27321. * @param endValue End value of the animation curve
  27322. * @param inTangent Start tangent of the animation curve
  27323. * @param gradient Scalar amount to interpolate
  27324. * @returns Interpolated Vector2 value
  27325. */
  27326. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27327. /**
  27328. * Interpolates a size linearly
  27329. * @param startValue Start value of the animation curve
  27330. * @param endValue End value of the animation curve
  27331. * @param gradient Scalar amount to interpolate
  27332. * @returns Interpolated Size value
  27333. */
  27334. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27335. /**
  27336. * Interpolates a Color3 linearly
  27337. * @param startValue Start value of the animation curve
  27338. * @param endValue End value of the animation curve
  27339. * @param gradient Scalar amount to interpolate
  27340. * @returns Interpolated Color3 value
  27341. */
  27342. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27343. /**
  27344. * @hidden Internal use only
  27345. */
  27346. _getKeyValue(value: any): any;
  27347. /**
  27348. * @hidden Internal use only
  27349. */
  27350. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27351. /**
  27352. * Defines the function to use to interpolate matrices
  27353. * @param startValue defines the start matrix
  27354. * @param endValue defines the end matrix
  27355. * @param gradient defines the gradient between both matrices
  27356. * @param result defines an optional target matrix where to store the interpolation
  27357. * @returns the interpolated matrix
  27358. */
  27359. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27360. /**
  27361. * Makes a copy of the animation
  27362. * @returns Cloned animation
  27363. */
  27364. clone(): Animation;
  27365. /**
  27366. * Sets the key frames of the animation
  27367. * @param values The animation key frames to set
  27368. */
  27369. setKeys(values: Array<IAnimationKey>): void;
  27370. /**
  27371. * Serializes the animation to an object
  27372. * @returns Serialized object
  27373. */
  27374. serialize(): any;
  27375. /**
  27376. * Float animation type
  27377. */
  27378. private static _ANIMATIONTYPE_FLOAT;
  27379. /**
  27380. * Vector3 animation type
  27381. */
  27382. private static _ANIMATIONTYPE_VECTOR3;
  27383. /**
  27384. * Quaternion animation type
  27385. */
  27386. private static _ANIMATIONTYPE_QUATERNION;
  27387. /**
  27388. * Matrix animation type
  27389. */
  27390. private static _ANIMATIONTYPE_MATRIX;
  27391. /**
  27392. * Color3 animation type
  27393. */
  27394. private static _ANIMATIONTYPE_COLOR3;
  27395. /**
  27396. * Vector2 animation type
  27397. */
  27398. private static _ANIMATIONTYPE_VECTOR2;
  27399. /**
  27400. * Size animation type
  27401. */
  27402. private static _ANIMATIONTYPE_SIZE;
  27403. /**
  27404. * Relative Loop Mode
  27405. */
  27406. private static _ANIMATIONLOOPMODE_RELATIVE;
  27407. /**
  27408. * Cycle Loop Mode
  27409. */
  27410. private static _ANIMATIONLOOPMODE_CYCLE;
  27411. /**
  27412. * Constant Loop Mode
  27413. */
  27414. private static _ANIMATIONLOOPMODE_CONSTANT;
  27415. /**
  27416. * Get the float animation type
  27417. */
  27418. static readonly ANIMATIONTYPE_FLOAT: number;
  27419. /**
  27420. * Get the Vector3 animation type
  27421. */
  27422. static readonly ANIMATIONTYPE_VECTOR3: number;
  27423. /**
  27424. * Get the Vector2 animation type
  27425. */
  27426. static readonly ANIMATIONTYPE_VECTOR2: number;
  27427. /**
  27428. * Get the Size animation type
  27429. */
  27430. static readonly ANIMATIONTYPE_SIZE: number;
  27431. /**
  27432. * Get the Quaternion animation type
  27433. */
  27434. static readonly ANIMATIONTYPE_QUATERNION: number;
  27435. /**
  27436. * Get the Matrix animation type
  27437. */
  27438. static readonly ANIMATIONTYPE_MATRIX: number;
  27439. /**
  27440. * Get the Color3 animation type
  27441. */
  27442. static readonly ANIMATIONTYPE_COLOR3: number;
  27443. /**
  27444. * Get the Relative Loop Mode
  27445. */
  27446. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27447. /**
  27448. * Get the Cycle Loop Mode
  27449. */
  27450. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27451. /**
  27452. * Get the Constant Loop Mode
  27453. */
  27454. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27455. /** @hidden */
  27456. static _UniversalLerp(left: any, right: any, amount: number): any;
  27457. /**
  27458. * Parses an animation object and creates an animation
  27459. * @param parsedAnimation Parsed animation object
  27460. * @returns Animation object
  27461. */
  27462. static Parse(parsedAnimation: any): Animation;
  27463. /**
  27464. * Appends the serialized animations from the source animations
  27465. * @param source Source containing the animations
  27466. * @param destination Target to store the animations
  27467. */
  27468. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27469. }
  27470. }
  27471. declare module BABYLON {
  27472. /**
  27473. * Interface containing an array of animations
  27474. */
  27475. export interface IAnimatable {
  27476. /**
  27477. * Array of animations
  27478. */
  27479. animations: Nullable<Array<Animation>>;
  27480. }
  27481. }
  27482. declare module BABYLON {
  27483. /**
  27484. * This represents all the required information to add a fresnel effect on a material:
  27485. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27486. */
  27487. export class FresnelParameters {
  27488. private _isEnabled;
  27489. /**
  27490. * Define if the fresnel effect is enable or not.
  27491. */
  27492. isEnabled: boolean;
  27493. /**
  27494. * Define the color used on edges (grazing angle)
  27495. */
  27496. leftColor: Color3;
  27497. /**
  27498. * Define the color used on center
  27499. */
  27500. rightColor: Color3;
  27501. /**
  27502. * Define bias applied to computed fresnel term
  27503. */
  27504. bias: number;
  27505. /**
  27506. * Defined the power exponent applied to fresnel term
  27507. */
  27508. power: number;
  27509. /**
  27510. * Clones the current fresnel and its valuues
  27511. * @returns a clone fresnel configuration
  27512. */
  27513. clone(): FresnelParameters;
  27514. /**
  27515. * Serializes the current fresnel parameters to a JSON representation.
  27516. * @return the JSON serialization
  27517. */
  27518. serialize(): any;
  27519. /**
  27520. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27521. * @param parsedFresnelParameters Define the JSON representation
  27522. * @returns the parsed parameters
  27523. */
  27524. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27525. }
  27526. }
  27527. declare module BABYLON {
  27528. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27529. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27530. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27531. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27532. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27533. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27534. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27535. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27536. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27537. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27538. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27539. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27540. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27541. /**
  27542. * Decorator used to define property that can be serialized as reference to a camera
  27543. * @param sourceName defines the name of the property to decorate
  27544. */
  27545. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27546. /**
  27547. * Class used to help serialization objects
  27548. */
  27549. export class SerializationHelper {
  27550. /** @hidden */
  27551. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27552. /** @hidden */
  27553. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27554. /** @hidden */
  27555. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27556. /** @hidden */
  27557. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27558. /**
  27559. * Appends the serialized animations from the source animations
  27560. * @param source Source containing the animations
  27561. * @param destination Target to store the animations
  27562. */
  27563. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27564. /**
  27565. * Static function used to serialized a specific entity
  27566. * @param entity defines the entity to serialize
  27567. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27568. * @returns a JSON compatible object representing the serialization of the entity
  27569. */
  27570. static Serialize<T>(entity: T, serializationObject?: any): any;
  27571. /**
  27572. * Creates a new entity from a serialization data object
  27573. * @param creationFunction defines a function used to instanciated the new entity
  27574. * @param source defines the source serialization data
  27575. * @param scene defines the hosting scene
  27576. * @param rootUrl defines the root url for resources
  27577. * @returns a new entity
  27578. */
  27579. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27580. /**
  27581. * Clones an object
  27582. * @param creationFunction defines the function used to instanciate the new object
  27583. * @param source defines the source object
  27584. * @returns the cloned object
  27585. */
  27586. static Clone<T>(creationFunction: () => T, source: T): T;
  27587. /**
  27588. * Instanciates a new object based on a source one (some data will be shared between both object)
  27589. * @param creationFunction defines the function used to instanciate the new object
  27590. * @param source defines the source object
  27591. * @returns the new object
  27592. */
  27593. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27594. }
  27595. }
  27596. declare module BABYLON {
  27597. /**
  27598. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27599. */
  27600. export interface CubeMapInfo {
  27601. /**
  27602. * The pixel array for the front face.
  27603. * This is stored in format, left to right, up to down format.
  27604. */
  27605. front: Nullable<ArrayBufferView>;
  27606. /**
  27607. * The pixel array for the back face.
  27608. * This is stored in format, left to right, up to down format.
  27609. */
  27610. back: Nullable<ArrayBufferView>;
  27611. /**
  27612. * The pixel array for the left face.
  27613. * This is stored in format, left to right, up to down format.
  27614. */
  27615. left: Nullable<ArrayBufferView>;
  27616. /**
  27617. * The pixel array for the right face.
  27618. * This is stored in format, left to right, up to down format.
  27619. */
  27620. right: Nullable<ArrayBufferView>;
  27621. /**
  27622. * The pixel array for the up face.
  27623. * This is stored in format, left to right, up to down format.
  27624. */
  27625. up: Nullable<ArrayBufferView>;
  27626. /**
  27627. * The pixel array for the down face.
  27628. * This is stored in format, left to right, up to down format.
  27629. */
  27630. down: Nullable<ArrayBufferView>;
  27631. /**
  27632. * The size of the cubemap stored.
  27633. *
  27634. * Each faces will be size * size pixels.
  27635. */
  27636. size: number;
  27637. /**
  27638. * The format of the texture.
  27639. *
  27640. * RGBA, RGB.
  27641. */
  27642. format: number;
  27643. /**
  27644. * The type of the texture data.
  27645. *
  27646. * UNSIGNED_INT, FLOAT.
  27647. */
  27648. type: number;
  27649. /**
  27650. * Specifies whether the texture is in gamma space.
  27651. */
  27652. gammaSpace: boolean;
  27653. }
  27654. /**
  27655. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27656. */
  27657. export class PanoramaToCubeMapTools {
  27658. private static FACE_FRONT;
  27659. private static FACE_BACK;
  27660. private static FACE_RIGHT;
  27661. private static FACE_LEFT;
  27662. private static FACE_DOWN;
  27663. private static FACE_UP;
  27664. /**
  27665. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27666. *
  27667. * @param float32Array The source data.
  27668. * @param inputWidth The width of the input panorama.
  27669. * @param inputHeight The height of the input panorama.
  27670. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27671. * @return The cubemap data
  27672. */
  27673. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27674. private static CreateCubemapTexture;
  27675. private static CalcProjectionSpherical;
  27676. }
  27677. }
  27678. declare module BABYLON {
  27679. /**
  27680. * Helper class dealing with the extraction of spherical polynomial dataArray
  27681. * from a cube map.
  27682. */
  27683. export class CubeMapToSphericalPolynomialTools {
  27684. private static FileFaces;
  27685. /**
  27686. * Converts a texture to the according Spherical Polynomial data.
  27687. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27688. *
  27689. * @param texture The texture to extract the information from.
  27690. * @return The Spherical Polynomial data.
  27691. */
  27692. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27693. /**
  27694. * Converts a cubemap to the according Spherical Polynomial data.
  27695. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27696. *
  27697. * @param cubeInfo The Cube map to extract the information from.
  27698. * @return The Spherical Polynomial data.
  27699. */
  27700. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27701. }
  27702. }
  27703. declare module BABYLON {
  27704. /**
  27705. * Class used to manipulate GUIDs
  27706. */
  27707. export class GUID {
  27708. /**
  27709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27710. * Be aware Math.random() could cause collisions, but:
  27711. * "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"
  27712. * @returns a pseudo random id
  27713. */
  27714. static RandomId(): string;
  27715. }
  27716. }
  27717. declare module BABYLON {
  27718. /**
  27719. * Base class of all the textures in babylon.
  27720. * It groups all the common properties the materials, post process, lights... might need
  27721. * in order to make a correct use of the texture.
  27722. */
  27723. export class BaseTexture implements IAnimatable {
  27724. /**
  27725. * Default anisotropic filtering level for the application.
  27726. * It is set to 4 as a good tradeoff between perf and quality.
  27727. */
  27728. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27729. /**
  27730. * Gets or sets the unique id of the texture
  27731. */
  27732. uniqueId: number;
  27733. /**
  27734. * Define the name of the texture.
  27735. */
  27736. name: string;
  27737. /**
  27738. * Gets or sets an object used to store user defined information.
  27739. */
  27740. metadata: any;
  27741. /**
  27742. * For internal use only. Please do not use.
  27743. */
  27744. reservedDataStore: any;
  27745. private _hasAlpha;
  27746. /**
  27747. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27748. */
  27749. hasAlpha: boolean;
  27750. /**
  27751. * Defines if the alpha value should be determined via the rgb values.
  27752. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27753. */
  27754. getAlphaFromRGB: boolean;
  27755. /**
  27756. * Intensity or strength of the texture.
  27757. * It is commonly used by materials to fine tune the intensity of the texture
  27758. */
  27759. level: number;
  27760. /**
  27761. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27762. * This is part of the texture as textures usually maps to one uv set.
  27763. */
  27764. coordinatesIndex: number;
  27765. private _coordinatesMode;
  27766. /**
  27767. * How a texture is mapped.
  27768. *
  27769. * | Value | Type | Description |
  27770. * | ----- | ----------------------------------- | ----------- |
  27771. * | 0 | EXPLICIT_MODE | |
  27772. * | 1 | SPHERICAL_MODE | |
  27773. * | 2 | PLANAR_MODE | |
  27774. * | 3 | CUBIC_MODE | |
  27775. * | 4 | PROJECTION_MODE | |
  27776. * | 5 | SKYBOX_MODE | |
  27777. * | 6 | INVCUBIC_MODE | |
  27778. * | 7 | EQUIRECTANGULAR_MODE | |
  27779. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27780. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27781. */
  27782. coordinatesMode: number;
  27783. /**
  27784. * | Value | Type | Description |
  27785. * | ----- | ------------------ | ----------- |
  27786. * | 0 | CLAMP_ADDRESSMODE | |
  27787. * | 1 | WRAP_ADDRESSMODE | |
  27788. * | 2 | MIRROR_ADDRESSMODE | |
  27789. */
  27790. wrapU: number;
  27791. /**
  27792. * | Value | Type | Description |
  27793. * | ----- | ------------------ | ----------- |
  27794. * | 0 | CLAMP_ADDRESSMODE | |
  27795. * | 1 | WRAP_ADDRESSMODE | |
  27796. * | 2 | MIRROR_ADDRESSMODE | |
  27797. */
  27798. wrapV: number;
  27799. /**
  27800. * | Value | Type | Description |
  27801. * | ----- | ------------------ | ----------- |
  27802. * | 0 | CLAMP_ADDRESSMODE | |
  27803. * | 1 | WRAP_ADDRESSMODE | |
  27804. * | 2 | MIRROR_ADDRESSMODE | |
  27805. */
  27806. wrapR: number;
  27807. /**
  27808. * With compliant hardware and browser (supporting anisotropic filtering)
  27809. * this defines the level of anisotropic filtering in the texture.
  27810. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27811. */
  27812. anisotropicFilteringLevel: number;
  27813. /**
  27814. * Define if the texture is a cube texture or if false a 2d texture.
  27815. */
  27816. isCube: boolean;
  27817. /**
  27818. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27819. */
  27820. is3D: boolean;
  27821. /**
  27822. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27823. * HDR texture are usually stored in linear space.
  27824. * This only impacts the PBR and Background materials
  27825. */
  27826. gammaSpace: boolean;
  27827. /**
  27828. * Gets or sets whether or not the texture contains RGBD data.
  27829. */
  27830. isRGBD: boolean;
  27831. /**
  27832. * Is Z inverted in the texture (useful in a cube texture).
  27833. */
  27834. invertZ: boolean;
  27835. /**
  27836. * Are mip maps generated for this texture or not.
  27837. */
  27838. readonly noMipmap: boolean;
  27839. /**
  27840. * @hidden
  27841. */
  27842. lodLevelInAlpha: boolean;
  27843. /**
  27844. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27845. */
  27846. lodGenerationOffset: number;
  27847. /**
  27848. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27849. */
  27850. lodGenerationScale: number;
  27851. /**
  27852. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27853. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27854. * average roughness values.
  27855. */
  27856. linearSpecularLOD: boolean;
  27857. /**
  27858. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27859. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27860. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27861. */
  27862. irradianceTexture: Nullable<BaseTexture>;
  27863. /**
  27864. * Define if the texture is a render target.
  27865. */
  27866. isRenderTarget: boolean;
  27867. /**
  27868. * Define the unique id of the texture in the scene.
  27869. */
  27870. readonly uid: string;
  27871. /**
  27872. * Return a string representation of the texture.
  27873. * @returns the texture as a string
  27874. */
  27875. toString(): string;
  27876. /**
  27877. * Get the class name of the texture.
  27878. * @returns "BaseTexture"
  27879. */
  27880. getClassName(): string;
  27881. /**
  27882. * Define the list of animation attached to the texture.
  27883. */
  27884. animations: Animation[];
  27885. /**
  27886. * An event triggered when the texture is disposed.
  27887. */
  27888. onDisposeObservable: Observable<BaseTexture>;
  27889. private _onDisposeObserver;
  27890. /**
  27891. * Callback triggered when the texture has been disposed.
  27892. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27893. */
  27894. onDispose: () => void;
  27895. /**
  27896. * Define the current state of the loading sequence when in delayed load mode.
  27897. */
  27898. delayLoadState: number;
  27899. private _scene;
  27900. /** @hidden */
  27901. _texture: Nullable<InternalTexture>;
  27902. private _uid;
  27903. /**
  27904. * Define if the texture is preventinga material to render or not.
  27905. * If not and the texture is not ready, the engine will use a default black texture instead.
  27906. */
  27907. readonly isBlocking: boolean;
  27908. /**
  27909. * Instantiates a new BaseTexture.
  27910. * Base class of all the textures in babylon.
  27911. * It groups all the common properties the materials, post process, lights... might need
  27912. * in order to make a correct use of the texture.
  27913. * @param scene Define the scene the texture blongs to
  27914. */
  27915. constructor(scene: Nullable<Scene>);
  27916. /**
  27917. * Get the scene the texture belongs to.
  27918. * @returns the scene or null if undefined
  27919. */
  27920. getScene(): Nullable<Scene>;
  27921. /**
  27922. * Get the texture transform matrix used to offset tile the texture for istance.
  27923. * @returns the transformation matrix
  27924. */
  27925. getTextureMatrix(): Matrix;
  27926. /**
  27927. * Get the texture reflection matrix used to rotate/transform the reflection.
  27928. * @returns the reflection matrix
  27929. */
  27930. getReflectionTextureMatrix(): Matrix;
  27931. /**
  27932. * Get the underlying lower level texture from Babylon.
  27933. * @returns the insternal texture
  27934. */
  27935. getInternalTexture(): Nullable<InternalTexture>;
  27936. /**
  27937. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27938. * @returns true if ready or not blocking
  27939. */
  27940. isReadyOrNotBlocking(): boolean;
  27941. /**
  27942. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27943. * @returns true if fully ready
  27944. */
  27945. isReady(): boolean;
  27946. private _cachedSize;
  27947. /**
  27948. * Get the size of the texture.
  27949. * @returns the texture size.
  27950. */
  27951. getSize(): ISize;
  27952. /**
  27953. * Get the base size of the texture.
  27954. * It can be different from the size if the texture has been resized for POT for instance
  27955. * @returns the base size
  27956. */
  27957. getBaseSize(): ISize;
  27958. /**
  27959. * Update the sampling mode of the texture.
  27960. * Default is Trilinear mode.
  27961. *
  27962. * | Value | Type | Description |
  27963. * | ----- | ------------------ | ----------- |
  27964. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27965. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27966. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27967. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27968. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27969. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27970. * | 7 | NEAREST_LINEAR | |
  27971. * | 8 | NEAREST_NEAREST | |
  27972. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27973. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27974. * | 11 | LINEAR_LINEAR | |
  27975. * | 12 | LINEAR_NEAREST | |
  27976. *
  27977. * > _mag_: magnification filter (close to the viewer)
  27978. * > _min_: minification filter (far from the viewer)
  27979. * > _mip_: filter used between mip map levels
  27980. *@param samplingMode Define the new sampling mode of the texture
  27981. */
  27982. updateSamplingMode(samplingMode: number): void;
  27983. /**
  27984. * Scales the texture if is `canRescale()`
  27985. * @param ratio the resize factor we want to use to rescale
  27986. */
  27987. scale(ratio: number): void;
  27988. /**
  27989. * Get if the texture can rescale.
  27990. */
  27991. readonly canRescale: boolean;
  27992. /** @hidden */
  27993. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27994. /** @hidden */
  27995. _rebuild(): void;
  27996. /**
  27997. * Triggers the load sequence in delayed load mode.
  27998. */
  27999. delayLoad(): void;
  28000. /**
  28001. * Clones the texture.
  28002. * @returns the cloned texture
  28003. */
  28004. clone(): Nullable<BaseTexture>;
  28005. /**
  28006. * Get the texture underlying type (INT, FLOAT...)
  28007. */
  28008. readonly textureType: number;
  28009. /**
  28010. * Get the texture underlying format (RGB, RGBA...)
  28011. */
  28012. readonly textureFormat: number;
  28013. /**
  28014. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28015. * This will returns an RGBA array buffer containing either in values (0-255) or
  28016. * float values (0-1) depending of the underlying buffer type.
  28017. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28018. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28019. * @param buffer defines a user defined buffer to fill with data (can be null)
  28020. * @returns The Array buffer containing the pixels data.
  28021. */
  28022. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28023. /**
  28024. * Release and destroy the underlying lower level texture aka internalTexture.
  28025. */
  28026. releaseInternalTexture(): void;
  28027. /**
  28028. * Get the polynomial representation of the texture data.
  28029. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28030. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28031. */
  28032. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28033. /** @hidden */
  28034. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28035. /** @hidden */
  28036. readonly _lodTextureMid: Nullable<BaseTexture>;
  28037. /** @hidden */
  28038. readonly _lodTextureLow: Nullable<BaseTexture>;
  28039. /**
  28040. * Dispose the texture and release its associated resources.
  28041. */
  28042. dispose(): void;
  28043. /**
  28044. * Serialize the texture into a JSON representation that can be parsed later on.
  28045. * @returns the JSON representation of the texture
  28046. */
  28047. serialize(): any;
  28048. /**
  28049. * Helper function to be called back once a list of texture contains only ready textures.
  28050. * @param textures Define the list of textures to wait for
  28051. * @param callback Define the callback triggered once the entire list will be ready
  28052. */
  28053. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28054. }
  28055. }
  28056. declare module BABYLON {
  28057. /**
  28058. * Class used to store data associated with WebGL texture data for the engine
  28059. * This class should not be used directly
  28060. */
  28061. export class InternalTexture {
  28062. /** @hidden */
  28063. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28064. /**
  28065. * The source of the texture data is unknown
  28066. */
  28067. static DATASOURCE_UNKNOWN: number;
  28068. /**
  28069. * Texture data comes from an URL
  28070. */
  28071. static DATASOURCE_URL: number;
  28072. /**
  28073. * Texture data is only used for temporary storage
  28074. */
  28075. static DATASOURCE_TEMP: number;
  28076. /**
  28077. * Texture data comes from raw data (ArrayBuffer)
  28078. */
  28079. static DATASOURCE_RAW: number;
  28080. /**
  28081. * Texture content is dynamic (video or dynamic texture)
  28082. */
  28083. static DATASOURCE_DYNAMIC: number;
  28084. /**
  28085. * Texture content is generated by rendering to it
  28086. */
  28087. static DATASOURCE_RENDERTARGET: number;
  28088. /**
  28089. * Texture content is part of a multi render target process
  28090. */
  28091. static DATASOURCE_MULTIRENDERTARGET: number;
  28092. /**
  28093. * Texture data comes from a cube data file
  28094. */
  28095. static DATASOURCE_CUBE: number;
  28096. /**
  28097. * Texture data comes from a raw cube data
  28098. */
  28099. static DATASOURCE_CUBERAW: number;
  28100. /**
  28101. * Texture data come from a prefiltered cube data file
  28102. */
  28103. static DATASOURCE_CUBEPREFILTERED: number;
  28104. /**
  28105. * Texture content is raw 3D data
  28106. */
  28107. static DATASOURCE_RAW3D: number;
  28108. /**
  28109. * Texture content is a depth texture
  28110. */
  28111. static DATASOURCE_DEPTHTEXTURE: number;
  28112. /**
  28113. * Texture data comes from a raw cube data encoded with RGBD
  28114. */
  28115. static DATASOURCE_CUBERAW_RGBD: number;
  28116. /**
  28117. * Defines if the texture is ready
  28118. */
  28119. isReady: boolean;
  28120. /**
  28121. * Defines if the texture is a cube texture
  28122. */
  28123. isCube: boolean;
  28124. /**
  28125. * Defines if the texture contains 3D data
  28126. */
  28127. is3D: boolean;
  28128. /**
  28129. * Defines if the texture contains multiview data
  28130. */
  28131. isMultiview: boolean;
  28132. /**
  28133. * Gets the URL used to load this texture
  28134. */
  28135. url: string;
  28136. /**
  28137. * Gets the sampling mode of the texture
  28138. */
  28139. samplingMode: number;
  28140. /**
  28141. * Gets a boolean indicating if the texture needs mipmaps generation
  28142. */
  28143. generateMipMaps: boolean;
  28144. /**
  28145. * Gets the number of samples used by the texture (WebGL2+ only)
  28146. */
  28147. samples: number;
  28148. /**
  28149. * Gets the type of the texture (int, float...)
  28150. */
  28151. type: number;
  28152. /**
  28153. * Gets the format of the texture (RGB, RGBA...)
  28154. */
  28155. format: number;
  28156. /**
  28157. * Observable called when the texture is loaded
  28158. */
  28159. onLoadedObservable: Observable<InternalTexture>;
  28160. /**
  28161. * Gets the width of the texture
  28162. */
  28163. width: number;
  28164. /**
  28165. * Gets the height of the texture
  28166. */
  28167. height: number;
  28168. /**
  28169. * Gets the depth of the texture
  28170. */
  28171. depth: number;
  28172. /**
  28173. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28174. */
  28175. baseWidth: number;
  28176. /**
  28177. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28178. */
  28179. baseHeight: number;
  28180. /**
  28181. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28182. */
  28183. baseDepth: number;
  28184. /**
  28185. * Gets a boolean indicating if the texture is inverted on Y axis
  28186. */
  28187. invertY: boolean;
  28188. /** @hidden */
  28189. _invertVScale: boolean;
  28190. /** @hidden */
  28191. _associatedChannel: number;
  28192. /** @hidden */
  28193. _dataSource: number;
  28194. /** @hidden */
  28195. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28196. /** @hidden */
  28197. _bufferView: Nullable<ArrayBufferView>;
  28198. /** @hidden */
  28199. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28200. /** @hidden */
  28201. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28202. /** @hidden */
  28203. _size: number;
  28204. /** @hidden */
  28205. _extension: string;
  28206. /** @hidden */
  28207. _files: Nullable<string[]>;
  28208. /** @hidden */
  28209. _workingCanvas: Nullable<HTMLCanvasElement>;
  28210. /** @hidden */
  28211. _workingContext: Nullable<CanvasRenderingContext2D>;
  28212. /** @hidden */
  28213. _framebuffer: Nullable<WebGLFramebuffer>;
  28214. /** @hidden */
  28215. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28216. /** @hidden */
  28217. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28218. /** @hidden */
  28219. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28220. /** @hidden */
  28221. _attachments: Nullable<number[]>;
  28222. /** @hidden */
  28223. _cachedCoordinatesMode: Nullable<number>;
  28224. /** @hidden */
  28225. _cachedWrapU: Nullable<number>;
  28226. /** @hidden */
  28227. _cachedWrapV: Nullable<number>;
  28228. /** @hidden */
  28229. _cachedWrapR: Nullable<number>;
  28230. /** @hidden */
  28231. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28232. /** @hidden */
  28233. _isDisabled: boolean;
  28234. /** @hidden */
  28235. _compression: Nullable<string>;
  28236. /** @hidden */
  28237. _generateStencilBuffer: boolean;
  28238. /** @hidden */
  28239. _generateDepthBuffer: boolean;
  28240. /** @hidden */
  28241. _comparisonFunction: number;
  28242. /** @hidden */
  28243. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28244. /** @hidden */
  28245. _lodGenerationScale: number;
  28246. /** @hidden */
  28247. _lodGenerationOffset: number;
  28248. /** @hidden */
  28249. _colorTextureArray: Nullable<WebGLTexture>;
  28250. /** @hidden */
  28251. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28252. /** @hidden */
  28253. _lodTextureHigh: Nullable<BaseTexture>;
  28254. /** @hidden */
  28255. _lodTextureMid: Nullable<BaseTexture>;
  28256. /** @hidden */
  28257. _lodTextureLow: Nullable<BaseTexture>;
  28258. /** @hidden */
  28259. _isRGBD: boolean;
  28260. /** @hidden */
  28261. _linearSpecularLOD: boolean;
  28262. /** @hidden */
  28263. _irradianceTexture: Nullable<BaseTexture>;
  28264. /** @hidden */
  28265. _webGLTexture: Nullable<WebGLTexture>;
  28266. /** @hidden */
  28267. _references: number;
  28268. private _engine;
  28269. /**
  28270. * Gets the Engine the texture belongs to.
  28271. * @returns The babylon engine
  28272. */
  28273. getEngine(): Engine;
  28274. /**
  28275. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28276. */
  28277. readonly dataSource: number;
  28278. /**
  28279. * Creates a new InternalTexture
  28280. * @param engine defines the engine to use
  28281. * @param dataSource defines the type of data that will be used
  28282. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28283. */
  28284. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28285. /**
  28286. * Increments the number of references (ie. the number of Texture that point to it)
  28287. */
  28288. incrementReferences(): void;
  28289. /**
  28290. * Change the size of the texture (not the size of the content)
  28291. * @param width defines the new width
  28292. * @param height defines the new height
  28293. * @param depth defines the new depth (1 by default)
  28294. */
  28295. updateSize(width: int, height: int, depth?: int): void;
  28296. /** @hidden */
  28297. _rebuild(): void;
  28298. /** @hidden */
  28299. _swapAndDie(target: InternalTexture): void;
  28300. /**
  28301. * Dispose the current allocated resources
  28302. */
  28303. dispose(): void;
  28304. }
  28305. }
  28306. declare module BABYLON {
  28307. /**
  28308. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28309. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28310. */
  28311. export class EffectFallbacks {
  28312. private _defines;
  28313. private _currentRank;
  28314. private _maxRank;
  28315. private _mesh;
  28316. /**
  28317. * Removes the fallback from the bound mesh.
  28318. */
  28319. unBindMesh(): void;
  28320. /**
  28321. * Adds a fallback on the specified property.
  28322. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28323. * @param define The name of the define in the shader
  28324. */
  28325. addFallback(rank: number, define: string): void;
  28326. /**
  28327. * Sets the mesh to use CPU skinning when needing to fallback.
  28328. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28329. * @param mesh The mesh to use the fallbacks.
  28330. */
  28331. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28332. /**
  28333. * Checks to see if more fallbacks are still availible.
  28334. */
  28335. readonly hasMoreFallbacks: boolean;
  28336. /**
  28337. * Removes the defines that should be removed when falling back.
  28338. * @param currentDefines defines the current define statements for the shader.
  28339. * @param effect defines the current effect we try to compile
  28340. * @returns The resulting defines with defines of the current rank removed.
  28341. */
  28342. reduce(currentDefines: string, effect: Effect): string;
  28343. }
  28344. /**
  28345. * Options to be used when creating an effect.
  28346. */
  28347. export class EffectCreationOptions {
  28348. /**
  28349. * Atrributes that will be used in the shader.
  28350. */
  28351. attributes: string[];
  28352. /**
  28353. * Uniform varible names that will be set in the shader.
  28354. */
  28355. uniformsNames: string[];
  28356. /**
  28357. * Uniform buffer varible names that will be set in the shader.
  28358. */
  28359. uniformBuffersNames: string[];
  28360. /**
  28361. * Sampler texture variable names that will be set in the shader.
  28362. */
  28363. samplers: string[];
  28364. /**
  28365. * Define statements that will be set in the shader.
  28366. */
  28367. defines: any;
  28368. /**
  28369. * Possible fallbacks for this effect to improve performance when needed.
  28370. */
  28371. fallbacks: Nullable<EffectFallbacks>;
  28372. /**
  28373. * Callback that will be called when the shader is compiled.
  28374. */
  28375. onCompiled: Nullable<(effect: Effect) => void>;
  28376. /**
  28377. * Callback that will be called if an error occurs during shader compilation.
  28378. */
  28379. onError: Nullable<(effect: Effect, errors: string) => void>;
  28380. /**
  28381. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28382. */
  28383. indexParameters: any;
  28384. /**
  28385. * Max number of lights that can be used in the shader.
  28386. */
  28387. maxSimultaneousLights: number;
  28388. /**
  28389. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28390. */
  28391. transformFeedbackVaryings: Nullable<string[]>;
  28392. }
  28393. /**
  28394. * Effect containing vertex and fragment shader that can be executed on an object.
  28395. */
  28396. export class Effect implements IDisposable {
  28397. /**
  28398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28399. */
  28400. static ShadersRepository: string;
  28401. /**
  28402. * Name of the effect.
  28403. */
  28404. name: any;
  28405. /**
  28406. * String container all the define statements that should be set on the shader.
  28407. */
  28408. defines: string;
  28409. /**
  28410. * Callback that will be called when the shader is compiled.
  28411. */
  28412. onCompiled: Nullable<(effect: Effect) => void>;
  28413. /**
  28414. * Callback that will be called if an error occurs during shader compilation.
  28415. */
  28416. onError: Nullable<(effect: Effect, errors: string) => void>;
  28417. /**
  28418. * Callback that will be called when effect is bound.
  28419. */
  28420. onBind: Nullable<(effect: Effect) => void>;
  28421. /**
  28422. * Unique ID of the effect.
  28423. */
  28424. uniqueId: number;
  28425. /**
  28426. * Observable that will be called when the shader is compiled.
  28427. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28428. */
  28429. onCompileObservable: Observable<Effect>;
  28430. /**
  28431. * Observable that will be called if an error occurs during shader compilation.
  28432. */
  28433. onErrorObservable: Observable<Effect>;
  28434. /** @hidden */
  28435. _onBindObservable: Nullable<Observable<Effect>>;
  28436. /**
  28437. * Observable that will be called when effect is bound.
  28438. */
  28439. readonly onBindObservable: Observable<Effect>;
  28440. /** @hidden */
  28441. _bonesComputationForcedToCPU: boolean;
  28442. private static _uniqueIdSeed;
  28443. private _engine;
  28444. private _uniformBuffersNames;
  28445. private _uniformsNames;
  28446. private _samplerList;
  28447. private _samplers;
  28448. private _isReady;
  28449. private _compilationError;
  28450. private _attributesNames;
  28451. private _attributes;
  28452. private _uniforms;
  28453. /**
  28454. * Key for the effect.
  28455. * @hidden
  28456. */
  28457. _key: string;
  28458. private _indexParameters;
  28459. private _fallbacks;
  28460. private _vertexSourceCode;
  28461. private _fragmentSourceCode;
  28462. private _vertexSourceCodeOverride;
  28463. private _fragmentSourceCodeOverride;
  28464. private _transformFeedbackVaryings;
  28465. /**
  28466. * Compiled shader to webGL program.
  28467. * @hidden
  28468. */
  28469. _pipelineContext: Nullable<IPipelineContext>;
  28470. private _valueCache;
  28471. private static _baseCache;
  28472. /**
  28473. * Instantiates an effect.
  28474. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28475. * @param baseName Name of the effect.
  28476. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28477. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28478. * @param samplers List of sampler variables that will be passed to the shader.
  28479. * @param engine Engine to be used to render the effect
  28480. * @param defines Define statements to be added to the shader.
  28481. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28482. * @param onCompiled Callback that will be called when the shader is compiled.
  28483. * @param onError Callback that will be called if an error occurs during shader compilation.
  28484. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28485. */
  28486. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28487. private _useFinalCode;
  28488. /**
  28489. * Unique key for this effect
  28490. */
  28491. readonly key: string;
  28492. /**
  28493. * If the effect has been compiled and prepared.
  28494. * @returns if the effect is compiled and prepared.
  28495. */
  28496. isReady(): boolean;
  28497. private _isReadyInternal;
  28498. /**
  28499. * The engine the effect was initialized with.
  28500. * @returns the engine.
  28501. */
  28502. getEngine(): Engine;
  28503. /**
  28504. * The pipeline context for this effect
  28505. * @returns the associated pipeline context
  28506. */
  28507. getPipelineContext(): Nullable<IPipelineContext>;
  28508. /**
  28509. * The set of names of attribute variables for the shader.
  28510. * @returns An array of attribute names.
  28511. */
  28512. getAttributesNames(): string[];
  28513. /**
  28514. * Returns the attribute at the given index.
  28515. * @param index The index of the attribute.
  28516. * @returns The location of the attribute.
  28517. */
  28518. getAttributeLocation(index: number): number;
  28519. /**
  28520. * Returns the attribute based on the name of the variable.
  28521. * @param name of the attribute to look up.
  28522. * @returns the attribute location.
  28523. */
  28524. getAttributeLocationByName(name: string): number;
  28525. /**
  28526. * The number of attributes.
  28527. * @returns the numnber of attributes.
  28528. */
  28529. getAttributesCount(): number;
  28530. /**
  28531. * Gets the index of a uniform variable.
  28532. * @param uniformName of the uniform to look up.
  28533. * @returns the index.
  28534. */
  28535. getUniformIndex(uniformName: string): number;
  28536. /**
  28537. * Returns the attribute based on the name of the variable.
  28538. * @param uniformName of the uniform to look up.
  28539. * @returns the location of the uniform.
  28540. */
  28541. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28542. /**
  28543. * Returns an array of sampler variable names
  28544. * @returns The array of sampler variable neames.
  28545. */
  28546. getSamplers(): string[];
  28547. /**
  28548. * The error from the last compilation.
  28549. * @returns the error string.
  28550. */
  28551. getCompilationError(): string;
  28552. /**
  28553. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28554. * @param func The callback to be used.
  28555. */
  28556. executeWhenCompiled(func: (effect: Effect) => void): void;
  28557. private _checkIsReady;
  28558. /** @hidden */
  28559. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28560. /** @hidden */
  28561. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28562. /** @hidden */
  28563. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28564. /**
  28565. * Recompiles the webGL program
  28566. * @param vertexSourceCode The source code for the vertex shader.
  28567. * @param fragmentSourceCode The source code for the fragment shader.
  28568. * @param onCompiled Callback called when completed.
  28569. * @param onError Callback called on error.
  28570. * @hidden
  28571. */
  28572. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28573. /**
  28574. * Prepares the effect
  28575. * @hidden
  28576. */
  28577. _prepareEffect(): void;
  28578. private _processCompilationErrors;
  28579. /**
  28580. * Checks if the effect is supported. (Must be called after compilation)
  28581. */
  28582. readonly isSupported: boolean;
  28583. /**
  28584. * Binds a texture to the engine to be used as output of the shader.
  28585. * @param channel Name of the output variable.
  28586. * @param texture Texture to bind.
  28587. * @hidden
  28588. */
  28589. _bindTexture(channel: string, texture: InternalTexture): void;
  28590. /**
  28591. * Sets a texture on the engine to be used in the shader.
  28592. * @param channel Name of the sampler variable.
  28593. * @param texture Texture to set.
  28594. */
  28595. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28596. /**
  28597. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28598. * @param channel Name of the sampler variable.
  28599. * @param texture Texture to set.
  28600. */
  28601. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28602. /**
  28603. * Sets an array of textures on the engine to be used in the shader.
  28604. * @param channel Name of the variable.
  28605. * @param textures Textures to set.
  28606. */
  28607. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28608. /**
  28609. * 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)
  28610. * @param channel Name of the sampler variable.
  28611. * @param postProcess Post process to get the input texture from.
  28612. */
  28613. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28614. /**
  28615. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28616. * 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)
  28617. * @param channel Name of the sampler variable.
  28618. * @param postProcess Post process to get the output texture from.
  28619. */
  28620. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28621. /** @hidden */
  28622. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28623. /** @hidden */
  28624. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28625. /** @hidden */
  28626. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28627. /** @hidden */
  28628. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28629. /**
  28630. * Binds a buffer to a uniform.
  28631. * @param buffer Buffer to bind.
  28632. * @param name Name of the uniform variable to bind to.
  28633. */
  28634. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28635. /**
  28636. * Binds block to a uniform.
  28637. * @param blockName Name of the block to bind.
  28638. * @param index Index to bind.
  28639. */
  28640. bindUniformBlock(blockName: string, index: number): void;
  28641. /**
  28642. * Sets an interger value on a uniform variable.
  28643. * @param uniformName Name of the variable.
  28644. * @param value Value to be set.
  28645. * @returns this effect.
  28646. */
  28647. setInt(uniformName: string, value: number): Effect;
  28648. /**
  28649. * Sets an int array on a uniform variable.
  28650. * @param uniformName Name of the variable.
  28651. * @param array array to be set.
  28652. * @returns this effect.
  28653. */
  28654. setIntArray(uniformName: string, array: Int32Array): Effect;
  28655. /**
  28656. * 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)
  28657. * @param uniformName Name of the variable.
  28658. * @param array array to be set.
  28659. * @returns this effect.
  28660. */
  28661. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28662. /**
  28663. * 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)
  28664. * @param uniformName Name of the variable.
  28665. * @param array array to be set.
  28666. * @returns this effect.
  28667. */
  28668. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28669. /**
  28670. * 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)
  28671. * @param uniformName Name of the variable.
  28672. * @param array array to be set.
  28673. * @returns this effect.
  28674. */
  28675. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28676. /**
  28677. * Sets an float array on a uniform variable.
  28678. * @param uniformName Name of the variable.
  28679. * @param array array to be set.
  28680. * @returns this effect.
  28681. */
  28682. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28683. /**
  28684. * 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)
  28685. * @param uniformName Name of the variable.
  28686. * @param array array to be set.
  28687. * @returns this effect.
  28688. */
  28689. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28690. /**
  28691. * 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)
  28692. * @param uniformName Name of the variable.
  28693. * @param array array to be set.
  28694. * @returns this effect.
  28695. */
  28696. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28697. /**
  28698. * 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)
  28699. * @param uniformName Name of the variable.
  28700. * @param array array to be set.
  28701. * @returns this effect.
  28702. */
  28703. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28704. /**
  28705. * Sets an array on a uniform variable.
  28706. * @param uniformName Name of the variable.
  28707. * @param array array to be set.
  28708. * @returns this effect.
  28709. */
  28710. setArray(uniformName: string, array: number[]): Effect;
  28711. /**
  28712. * 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)
  28713. * @param uniformName Name of the variable.
  28714. * @param array array to be set.
  28715. * @returns this effect.
  28716. */
  28717. setArray2(uniformName: string, array: number[]): Effect;
  28718. /**
  28719. * 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)
  28720. * @param uniformName Name of the variable.
  28721. * @param array array to be set.
  28722. * @returns this effect.
  28723. */
  28724. setArray3(uniformName: string, array: number[]): Effect;
  28725. /**
  28726. * 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)
  28727. * @param uniformName Name of the variable.
  28728. * @param array array to be set.
  28729. * @returns this effect.
  28730. */
  28731. setArray4(uniformName: string, array: number[]): Effect;
  28732. /**
  28733. * Sets matrices on a uniform variable.
  28734. * @param uniformName Name of the variable.
  28735. * @param matrices matrices to be set.
  28736. * @returns this effect.
  28737. */
  28738. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28739. /**
  28740. * Sets matrix on a uniform variable.
  28741. * @param uniformName Name of the variable.
  28742. * @param matrix matrix to be set.
  28743. * @returns this effect.
  28744. */
  28745. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28746. /**
  28747. * 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)
  28748. * @param uniformName Name of the variable.
  28749. * @param matrix matrix to be set.
  28750. * @returns this effect.
  28751. */
  28752. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28753. /**
  28754. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28755. * @param uniformName Name of the variable.
  28756. * @param matrix matrix to be set.
  28757. * @returns this effect.
  28758. */
  28759. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28760. /**
  28761. * Sets a float on a uniform variable.
  28762. * @param uniformName Name of the variable.
  28763. * @param value value to be set.
  28764. * @returns this effect.
  28765. */
  28766. setFloat(uniformName: string, value: number): Effect;
  28767. /**
  28768. * Sets a boolean on a uniform variable.
  28769. * @param uniformName Name of the variable.
  28770. * @param bool value to be set.
  28771. * @returns this effect.
  28772. */
  28773. setBool(uniformName: string, bool: boolean): Effect;
  28774. /**
  28775. * Sets a Vector2 on a uniform variable.
  28776. * @param uniformName Name of the variable.
  28777. * @param vector2 vector2 to be set.
  28778. * @returns this effect.
  28779. */
  28780. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28781. /**
  28782. * Sets a float2 on a uniform variable.
  28783. * @param uniformName Name of the variable.
  28784. * @param x First float in float2.
  28785. * @param y Second float in float2.
  28786. * @returns this effect.
  28787. */
  28788. setFloat2(uniformName: string, x: number, y: number): Effect;
  28789. /**
  28790. * Sets a Vector3 on a uniform variable.
  28791. * @param uniformName Name of the variable.
  28792. * @param vector3 Value to be set.
  28793. * @returns this effect.
  28794. */
  28795. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28796. /**
  28797. * Sets a float3 on a uniform variable.
  28798. * @param uniformName Name of the variable.
  28799. * @param x First float in float3.
  28800. * @param y Second float in float3.
  28801. * @param z Third float in float3.
  28802. * @returns this effect.
  28803. */
  28804. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28805. /**
  28806. * Sets a Vector4 on a uniform variable.
  28807. * @param uniformName Name of the variable.
  28808. * @param vector4 Value to be set.
  28809. * @returns this effect.
  28810. */
  28811. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28812. /**
  28813. * Sets a float4 on a uniform variable.
  28814. * @param uniformName Name of the variable.
  28815. * @param x First float in float4.
  28816. * @param y Second float in float4.
  28817. * @param z Third float in float4.
  28818. * @param w Fourth float in float4.
  28819. * @returns this effect.
  28820. */
  28821. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28822. /**
  28823. * Sets a Color3 on a uniform variable.
  28824. * @param uniformName Name of the variable.
  28825. * @param color3 Value to be set.
  28826. * @returns this effect.
  28827. */
  28828. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28829. /**
  28830. * Sets a Color4 on a uniform variable.
  28831. * @param uniformName Name of the variable.
  28832. * @param color3 Value to be set.
  28833. * @param alpha Alpha value to be set.
  28834. * @returns this effect.
  28835. */
  28836. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28837. /**
  28838. * Sets a Color4 on a uniform variable
  28839. * @param uniformName defines the name of the variable
  28840. * @param color4 defines the value to be set
  28841. * @returns this effect.
  28842. */
  28843. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28844. /** Release all associated resources */
  28845. dispose(): void;
  28846. /**
  28847. * This function will add a new shader to the shader store
  28848. * @param name the name of the shader
  28849. * @param pixelShader optional pixel shader content
  28850. * @param vertexShader optional vertex shader content
  28851. */
  28852. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28853. /**
  28854. * Store of each shader (The can be looked up using effect.key)
  28855. */
  28856. static ShadersStore: {
  28857. [key: string]: string;
  28858. };
  28859. /**
  28860. * Store of each included file for a shader (The can be looked up using effect.key)
  28861. */
  28862. static IncludesShadersStore: {
  28863. [key: string]: string;
  28864. };
  28865. /**
  28866. * Resets the cache of effects.
  28867. */
  28868. static ResetCache(): void;
  28869. }
  28870. }
  28871. declare module BABYLON {
  28872. /**
  28873. * Uniform buffer objects.
  28874. *
  28875. * Handles blocks of uniform on the GPU.
  28876. *
  28877. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28878. *
  28879. * For more information, please refer to :
  28880. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28881. */
  28882. export class UniformBuffer {
  28883. private _engine;
  28884. private _buffer;
  28885. private _data;
  28886. private _bufferData;
  28887. private _dynamic?;
  28888. private _uniformLocations;
  28889. private _uniformSizes;
  28890. private _uniformLocationPointer;
  28891. private _needSync;
  28892. private _noUBO;
  28893. private _currentEffect;
  28894. private static _MAX_UNIFORM_SIZE;
  28895. private static _tempBuffer;
  28896. /**
  28897. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28898. * This is dynamic to allow compat with webgl 1 and 2.
  28899. * You will need to pass the name of the uniform as well as the value.
  28900. */
  28901. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28902. /**
  28903. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28904. * This is dynamic to allow compat with webgl 1 and 2.
  28905. * You will need to pass the name of the uniform as well as the value.
  28906. */
  28907. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28908. /**
  28909. * Lambda to Update a single float in a uniform buffer.
  28910. * This is dynamic to allow compat with webgl 1 and 2.
  28911. * You will need to pass the name of the uniform as well as the value.
  28912. */
  28913. updateFloat: (name: string, x: number) => void;
  28914. /**
  28915. * Lambda to Update a vec2 of float in a uniform buffer.
  28916. * This is dynamic to allow compat with webgl 1 and 2.
  28917. * You will need to pass the name of the uniform as well as the value.
  28918. */
  28919. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28920. /**
  28921. * Lambda to Update a vec3 of float in a uniform buffer.
  28922. * This is dynamic to allow compat with webgl 1 and 2.
  28923. * You will need to pass the name of the uniform as well as the value.
  28924. */
  28925. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28926. /**
  28927. * Lambda to Update a vec4 of float in a uniform buffer.
  28928. * This is dynamic to allow compat with webgl 1 and 2.
  28929. * You will need to pass the name of the uniform as well as the value.
  28930. */
  28931. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28932. /**
  28933. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28934. * This is dynamic to allow compat with webgl 1 and 2.
  28935. * You will need to pass the name of the uniform as well as the value.
  28936. */
  28937. updateMatrix: (name: string, mat: Matrix) => void;
  28938. /**
  28939. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28940. * This is dynamic to allow compat with webgl 1 and 2.
  28941. * You will need to pass the name of the uniform as well as the value.
  28942. */
  28943. updateVector3: (name: string, vector: Vector3) => void;
  28944. /**
  28945. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28946. * This is dynamic to allow compat with webgl 1 and 2.
  28947. * You will need to pass the name of the uniform as well as the value.
  28948. */
  28949. updateVector4: (name: string, vector: Vector4) => void;
  28950. /**
  28951. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28952. * This is dynamic to allow compat with webgl 1 and 2.
  28953. * You will need to pass the name of the uniform as well as the value.
  28954. */
  28955. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28956. /**
  28957. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28958. * This is dynamic to allow compat with webgl 1 and 2.
  28959. * You will need to pass the name of the uniform as well as the value.
  28960. */
  28961. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28962. /**
  28963. * Instantiates a new Uniform buffer objects.
  28964. *
  28965. * Handles blocks of uniform on the GPU.
  28966. *
  28967. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28968. *
  28969. * For more information, please refer to :
  28970. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28971. * @param engine Define the engine the buffer is associated with
  28972. * @param data Define the data contained in the buffer
  28973. * @param dynamic Define if the buffer is updatable
  28974. */
  28975. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28976. /**
  28977. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28978. * or just falling back on setUniformXXX calls.
  28979. */
  28980. readonly useUbo: boolean;
  28981. /**
  28982. * Indicates if the WebGL underlying uniform buffer is in sync
  28983. * with the javascript cache data.
  28984. */
  28985. readonly isSync: boolean;
  28986. /**
  28987. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28988. * Also, a dynamic UniformBuffer will disable cache verification and always
  28989. * update the underlying WebGL uniform buffer to the GPU.
  28990. * @returns if Dynamic, otherwise false
  28991. */
  28992. isDynamic(): boolean;
  28993. /**
  28994. * The data cache on JS side.
  28995. * @returns the underlying data as a float array
  28996. */
  28997. getData(): Float32Array;
  28998. /**
  28999. * The underlying WebGL Uniform buffer.
  29000. * @returns the webgl buffer
  29001. */
  29002. getBuffer(): Nullable<DataBuffer>;
  29003. /**
  29004. * std140 layout specifies how to align data within an UBO structure.
  29005. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29006. * for specs.
  29007. */
  29008. private _fillAlignment;
  29009. /**
  29010. * Adds an uniform in the buffer.
  29011. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29012. * for the layout to be correct !
  29013. * @param name Name of the uniform, as used in the uniform block in the shader.
  29014. * @param size Data size, or data directly.
  29015. */
  29016. addUniform(name: string, size: number | number[]): void;
  29017. /**
  29018. * Adds a Matrix 4x4 to the uniform buffer.
  29019. * @param name Name of the uniform, as used in the uniform block in the shader.
  29020. * @param mat A 4x4 matrix.
  29021. */
  29022. addMatrix(name: string, mat: Matrix): void;
  29023. /**
  29024. * Adds a vec2 to the uniform buffer.
  29025. * @param name Name of the uniform, as used in the uniform block in the shader.
  29026. * @param x Define the x component value of the vec2
  29027. * @param y Define the y component value of the vec2
  29028. */
  29029. addFloat2(name: string, x: number, y: number): void;
  29030. /**
  29031. * Adds a vec3 to the uniform buffer.
  29032. * @param name Name of the uniform, as used in the uniform block in the shader.
  29033. * @param x Define the x component value of the vec3
  29034. * @param y Define the y component value of the vec3
  29035. * @param z Define the z component value of the vec3
  29036. */
  29037. addFloat3(name: string, x: number, y: number, z: number): void;
  29038. /**
  29039. * Adds a vec3 to the uniform buffer.
  29040. * @param name Name of the uniform, as used in the uniform block in the shader.
  29041. * @param color Define the vec3 from a Color
  29042. */
  29043. addColor3(name: string, color: Color3): void;
  29044. /**
  29045. * Adds a vec4 to the uniform buffer.
  29046. * @param name Name of the uniform, as used in the uniform block in the shader.
  29047. * @param color Define the rgb components from a Color
  29048. * @param alpha Define the a component of the vec4
  29049. */
  29050. addColor4(name: string, color: Color3, alpha: number): void;
  29051. /**
  29052. * Adds a vec3 to the uniform buffer.
  29053. * @param name Name of the uniform, as used in the uniform block in the shader.
  29054. * @param vector Define the vec3 components from a Vector
  29055. */
  29056. addVector3(name: string, vector: Vector3): void;
  29057. /**
  29058. * Adds a Matrix 3x3 to the uniform buffer.
  29059. * @param name Name of the uniform, as used in the uniform block in the shader.
  29060. */
  29061. addMatrix3x3(name: string): void;
  29062. /**
  29063. * Adds a Matrix 2x2 to the uniform buffer.
  29064. * @param name Name of the uniform, as used in the uniform block in the shader.
  29065. */
  29066. addMatrix2x2(name: string): void;
  29067. /**
  29068. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29069. */
  29070. create(): void;
  29071. /** @hidden */
  29072. _rebuild(): void;
  29073. /**
  29074. * Updates the WebGL Uniform Buffer on the GPU.
  29075. * If the `dynamic` flag is set to true, no cache comparison is done.
  29076. * Otherwise, the buffer will be updated only if the cache differs.
  29077. */
  29078. update(): void;
  29079. /**
  29080. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29081. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29082. * @param data Define the flattened data
  29083. * @param size Define the size of the data.
  29084. */
  29085. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29086. private _valueCache;
  29087. private _cacheMatrix;
  29088. private _updateMatrix3x3ForUniform;
  29089. private _updateMatrix3x3ForEffect;
  29090. private _updateMatrix2x2ForEffect;
  29091. private _updateMatrix2x2ForUniform;
  29092. private _updateFloatForEffect;
  29093. private _updateFloatForUniform;
  29094. private _updateFloat2ForEffect;
  29095. private _updateFloat2ForUniform;
  29096. private _updateFloat3ForEffect;
  29097. private _updateFloat3ForUniform;
  29098. private _updateFloat4ForEffect;
  29099. private _updateFloat4ForUniform;
  29100. private _updateMatrixForEffect;
  29101. private _updateMatrixForUniform;
  29102. private _updateVector3ForEffect;
  29103. private _updateVector3ForUniform;
  29104. private _updateVector4ForEffect;
  29105. private _updateVector4ForUniform;
  29106. private _updateColor3ForEffect;
  29107. private _updateColor3ForUniform;
  29108. private _updateColor4ForEffect;
  29109. private _updateColor4ForUniform;
  29110. /**
  29111. * Sets a sampler uniform on the effect.
  29112. * @param name Define the name of the sampler.
  29113. * @param texture Define the texture to set in the sampler
  29114. */
  29115. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29116. /**
  29117. * Directly updates the value of the uniform in the cache AND on the GPU.
  29118. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29119. * @param data Define the flattened data
  29120. */
  29121. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29122. /**
  29123. * Binds this uniform buffer to an effect.
  29124. * @param effect Define the effect to bind the buffer to
  29125. * @param name Name of the uniform block in the shader.
  29126. */
  29127. bindToEffect(effect: Effect, name: string): void;
  29128. /**
  29129. * Disposes the uniform buffer.
  29130. */
  29131. dispose(): void;
  29132. }
  29133. }
  29134. declare module BABYLON {
  29135. /**
  29136. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29138. */
  29139. export class Analyser {
  29140. /**
  29141. * Gets or sets the smoothing
  29142. * @ignorenaming
  29143. */
  29144. SMOOTHING: number;
  29145. /**
  29146. * Gets or sets the FFT table size
  29147. * @ignorenaming
  29148. */
  29149. FFT_SIZE: number;
  29150. /**
  29151. * Gets or sets the bar graph amplitude
  29152. * @ignorenaming
  29153. */
  29154. BARGRAPHAMPLITUDE: number;
  29155. /**
  29156. * Gets or sets the position of the debug canvas
  29157. * @ignorenaming
  29158. */
  29159. DEBUGCANVASPOS: {
  29160. x: number;
  29161. y: number;
  29162. };
  29163. /**
  29164. * Gets or sets the debug canvas size
  29165. * @ignorenaming
  29166. */
  29167. DEBUGCANVASSIZE: {
  29168. width: number;
  29169. height: number;
  29170. };
  29171. private _byteFreqs;
  29172. private _byteTime;
  29173. private _floatFreqs;
  29174. private _webAudioAnalyser;
  29175. private _debugCanvas;
  29176. private _debugCanvasContext;
  29177. private _scene;
  29178. private _registerFunc;
  29179. private _audioEngine;
  29180. /**
  29181. * Creates a new analyser
  29182. * @param scene defines hosting scene
  29183. */
  29184. constructor(scene: Scene);
  29185. /**
  29186. * Get the number of data values you will have to play with for the visualization
  29187. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29188. * @returns a number
  29189. */
  29190. getFrequencyBinCount(): number;
  29191. /**
  29192. * Gets the current frequency data as a byte array
  29193. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29194. * @returns a Uint8Array
  29195. */
  29196. getByteFrequencyData(): Uint8Array;
  29197. /**
  29198. * Gets the current waveform as a byte array
  29199. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29200. * @returns a Uint8Array
  29201. */
  29202. getByteTimeDomainData(): Uint8Array;
  29203. /**
  29204. * Gets the current frequency data as a float array
  29205. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29206. * @returns a Float32Array
  29207. */
  29208. getFloatFrequencyData(): Float32Array;
  29209. /**
  29210. * Renders the debug canvas
  29211. */
  29212. drawDebugCanvas(): void;
  29213. /**
  29214. * Stops rendering the debug canvas and removes it
  29215. */
  29216. stopDebugCanvas(): void;
  29217. /**
  29218. * Connects two audio nodes
  29219. * @param inputAudioNode defines first node to connect
  29220. * @param outputAudioNode defines second node to connect
  29221. */
  29222. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29223. /**
  29224. * Releases all associated resources
  29225. */
  29226. dispose(): void;
  29227. }
  29228. }
  29229. declare module BABYLON {
  29230. /**
  29231. * This represents an audio engine and it is responsible
  29232. * to play, synchronize and analyse sounds throughout the application.
  29233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29234. */
  29235. export interface IAudioEngine extends IDisposable {
  29236. /**
  29237. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29238. */
  29239. readonly canUseWebAudio: boolean;
  29240. /**
  29241. * Gets the current AudioContext if available.
  29242. */
  29243. readonly audioContext: Nullable<AudioContext>;
  29244. /**
  29245. * The master gain node defines the global audio volume of your audio engine.
  29246. */
  29247. readonly masterGain: GainNode;
  29248. /**
  29249. * Gets whether or not mp3 are supported by your browser.
  29250. */
  29251. readonly isMP3supported: boolean;
  29252. /**
  29253. * Gets whether or not ogg are supported by your browser.
  29254. */
  29255. readonly isOGGsupported: boolean;
  29256. /**
  29257. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29258. * @ignoreNaming
  29259. */
  29260. WarnedWebAudioUnsupported: boolean;
  29261. /**
  29262. * Defines if the audio engine relies on a custom unlocked button.
  29263. * In this case, the embedded button will not be displayed.
  29264. */
  29265. useCustomUnlockedButton: boolean;
  29266. /**
  29267. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29268. */
  29269. readonly unlocked: boolean;
  29270. /**
  29271. * Event raised when audio has been unlocked on the browser.
  29272. */
  29273. onAudioUnlockedObservable: Observable<AudioEngine>;
  29274. /**
  29275. * Event raised when audio has been locked on the browser.
  29276. */
  29277. onAudioLockedObservable: Observable<AudioEngine>;
  29278. /**
  29279. * Flags the audio engine in Locked state.
  29280. * This happens due to new browser policies preventing audio to autoplay.
  29281. */
  29282. lock(): void;
  29283. /**
  29284. * Unlocks the audio engine once a user action has been done on the dom.
  29285. * This is helpful to resume play once browser policies have been satisfied.
  29286. */
  29287. unlock(): void;
  29288. }
  29289. /**
  29290. * This represents the default audio engine used in babylon.
  29291. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29293. */
  29294. export class AudioEngine implements IAudioEngine {
  29295. private _audioContext;
  29296. private _audioContextInitialized;
  29297. private _muteButton;
  29298. private _hostElement;
  29299. /**
  29300. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29301. */
  29302. canUseWebAudio: boolean;
  29303. /**
  29304. * The master gain node defines the global audio volume of your audio engine.
  29305. */
  29306. masterGain: GainNode;
  29307. /**
  29308. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29309. * @ignoreNaming
  29310. */
  29311. WarnedWebAudioUnsupported: boolean;
  29312. /**
  29313. * Gets whether or not mp3 are supported by your browser.
  29314. */
  29315. isMP3supported: boolean;
  29316. /**
  29317. * Gets whether or not ogg are supported by your browser.
  29318. */
  29319. isOGGsupported: boolean;
  29320. /**
  29321. * Gets whether audio has been unlocked on the device.
  29322. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29323. * a user interaction has happened.
  29324. */
  29325. unlocked: boolean;
  29326. /**
  29327. * Defines if the audio engine relies on a custom unlocked button.
  29328. * In this case, the embedded button will not be displayed.
  29329. */
  29330. useCustomUnlockedButton: boolean;
  29331. /**
  29332. * Event raised when audio has been unlocked on the browser.
  29333. */
  29334. onAudioUnlockedObservable: Observable<AudioEngine>;
  29335. /**
  29336. * Event raised when audio has been locked on the browser.
  29337. */
  29338. onAudioLockedObservable: Observable<AudioEngine>;
  29339. /**
  29340. * Gets the current AudioContext if available.
  29341. */
  29342. readonly audioContext: Nullable<AudioContext>;
  29343. private _connectedAnalyser;
  29344. /**
  29345. * Instantiates a new audio engine.
  29346. *
  29347. * There should be only one per page as some browsers restrict the number
  29348. * of audio contexts you can create.
  29349. * @param hostElement defines the host element where to display the mute icon if necessary
  29350. */
  29351. constructor(hostElement?: Nullable<HTMLElement>);
  29352. /**
  29353. * Flags the audio engine in Locked state.
  29354. * This happens due to new browser policies preventing audio to autoplay.
  29355. */
  29356. lock(): void;
  29357. /**
  29358. * Unlocks the audio engine once a user action has been done on the dom.
  29359. * This is helpful to resume play once browser policies have been satisfied.
  29360. */
  29361. unlock(): void;
  29362. private _resumeAudioContext;
  29363. private _initializeAudioContext;
  29364. private _tryToRun;
  29365. private _triggerRunningState;
  29366. private _triggerSuspendedState;
  29367. private _displayMuteButton;
  29368. private _moveButtonToTopLeft;
  29369. private _onResize;
  29370. private _hideMuteButton;
  29371. /**
  29372. * Destroy and release the resources associated with the audio ccontext.
  29373. */
  29374. dispose(): void;
  29375. /**
  29376. * Gets the global volume sets on the master gain.
  29377. * @returns the global volume if set or -1 otherwise
  29378. */
  29379. getGlobalVolume(): number;
  29380. /**
  29381. * Sets the global volume of your experience (sets on the master gain).
  29382. * @param newVolume Defines the new global volume of the application
  29383. */
  29384. setGlobalVolume(newVolume: number): void;
  29385. /**
  29386. * Connect the audio engine to an audio analyser allowing some amazing
  29387. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29389. * @param analyser The analyser to connect to the engine
  29390. */
  29391. connectToAnalyser(analyser: Analyser): void;
  29392. }
  29393. }
  29394. declare module BABYLON {
  29395. /**
  29396. * Interface used to present a loading screen while loading a scene
  29397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29398. */
  29399. export interface ILoadingScreen {
  29400. /**
  29401. * Function called to display the loading screen
  29402. */
  29403. displayLoadingUI: () => void;
  29404. /**
  29405. * Function called to hide the loading screen
  29406. */
  29407. hideLoadingUI: () => void;
  29408. /**
  29409. * Gets or sets the color to use for the background
  29410. */
  29411. loadingUIBackgroundColor: string;
  29412. /**
  29413. * Gets or sets the text to display while loading
  29414. */
  29415. loadingUIText: string;
  29416. }
  29417. /**
  29418. * Class used for the default loading screen
  29419. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29420. */
  29421. export class DefaultLoadingScreen implements ILoadingScreen {
  29422. private _renderingCanvas;
  29423. private _loadingText;
  29424. private _loadingDivBackgroundColor;
  29425. private _loadingDiv;
  29426. private _loadingTextDiv;
  29427. /** Gets or sets the logo url to use for the default loading screen */
  29428. static DefaultLogoUrl: string;
  29429. /** Gets or sets the spinner url to use for the default loading screen */
  29430. static DefaultSpinnerUrl: string;
  29431. /**
  29432. * Creates a new default loading screen
  29433. * @param _renderingCanvas defines the canvas used to render the scene
  29434. * @param _loadingText defines the default text to display
  29435. * @param _loadingDivBackgroundColor defines the default background color
  29436. */
  29437. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29438. /**
  29439. * Function called to display the loading screen
  29440. */
  29441. displayLoadingUI(): void;
  29442. /**
  29443. * Function called to hide the loading screen
  29444. */
  29445. hideLoadingUI(): void;
  29446. /**
  29447. * Gets or sets the text to display while loading
  29448. */
  29449. loadingUIText: string;
  29450. /**
  29451. * Gets or sets the color to use for the background
  29452. */
  29453. loadingUIBackgroundColor: string;
  29454. private _resizeLoadingUI;
  29455. }
  29456. }
  29457. declare module BABYLON {
  29458. /** @hidden */
  29459. export class WebGLPipelineContext implements IPipelineContext {
  29460. engine: Engine;
  29461. program: Nullable<WebGLProgram>;
  29462. context?: WebGLRenderingContext;
  29463. vertexShader?: WebGLShader;
  29464. fragmentShader?: WebGLShader;
  29465. isParallelCompiled: boolean;
  29466. onCompiled?: () => void;
  29467. transformFeedback?: WebGLTransformFeedback | null;
  29468. readonly isAsync: boolean;
  29469. readonly isReady: boolean;
  29470. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29471. }
  29472. }
  29473. declare module BABYLON {
  29474. /** @hidden */
  29475. export class WebGLDataBuffer extends DataBuffer {
  29476. private _buffer;
  29477. constructor(resource: WebGLBuffer);
  29478. readonly underlyingResource: any;
  29479. }
  29480. }
  29481. declare module BABYLON {
  29482. /** @hidden */
  29483. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29484. attributeProcessor(attribute: string): string;
  29485. varyingProcessor(varying: string, isFragment: boolean): string;
  29486. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29487. }
  29488. }
  29489. declare module BABYLON {
  29490. /**
  29491. * This class is used to track a performance counter which is number based.
  29492. * The user has access to many properties which give statistics of different nature.
  29493. *
  29494. * The implementer can track two kinds of Performance Counter: time and count.
  29495. * 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.
  29496. * 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.
  29497. */
  29498. export class PerfCounter {
  29499. /**
  29500. * Gets or sets a global boolean to turn on and off all the counters
  29501. */
  29502. static Enabled: boolean;
  29503. /**
  29504. * Returns the smallest value ever
  29505. */
  29506. readonly min: number;
  29507. /**
  29508. * Returns the biggest value ever
  29509. */
  29510. readonly max: number;
  29511. /**
  29512. * Returns the average value since the performance counter is running
  29513. */
  29514. readonly average: number;
  29515. /**
  29516. * Returns the average value of the last second the counter was monitored
  29517. */
  29518. readonly lastSecAverage: number;
  29519. /**
  29520. * Returns the current value
  29521. */
  29522. readonly current: number;
  29523. /**
  29524. * Gets the accumulated total
  29525. */
  29526. readonly total: number;
  29527. /**
  29528. * Gets the total value count
  29529. */
  29530. readonly count: number;
  29531. /**
  29532. * Creates a new counter
  29533. */
  29534. constructor();
  29535. /**
  29536. * Call this method to start monitoring a new frame.
  29537. * 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.
  29538. */
  29539. fetchNewFrame(): void;
  29540. /**
  29541. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29542. * @param newCount the count value to add to the monitored count
  29543. * @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.
  29544. */
  29545. addCount(newCount: number, fetchResult: boolean): void;
  29546. /**
  29547. * Start monitoring this performance counter
  29548. */
  29549. beginMonitoring(): void;
  29550. /**
  29551. * Compute the time lapsed since the previous beginMonitoring() call.
  29552. * @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
  29553. */
  29554. endMonitoring(newFrame?: boolean): void;
  29555. private _fetchResult;
  29556. private _startMonitoringTime;
  29557. private _min;
  29558. private _max;
  29559. private _average;
  29560. private _current;
  29561. private _totalValueCount;
  29562. private _totalAccumulated;
  29563. private _lastSecAverage;
  29564. private _lastSecAccumulated;
  29565. private _lastSecTime;
  29566. private _lastSecValueCount;
  29567. }
  29568. }
  29569. declare module BABYLON {
  29570. /**
  29571. * Interface for any object that can request an animation frame
  29572. */
  29573. export interface ICustomAnimationFrameRequester {
  29574. /**
  29575. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29576. */
  29577. renderFunction?: Function;
  29578. /**
  29579. * Called to request the next frame to render to
  29580. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29581. */
  29582. requestAnimationFrame: Function;
  29583. /**
  29584. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29585. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29586. */
  29587. requestID?: number;
  29588. }
  29589. }
  29590. declare module BABYLON {
  29591. /**
  29592. * Settings for finer control over video usage
  29593. */
  29594. export interface VideoTextureSettings {
  29595. /**
  29596. * Applies `autoplay` to video, if specified
  29597. */
  29598. autoPlay?: boolean;
  29599. /**
  29600. * Applies `loop` to video, if specified
  29601. */
  29602. loop?: boolean;
  29603. /**
  29604. * Automatically updates internal texture from video at every frame in the render loop
  29605. */
  29606. autoUpdateTexture: boolean;
  29607. /**
  29608. * Image src displayed during the video loading or until the user interacts with the video.
  29609. */
  29610. poster?: string;
  29611. }
  29612. /**
  29613. * If you want to display a video in your scene, this is the special texture for that.
  29614. * This special texture works similar to other textures, with the exception of a few parameters.
  29615. * @see https://doc.babylonjs.com/how_to/video_texture
  29616. */
  29617. export class VideoTexture extends Texture {
  29618. /**
  29619. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29620. */
  29621. readonly autoUpdateTexture: boolean;
  29622. /**
  29623. * The video instance used by the texture internally
  29624. */
  29625. readonly video: HTMLVideoElement;
  29626. private _onUserActionRequestedObservable;
  29627. /**
  29628. * Event triggerd when a dom action is required by the user to play the video.
  29629. * This happens due to recent changes in browser policies preventing video to auto start.
  29630. */
  29631. readonly onUserActionRequestedObservable: Observable<Texture>;
  29632. private _generateMipMaps;
  29633. private _engine;
  29634. private _stillImageCaptured;
  29635. private _displayingPosterTexture;
  29636. private _settings;
  29637. private _createInternalTextureOnEvent;
  29638. private _frameId;
  29639. /**
  29640. * Creates a video texture.
  29641. * If you want to display a video in your scene, this is the special texture for that.
  29642. * This special texture works similar to other textures, with the exception of a few parameters.
  29643. * @see https://doc.babylonjs.com/how_to/video_texture
  29644. * @param name optional name, will detect from video source, if not defined
  29645. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29646. * @param scene is obviously the current scene.
  29647. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29648. * @param invertY is false by default but can be used to invert video on Y axis
  29649. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29650. * @param settings allows finer control over video usage
  29651. */
  29652. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29653. private _getName;
  29654. private _getVideo;
  29655. private _createInternalTexture;
  29656. private reset;
  29657. /**
  29658. * @hidden Internal method to initiate `update`.
  29659. */
  29660. _rebuild(): void;
  29661. /**
  29662. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29663. */
  29664. update(): void;
  29665. /**
  29666. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29667. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29668. */
  29669. updateTexture(isVisible: boolean): void;
  29670. protected _updateInternalTexture: () => void;
  29671. /**
  29672. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29673. * @param url New url.
  29674. */
  29675. updateURL(url: string): void;
  29676. /**
  29677. * Dispose the texture and release its associated resources.
  29678. */
  29679. dispose(): void;
  29680. /**
  29681. * Creates a video texture straight from a stream.
  29682. * @param scene Define the scene the texture should be created in
  29683. * @param stream Define the stream the texture should be created from
  29684. * @returns The created video texture as a promise
  29685. */
  29686. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29687. /**
  29688. * Creates a video texture straight from your WebCam video feed.
  29689. * @param scene Define the scene the texture should be created in
  29690. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29691. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29692. * @returns The created video texture as a promise
  29693. */
  29694. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29695. minWidth: number;
  29696. maxWidth: number;
  29697. minHeight: number;
  29698. maxHeight: number;
  29699. deviceId: string;
  29700. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29701. /**
  29702. * Creates a video texture straight from your WebCam video feed.
  29703. * @param scene Define the scene the texture should be created in
  29704. * @param onReady Define a callback to triggered once the texture will be ready
  29705. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29706. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29707. */
  29708. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29709. minWidth: number;
  29710. maxWidth: number;
  29711. minHeight: number;
  29712. maxHeight: number;
  29713. deviceId: string;
  29714. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29715. }
  29716. }
  29717. declare module BABYLON {
  29718. /**
  29719. * Defines the interface used by objects containing a viewport (like a camera)
  29720. */
  29721. interface IViewportOwnerLike {
  29722. /**
  29723. * Gets or sets the viewport
  29724. */
  29725. viewport: IViewportLike;
  29726. }
  29727. /**
  29728. * Interface for attribute information associated with buffer instanciation
  29729. */
  29730. export class InstancingAttributeInfo {
  29731. /**
  29732. * Index/offset of the attribute in the vertex shader
  29733. */
  29734. index: number;
  29735. /**
  29736. * size of the attribute, 1, 2, 3 or 4
  29737. */
  29738. attributeSize: number;
  29739. /**
  29740. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29741. * default is FLOAT
  29742. */
  29743. attribyteType: number;
  29744. /**
  29745. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29746. */
  29747. normalized: boolean;
  29748. /**
  29749. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29750. */
  29751. offset: number;
  29752. /**
  29753. * Name of the GLSL attribute, for debugging purpose only
  29754. */
  29755. attributeName: string;
  29756. }
  29757. /**
  29758. * Define options used to create a depth texture
  29759. */
  29760. export class DepthTextureCreationOptions {
  29761. /** Specifies whether or not a stencil should be allocated in the texture */
  29762. generateStencil?: boolean;
  29763. /** Specifies whether or not bilinear filtering is enable on the texture */
  29764. bilinearFiltering?: boolean;
  29765. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29766. comparisonFunction?: number;
  29767. /** Specifies if the created texture is a cube texture */
  29768. isCube?: boolean;
  29769. }
  29770. /**
  29771. * Class used to describe the capabilities of the engine relatively to the current browser
  29772. */
  29773. export class EngineCapabilities {
  29774. /** Maximum textures units per fragment shader */
  29775. maxTexturesImageUnits: number;
  29776. /** Maximum texture units per vertex shader */
  29777. maxVertexTextureImageUnits: number;
  29778. /** Maximum textures units in the entire pipeline */
  29779. maxCombinedTexturesImageUnits: number;
  29780. /** Maximum texture size */
  29781. maxTextureSize: number;
  29782. /** Maximum cube texture size */
  29783. maxCubemapTextureSize: number;
  29784. /** Maximum render texture size */
  29785. maxRenderTextureSize: number;
  29786. /** Maximum number of vertex attributes */
  29787. maxVertexAttribs: number;
  29788. /** Maximum number of varyings */
  29789. maxVaryingVectors: number;
  29790. /** Maximum number of uniforms per vertex shader */
  29791. maxVertexUniformVectors: number;
  29792. /** Maximum number of uniforms per fragment shader */
  29793. maxFragmentUniformVectors: number;
  29794. /** Defines if standard derivates (dx/dy) are supported */
  29795. standardDerivatives: boolean;
  29796. /** Defines if s3tc texture compression is supported */
  29797. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29798. /** Defines if pvrtc texture compression is supported */
  29799. pvrtc: any;
  29800. /** Defines if etc1 texture compression is supported */
  29801. etc1: any;
  29802. /** Defines if etc2 texture compression is supported */
  29803. etc2: any;
  29804. /** Defines if astc texture compression is supported */
  29805. astc: any;
  29806. /** Defines if float textures are supported */
  29807. textureFloat: boolean;
  29808. /** Defines if vertex array objects are supported */
  29809. vertexArrayObject: boolean;
  29810. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29811. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29812. /** Gets the maximum level of anisotropy supported */
  29813. maxAnisotropy: number;
  29814. /** Defines if instancing is supported */
  29815. instancedArrays: boolean;
  29816. /** Defines if 32 bits indices are supported */
  29817. uintIndices: boolean;
  29818. /** Defines if high precision shaders are supported */
  29819. highPrecisionShaderSupported: boolean;
  29820. /** Defines if depth reading in the fragment shader is supported */
  29821. fragmentDepthSupported: boolean;
  29822. /** Defines if float texture linear filtering is supported*/
  29823. textureFloatLinearFiltering: boolean;
  29824. /** Defines if rendering to float textures is supported */
  29825. textureFloatRender: boolean;
  29826. /** Defines if half float textures are supported*/
  29827. textureHalfFloat: boolean;
  29828. /** Defines if half float texture linear filtering is supported*/
  29829. textureHalfFloatLinearFiltering: boolean;
  29830. /** Defines if rendering to half float textures is supported */
  29831. textureHalfFloatRender: boolean;
  29832. /** Defines if textureLOD shader command is supported */
  29833. textureLOD: boolean;
  29834. /** Defines if draw buffers extension is supported */
  29835. drawBuffersExtension: boolean;
  29836. /** Defines if depth textures are supported */
  29837. depthTextureExtension: boolean;
  29838. /** Defines if float color buffer are supported */
  29839. colorBufferFloat: boolean;
  29840. /** Gets disjoint timer query extension (null if not supported) */
  29841. timerQuery: EXT_disjoint_timer_query;
  29842. /** Defines if timestamp can be used with timer query */
  29843. canUseTimestampForTimerQuery: boolean;
  29844. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29845. multiview: any;
  29846. /** Function used to let the system compiles shaders in background */
  29847. parallelShaderCompile: {
  29848. COMPLETION_STATUS_KHR: number;
  29849. };
  29850. /** Max number of texture samples for MSAA */
  29851. maxMSAASamples: number;
  29852. /** Defines if the blend min max extension is supported */
  29853. blendMinMax: boolean;
  29854. }
  29855. /** Interface defining initialization parameters for Engine class */
  29856. export interface EngineOptions extends WebGLContextAttributes {
  29857. /**
  29858. * Defines if the engine should no exceed a specified device ratio
  29859. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29860. */
  29861. limitDeviceRatio?: number;
  29862. /**
  29863. * Defines if webvr should be enabled automatically
  29864. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29865. */
  29866. autoEnableWebVR?: boolean;
  29867. /**
  29868. * Defines if webgl2 should be turned off even if supported
  29869. * @see http://doc.babylonjs.com/features/webgl2
  29870. */
  29871. disableWebGL2Support?: boolean;
  29872. /**
  29873. * Defines if webaudio should be initialized as well
  29874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29875. */
  29876. audioEngine?: boolean;
  29877. /**
  29878. * Defines if animations should run using a deterministic lock step
  29879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29880. */
  29881. deterministicLockstep?: boolean;
  29882. /** Defines the maximum steps to use with deterministic lock step mode */
  29883. lockstepMaxSteps?: number;
  29884. /**
  29885. * Defines that engine should ignore context lost events
  29886. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29887. */
  29888. doNotHandleContextLost?: boolean;
  29889. /**
  29890. * Defines that engine should ignore modifying touch action attribute and style
  29891. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29892. */
  29893. doNotHandleTouchAction?: boolean;
  29894. /**
  29895. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29896. */
  29897. useHighPrecisionFloats?: boolean;
  29898. }
  29899. /**
  29900. * Defines the interface used by display changed events
  29901. */
  29902. export interface IDisplayChangedEventArgs {
  29903. /** Gets the vrDisplay object (if any) */
  29904. vrDisplay: Nullable<any>;
  29905. /** Gets a boolean indicating if webVR is supported */
  29906. vrSupported: boolean;
  29907. }
  29908. /**
  29909. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29910. */
  29911. export class Engine {
  29912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29913. static ExceptionList: ({
  29914. key: string;
  29915. capture: string;
  29916. captureConstraint: number;
  29917. targets: string[];
  29918. } | {
  29919. key: string;
  29920. capture: null;
  29921. captureConstraint: null;
  29922. targets: string[];
  29923. })[];
  29924. /** Gets the list of created engines */
  29925. static readonly Instances: Engine[];
  29926. /**
  29927. * Gets the latest created engine
  29928. */
  29929. static readonly LastCreatedEngine: Nullable<Engine>;
  29930. /**
  29931. * Gets the latest created scene
  29932. */
  29933. static readonly LastCreatedScene: Nullable<Scene>;
  29934. /**
  29935. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29936. * @param flag defines which part of the materials must be marked as dirty
  29937. * @param predicate defines a predicate used to filter which materials should be affected
  29938. */
  29939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29940. /** @hidden */
  29941. static _TextureLoaders: IInternalTextureLoader[];
  29942. /** Defines that alpha blending is disabled */
  29943. static readonly ALPHA_DISABLE: number;
  29944. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29945. static readonly ALPHA_ADD: number;
  29946. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29947. static readonly ALPHA_COMBINE: number;
  29948. /** Defines that alpha blending to DEST - SRC * DEST */
  29949. static readonly ALPHA_SUBTRACT: number;
  29950. /** Defines that alpha blending to SRC * DEST */
  29951. static readonly ALPHA_MULTIPLY: number;
  29952. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29953. static readonly ALPHA_MAXIMIZED: number;
  29954. /** Defines that alpha blending to SRC + DEST */
  29955. static readonly ALPHA_ONEONE: number;
  29956. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29957. static readonly ALPHA_PREMULTIPLIED: number;
  29958. /**
  29959. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29960. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29961. */
  29962. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29963. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29964. static readonly ALPHA_INTERPOLATE: number;
  29965. /**
  29966. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29967. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29968. */
  29969. static readonly ALPHA_SCREENMODE: number;
  29970. /** Defines that the ressource is not delayed*/
  29971. static readonly DELAYLOADSTATE_NONE: number;
  29972. /** Defines that the ressource was successfully delay loaded */
  29973. static readonly DELAYLOADSTATE_LOADED: number;
  29974. /** Defines that the ressource is currently delay loading */
  29975. static readonly DELAYLOADSTATE_LOADING: number;
  29976. /** Defines that the ressource is delayed and has not started loading */
  29977. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29978. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29979. static readonly NEVER: number;
  29980. /** 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 */
  29981. static readonly ALWAYS: number;
  29982. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29983. static readonly LESS: number;
  29984. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29985. static readonly EQUAL: number;
  29986. /** 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 */
  29987. static readonly LEQUAL: number;
  29988. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29989. static readonly GREATER: number;
  29990. /** 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 */
  29991. static readonly GEQUAL: number;
  29992. /** 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 */
  29993. static readonly NOTEQUAL: number;
  29994. /** Passed to stencilOperation to specify that stencil value must be kept */
  29995. static readonly KEEP: number;
  29996. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29997. static readonly REPLACE: number;
  29998. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29999. static readonly INCR: number;
  30000. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30001. static readonly DECR: number;
  30002. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30003. static readonly INVERT: number;
  30004. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30005. static readonly INCR_WRAP: number;
  30006. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30007. static readonly DECR_WRAP: number;
  30008. /** Texture is not repeating outside of 0..1 UVs */
  30009. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30010. /** Texture is repeating outside of 0..1 UVs */
  30011. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30012. /** Texture is repeating and mirrored */
  30013. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30014. /** ALPHA */
  30015. static readonly TEXTUREFORMAT_ALPHA: number;
  30016. /** LUMINANCE */
  30017. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30018. /** LUMINANCE_ALPHA */
  30019. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30020. /** RGB */
  30021. static readonly TEXTUREFORMAT_RGB: number;
  30022. /** RGBA */
  30023. static readonly TEXTUREFORMAT_RGBA: number;
  30024. /** RED */
  30025. static readonly TEXTUREFORMAT_RED: number;
  30026. /** RED (2nd reference) */
  30027. static readonly TEXTUREFORMAT_R: number;
  30028. /** RG */
  30029. static readonly TEXTUREFORMAT_RG: number;
  30030. /** RED_INTEGER */
  30031. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30032. /** RED_INTEGER (2nd reference) */
  30033. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30034. /** RG_INTEGER */
  30035. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30036. /** RGB_INTEGER */
  30037. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30038. /** RGBA_INTEGER */
  30039. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30040. /** UNSIGNED_BYTE */
  30041. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30042. /** UNSIGNED_BYTE (2nd reference) */
  30043. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30044. /** FLOAT */
  30045. static readonly TEXTURETYPE_FLOAT: number;
  30046. /** HALF_FLOAT */
  30047. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30048. /** BYTE */
  30049. static readonly TEXTURETYPE_BYTE: number;
  30050. /** SHORT */
  30051. static readonly TEXTURETYPE_SHORT: number;
  30052. /** UNSIGNED_SHORT */
  30053. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30054. /** INT */
  30055. static readonly TEXTURETYPE_INT: number;
  30056. /** UNSIGNED_INT */
  30057. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30058. /** UNSIGNED_SHORT_4_4_4_4 */
  30059. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30060. /** UNSIGNED_SHORT_5_5_5_1 */
  30061. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30062. /** UNSIGNED_SHORT_5_6_5 */
  30063. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30064. /** UNSIGNED_INT_2_10_10_10_REV */
  30065. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30066. /** UNSIGNED_INT_24_8 */
  30067. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30068. /** UNSIGNED_INT_10F_11F_11F_REV */
  30069. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30070. /** UNSIGNED_INT_5_9_9_9_REV */
  30071. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30072. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30073. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30074. /** nearest is mag = nearest and min = nearest and mip = linear */
  30075. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30077. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30078. /** Trilinear is mag = linear and min = linear and mip = linear */
  30079. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30080. /** nearest is mag = nearest and min = nearest and mip = linear */
  30081. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30082. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30083. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30084. /** Trilinear is mag = linear and min = linear and mip = linear */
  30085. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30086. /** mag = nearest and min = nearest and mip = nearest */
  30087. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30088. /** mag = nearest and min = linear and mip = nearest */
  30089. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30090. /** mag = nearest and min = linear and mip = linear */
  30091. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30092. /** mag = nearest and min = linear and mip = none */
  30093. static readonly TEXTURE_NEAREST_LINEAR: number;
  30094. /** mag = nearest and min = nearest and mip = none */
  30095. static readonly TEXTURE_NEAREST_NEAREST: number;
  30096. /** mag = linear and min = nearest and mip = nearest */
  30097. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30098. /** mag = linear and min = nearest and mip = linear */
  30099. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30100. /** mag = linear and min = linear and mip = none */
  30101. static readonly TEXTURE_LINEAR_LINEAR: number;
  30102. /** mag = linear and min = nearest and mip = none */
  30103. static readonly TEXTURE_LINEAR_NEAREST: number;
  30104. /** Explicit coordinates mode */
  30105. static readonly TEXTURE_EXPLICIT_MODE: number;
  30106. /** Spherical coordinates mode */
  30107. static readonly TEXTURE_SPHERICAL_MODE: number;
  30108. /** Planar coordinates mode */
  30109. static readonly TEXTURE_PLANAR_MODE: number;
  30110. /** Cubic coordinates mode */
  30111. static readonly TEXTURE_CUBIC_MODE: number;
  30112. /** Projection coordinates mode */
  30113. static readonly TEXTURE_PROJECTION_MODE: number;
  30114. /** Skybox coordinates mode */
  30115. static readonly TEXTURE_SKYBOX_MODE: number;
  30116. /** Inverse Cubic coordinates mode */
  30117. static readonly TEXTURE_INVCUBIC_MODE: number;
  30118. /** Equirectangular coordinates mode */
  30119. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30120. /** Equirectangular Fixed coordinates mode */
  30121. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30122. /** Equirectangular Fixed Mirrored coordinates mode */
  30123. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30124. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30125. static readonly SCALEMODE_FLOOR: number;
  30126. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30127. static readonly SCALEMODE_NEAREST: number;
  30128. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30129. static readonly SCALEMODE_CEILING: number;
  30130. /**
  30131. * Returns the current npm package of the sdk
  30132. */
  30133. static readonly NpmPackage: string;
  30134. /**
  30135. * Returns the current version of the framework
  30136. */
  30137. static readonly Version: string;
  30138. /**
  30139. * Returns a string describing the current engine
  30140. */
  30141. readonly description: string;
  30142. /**
  30143. * Gets or sets the epsilon value used by collision engine
  30144. */
  30145. static CollisionsEpsilon: number;
  30146. /**
  30147. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30148. */
  30149. static ShadersRepository: string;
  30150. /**
  30151. * Method called to create the default loading screen.
  30152. * This can be overriden in your own app.
  30153. * @param canvas The rendering canvas element
  30154. * @returns The loading screen
  30155. */
  30156. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30157. /**
  30158. * Method called to create the default rescale post process on each engine.
  30159. */
  30160. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30161. /** @hidden */
  30162. _shaderProcessor: IShaderProcessor;
  30163. /**
  30164. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30165. */
  30166. forcePOTTextures: boolean;
  30167. /**
  30168. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30169. */
  30170. isFullscreen: boolean;
  30171. /**
  30172. * Gets a boolean indicating if the pointer is currently locked
  30173. */
  30174. isPointerLock: boolean;
  30175. /**
  30176. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30177. */
  30178. cullBackFaces: boolean;
  30179. /**
  30180. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30181. */
  30182. renderEvenInBackground: boolean;
  30183. /**
  30184. * Gets or sets a boolean indicating that cache can be kept between frames
  30185. */
  30186. preventCacheWipeBetweenFrames: boolean;
  30187. /**
  30188. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30189. **/
  30190. enableOfflineSupport: boolean;
  30191. /**
  30192. * 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)
  30193. **/
  30194. disableManifestCheck: boolean;
  30195. /**
  30196. * Gets the list of created scenes
  30197. */
  30198. scenes: Scene[];
  30199. /**
  30200. * Event raised when a new scene is created
  30201. */
  30202. onNewSceneAddedObservable: Observable<Scene>;
  30203. /**
  30204. * Gets the list of created postprocesses
  30205. */
  30206. postProcesses: PostProcess[];
  30207. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30208. validateShaderPrograms: boolean;
  30209. /**
  30210. * Observable event triggered each time the rendering canvas is resized
  30211. */
  30212. onResizeObservable: Observable<Engine>;
  30213. /**
  30214. * Observable event triggered each time the canvas loses focus
  30215. */
  30216. onCanvasBlurObservable: Observable<Engine>;
  30217. /**
  30218. * Observable event triggered each time the canvas gains focus
  30219. */
  30220. onCanvasFocusObservable: Observable<Engine>;
  30221. /**
  30222. * Observable event triggered each time the canvas receives pointerout event
  30223. */
  30224. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30225. /**
  30226. * Observable event triggered before each texture is initialized
  30227. */
  30228. onBeforeTextureInitObservable: Observable<Texture>;
  30229. /**
  30230. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30231. */
  30232. disableUniformBuffers: boolean;
  30233. /** @hidden */
  30234. _uniformBuffers: UniformBuffer[];
  30235. /**
  30236. * Gets a boolean indicating that the engine supports uniform buffers
  30237. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30238. */
  30239. readonly supportsUniformBuffers: boolean;
  30240. /**
  30241. * Observable raised when the engine begins a new frame
  30242. */
  30243. onBeginFrameObservable: Observable<Engine>;
  30244. /**
  30245. * If set, will be used to request the next animation frame for the render loop
  30246. */
  30247. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30248. /**
  30249. * Observable raised when the engine ends the current frame
  30250. */
  30251. onEndFrameObservable: Observable<Engine>;
  30252. /**
  30253. * Observable raised when the engine is about to compile a shader
  30254. */
  30255. onBeforeShaderCompilationObservable: Observable<Engine>;
  30256. /**
  30257. * Observable raised when the engine has jsut compiled a shader
  30258. */
  30259. onAfterShaderCompilationObservable: Observable<Engine>;
  30260. /** @hidden */
  30261. _gl: WebGLRenderingContext;
  30262. private _renderingCanvas;
  30263. private _windowIsBackground;
  30264. protected _webGLVersion: number;
  30265. protected _highPrecisionShadersAllowed: boolean;
  30266. /** @hidden */
  30267. readonly _shouldUseHighPrecisionShader: boolean;
  30268. /**
  30269. * Gets a boolean indicating that only power of 2 textures are supported
  30270. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30271. */
  30272. readonly needPOTTextures: boolean;
  30273. /** @hidden */
  30274. _badOS: boolean;
  30275. /** @hidden */
  30276. _badDesktopOS: boolean;
  30277. /**
  30278. * Gets the audio engine
  30279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30280. * @ignorenaming
  30281. */
  30282. static audioEngine: IAudioEngine;
  30283. /**
  30284. * Default AudioEngine factory responsible of creating the Audio Engine.
  30285. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30286. */
  30287. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30288. /**
  30289. * Default offline support factory responsible of creating a tool used to store data locally.
  30290. * By default, this will create a Database object if the workload has been embedded.
  30291. */
  30292. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30293. private _onFocus;
  30294. private _onBlur;
  30295. private _onCanvasPointerOut;
  30296. private _onCanvasBlur;
  30297. private _onCanvasFocus;
  30298. private _onFullscreenChange;
  30299. private _onPointerLockChange;
  30300. private _hardwareScalingLevel;
  30301. /** @hidden */
  30302. _caps: EngineCapabilities;
  30303. private _pointerLockRequested;
  30304. private _isStencilEnable;
  30305. protected _colorWrite: boolean;
  30306. private _loadingScreen;
  30307. /** @hidden */
  30308. _drawCalls: PerfCounter;
  30309. private _glVersion;
  30310. private _glRenderer;
  30311. private _glVendor;
  30312. private _videoTextureSupported;
  30313. private _renderingQueueLaunched;
  30314. private _activeRenderLoops;
  30315. private _deterministicLockstep;
  30316. private _lockstepMaxSteps;
  30317. /**
  30318. * Observable signaled when a context lost event is raised
  30319. */
  30320. onContextLostObservable: Observable<Engine>;
  30321. /**
  30322. * Observable signaled when a context restored event is raised
  30323. */
  30324. onContextRestoredObservable: Observable<Engine>;
  30325. private _onContextLost;
  30326. private _onContextRestored;
  30327. private _contextWasLost;
  30328. /** @hidden */
  30329. _doNotHandleContextLost: boolean;
  30330. /**
  30331. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30333. */
  30334. doNotHandleContextLost: boolean;
  30335. private _performanceMonitor;
  30336. private _fps;
  30337. private _deltaTime;
  30338. /**
  30339. * Turn this value on if you want to pause FPS computation when in background
  30340. */
  30341. disablePerformanceMonitorInBackground: boolean;
  30342. /**
  30343. * Gets the performance monitor attached to this engine
  30344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30345. */
  30346. readonly performanceMonitor: PerformanceMonitor;
  30347. /**
  30348. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30349. */
  30350. disableVertexArrayObjects: boolean;
  30351. /** @hidden */
  30352. protected _depthCullingState: _DepthCullingState;
  30353. /** @hidden */
  30354. protected _stencilState: _StencilState;
  30355. /** @hidden */
  30356. protected _alphaState: _AlphaState;
  30357. /** @hidden */
  30358. protected _alphaMode: number;
  30359. /** @hidden */
  30360. protected _alphaEquation: number;
  30361. /** @hidden */
  30362. _internalTexturesCache: InternalTexture[];
  30363. /** @hidden */
  30364. protected _activeChannel: number;
  30365. private _currentTextureChannel;
  30366. /** @hidden */
  30367. protected _boundTexturesCache: {
  30368. [key: string]: Nullable<InternalTexture>;
  30369. };
  30370. /** @hidden */
  30371. protected _currentEffect: Nullable<Effect>;
  30372. /** @hidden */
  30373. protected _currentProgram: Nullable<WebGLProgram>;
  30374. private _compiledEffects;
  30375. private _vertexAttribArraysEnabled;
  30376. /** @hidden */
  30377. protected _cachedViewport: Nullable<IViewportLike>;
  30378. private _cachedVertexArrayObject;
  30379. /** @hidden */
  30380. protected _cachedVertexBuffers: any;
  30381. /** @hidden */
  30382. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30383. /** @hidden */
  30384. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30385. /** @hidden */
  30386. _currentRenderTarget: Nullable<InternalTexture>;
  30387. private _uintIndicesCurrentlySet;
  30388. private _currentBoundBuffer;
  30389. /** @hidden */
  30390. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30391. private _currentBufferPointers;
  30392. private _currentInstanceLocations;
  30393. private _currentInstanceBuffers;
  30394. private _textureUnits;
  30395. /** @hidden */
  30396. _workingCanvas: Nullable<HTMLCanvasElement>;
  30397. /** @hidden */
  30398. _workingContext: Nullable<CanvasRenderingContext2D>;
  30399. private _rescalePostProcess;
  30400. private _dummyFramebuffer;
  30401. private _externalData;
  30402. /** @hidden */
  30403. _bindedRenderFunction: any;
  30404. private _vaoRecordInProgress;
  30405. private _mustWipeVertexAttributes;
  30406. private _emptyTexture;
  30407. private _emptyCubeTexture;
  30408. private _emptyTexture3D;
  30409. /** @hidden */
  30410. _frameHandler: number;
  30411. private _nextFreeTextureSlots;
  30412. private _maxSimultaneousTextures;
  30413. private _activeRequests;
  30414. private _texturesSupported;
  30415. /** @hidden */
  30416. _textureFormatInUse: Nullable<string>;
  30417. /**
  30418. * Gets the list of texture formats supported
  30419. */
  30420. readonly texturesSupported: Array<string>;
  30421. /**
  30422. * Gets the list of texture formats in use
  30423. */
  30424. readonly textureFormatInUse: Nullable<string>;
  30425. /**
  30426. * Gets the current viewport
  30427. */
  30428. readonly currentViewport: Nullable<IViewportLike>;
  30429. /**
  30430. * Gets the default empty texture
  30431. */
  30432. readonly emptyTexture: InternalTexture;
  30433. /**
  30434. * Gets the default empty 3D texture
  30435. */
  30436. readonly emptyTexture3D: InternalTexture;
  30437. /**
  30438. * Gets the default empty cube texture
  30439. */
  30440. readonly emptyCubeTexture: InternalTexture;
  30441. /**
  30442. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30443. */
  30444. readonly premultipliedAlpha: boolean;
  30445. /**
  30446. * Creates a new engine
  30447. * @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
  30448. * @param antialias defines enable antialiasing (default: false)
  30449. * @param options defines further options to be sent to the getContext() function
  30450. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30451. */
  30452. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30453. /**
  30454. * Initializes a webVR display and starts listening to display change events
  30455. * The onVRDisplayChangedObservable will be notified upon these changes
  30456. * @returns The onVRDisplayChangedObservable
  30457. */
  30458. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30459. /** @hidden */
  30460. _prepareVRComponent(): void;
  30461. /** @hidden */
  30462. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30463. /** @hidden */
  30464. _submitVRFrame(): void;
  30465. /**
  30466. * Call this function to leave webVR mode
  30467. * Will do nothing if webVR is not supported or if there is no webVR device
  30468. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30469. */
  30470. disableVR(): void;
  30471. /**
  30472. * Gets a boolean indicating that the system is in VR mode and is presenting
  30473. * @returns true if VR mode is engaged
  30474. */
  30475. isVRPresenting(): boolean;
  30476. /** @hidden */
  30477. _requestVRFrame(): void;
  30478. private _disableTouchAction;
  30479. private _rebuildInternalTextures;
  30480. private _rebuildEffects;
  30481. /**
  30482. * Gets a boolean indicating if all created effects are ready
  30483. * @returns true if all effects are ready
  30484. */
  30485. areAllEffectsReady(): boolean;
  30486. private _rebuildBuffers;
  30487. private _initGLContext;
  30488. /**
  30489. * Gets version of the current webGL context
  30490. */
  30491. readonly webGLVersion: number;
  30492. /**
  30493. * Gets a string idenfifying the name of the class
  30494. * @returns "Engine" string
  30495. */
  30496. getClassName(): string;
  30497. /**
  30498. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30499. */
  30500. readonly isStencilEnable: boolean;
  30501. /** @hidden */
  30502. _prepareWorkingCanvas(): void;
  30503. /**
  30504. * Reset the texture cache to empty state
  30505. */
  30506. resetTextureCache(): void;
  30507. /**
  30508. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30510. * @returns true if engine is in deterministic lock step mode
  30511. */
  30512. isDeterministicLockStep(): boolean;
  30513. /**
  30514. * Gets the max steps when engine is running in deterministic lock step
  30515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30516. * @returns the max steps
  30517. */
  30518. getLockstepMaxSteps(): number;
  30519. /**
  30520. * Gets an object containing information about the current webGL context
  30521. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30522. */
  30523. getGlInfo(): {
  30524. vendor: string;
  30525. renderer: string;
  30526. version: string;
  30527. };
  30528. /**
  30529. * Gets current aspect ratio
  30530. * @param viewportOwner defines the camera to use to get the aspect ratio
  30531. * @param useScreen defines if screen size must be used (or the current render target if any)
  30532. * @returns a number defining the aspect ratio
  30533. */
  30534. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30535. /**
  30536. * Gets current screen aspect ratio
  30537. * @returns a number defining the aspect ratio
  30538. */
  30539. getScreenAspectRatio(): number;
  30540. /**
  30541. * Gets the current render width
  30542. * @param useScreen defines if screen size must be used (or the current render target if any)
  30543. * @returns a number defining the current render width
  30544. */
  30545. getRenderWidth(useScreen?: boolean): number;
  30546. /**
  30547. * Gets the current render height
  30548. * @param useScreen defines if screen size must be used (or the current render target if any)
  30549. * @returns a number defining the current render height
  30550. */
  30551. getRenderHeight(useScreen?: boolean): number;
  30552. /**
  30553. * Gets the HTML canvas attached with the current webGL context
  30554. * @returns a HTML canvas
  30555. */
  30556. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30557. /**
  30558. * Gets host window
  30559. * @returns the host window object
  30560. */
  30561. getHostWindow(): Window;
  30562. /**
  30563. * Gets host document
  30564. * @returns the host document object
  30565. */
  30566. getHostDocument(): Document;
  30567. /**
  30568. * Gets the client rect of the HTML canvas attached with the current webGL context
  30569. * @returns a client rectanglee
  30570. */
  30571. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30572. /**
  30573. * Defines the hardware scaling level.
  30574. * By default the hardware scaling level is computed from the window device ratio.
  30575. * 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.
  30576. * @param level defines the level to use
  30577. */
  30578. setHardwareScalingLevel(level: number): void;
  30579. /**
  30580. * Gets the current hardware scaling level.
  30581. * By default the hardware scaling level is computed from the window device ratio.
  30582. * 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.
  30583. * @returns a number indicating the current hardware scaling level
  30584. */
  30585. getHardwareScalingLevel(): number;
  30586. /**
  30587. * Gets the list of loaded textures
  30588. * @returns an array containing all loaded textures
  30589. */
  30590. getLoadedTexturesCache(): InternalTexture[];
  30591. /**
  30592. * Gets the object containing all engine capabilities
  30593. * @returns the EngineCapabilities object
  30594. */
  30595. getCaps(): EngineCapabilities;
  30596. /**
  30597. * Gets the current depth function
  30598. * @returns a number defining the depth function
  30599. */
  30600. getDepthFunction(): Nullable<number>;
  30601. /**
  30602. * Sets the current depth function
  30603. * @param depthFunc defines the function to use
  30604. */
  30605. setDepthFunction(depthFunc: number): void;
  30606. /**
  30607. * Sets the current depth function to GREATER
  30608. */
  30609. setDepthFunctionToGreater(): void;
  30610. /**
  30611. * Sets the current depth function to GEQUAL
  30612. */
  30613. setDepthFunctionToGreaterOrEqual(): void;
  30614. /**
  30615. * Sets the current depth function to LESS
  30616. */
  30617. setDepthFunctionToLess(): void;
  30618. private _cachedStencilBuffer;
  30619. private _cachedStencilFunction;
  30620. private _cachedStencilMask;
  30621. private _cachedStencilOperationPass;
  30622. private _cachedStencilOperationFail;
  30623. private _cachedStencilOperationDepthFail;
  30624. private _cachedStencilReference;
  30625. /**
  30626. * Caches the the state of the stencil buffer
  30627. */
  30628. cacheStencilState(): void;
  30629. /**
  30630. * Restores the state of the stencil buffer
  30631. */
  30632. restoreStencilState(): void;
  30633. /**
  30634. * Sets the current depth function to LEQUAL
  30635. */
  30636. setDepthFunctionToLessOrEqual(): void;
  30637. /**
  30638. * Gets a boolean indicating if stencil buffer is enabled
  30639. * @returns the current stencil buffer state
  30640. */
  30641. getStencilBuffer(): boolean;
  30642. /**
  30643. * Enable or disable the stencil buffer
  30644. * @param enable defines if the stencil buffer must be enabled or disabled
  30645. */
  30646. setStencilBuffer(enable: boolean): void;
  30647. /**
  30648. * Gets the current stencil mask
  30649. * @returns a number defining the new stencil mask to use
  30650. */
  30651. getStencilMask(): number;
  30652. /**
  30653. * Sets the current stencil mask
  30654. * @param mask defines the new stencil mask to use
  30655. */
  30656. setStencilMask(mask: number): void;
  30657. /**
  30658. * Gets the current stencil function
  30659. * @returns a number defining the stencil function to use
  30660. */
  30661. getStencilFunction(): number;
  30662. /**
  30663. * Gets the current stencil reference value
  30664. * @returns a number defining the stencil reference value to use
  30665. */
  30666. getStencilFunctionReference(): number;
  30667. /**
  30668. * Gets the current stencil mask
  30669. * @returns a number defining the stencil mask to use
  30670. */
  30671. getStencilFunctionMask(): number;
  30672. /**
  30673. * Sets the current stencil function
  30674. * @param stencilFunc defines the new stencil function to use
  30675. */
  30676. setStencilFunction(stencilFunc: number): void;
  30677. /**
  30678. * Sets the current stencil reference
  30679. * @param reference defines the new stencil reference to use
  30680. */
  30681. setStencilFunctionReference(reference: number): void;
  30682. /**
  30683. * Sets the current stencil mask
  30684. * @param mask defines the new stencil mask to use
  30685. */
  30686. setStencilFunctionMask(mask: number): void;
  30687. /**
  30688. * Gets the current stencil operation when stencil fails
  30689. * @returns a number defining stencil operation to use when stencil fails
  30690. */
  30691. getStencilOperationFail(): number;
  30692. /**
  30693. * Gets the current stencil operation when depth fails
  30694. * @returns a number defining stencil operation to use when depth fails
  30695. */
  30696. getStencilOperationDepthFail(): number;
  30697. /**
  30698. * Gets the current stencil operation when stencil passes
  30699. * @returns a number defining stencil operation to use when stencil passes
  30700. */
  30701. getStencilOperationPass(): number;
  30702. /**
  30703. * Sets the stencil operation to use when stencil fails
  30704. * @param operation defines the stencil operation to use when stencil fails
  30705. */
  30706. setStencilOperationFail(operation: number): void;
  30707. /**
  30708. * Sets the stencil operation to use when depth fails
  30709. * @param operation defines the stencil operation to use when depth fails
  30710. */
  30711. setStencilOperationDepthFail(operation: number): void;
  30712. /**
  30713. * Sets the stencil operation to use when stencil passes
  30714. * @param operation defines the stencil operation to use when stencil passes
  30715. */
  30716. setStencilOperationPass(operation: number): void;
  30717. /**
  30718. * Sets a boolean indicating if the dithering state is enabled or disabled
  30719. * @param value defines the dithering state
  30720. */
  30721. setDitheringState(value: boolean): void;
  30722. /**
  30723. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30724. * @param value defines the rasterizer state
  30725. */
  30726. setRasterizerState(value: boolean): void;
  30727. /**
  30728. * stop executing a render loop function and remove it from the execution array
  30729. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30730. */
  30731. stopRenderLoop(renderFunction?: () => void): void;
  30732. /** @hidden */
  30733. _renderLoop(): void;
  30734. /**
  30735. * Can be used to override the current requestAnimationFrame requester.
  30736. * @hidden
  30737. */
  30738. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30739. /**
  30740. * Register and execute a render loop. The engine can have more than one render function
  30741. * @param renderFunction defines the function to continuously execute
  30742. */
  30743. runRenderLoop(renderFunction: () => void): void;
  30744. /**
  30745. * Toggle full screen mode
  30746. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30747. */
  30748. switchFullscreen(requestPointerLock: boolean): void;
  30749. /**
  30750. * Enters full screen mode
  30751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30752. */
  30753. enterFullscreen(requestPointerLock: boolean): void;
  30754. /**
  30755. * Exits full screen mode
  30756. */
  30757. exitFullscreen(): void;
  30758. /**
  30759. * Enters Pointerlock mode
  30760. */
  30761. enterPointerlock(): void;
  30762. /**
  30763. * Exits Pointerlock mode
  30764. */
  30765. exitPointerlock(): void;
  30766. /**
  30767. * Clear the current render buffer or the current render target (if any is set up)
  30768. * @param color defines the color to use
  30769. * @param backBuffer defines if the back buffer must be cleared
  30770. * @param depth defines if the depth buffer must be cleared
  30771. * @param stencil defines if the stencil buffer must be cleared
  30772. */
  30773. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30774. /**
  30775. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30776. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30777. * @param y defines the y-coordinate of the corner of the clear rectangle
  30778. * @param width defines the width of the clear rectangle
  30779. * @param height defines the height of the clear rectangle
  30780. * @param clearColor defines the clear color
  30781. */
  30782. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30783. /**
  30784. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30785. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30786. * @param y defines the y-coordinate of the corner of the clear rectangle
  30787. * @param width defines the width of the clear rectangle
  30788. * @param height defines the height of the clear rectangle
  30789. */
  30790. enableScissor(x: number, y: number, width: number, height: number): void;
  30791. /**
  30792. * Disable previously set scissor test rectangle
  30793. */
  30794. disableScissor(): void;
  30795. private _viewportCached;
  30796. /** @hidden */
  30797. _viewport(x: number, y: number, width: number, height: number): void;
  30798. /**
  30799. * Set the WebGL's viewport
  30800. * @param viewport defines the viewport element to be used
  30801. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30802. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30803. */
  30804. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30805. /**
  30806. * Directly set the WebGL Viewport
  30807. * @param x defines the x coordinate of the viewport (in screen space)
  30808. * @param y defines the y coordinate of the viewport (in screen space)
  30809. * @param width defines the width of the viewport (in screen space)
  30810. * @param height defines the height of the viewport (in screen space)
  30811. * @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
  30812. */
  30813. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30814. /**
  30815. * Begin a new frame
  30816. */
  30817. beginFrame(): void;
  30818. /**
  30819. * Enf the current frame
  30820. */
  30821. endFrame(): void;
  30822. /**
  30823. * Resize the view according to the canvas' size
  30824. */
  30825. resize(): void;
  30826. /**
  30827. * Force a specific size of the canvas
  30828. * @param width defines the new canvas' width
  30829. * @param height defines the new canvas' height
  30830. */
  30831. setSize(width: number, height: number): void;
  30832. /**
  30833. * Binds the frame buffer to the specified texture.
  30834. * @param texture The texture to render to or null for the default canvas
  30835. * @param faceIndex The face of the texture to render to in case of cube texture
  30836. * @param requiredWidth The width of the target to render to
  30837. * @param requiredHeight The height of the target to render to
  30838. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30839. * @param depthStencilTexture The depth stencil texture to use to render
  30840. * @param lodLevel defines le lod level to bind to the frame buffer
  30841. */
  30842. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30843. /** @hidden */
  30844. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30845. /**
  30846. * Unbind the current render target texture from the webGL context
  30847. * @param texture defines the render target texture to unbind
  30848. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30849. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30850. */
  30851. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30852. /**
  30853. * Force the mipmap generation for the given render target texture
  30854. * @param texture defines the render target texture to use
  30855. */
  30856. generateMipMapsForCubemap(texture: InternalTexture): void;
  30857. /**
  30858. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30859. */
  30860. flushFramebuffer(): void;
  30861. /**
  30862. * Unbind the current render target and bind the default framebuffer
  30863. */
  30864. restoreDefaultFramebuffer(): void;
  30865. /**
  30866. * Create an uniform buffer
  30867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30868. * @param elements defines the content of the uniform buffer
  30869. * @returns the webGL uniform buffer
  30870. */
  30871. createUniformBuffer(elements: FloatArray): DataBuffer;
  30872. /**
  30873. * Create a dynamic uniform buffer
  30874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30875. * @param elements defines the content of the uniform buffer
  30876. * @returns the webGL uniform buffer
  30877. */
  30878. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30879. /**
  30880. * Update an existing uniform buffer
  30881. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30882. * @param uniformBuffer defines the target uniform buffer
  30883. * @param elements defines the content to update
  30884. * @param offset defines the offset in the uniform buffer where update should start
  30885. * @param count defines the size of the data to update
  30886. */
  30887. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30888. private _resetVertexBufferBinding;
  30889. /**
  30890. * Creates a vertex buffer
  30891. * @param data the data for the vertex buffer
  30892. * @returns the new WebGL static buffer
  30893. */
  30894. createVertexBuffer(data: DataArray): DataBuffer;
  30895. /**
  30896. * Creates a dynamic vertex buffer
  30897. * @param data the data for the dynamic vertex buffer
  30898. * @returns the new WebGL dynamic buffer
  30899. */
  30900. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30901. /**
  30902. * Update a dynamic index buffer
  30903. * @param indexBuffer defines the target index buffer
  30904. * @param indices defines the data to update
  30905. * @param offset defines the offset in the target index buffer where update should start
  30906. */
  30907. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30908. /**
  30909. * Updates a dynamic vertex buffer.
  30910. * @param vertexBuffer the vertex buffer to update
  30911. * @param data the data used to update the vertex buffer
  30912. * @param byteOffset the byte offset of the data
  30913. * @param byteLength the byte length of the data
  30914. */
  30915. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30916. private _resetIndexBufferBinding;
  30917. /**
  30918. * Creates a new index buffer
  30919. * @param indices defines the content of the index buffer
  30920. * @param updatable defines if the index buffer must be updatable
  30921. * @returns a new webGL buffer
  30922. */
  30923. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30924. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30925. /**
  30926. * Bind a webGL buffer to the webGL context
  30927. * @param buffer defines the buffer to bind
  30928. */
  30929. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30930. /**
  30931. * Bind an uniform buffer to the current webGL context
  30932. * @param buffer defines the buffer to bind
  30933. */
  30934. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30935. /**
  30936. * Bind a buffer to the current webGL context at a given location
  30937. * @param buffer defines the buffer to bind
  30938. * @param location defines the index where to bind the buffer
  30939. */
  30940. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30941. /**
  30942. * Bind a specific block at a given index in a specific shader program
  30943. * @param pipelineContext defines the pipeline context to use
  30944. * @param blockName defines the block name
  30945. * @param index defines the index where to bind the block
  30946. */
  30947. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30948. private bindIndexBuffer;
  30949. private bindBuffer;
  30950. /**
  30951. * update the bound buffer with the given data
  30952. * @param data defines the data to update
  30953. */
  30954. updateArrayBuffer(data: Float32Array): void;
  30955. private _vertexAttribPointer;
  30956. private _bindIndexBufferWithCache;
  30957. private _bindVertexBuffersAttributes;
  30958. /**
  30959. * Records a vertex array object
  30960. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30961. * @param vertexBuffers defines the list of vertex buffers to store
  30962. * @param indexBuffer defines the index buffer to store
  30963. * @param effect defines the effect to store
  30964. * @returns the new vertex array object
  30965. */
  30966. recordVertexArrayObject(vertexBuffers: {
  30967. [key: string]: VertexBuffer;
  30968. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30969. /**
  30970. * Bind a specific vertex array object
  30971. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30972. * @param vertexArrayObject defines the vertex array object to bind
  30973. * @param indexBuffer defines the index buffer to bind
  30974. */
  30975. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30976. /**
  30977. * Bind webGl buffers directly to the webGL context
  30978. * @param vertexBuffer defines the vertex buffer to bind
  30979. * @param indexBuffer defines the index buffer to bind
  30980. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30981. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30982. * @param effect defines the effect associated with the vertex buffer
  30983. */
  30984. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30985. private _unbindVertexArrayObject;
  30986. /**
  30987. * Bind a list of vertex buffers to the webGL context
  30988. * @param vertexBuffers defines the list of vertex buffers to bind
  30989. * @param indexBuffer defines the index buffer to bind
  30990. * @param effect defines the effect associated with the vertex buffers
  30991. */
  30992. bindBuffers(vertexBuffers: {
  30993. [key: string]: Nullable<VertexBuffer>;
  30994. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30995. /**
  30996. * Unbind all instance attributes
  30997. */
  30998. unbindInstanceAttributes(): void;
  30999. /**
  31000. * Release and free the memory of a vertex array object
  31001. * @param vao defines the vertex array object to delete
  31002. */
  31003. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31004. /** @hidden */
  31005. _releaseBuffer(buffer: DataBuffer): boolean;
  31006. protected _deleteBuffer(buffer: DataBuffer): void;
  31007. /**
  31008. * Creates a webGL buffer to use with instanciation
  31009. * @param capacity defines the size of the buffer
  31010. * @returns the webGL buffer
  31011. */
  31012. createInstancesBuffer(capacity: number): DataBuffer;
  31013. /**
  31014. * Delete a webGL buffer used with instanciation
  31015. * @param buffer defines the webGL buffer to delete
  31016. */
  31017. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31018. /**
  31019. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31020. * @param instancesBuffer defines the webGL buffer to update and bind
  31021. * @param data defines the data to store in the buffer
  31022. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31023. */
  31024. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31025. /**
  31026. * Apply all cached states (depth, culling, stencil and alpha)
  31027. */
  31028. applyStates(): void;
  31029. /**
  31030. * Send a draw order
  31031. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31032. * @param indexStart defines the starting index
  31033. * @param indexCount defines the number of index to draw
  31034. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31035. */
  31036. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31037. /**
  31038. * Draw a list of points
  31039. * @param verticesStart defines the index of first vertex to draw
  31040. * @param verticesCount defines the count of vertices to draw
  31041. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31042. */
  31043. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31044. /**
  31045. * Draw a list of unindexed primitives
  31046. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31047. * @param verticesStart defines the index of first vertex to draw
  31048. * @param verticesCount defines the count of vertices to draw
  31049. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31050. */
  31051. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31052. /**
  31053. * Draw a list of indexed primitives
  31054. * @param fillMode defines the primitive to use
  31055. * @param indexStart defines the starting index
  31056. * @param indexCount defines the number of index to draw
  31057. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31058. */
  31059. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31060. /**
  31061. * Draw a list of unindexed primitives
  31062. * @param fillMode defines the primitive to use
  31063. * @param verticesStart defines the index of first vertex to draw
  31064. * @param verticesCount defines the count of vertices to draw
  31065. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31066. */
  31067. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31068. private _drawMode;
  31069. /** @hidden */
  31070. _releaseEffect(effect: Effect): void;
  31071. /** @hidden */
  31072. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31073. /**
  31074. * Create a new effect (used to store vertex/fragment shaders)
  31075. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31076. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31077. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31078. * @param samplers defines an array of string used to represent textures
  31079. * @param defines defines the string containing the defines to use to compile the shaders
  31080. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31081. * @param onCompiled defines a function to call when the effect creation is successful
  31082. * @param onError defines a function to call when the effect creation has failed
  31083. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31084. * @returns the new Effect
  31085. */
  31086. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31087. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31088. private _compileShader;
  31089. private _compileRawShader;
  31090. /**
  31091. * Directly creates a webGL program
  31092. * @param pipelineContext defines the pipeline context to attach to
  31093. * @param vertexCode defines the vertex shader code to use
  31094. * @param fragmentCode defines the fragment shader code to use
  31095. * @param context defines the webGL context to use (if not set, the current one will be used)
  31096. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31097. * @returns the new webGL program
  31098. */
  31099. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31100. /**
  31101. * Creates a webGL program
  31102. * @param pipelineContext defines the pipeline context to attach to
  31103. * @param vertexCode defines the vertex shader code to use
  31104. * @param fragmentCode defines the fragment shader code to use
  31105. * @param defines defines the string containing the defines to use to compile the shaders
  31106. * @param context defines the webGL context to use (if not set, the current one will be used)
  31107. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31108. * @returns the new webGL program
  31109. */
  31110. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31111. /**
  31112. * Creates a new pipeline context
  31113. * @returns the new pipeline
  31114. */
  31115. createPipelineContext(): IPipelineContext;
  31116. private _createShaderProgram;
  31117. private _finalizePipelineContext;
  31118. /** @hidden */
  31119. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31120. /** @hidden */
  31121. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31122. /** @hidden */
  31123. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31124. /**
  31125. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31126. * @param pipelineContext defines the pipeline context to use
  31127. * @param uniformsNames defines the list of uniform names
  31128. * @returns an array of webGL uniform locations
  31129. */
  31130. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31131. /**
  31132. * Gets the lsit of active attributes for a given webGL program
  31133. * @param pipelineContext defines the pipeline context to use
  31134. * @param attributesNames defines the list of attribute names to get
  31135. * @returns an array of indices indicating the offset of each attribute
  31136. */
  31137. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31138. /**
  31139. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31140. * @param effect defines the effect to activate
  31141. */
  31142. enableEffect(effect: Nullable<Effect>): void;
  31143. /**
  31144. * Set the value of an uniform to an array of int32
  31145. * @param uniform defines the webGL uniform location where to store the value
  31146. * @param array defines the array of int32 to store
  31147. */
  31148. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31149. /**
  31150. * Set the value of an uniform to an array of int32 (stored as vec2)
  31151. * @param uniform defines the webGL uniform location where to store the value
  31152. * @param array defines the array of int32 to store
  31153. */
  31154. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31155. /**
  31156. * Set the value of an uniform to an array of int32 (stored as vec3)
  31157. * @param uniform defines the webGL uniform location where to store the value
  31158. * @param array defines the array of int32 to store
  31159. */
  31160. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31161. /**
  31162. * Set the value of an uniform to an array of int32 (stored as vec4)
  31163. * @param uniform defines the webGL uniform location where to store the value
  31164. * @param array defines the array of int32 to store
  31165. */
  31166. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31167. /**
  31168. * Set the value of an uniform to an array of float32
  31169. * @param uniform defines the webGL uniform location where to store the value
  31170. * @param array defines the array of float32 to store
  31171. */
  31172. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31173. /**
  31174. * Set the value of an uniform to an array of float32 (stored as vec2)
  31175. * @param uniform defines the webGL uniform location where to store the value
  31176. * @param array defines the array of float32 to store
  31177. */
  31178. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31179. /**
  31180. * Set the value of an uniform to an array of float32 (stored as vec3)
  31181. * @param uniform defines the webGL uniform location where to store the value
  31182. * @param array defines the array of float32 to store
  31183. */
  31184. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31185. /**
  31186. * Set the value of an uniform to an array of float32 (stored as vec4)
  31187. * @param uniform defines the webGL uniform location where to store the value
  31188. * @param array defines the array of float32 to store
  31189. */
  31190. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31191. /**
  31192. * Set the value of an uniform to an array of number
  31193. * @param uniform defines the webGL uniform location where to store the value
  31194. * @param array defines the array of number to store
  31195. */
  31196. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31197. /**
  31198. * Set the value of an uniform to an array of number (stored as vec2)
  31199. * @param uniform defines the webGL uniform location where to store the value
  31200. * @param array defines the array of number to store
  31201. */
  31202. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31203. /**
  31204. * Set the value of an uniform to an array of number (stored as vec3)
  31205. * @param uniform defines the webGL uniform location where to store the value
  31206. * @param array defines the array of number to store
  31207. */
  31208. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31209. /**
  31210. * Set the value of an uniform to an array of number (stored as vec4)
  31211. * @param uniform defines the webGL uniform location where to store the value
  31212. * @param array defines the array of number to store
  31213. */
  31214. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31215. /**
  31216. * Set the value of an uniform to an array of float32 (stored as matrices)
  31217. * @param uniform defines the webGL uniform location where to store the value
  31218. * @param matrices defines the array of float32 to store
  31219. */
  31220. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31221. /**
  31222. * Set the value of an uniform to a matrix (3x3)
  31223. * @param uniform defines the webGL uniform location where to store the value
  31224. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31225. */
  31226. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31227. /**
  31228. * Set the value of an uniform to a matrix (2x2)
  31229. * @param uniform defines the webGL uniform location where to store the value
  31230. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31231. */
  31232. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31233. /**
  31234. * Set the value of an uniform to a number (int)
  31235. * @param uniform defines the webGL uniform location where to store the value
  31236. * @param value defines the int number to store
  31237. */
  31238. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31239. /**
  31240. * Set the value of an uniform to a number (float)
  31241. * @param uniform defines the webGL uniform location where to store the value
  31242. * @param value defines the float number to store
  31243. */
  31244. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31245. /**
  31246. * Set the value of an uniform to a vec2
  31247. * @param uniform defines the webGL uniform location where to store the value
  31248. * @param x defines the 1st component of the value
  31249. * @param y defines the 2nd component of the value
  31250. */
  31251. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31252. /**
  31253. * Set the value of an uniform to a vec3
  31254. * @param uniform defines the webGL uniform location where to store the value
  31255. * @param x defines the 1st component of the value
  31256. * @param y defines the 2nd component of the value
  31257. * @param z defines the 3rd component of the value
  31258. */
  31259. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31260. /**
  31261. * Set the value of an uniform to a boolean
  31262. * @param uniform defines the webGL uniform location where to store the value
  31263. * @param bool defines the boolean to store
  31264. */
  31265. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31266. /**
  31267. * Set the value of an uniform to a vec4
  31268. * @param uniform defines the webGL uniform location where to store the value
  31269. * @param x defines the 1st component of the value
  31270. * @param y defines the 2nd component of the value
  31271. * @param z defines the 3rd component of the value
  31272. * @param w defines the 4th component of the value
  31273. */
  31274. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31275. /**
  31276. * Sets a Color4 on a uniform variable
  31277. * @param uniform defines the uniform location
  31278. * @param color4 defines the value to be set
  31279. */
  31280. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31281. /**
  31282. * Set various states to the webGL context
  31283. * @param culling defines backface culling state
  31284. * @param zOffset defines the value to apply to zOffset (0 by default)
  31285. * @param force defines if states must be applied even if cache is up to date
  31286. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31287. */
  31288. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31289. /**
  31290. * Set the z offset to apply to current rendering
  31291. * @param value defines the offset to apply
  31292. */
  31293. setZOffset(value: number): void;
  31294. /**
  31295. * Gets the current value of the zOffset
  31296. * @returns the current zOffset state
  31297. */
  31298. getZOffset(): number;
  31299. /**
  31300. * Enable or disable depth buffering
  31301. * @param enable defines the state to set
  31302. */
  31303. setDepthBuffer(enable: boolean): void;
  31304. /**
  31305. * Gets a boolean indicating if depth writing is enabled
  31306. * @returns the current depth writing state
  31307. */
  31308. getDepthWrite(): boolean;
  31309. /**
  31310. * Enable or disable depth writing
  31311. * @param enable defines the state to set
  31312. */
  31313. setDepthWrite(enable: boolean): void;
  31314. /**
  31315. * Enable or disable color writing
  31316. * @param enable defines the state to set
  31317. */
  31318. setColorWrite(enable: boolean): void;
  31319. /**
  31320. * Gets a boolean indicating if color writing is enabled
  31321. * @returns the current color writing state
  31322. */
  31323. getColorWrite(): boolean;
  31324. /**
  31325. * Sets alpha constants used by some alpha blending modes
  31326. * @param r defines the red component
  31327. * @param g defines the green component
  31328. * @param b defines the blue component
  31329. * @param a defines the alpha component
  31330. */
  31331. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31332. /**
  31333. * Sets the current alpha mode
  31334. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31335. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31337. */
  31338. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31339. /**
  31340. * Gets the current alpha mode
  31341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31342. * @returns the current alpha mode
  31343. */
  31344. getAlphaMode(): number;
  31345. /**
  31346. * Sets the current alpha equation
  31347. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31348. */
  31349. setAlphaEquation(equation: number): void;
  31350. /**
  31351. * Gets the current alpha equation.
  31352. * @returns the current alpha equation
  31353. */
  31354. getAlphaEquation(): number;
  31355. /**
  31356. * Clears the list of texture accessible through engine.
  31357. * This can help preventing texture load conflict due to name collision.
  31358. */
  31359. clearInternalTexturesCache(): void;
  31360. /**
  31361. * Force the entire cache to be cleared
  31362. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31363. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31364. */
  31365. wipeCaches(bruteForce?: boolean): void;
  31366. /**
  31367. * Set the compressed texture format to use, based on the formats you have, and the formats
  31368. * supported by the hardware / browser.
  31369. *
  31370. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31371. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31372. * to API arguments needed to compressed textures. This puts the burden on the container
  31373. * generator to house the arcane code for determining these for current & future formats.
  31374. *
  31375. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31376. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31377. *
  31378. * Note: The result of this call is not taken into account when a texture is base64.
  31379. *
  31380. * @param formatsAvailable defines the list of those format families you have created
  31381. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31382. *
  31383. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31384. * @returns The extension selected.
  31385. */
  31386. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31387. /** @hidden */
  31388. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31389. min: number;
  31390. mag: number;
  31391. };
  31392. /** @hidden */
  31393. _createTexture(): WebGLTexture;
  31394. /**
  31395. * Usually called from Texture.ts.
  31396. * Passed information to create a WebGLTexture
  31397. * @param urlArg defines a value which contains one of the following:
  31398. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31399. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31400. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31402. * @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)
  31403. * @param scene needed for loading to the correct scene
  31404. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31405. * @param onLoad optional callback to be called upon successful completion
  31406. * @param onError optional callback to be called upon failure
  31407. * @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
  31408. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31409. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31410. * @param forcedExtension defines the extension to use to pick the right loader
  31411. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31412. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31413. */
  31414. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31415. /**
  31416. * @hidden
  31417. * Rescales a texture
  31418. * @param source input texutre
  31419. * @param destination destination texture
  31420. * @param scene scene to use to render the resize
  31421. * @param internalFormat format to use when resizing
  31422. * @param onComplete callback to be called when resize has completed
  31423. */
  31424. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31425. private _unpackFlipYCached;
  31426. /**
  31427. * In case you are sharing the context with other applications, it might
  31428. * be interested to not cache the unpack flip y state to ensure a consistent
  31429. * value would be set.
  31430. */
  31431. enableUnpackFlipYCached: boolean;
  31432. /** @hidden */
  31433. _unpackFlipY(value: boolean): void;
  31434. /** @hidden */
  31435. _getUnpackAlignement(): number;
  31436. /**
  31437. * Creates a dynamic texture
  31438. * @param width defines the width of the texture
  31439. * @param height defines the height of the texture
  31440. * @param generateMipMaps defines if the engine should generate the mip levels
  31441. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31442. * @returns the dynamic texture inside an InternalTexture
  31443. */
  31444. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31445. /**
  31446. * Update the sampling mode of a given texture
  31447. * @param samplingMode defines the required sampling mode
  31448. * @param texture defines the texture to update
  31449. */
  31450. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31451. /**
  31452. * Update the content of a dynamic texture
  31453. * @param texture defines the texture to update
  31454. * @param canvas defines the canvas containing the source
  31455. * @param invertY defines if data must be stored with Y axis inverted
  31456. * @param premulAlpha defines if alpha is stored as premultiplied
  31457. * @param format defines the format of the data
  31458. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31459. */
  31460. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31461. /**
  31462. * Update a video texture
  31463. * @param texture defines the texture to update
  31464. * @param video defines the video element to use
  31465. * @param invertY defines if data must be stored with Y axis inverted
  31466. */
  31467. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31468. /**
  31469. * Updates a depth texture Comparison Mode and Function.
  31470. * If the comparison Function is equal to 0, the mode will be set to none.
  31471. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31472. * @param texture The texture to set the comparison function for
  31473. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31474. */
  31475. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31476. /** @hidden */
  31477. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31478. width: number;
  31479. height: number;
  31480. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31481. /**
  31482. * Creates a depth stencil texture.
  31483. * This is only available in WebGL 2 or with the depth texture extension available.
  31484. * @param size The size of face edge in the texture.
  31485. * @param options The options defining the texture.
  31486. * @returns The texture
  31487. */
  31488. createDepthStencilTexture(size: number | {
  31489. width: number;
  31490. height: number;
  31491. }, options: DepthTextureCreationOptions): InternalTexture;
  31492. /**
  31493. * Creates a depth stencil texture.
  31494. * This is only available in WebGL 2 or with the depth texture extension available.
  31495. * @param size The size of face edge in the texture.
  31496. * @param options The options defining the texture.
  31497. * @returns The texture
  31498. */
  31499. private _createDepthStencilTexture;
  31500. /**
  31501. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31502. * @param renderTarget The render target to set the frame buffer for
  31503. */
  31504. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31505. /**
  31506. * Creates a new render target texture
  31507. * @param size defines the size of the texture
  31508. * @param options defines the options used to create the texture
  31509. * @returns a new render target texture stored in an InternalTexture
  31510. */
  31511. createRenderTargetTexture(size: number | {
  31512. width: number;
  31513. height: number;
  31514. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31515. /** @hidden */
  31516. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31517. /**
  31518. * Updates the sample count of a render target texture
  31519. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31520. * @param texture defines the texture to update
  31521. * @param samples defines the sample count to set
  31522. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31523. */
  31524. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31525. /** @hidden */
  31526. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31527. /** @hidden */
  31528. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31529. /** @hidden */
  31530. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31531. /** @hidden */
  31532. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31533. /**
  31534. * @hidden
  31535. */
  31536. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31537. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31538. private _prepareWebGLTexture;
  31539. /** @hidden */
  31540. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31541. /** @hidden */
  31542. _releaseFramebufferObjects(texture: InternalTexture): void;
  31543. /** @hidden */
  31544. _releaseTexture(texture: InternalTexture): void;
  31545. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31546. protected _setProgram(program: WebGLProgram): void;
  31547. protected _boundUniforms: {
  31548. [key: number]: WebGLUniformLocation;
  31549. };
  31550. /**
  31551. * Binds an effect to the webGL context
  31552. * @param effect defines the effect to bind
  31553. */
  31554. bindSamplers(effect: Effect): void;
  31555. private _activateCurrentTexture;
  31556. /** @hidden */
  31557. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31558. /** @hidden */
  31559. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31560. /**
  31561. * Sets a texture to the webGL context from a postprocess
  31562. * @param channel defines the channel to use
  31563. * @param postProcess defines the source postprocess
  31564. */
  31565. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31566. /**
  31567. * Binds the output of the passed in post process to the texture channel specified
  31568. * @param channel The channel the texture should be bound to
  31569. * @param postProcess The post process which's output should be bound
  31570. */
  31571. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31572. /**
  31573. * Unbind all textures from the webGL context
  31574. */
  31575. unbindAllTextures(): void;
  31576. /**
  31577. * Sets a texture to the according uniform.
  31578. * @param channel The texture channel
  31579. * @param uniform The uniform to set
  31580. * @param texture The texture to apply
  31581. */
  31582. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31583. /**
  31584. * Sets a depth stencil texture from a render target to the according uniform.
  31585. * @param channel The texture channel
  31586. * @param uniform The uniform to set
  31587. * @param texture The render target texture containing the depth stencil texture to apply
  31588. */
  31589. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31590. private _bindSamplerUniformToChannel;
  31591. private _getTextureWrapMode;
  31592. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31593. /**
  31594. * Sets an array of texture to the webGL context
  31595. * @param channel defines the channel where the texture array must be set
  31596. * @param uniform defines the associated uniform location
  31597. * @param textures defines the array of textures to bind
  31598. */
  31599. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31600. /** @hidden */
  31601. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31602. private _setTextureParameterFloat;
  31603. private _setTextureParameterInteger;
  31604. /**
  31605. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31606. * @param x defines the x coordinate of the rectangle where pixels must be read
  31607. * @param y defines the y coordinate of the rectangle where pixels must be read
  31608. * @param width defines the width of the rectangle where pixels must be read
  31609. * @param height defines the height of the rectangle where pixels must be read
  31610. * @returns a Uint8Array containing RGBA colors
  31611. */
  31612. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31613. /**
  31614. * Add an externaly attached data from its key.
  31615. * This method call will fail and return false, if such key already exists.
  31616. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31617. * @param key the unique key that identifies the data
  31618. * @param data the data object to associate to the key for this Engine instance
  31619. * @return true if no such key were already present and the data was added successfully, false otherwise
  31620. */
  31621. addExternalData<T>(key: string, data: T): boolean;
  31622. /**
  31623. * Get an externaly attached data from its key
  31624. * @param key the unique key that identifies the data
  31625. * @return the associated data, if present (can be null), or undefined if not present
  31626. */
  31627. getExternalData<T>(key: string): T;
  31628. /**
  31629. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31630. * @param key the unique key that identifies the data
  31631. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31632. * @return the associated data, can be null if the factory returned null.
  31633. */
  31634. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31635. /**
  31636. * Remove an externaly attached data from the Engine instance
  31637. * @param key the unique key that identifies the data
  31638. * @return true if the data was successfully removed, false if it doesn't exist
  31639. */
  31640. removeExternalData(key: string): boolean;
  31641. /**
  31642. * Unbind all vertex attributes from the webGL context
  31643. */
  31644. unbindAllAttributes(): void;
  31645. /**
  31646. * 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
  31647. */
  31648. releaseEffects(): void;
  31649. /**
  31650. * Dispose and release all associated resources
  31651. */
  31652. dispose(): void;
  31653. /**
  31654. * Display the loading screen
  31655. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31656. */
  31657. displayLoadingUI(): void;
  31658. /**
  31659. * Hide the loading screen
  31660. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31661. */
  31662. hideLoadingUI(): void;
  31663. /**
  31664. * Gets the current loading screen object
  31665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31666. */
  31667. /**
  31668. * Sets the current loading screen object
  31669. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31670. */
  31671. loadingScreen: ILoadingScreen;
  31672. /**
  31673. * Sets the current loading screen text
  31674. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31675. */
  31676. loadingUIText: string;
  31677. /**
  31678. * Sets the current loading screen background color
  31679. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31680. */
  31681. loadingUIBackgroundColor: string;
  31682. /**
  31683. * Attach a new callback raised when context lost event is fired
  31684. * @param callback defines the callback to call
  31685. */
  31686. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31687. /**
  31688. * Attach a new callback raised when context restored event is fired
  31689. * @param callback defines the callback to call
  31690. */
  31691. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31692. /**
  31693. * Gets the source code of the vertex shader associated with a specific webGL program
  31694. * @param program defines the program to use
  31695. * @returns a string containing the source code of the vertex shader associated with the program
  31696. */
  31697. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31698. /**
  31699. * Gets the source code of the fragment shader associated with a specific webGL program
  31700. * @param program defines the program to use
  31701. * @returns a string containing the source code of the fragment shader associated with the program
  31702. */
  31703. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31704. /**
  31705. * Get the current error code of the webGL context
  31706. * @returns the error code
  31707. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31708. */
  31709. getError(): number;
  31710. /**
  31711. * Gets the current framerate
  31712. * @returns a number representing the framerate
  31713. */
  31714. getFps(): number;
  31715. /**
  31716. * Gets the time spent between current and previous frame
  31717. * @returns a number representing the delta time in ms
  31718. */
  31719. getDeltaTime(): number;
  31720. private _measureFps;
  31721. /** @hidden */
  31722. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31723. private _canRenderToFloatFramebuffer;
  31724. private _canRenderToHalfFloatFramebuffer;
  31725. private _canRenderToFramebuffer;
  31726. /** @hidden */
  31727. _getWebGLTextureType(type: number): number;
  31728. /** @hidden */
  31729. _getInternalFormat(format: number): number;
  31730. /** @hidden */
  31731. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31732. /** @hidden */
  31733. _getRGBAMultiSampleBufferFormat(type: number): number;
  31734. /** @hidden */
  31735. _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;
  31736. /** @hidden */
  31737. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31738. /**
  31739. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31740. * @returns true if the engine can be created
  31741. * @ignorenaming
  31742. */
  31743. static isSupported(): boolean;
  31744. /**
  31745. * Find the next highest power of two.
  31746. * @param x Number to start search from.
  31747. * @return Next highest power of two.
  31748. */
  31749. static CeilingPOT(x: number): number;
  31750. /**
  31751. * Find the next lowest power of two.
  31752. * @param x Number to start search from.
  31753. * @return Next lowest power of two.
  31754. */
  31755. static FloorPOT(x: number): number;
  31756. /**
  31757. * Find the nearest power of two.
  31758. * @param x Number to start search from.
  31759. * @return Next nearest power of two.
  31760. */
  31761. static NearestPOT(x: number): number;
  31762. /**
  31763. * Get the closest exponent of two
  31764. * @param value defines the value to approximate
  31765. * @param max defines the maximum value to return
  31766. * @param mode defines how to define the closest value
  31767. * @returns closest exponent of two of the given value
  31768. */
  31769. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31770. /**
  31771. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31772. * @param func - the function to be called
  31773. * @param requester - the object that will request the next frame. Falls back to window.
  31774. * @returns frame number
  31775. */
  31776. static QueueNewFrame(func: () => void, requester?: any): number;
  31777. /**
  31778. * Ask the browser to promote the current element to pointerlock mode
  31779. * @param element defines the DOM element to promote
  31780. */
  31781. static _RequestPointerlock(element: HTMLElement): void;
  31782. /**
  31783. * Asks the browser to exit pointerlock mode
  31784. */
  31785. static _ExitPointerlock(): void;
  31786. /**
  31787. * Ask the browser to promote the current element to fullscreen rendering mode
  31788. * @param element defines the DOM element to promote
  31789. */
  31790. static _RequestFullscreen(element: HTMLElement): void;
  31791. /**
  31792. * Asks the browser to exit fullscreen mode
  31793. */
  31794. static _ExitFullscreen(): void;
  31795. }
  31796. }
  31797. declare module BABYLON {
  31798. /**
  31799. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31800. * during the life time of the application.
  31801. */
  31802. export class EngineStore {
  31803. /** Gets the list of created engines */
  31804. static Instances: Engine[];
  31805. /** @hidden */
  31806. static _LastCreatedScene: Nullable<Scene>;
  31807. /**
  31808. * Gets the latest created engine
  31809. */
  31810. static readonly LastCreatedEngine: Nullable<Engine>;
  31811. /**
  31812. * Gets the latest created scene
  31813. */
  31814. static readonly LastCreatedScene: Nullable<Scene>;
  31815. /**
  31816. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31817. * @ignorenaming
  31818. */
  31819. static UseFallbackTexture: boolean;
  31820. /**
  31821. * Texture content used if a texture cannot loaded
  31822. * @ignorenaming
  31823. */
  31824. static FallbackTexture: string;
  31825. }
  31826. }
  31827. declare module BABYLON {
  31828. /**
  31829. * Helper class that provides a small promise polyfill
  31830. */
  31831. export class PromisePolyfill {
  31832. /**
  31833. * Static function used to check if the polyfill is required
  31834. * If this is the case then the function will inject the polyfill to window.Promise
  31835. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31836. */
  31837. static Apply(force?: boolean): void;
  31838. }
  31839. }
  31840. declare module BABYLON {
  31841. /**
  31842. * Interface for screenshot methods with describe argument called `size` as object with options
  31843. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31844. */
  31845. export interface IScreenshotSize {
  31846. /**
  31847. * number in pixels for canvas height
  31848. */
  31849. height?: number;
  31850. /**
  31851. * multiplier allowing render at a higher or lower resolution
  31852. * If value is defined then height and width will be ignored and taken from camera
  31853. */
  31854. precision?: number;
  31855. /**
  31856. * number in pixels for canvas width
  31857. */
  31858. width?: number;
  31859. }
  31860. }
  31861. declare module BABYLON {
  31862. interface IColor4Like {
  31863. r: float;
  31864. g: float;
  31865. b: float;
  31866. a: float;
  31867. }
  31868. /**
  31869. * Class containing a set of static utilities functions
  31870. */
  31871. export class Tools {
  31872. /**
  31873. * Gets or sets the base URL to use to load assets
  31874. */
  31875. static BaseUrl: string;
  31876. /**
  31877. * Enable/Disable Custom HTTP Request Headers globally.
  31878. * default = false
  31879. * @see CustomRequestHeaders
  31880. */
  31881. static UseCustomRequestHeaders: boolean;
  31882. /**
  31883. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31884. * i.e. when loading files, where the server/service expects an Authorization header
  31885. */
  31886. static CustomRequestHeaders: {
  31887. [key: string]: string;
  31888. };
  31889. /**
  31890. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31891. */
  31892. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31893. /**
  31894. * Default behaviour for cors in the application.
  31895. * It can be a string if the expected behavior is identical in the entire app.
  31896. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31897. */
  31898. static CorsBehavior: string | ((url: string | string[]) => string);
  31899. /**
  31900. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31901. * @ignorenaming
  31902. */
  31903. static UseFallbackTexture: boolean;
  31904. /**
  31905. * Use this object to register external classes like custom textures or material
  31906. * to allow the laoders to instantiate them
  31907. */
  31908. static RegisteredExternalClasses: {
  31909. [key: string]: Object;
  31910. };
  31911. /**
  31912. * Texture content used if a texture cannot loaded
  31913. * @ignorenaming
  31914. */
  31915. static fallbackTexture: string;
  31916. /**
  31917. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31918. * @param u defines the coordinate on X axis
  31919. * @param v defines the coordinate on Y axis
  31920. * @param width defines the width of the source data
  31921. * @param height defines the height of the source data
  31922. * @param pixels defines the source byte array
  31923. * @param color defines the output color
  31924. */
  31925. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31926. /**
  31927. * Interpolates between a and b via alpha
  31928. * @param a The lower value (returned when alpha = 0)
  31929. * @param b The upper value (returned when alpha = 1)
  31930. * @param alpha The interpolation-factor
  31931. * @return The mixed value
  31932. */
  31933. static Mix(a: number, b: number, alpha: number): number;
  31934. /**
  31935. * Tries to instantiate a new object from a given class name
  31936. * @param className defines the class name to instantiate
  31937. * @returns the new object or null if the system was not able to do the instantiation
  31938. */
  31939. static Instantiate(className: string): any;
  31940. /**
  31941. * Provides a slice function that will work even on IE
  31942. * @param data defines the array to slice
  31943. * @param start defines the start of the data (optional)
  31944. * @param end defines the end of the data (optional)
  31945. * @returns the new sliced array
  31946. */
  31947. static Slice<T>(data: T, start?: number, end?: number): T;
  31948. /**
  31949. * Polyfill for setImmediate
  31950. * @param action defines the action to execute after the current execution block
  31951. */
  31952. static SetImmediate(action: () => void): void;
  31953. /**
  31954. * Function indicating if a number is an exponent of 2
  31955. * @param value defines the value to test
  31956. * @returns true if the value is an exponent of 2
  31957. */
  31958. static IsExponentOfTwo(value: number): boolean;
  31959. private static _tmpFloatArray;
  31960. /**
  31961. * Returns the nearest 32-bit single precision float representation of a Number
  31962. * @param value A Number. If the parameter is of a different type, it will get converted
  31963. * to a number or to NaN if it cannot be converted
  31964. * @returns number
  31965. */
  31966. static FloatRound(value: number): number;
  31967. /**
  31968. * Extracts the filename from a path
  31969. * @param path defines the path to use
  31970. * @returns the filename
  31971. */
  31972. static GetFilename(path: string): string;
  31973. /**
  31974. * Extracts the "folder" part of a path (everything before the filename).
  31975. * @param uri The URI to extract the info from
  31976. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31977. * @returns The "folder" part of the path
  31978. */
  31979. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31980. /**
  31981. * Extracts text content from a DOM element hierarchy
  31982. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31983. */
  31984. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31985. /**
  31986. * Convert an angle in radians to degrees
  31987. * @param angle defines the angle to convert
  31988. * @returns the angle in degrees
  31989. */
  31990. static ToDegrees(angle: number): number;
  31991. /**
  31992. * Convert an angle in degrees to radians
  31993. * @param angle defines the angle to convert
  31994. * @returns the angle in radians
  31995. */
  31996. static ToRadians(angle: number): number;
  31997. /**
  31998. * Encode a buffer to a base64 string
  31999. * @param buffer defines the buffer to encode
  32000. * @returns the encoded string
  32001. */
  32002. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32003. /**
  32004. * Returns an array if obj is not an array
  32005. * @param obj defines the object to evaluate as an array
  32006. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32007. * @returns either obj directly if obj is an array or a new array containing obj
  32008. */
  32009. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32010. /**
  32011. * Gets the pointer prefix to use
  32012. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32013. */
  32014. static GetPointerPrefix(): string;
  32015. /**
  32016. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32017. * @param url define the url we are trying
  32018. * @param element define the dom element where to configure the cors policy
  32019. */
  32020. static SetCorsBehavior(url: string | string[], element: {
  32021. crossOrigin: string | null;
  32022. }): void;
  32023. /**
  32024. * Removes unwanted characters from an url
  32025. * @param url defines the url to clean
  32026. * @returns the cleaned url
  32027. */
  32028. static CleanUrl(url: string): string;
  32029. /**
  32030. * Gets or sets a function used to pre-process url before using them to load assets
  32031. */
  32032. static PreprocessUrl: (url: string) => string;
  32033. /**
  32034. * Loads an image as an HTMLImageElement.
  32035. * @param input url string, ArrayBuffer, or Blob to load
  32036. * @param onLoad callback called when the image successfully loads
  32037. * @param onError callback called when the image fails to load
  32038. * @param offlineProvider offline provider for caching
  32039. * @returns the HTMLImageElement of the loaded image
  32040. */
  32041. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32042. /**
  32043. * Loads a file
  32044. * @param url url string, ArrayBuffer, or Blob to load
  32045. * @param onSuccess callback called when the file successfully loads
  32046. * @param onProgress callback called while file is loading (if the server supports this mode)
  32047. * @param offlineProvider defines the offline provider for caching
  32048. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32049. * @param onError callback called when the file fails to load
  32050. * @returns a file request object
  32051. */
  32052. 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;
  32053. /**
  32054. * Loads a file from a url
  32055. * @param url the file url to load
  32056. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32057. */
  32058. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32059. /**
  32060. * Load a script (identified by an url). When the url returns, the
  32061. * content of this file is added into a new script element, attached to the DOM (body element)
  32062. * @param scriptUrl defines the url of the script to laod
  32063. * @param onSuccess defines the callback called when the script is loaded
  32064. * @param onError defines the callback to call if an error occurs
  32065. * @param scriptId defines the id of the script element
  32066. */
  32067. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32068. /**
  32069. * Load an asynchronous script (identified by an url). When the url returns, the
  32070. * content of this file is added into a new script element, attached to the DOM (body element)
  32071. * @param scriptUrl defines the url of the script to laod
  32072. * @param scriptId defines the id of the script element
  32073. * @returns a promise request object
  32074. */
  32075. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32076. /**
  32077. * Loads a file from a blob
  32078. * @param fileToLoad defines the blob to use
  32079. * @param callback defines the callback to call when data is loaded
  32080. * @param progressCallback defines the callback to call during loading process
  32081. * @returns a file request object
  32082. */
  32083. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32084. /**
  32085. * Loads a file
  32086. * @param fileToLoad defines the file to load
  32087. * @param callback defines the callback to call when data is loaded
  32088. * @param progressCallBack defines the callback to call during loading process
  32089. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32090. * @returns a file request object
  32091. */
  32092. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32093. /**
  32094. * Creates a data url from a given string content
  32095. * @param content defines the content to convert
  32096. * @returns the new data url link
  32097. */
  32098. static FileAsURL(content: string): string;
  32099. /**
  32100. * Format the given number to a specific decimal format
  32101. * @param value defines the number to format
  32102. * @param decimals defines the number of decimals to use
  32103. * @returns the formatted string
  32104. */
  32105. static Format(value: number, decimals?: number): string;
  32106. /**
  32107. * Tries to copy an object by duplicating every property
  32108. * @param source defines the source object
  32109. * @param destination defines the target object
  32110. * @param doNotCopyList defines a list of properties to avoid
  32111. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32112. */
  32113. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32114. /**
  32115. * Gets a boolean indicating if the given object has no own property
  32116. * @param obj defines the object to test
  32117. * @returns true if object has no own property
  32118. */
  32119. static IsEmpty(obj: any): boolean;
  32120. /**
  32121. * Function used to register events at window level
  32122. * @param windowElement defines the Window object to use
  32123. * @param events defines the events to register
  32124. */
  32125. static RegisterTopRootEvents(windowElement: Window, events: {
  32126. name: string;
  32127. handler: Nullable<(e: FocusEvent) => any>;
  32128. }[]): void;
  32129. /**
  32130. * Function used to unregister events from window level
  32131. * @param windowElement defines the Window object to use
  32132. * @param events defines the events to unregister
  32133. */
  32134. static UnregisterTopRootEvents(windowElement: Window, events: {
  32135. name: string;
  32136. handler: Nullable<(e: FocusEvent) => any>;
  32137. }[]): void;
  32138. /**
  32139. * @ignore
  32140. */
  32141. static _ScreenshotCanvas: HTMLCanvasElement;
  32142. /**
  32143. * Dumps the current bound framebuffer
  32144. * @param width defines the rendering width
  32145. * @param height defines the rendering height
  32146. * @param engine defines the hosting engine
  32147. * @param successCallback defines the callback triggered once the data are available
  32148. * @param mimeType defines the mime type of the result
  32149. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32150. */
  32151. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32152. /**
  32153. * Converts the canvas data to blob.
  32154. * This acts as a polyfill for browsers not supporting the to blob function.
  32155. * @param canvas Defines the canvas to extract the data from
  32156. * @param successCallback Defines the callback triggered once the data are available
  32157. * @param mimeType Defines the mime type of the result
  32158. */
  32159. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32160. /**
  32161. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32162. * @param successCallback defines the callback triggered once the data are available
  32163. * @param mimeType defines the mime type of the result
  32164. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32165. */
  32166. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32167. /**
  32168. * Downloads a blob in the browser
  32169. * @param blob defines the blob to download
  32170. * @param fileName defines the name of the downloaded file
  32171. */
  32172. static Download(blob: Blob, fileName: string): void;
  32173. /**
  32174. * Captures a screenshot of the current rendering
  32175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32176. * @param engine defines the rendering engine
  32177. * @param camera defines the source camera
  32178. * @param size This parameter can be set to a single number or to an object with the
  32179. * following (optional) properties: precision, width, height. If a single number is passed,
  32180. * it will be used for both width and height. If an object is passed, the screenshot size
  32181. * will be derived from the parameters. The precision property is a multiplier allowing
  32182. * rendering at a higher or lower resolution
  32183. * @param successCallback defines the callback receives a single parameter which contains the
  32184. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32185. * src parameter of an <img> to display it
  32186. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32187. * Check your browser for supported MIME types
  32188. */
  32189. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32190. /**
  32191. * Captures a screenshot of the current rendering
  32192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32193. * @param engine defines the rendering engine
  32194. * @param camera defines the source camera
  32195. * @param size This parameter can be set to a single number or to an object with the
  32196. * following (optional) properties: precision, width, height. If a single number is passed,
  32197. * it will be used for both width and height. If an object is passed, the screenshot size
  32198. * will be derived from the parameters. The precision property is a multiplier allowing
  32199. * rendering at a higher or lower resolution
  32200. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32201. * Check your browser for supported MIME types
  32202. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32203. * to the src parameter of an <img> to display it
  32204. */
  32205. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32206. /**
  32207. * Generates an image screenshot from the specified camera.
  32208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32209. * @param engine The engine to use for rendering
  32210. * @param camera The camera to use for rendering
  32211. * @param size This parameter can be set to a single number or to an object with the
  32212. * following (optional) properties: precision, width, height. If a single number is passed,
  32213. * it will be used for both width and height. If an object is passed, the screenshot size
  32214. * will be derived from the parameters. The precision property is a multiplier allowing
  32215. * rendering at a higher or lower resolution
  32216. * @param successCallback The callback receives a single parameter which contains the
  32217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32218. * src parameter of an <img> to display it
  32219. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32220. * Check your browser for supported MIME types
  32221. * @param samples Texture samples (default: 1)
  32222. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32223. * @param fileName A name for for the downloaded file.
  32224. */
  32225. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32226. /**
  32227. * Generates an image screenshot from the specified camera.
  32228. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32229. * @param engine The engine to use for rendering
  32230. * @param camera The camera to use for rendering
  32231. * @param size This parameter can be set to a single number or to an object with the
  32232. * following (optional) properties: precision, width, height. If a single number is passed,
  32233. * it will be used for both width and height. If an object is passed, the screenshot size
  32234. * will be derived from the parameters. The precision property is a multiplier allowing
  32235. * rendering at a higher or lower resolution
  32236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32237. * Check your browser for supported MIME types
  32238. * @param samples Texture samples (default: 1)
  32239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32240. * @param fileName A name for for the downloaded file.
  32241. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32242. * to the src parameter of an <img> to display it
  32243. */
  32244. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32245. /**
  32246. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32247. * Be aware Math.random() could cause collisions, but:
  32248. * "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"
  32249. * @returns a pseudo random id
  32250. */
  32251. static RandomId(): string;
  32252. /**
  32253. * Test if the given uri is a base64 string
  32254. * @param uri The uri to test
  32255. * @return True if the uri is a base64 string or false otherwise
  32256. */
  32257. static IsBase64(uri: string): boolean;
  32258. /**
  32259. * Decode the given base64 uri.
  32260. * @param uri The uri to decode
  32261. * @return The decoded base64 data.
  32262. */
  32263. static DecodeBase64(uri: string): ArrayBuffer;
  32264. /**
  32265. * Gets the absolute url.
  32266. * @param url the input url
  32267. * @return the absolute url
  32268. */
  32269. static GetAbsoluteUrl(url: string): string;
  32270. /**
  32271. * No log
  32272. */
  32273. static readonly NoneLogLevel: number;
  32274. /**
  32275. * Only message logs
  32276. */
  32277. static readonly MessageLogLevel: number;
  32278. /**
  32279. * Only warning logs
  32280. */
  32281. static readonly WarningLogLevel: number;
  32282. /**
  32283. * Only error logs
  32284. */
  32285. static readonly ErrorLogLevel: number;
  32286. /**
  32287. * All logs
  32288. */
  32289. static readonly AllLogLevel: number;
  32290. /**
  32291. * Gets a value indicating the number of loading errors
  32292. * @ignorenaming
  32293. */
  32294. static readonly errorsCount: number;
  32295. /**
  32296. * Callback called when a new log is added
  32297. */
  32298. static OnNewCacheEntry: (entry: string) => void;
  32299. /**
  32300. * Log a message to the console
  32301. * @param message defines the message to log
  32302. */
  32303. static Log(message: string): void;
  32304. /**
  32305. * Write a warning message to the console
  32306. * @param message defines the message to log
  32307. */
  32308. static Warn(message: string): void;
  32309. /**
  32310. * Write an error message to the console
  32311. * @param message defines the message to log
  32312. */
  32313. static Error(message: string): void;
  32314. /**
  32315. * Gets current log cache (list of logs)
  32316. */
  32317. static readonly LogCache: string;
  32318. /**
  32319. * Clears the log cache
  32320. */
  32321. static ClearLogCache(): void;
  32322. /**
  32323. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32324. */
  32325. static LogLevels: number;
  32326. /**
  32327. * Checks if the window object exists
  32328. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32329. */
  32330. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32331. /**
  32332. * No performance log
  32333. */
  32334. static readonly PerformanceNoneLogLevel: number;
  32335. /**
  32336. * Use user marks to log performance
  32337. */
  32338. static readonly PerformanceUserMarkLogLevel: number;
  32339. /**
  32340. * Log performance to the console
  32341. */
  32342. static readonly PerformanceConsoleLogLevel: number;
  32343. private static _performance;
  32344. /**
  32345. * Sets the current performance log level
  32346. */
  32347. static PerformanceLogLevel: number;
  32348. private static _StartPerformanceCounterDisabled;
  32349. private static _EndPerformanceCounterDisabled;
  32350. private static _StartUserMark;
  32351. private static _EndUserMark;
  32352. private static _StartPerformanceConsole;
  32353. private static _EndPerformanceConsole;
  32354. /**
  32355. * Starts a performance counter
  32356. */
  32357. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32358. /**
  32359. * Ends a specific performance coutner
  32360. */
  32361. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32362. /**
  32363. * Gets either window.performance.now() if supported or Date.now() else
  32364. */
  32365. static readonly Now: number;
  32366. /**
  32367. * This method will return the name of the class used to create the instance of the given object.
  32368. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32369. * @param object the object to get the class name from
  32370. * @param isType defines if the object is actually a type
  32371. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32372. */
  32373. static GetClassName(object: any, isType?: boolean): string;
  32374. /**
  32375. * Gets the first element of an array satisfying a given predicate
  32376. * @param array defines the array to browse
  32377. * @param predicate defines the predicate to use
  32378. * @returns null if not found or the element
  32379. */
  32380. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32381. /**
  32382. * This method will return the name of the full name of the class, including its owning module (if any).
  32383. * 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).
  32384. * @param object the object to get the class name from
  32385. * @param isType defines if the object is actually a type
  32386. * @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.
  32387. * @ignorenaming
  32388. */
  32389. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32390. /**
  32391. * Returns a promise that resolves after the given amount of time.
  32392. * @param delay Number of milliseconds to delay
  32393. * @returns Promise that resolves after the given amount of time
  32394. */
  32395. static DelayAsync(delay: number): Promise<void>;
  32396. }
  32397. /**
  32398. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32399. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32400. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32401. * @param name The name of the class, case should be preserved
  32402. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32403. */
  32404. export function className(name: string, module?: string): (target: Object) => void;
  32405. /**
  32406. * An implementation of a loop for asynchronous functions.
  32407. */
  32408. export class AsyncLoop {
  32409. /**
  32410. * Defines the number of iterations for the loop
  32411. */
  32412. iterations: number;
  32413. /**
  32414. * Defines the current index of the loop.
  32415. */
  32416. index: number;
  32417. private _done;
  32418. private _fn;
  32419. private _successCallback;
  32420. /**
  32421. * Constructor.
  32422. * @param iterations the number of iterations.
  32423. * @param func the function to run each iteration
  32424. * @param successCallback the callback that will be called upon succesful execution
  32425. * @param offset starting offset.
  32426. */
  32427. constructor(
  32428. /**
  32429. * Defines the number of iterations for the loop
  32430. */
  32431. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32432. /**
  32433. * Execute the next iteration. Must be called after the last iteration was finished.
  32434. */
  32435. executeNext(): void;
  32436. /**
  32437. * Break the loop and run the success callback.
  32438. */
  32439. breakLoop(): void;
  32440. /**
  32441. * Create and run an async loop.
  32442. * @param iterations the number of iterations.
  32443. * @param fn the function to run each iteration
  32444. * @param successCallback the callback that will be called upon succesful execution
  32445. * @param offset starting offset.
  32446. * @returns the created async loop object
  32447. */
  32448. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32449. /**
  32450. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32451. * @param iterations total number of iterations
  32452. * @param syncedIterations number of synchronous iterations in each async iteration.
  32453. * @param fn the function to call each iteration.
  32454. * @param callback a success call back that will be called when iterating stops.
  32455. * @param breakFunction a break condition (optional)
  32456. * @param timeout timeout settings for the setTimeout function. default - 0.
  32457. * @returns the created async loop object
  32458. */
  32459. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32460. }
  32461. }
  32462. declare module BABYLON {
  32463. /** @hidden */
  32464. export interface ICollisionCoordinator {
  32465. createCollider(): Collider;
  32466. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32467. init(scene: Scene): void;
  32468. }
  32469. /** @hidden */
  32470. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32471. private _scene;
  32472. private _scaledPosition;
  32473. private _scaledVelocity;
  32474. private _finalPosition;
  32475. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32476. createCollider(): Collider;
  32477. init(scene: Scene): void;
  32478. private _collideWithWorld;
  32479. }
  32480. }
  32481. declare module BABYLON {
  32482. /**
  32483. * Class used to manage all inputs for the scene.
  32484. */
  32485. export class InputManager {
  32486. /** The distance in pixel that you have to move to prevent some events */
  32487. static DragMovementThreshold: number;
  32488. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32489. static LongPressDelay: number;
  32490. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32491. static DoubleClickDelay: number;
  32492. /** If you need to check double click without raising a single click at first click, enable this flag */
  32493. static ExclusiveDoubleClickMode: boolean;
  32494. private _wheelEventName;
  32495. private _onPointerMove;
  32496. private _onPointerDown;
  32497. private _onPointerUp;
  32498. private _initClickEvent;
  32499. private _initActionManager;
  32500. private _delayedSimpleClick;
  32501. private _delayedSimpleClickTimeout;
  32502. private _previousDelayedSimpleClickTimeout;
  32503. private _meshPickProceed;
  32504. private _previousButtonPressed;
  32505. private _currentPickResult;
  32506. private _previousPickResult;
  32507. private _totalPointersPressed;
  32508. private _doubleClickOccured;
  32509. private _pointerOverMesh;
  32510. private _pickedDownMesh;
  32511. private _pickedUpMesh;
  32512. private _pointerX;
  32513. private _pointerY;
  32514. private _unTranslatedPointerX;
  32515. private _unTranslatedPointerY;
  32516. private _startingPointerPosition;
  32517. private _previousStartingPointerPosition;
  32518. private _startingPointerTime;
  32519. private _previousStartingPointerTime;
  32520. private _pointerCaptures;
  32521. private _onKeyDown;
  32522. private _onKeyUp;
  32523. private _onCanvasFocusObserver;
  32524. private _onCanvasBlurObserver;
  32525. private _scene;
  32526. /**
  32527. * Creates a new InputManager
  32528. * @param scene defines the hosting scene
  32529. */
  32530. constructor(scene: Scene);
  32531. /**
  32532. * Gets the mesh that is currently under the pointer
  32533. */
  32534. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32535. /**
  32536. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32537. */
  32538. readonly unTranslatedPointer: Vector2;
  32539. /**
  32540. * Gets or sets the current on-screen X position of the pointer
  32541. */
  32542. pointerX: number;
  32543. /**
  32544. * Gets or sets the current on-screen Y position of the pointer
  32545. */
  32546. pointerY: number;
  32547. private _updatePointerPosition;
  32548. private _processPointerMove;
  32549. private _setRayOnPointerInfo;
  32550. private _checkPrePointerObservable;
  32551. /**
  32552. * Use this method to simulate a pointer move on a mesh
  32553. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32554. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32555. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32556. */
  32557. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32558. /**
  32559. * Use this method to simulate a pointer down on a mesh
  32560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32563. */
  32564. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32565. private _processPointerDown;
  32566. /** @hidden */
  32567. _isPointerSwiping(): boolean;
  32568. /**
  32569. * Use this method to simulate a pointer up on a mesh
  32570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32573. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32574. */
  32575. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32576. private _processPointerUp;
  32577. /**
  32578. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32579. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32580. * @returns true if the pointer was captured
  32581. */
  32582. isPointerCaptured(pointerId?: number): boolean;
  32583. /**
  32584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32585. * @param attachUp defines if you want to attach events to pointerup
  32586. * @param attachDown defines if you want to attach events to pointerdown
  32587. * @param attachMove defines if you want to attach events to pointermove
  32588. */
  32589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32590. /**
  32591. * Detaches all event handlers
  32592. */
  32593. detachControl(): void;
  32594. /**
  32595. * Force the value of meshUnderPointer
  32596. * @param mesh defines the mesh to use
  32597. */
  32598. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32599. /**
  32600. * Gets the mesh under the pointer
  32601. * @returns a Mesh or null if no mesh is under the pointer
  32602. */
  32603. getPointerOverMesh(): Nullable<AbstractMesh>;
  32604. }
  32605. }
  32606. declare module BABYLON {
  32607. /**
  32608. * Helper class used to generate session unique ID
  32609. */
  32610. export class UniqueIdGenerator {
  32611. private static _UniqueIdCounter;
  32612. /**
  32613. * Gets an unique (relatively to the current scene) Id
  32614. */
  32615. static readonly UniqueId: number;
  32616. }
  32617. }
  32618. declare module BABYLON {
  32619. /**
  32620. * This class defines the direct association between an animation and a target
  32621. */
  32622. export class TargetedAnimation {
  32623. /**
  32624. * Animation to perform
  32625. */
  32626. animation: Animation;
  32627. /**
  32628. * Target to animate
  32629. */
  32630. target: any;
  32631. /**
  32632. * Serialize the object
  32633. * @returns the JSON object representing the current entity
  32634. */
  32635. serialize(): any;
  32636. }
  32637. /**
  32638. * Use this class to create coordinated animations on multiple targets
  32639. */
  32640. export class AnimationGroup implements IDisposable {
  32641. /** The name of the animation group */
  32642. name: string;
  32643. private _scene;
  32644. private _targetedAnimations;
  32645. private _animatables;
  32646. private _from;
  32647. private _to;
  32648. private _isStarted;
  32649. private _isPaused;
  32650. private _speedRatio;
  32651. private _loopAnimation;
  32652. /**
  32653. * Gets or sets the unique id of the node
  32654. */
  32655. uniqueId: number;
  32656. /**
  32657. * This observable will notify when one animation have ended
  32658. */
  32659. onAnimationEndObservable: Observable<TargetedAnimation>;
  32660. /**
  32661. * Observer raised when one animation loops
  32662. */
  32663. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32664. /**
  32665. * This observable will notify when all animations have ended.
  32666. */
  32667. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32668. /**
  32669. * This observable will notify when all animations have paused.
  32670. */
  32671. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32672. /**
  32673. * This observable will notify when all animations are playing.
  32674. */
  32675. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32676. /**
  32677. * Gets the first frame
  32678. */
  32679. readonly from: number;
  32680. /**
  32681. * Gets the last frame
  32682. */
  32683. readonly to: number;
  32684. /**
  32685. * Define if the animations are started
  32686. */
  32687. readonly isStarted: boolean;
  32688. /**
  32689. * Gets a value indicating that the current group is playing
  32690. */
  32691. readonly isPlaying: boolean;
  32692. /**
  32693. * Gets or sets the speed ratio to use for all animations
  32694. */
  32695. /**
  32696. * Gets or sets the speed ratio to use for all animations
  32697. */
  32698. speedRatio: number;
  32699. /**
  32700. * Gets or sets if all animations should loop or not
  32701. */
  32702. loopAnimation: boolean;
  32703. /**
  32704. * Gets the targeted animations for this animation group
  32705. */
  32706. readonly targetedAnimations: Array<TargetedAnimation>;
  32707. /**
  32708. * returning the list of animatables controlled by this animation group.
  32709. */
  32710. readonly animatables: Array<Animatable>;
  32711. /**
  32712. * Instantiates a new Animation Group.
  32713. * This helps managing several animations at once.
  32714. * @see http://doc.babylonjs.com/how_to/group
  32715. * @param name Defines the name of the group
  32716. * @param scene Defines the scene the group belongs to
  32717. */
  32718. constructor(
  32719. /** The name of the animation group */
  32720. name: string, scene?: Nullable<Scene>);
  32721. /**
  32722. * Add an animation (with its target) in the group
  32723. * @param animation defines the animation we want to add
  32724. * @param target defines the target of the animation
  32725. * @returns the TargetedAnimation object
  32726. */
  32727. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32728. /**
  32729. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32730. * It can add constant keys at begin or end
  32731. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32732. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32733. * @returns the animation group
  32734. */
  32735. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32736. /**
  32737. * Start all animations on given targets
  32738. * @param loop defines if animations must loop
  32739. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32740. * @param from defines the from key (optional)
  32741. * @param to defines the to key (optional)
  32742. * @returns the current animation group
  32743. */
  32744. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32745. /**
  32746. * Pause all animations
  32747. * @returns the animation group
  32748. */
  32749. pause(): AnimationGroup;
  32750. /**
  32751. * Play all animations to initial state
  32752. * This function will start() the animations if they were not started or will restart() them if they were paused
  32753. * @param loop defines if animations must loop
  32754. * @returns the animation group
  32755. */
  32756. play(loop?: boolean): AnimationGroup;
  32757. /**
  32758. * Reset all animations to initial state
  32759. * @returns the animation group
  32760. */
  32761. reset(): AnimationGroup;
  32762. /**
  32763. * Restart animations from key 0
  32764. * @returns the animation group
  32765. */
  32766. restart(): AnimationGroup;
  32767. /**
  32768. * Stop all animations
  32769. * @returns the animation group
  32770. */
  32771. stop(): AnimationGroup;
  32772. /**
  32773. * Set animation weight for all animatables
  32774. * @param weight defines the weight to use
  32775. * @return the animationGroup
  32776. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32777. */
  32778. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32779. /**
  32780. * Synchronize and normalize all animatables with a source animatable
  32781. * @param root defines the root animatable to synchronize with
  32782. * @return the animationGroup
  32783. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32784. */
  32785. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32786. /**
  32787. * Goes to a specific frame in this animation group
  32788. * @param frame the frame number to go to
  32789. * @return the animationGroup
  32790. */
  32791. goToFrame(frame: number): AnimationGroup;
  32792. /**
  32793. * Dispose all associated resources
  32794. */
  32795. dispose(): void;
  32796. private _checkAnimationGroupEnded;
  32797. /**
  32798. * Clone the current animation group and returns a copy
  32799. * @param newName defines the name of the new group
  32800. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32801. * @returns the new aniamtion group
  32802. */
  32803. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32804. /**
  32805. * Serializes the animationGroup to an object
  32806. * @returns Serialized object
  32807. */
  32808. serialize(): any;
  32809. /**
  32810. * Returns a new AnimationGroup object parsed from the source provided.
  32811. * @param parsedAnimationGroup defines the source
  32812. * @param scene defines the scene that will receive the animationGroup
  32813. * @returns a new AnimationGroup
  32814. */
  32815. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32816. /**
  32817. * Returns the string "AnimationGroup"
  32818. * @returns "AnimationGroup"
  32819. */
  32820. getClassName(): string;
  32821. /**
  32822. * Creates a detailled string about the object
  32823. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32824. * @returns a string representing the object
  32825. */
  32826. toString(fullDetails?: boolean): string;
  32827. }
  32828. }
  32829. declare module BABYLON {
  32830. /**
  32831. * Define an interface for all classes that will hold resources
  32832. */
  32833. export interface IDisposable {
  32834. /**
  32835. * Releases all held resources
  32836. */
  32837. dispose(): void;
  32838. }
  32839. /** Interface defining initialization parameters for Scene class */
  32840. export interface SceneOptions {
  32841. /**
  32842. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32843. * It will improve performance when the number of geometries becomes important.
  32844. */
  32845. useGeometryUniqueIdsMap?: boolean;
  32846. /**
  32847. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32848. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32849. */
  32850. useMaterialMeshMap?: boolean;
  32851. /**
  32852. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32853. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32854. */
  32855. useClonedMeshhMap?: boolean;
  32856. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32857. virtual?: boolean;
  32858. }
  32859. /**
  32860. * Represents a scene to be rendered by the engine.
  32861. * @see http://doc.babylonjs.com/features/scene
  32862. */
  32863. export class Scene extends AbstractScene implements IAnimatable {
  32864. /** The fog is deactivated */
  32865. static readonly FOGMODE_NONE: number;
  32866. /** The fog density is following an exponential function */
  32867. static readonly FOGMODE_EXP: number;
  32868. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32869. static readonly FOGMODE_EXP2: number;
  32870. /** The fog density is following a linear function. */
  32871. static readonly FOGMODE_LINEAR: number;
  32872. /**
  32873. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32875. */
  32876. static MinDeltaTime: number;
  32877. /**
  32878. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32880. */
  32881. static MaxDeltaTime: number;
  32882. /**
  32883. * Factory used to create the default material.
  32884. * @param name The name of the material to create
  32885. * @param scene The scene to create the material for
  32886. * @returns The default material
  32887. */
  32888. static DefaultMaterialFactory(scene: Scene): Material;
  32889. /**
  32890. * Factory used to create the a collision coordinator.
  32891. * @returns The collision coordinator
  32892. */
  32893. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32894. /** @hidden */
  32895. _inputManager: InputManager;
  32896. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32897. cameraToUseForPointers: Nullable<Camera>;
  32898. /** @hidden */
  32899. readonly _isScene: boolean;
  32900. /**
  32901. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32902. */
  32903. autoClear: boolean;
  32904. /**
  32905. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32906. */
  32907. autoClearDepthAndStencil: boolean;
  32908. /**
  32909. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32910. */
  32911. clearColor: Color4;
  32912. /**
  32913. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32914. */
  32915. ambientColor: Color3;
  32916. /**
  32917. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32918. * It should only be one of the following (if not the default embedded one):
  32919. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32920. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32921. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32922. * The material properties need to be setup according to the type of texture in use.
  32923. */
  32924. environmentBRDFTexture: BaseTexture;
  32925. /** @hidden */
  32926. protected _environmentTexture: Nullable<BaseTexture>;
  32927. /**
  32928. * Texture used in all pbr material as the reflection texture.
  32929. * As in the majority of the scene they are the same (exception for multi room and so on),
  32930. * this is easier to reference from here than from all the materials.
  32931. */
  32932. /**
  32933. * Texture used in all pbr material as the reflection texture.
  32934. * As in the majority of the scene they are the same (exception for multi room and so on),
  32935. * this is easier to set here than in all the materials.
  32936. */
  32937. environmentTexture: Nullable<BaseTexture>;
  32938. /** @hidden */
  32939. protected _environmentIntensity: number;
  32940. /**
  32941. * Intensity of the environment in all pbr material.
  32942. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32943. * As in the majority of the scene they are the same (exception for multi room and so on),
  32944. * this is easier to reference from here than from all the materials.
  32945. */
  32946. /**
  32947. * Intensity of the environment in all pbr material.
  32948. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32949. * As in the majority of the scene they are the same (exception for multi room and so on),
  32950. * this is easier to set here than in all the materials.
  32951. */
  32952. environmentIntensity: number;
  32953. /** @hidden */
  32954. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32955. /**
  32956. * Default image processing configuration used either in the rendering
  32957. * Forward main pass or through the imageProcessingPostProcess if present.
  32958. * As in the majority of the scene they are the same (exception for multi camera),
  32959. * this is easier to reference from here than from all the materials and post process.
  32960. *
  32961. * No setter as we it is a shared configuration, you can set the values instead.
  32962. */
  32963. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32964. private _forceWireframe;
  32965. /**
  32966. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32967. */
  32968. forceWireframe: boolean;
  32969. private _forcePointsCloud;
  32970. /**
  32971. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32972. */
  32973. forcePointsCloud: boolean;
  32974. /**
  32975. * Gets or sets the active clipplane 1
  32976. */
  32977. clipPlane: Nullable<Plane>;
  32978. /**
  32979. * Gets or sets the active clipplane 2
  32980. */
  32981. clipPlane2: Nullable<Plane>;
  32982. /**
  32983. * Gets or sets the active clipplane 3
  32984. */
  32985. clipPlane3: Nullable<Plane>;
  32986. /**
  32987. * Gets or sets the active clipplane 4
  32988. */
  32989. clipPlane4: Nullable<Plane>;
  32990. /**
  32991. * Gets or sets a boolean indicating if animations are enabled
  32992. */
  32993. animationsEnabled: boolean;
  32994. private _animationPropertiesOverride;
  32995. /**
  32996. * Gets or sets the animation properties override
  32997. */
  32998. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32999. /**
  33000. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33001. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33002. */
  33003. useConstantAnimationDeltaTime: boolean;
  33004. /**
  33005. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33006. * Please note that it requires to run a ray cast through the scene on every frame
  33007. */
  33008. constantlyUpdateMeshUnderPointer: boolean;
  33009. /**
  33010. * Defines the HTML cursor to use when hovering over interactive elements
  33011. */
  33012. hoverCursor: string;
  33013. /**
  33014. * Defines the HTML default cursor to use (empty by default)
  33015. */
  33016. defaultCursor: string;
  33017. /**
  33018. * This is used to call preventDefault() on pointer down
  33019. * in order to block unwanted artifacts like system double clicks
  33020. */
  33021. preventDefaultOnPointerDown: boolean;
  33022. /**
  33023. * This is used to call preventDefault() on pointer up
  33024. * in order to block unwanted artifacts like system double clicks
  33025. */
  33026. preventDefaultOnPointerUp: boolean;
  33027. /**
  33028. * Gets or sets user defined metadata
  33029. */
  33030. metadata: any;
  33031. /**
  33032. * For internal use only. Please do not use.
  33033. */
  33034. reservedDataStore: any;
  33035. /**
  33036. * Gets the name of the plugin used to load this scene (null by default)
  33037. */
  33038. loadingPluginName: string;
  33039. /**
  33040. * Use this array to add regular expressions used to disable offline support for specific urls
  33041. */
  33042. disableOfflineSupportExceptionRules: RegExp[];
  33043. /**
  33044. * An event triggered when the scene is disposed.
  33045. */
  33046. onDisposeObservable: Observable<Scene>;
  33047. private _onDisposeObserver;
  33048. /** Sets a function to be executed when this scene is disposed. */
  33049. onDispose: () => void;
  33050. /**
  33051. * An event triggered before rendering the scene (right after animations and physics)
  33052. */
  33053. onBeforeRenderObservable: Observable<Scene>;
  33054. private _onBeforeRenderObserver;
  33055. /** Sets a function to be executed before rendering this scene */
  33056. beforeRender: Nullable<() => void>;
  33057. /**
  33058. * An event triggered after rendering the scene
  33059. */
  33060. onAfterRenderObservable: Observable<Scene>;
  33061. /**
  33062. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33063. */
  33064. onAfterRenderCameraObservable: Observable<Camera>;
  33065. private _onAfterRenderObserver;
  33066. /** Sets a function to be executed after rendering this scene */
  33067. afterRender: Nullable<() => void>;
  33068. /**
  33069. * An event triggered before animating the scene
  33070. */
  33071. onBeforeAnimationsObservable: Observable<Scene>;
  33072. /**
  33073. * An event triggered after animations processing
  33074. */
  33075. onAfterAnimationsObservable: Observable<Scene>;
  33076. /**
  33077. * An event triggered before draw calls are ready to be sent
  33078. */
  33079. onBeforeDrawPhaseObservable: Observable<Scene>;
  33080. /**
  33081. * An event triggered after draw calls have been sent
  33082. */
  33083. onAfterDrawPhaseObservable: Observable<Scene>;
  33084. /**
  33085. * An event triggered when the scene is ready
  33086. */
  33087. onReadyObservable: Observable<Scene>;
  33088. /**
  33089. * An event triggered before rendering a camera
  33090. */
  33091. onBeforeCameraRenderObservable: Observable<Camera>;
  33092. private _onBeforeCameraRenderObserver;
  33093. /** Sets a function to be executed before rendering a camera*/
  33094. beforeCameraRender: () => void;
  33095. /**
  33096. * An event triggered after rendering a camera
  33097. */
  33098. onAfterCameraRenderObservable: Observable<Camera>;
  33099. private _onAfterCameraRenderObserver;
  33100. /** Sets a function to be executed after rendering a camera*/
  33101. afterCameraRender: () => void;
  33102. /**
  33103. * An event triggered when active meshes evaluation is about to start
  33104. */
  33105. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33106. /**
  33107. * An event triggered when active meshes evaluation is done
  33108. */
  33109. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33110. /**
  33111. * An event triggered when particles rendering is about to start
  33112. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33113. */
  33114. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33115. /**
  33116. * An event triggered when particles rendering is done
  33117. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33118. */
  33119. onAfterParticlesRenderingObservable: Observable<Scene>;
  33120. /**
  33121. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33122. */
  33123. onDataLoadedObservable: Observable<Scene>;
  33124. /**
  33125. * An event triggered when a camera is created
  33126. */
  33127. onNewCameraAddedObservable: Observable<Camera>;
  33128. /**
  33129. * An event triggered when a camera is removed
  33130. */
  33131. onCameraRemovedObservable: Observable<Camera>;
  33132. /**
  33133. * An event triggered when a light is created
  33134. */
  33135. onNewLightAddedObservable: Observable<Light>;
  33136. /**
  33137. * An event triggered when a light is removed
  33138. */
  33139. onLightRemovedObservable: Observable<Light>;
  33140. /**
  33141. * An event triggered when a geometry is created
  33142. */
  33143. onNewGeometryAddedObservable: Observable<Geometry>;
  33144. /**
  33145. * An event triggered when a geometry is removed
  33146. */
  33147. onGeometryRemovedObservable: Observable<Geometry>;
  33148. /**
  33149. * An event triggered when a transform node is created
  33150. */
  33151. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33152. /**
  33153. * An event triggered when a transform node is removed
  33154. */
  33155. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33156. /**
  33157. * An event triggered when a mesh is created
  33158. */
  33159. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33160. /**
  33161. * An event triggered when a mesh is removed
  33162. */
  33163. onMeshRemovedObservable: Observable<AbstractMesh>;
  33164. /**
  33165. * An event triggered when a skeleton is created
  33166. */
  33167. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33168. /**
  33169. * An event triggered when a skeleton is removed
  33170. */
  33171. onSkeletonRemovedObservable: Observable<Skeleton>;
  33172. /**
  33173. * An event triggered when a material is created
  33174. */
  33175. onNewMaterialAddedObservable: Observable<Material>;
  33176. /**
  33177. * An event triggered when a material is removed
  33178. */
  33179. onMaterialRemovedObservable: Observable<Material>;
  33180. /**
  33181. * An event triggered when a texture is created
  33182. */
  33183. onNewTextureAddedObservable: Observable<BaseTexture>;
  33184. /**
  33185. * An event triggered when a texture is removed
  33186. */
  33187. onTextureRemovedObservable: Observable<BaseTexture>;
  33188. /**
  33189. * An event triggered when render targets are about to be rendered
  33190. * Can happen multiple times per frame.
  33191. */
  33192. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33193. /**
  33194. * An event triggered when render targets were rendered.
  33195. * Can happen multiple times per frame.
  33196. */
  33197. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33198. /**
  33199. * An event triggered before calculating deterministic simulation step
  33200. */
  33201. onBeforeStepObservable: Observable<Scene>;
  33202. /**
  33203. * An event triggered after calculating deterministic simulation step
  33204. */
  33205. onAfterStepObservable: Observable<Scene>;
  33206. /**
  33207. * An event triggered when the activeCamera property is updated
  33208. */
  33209. onActiveCameraChanged: Observable<Scene>;
  33210. /**
  33211. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33212. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33213. * 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)
  33214. */
  33215. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33216. /**
  33217. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33218. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33219. * 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)
  33220. */
  33221. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33222. /**
  33223. * This Observable will when a mesh has been imported into the scene.
  33224. */
  33225. onMeshImportedObservable: Observable<AbstractMesh>;
  33226. /**
  33227. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33228. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33229. */
  33230. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33231. /** @hidden */
  33232. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33233. /**
  33234. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33235. */
  33236. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33237. /**
  33238. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33239. */
  33240. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33241. /**
  33242. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33243. */
  33244. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33245. /** Callback called when a pointer move is detected */
  33246. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33247. /** Callback called when a pointer down is detected */
  33248. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33249. /** Callback called when a pointer up is detected */
  33250. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33251. /** Callback called when a pointer pick is detected */
  33252. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33253. /**
  33254. * 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).
  33255. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33256. */
  33257. onPrePointerObservable: Observable<PointerInfoPre>;
  33258. /**
  33259. * Observable event triggered each time an input event is received from the rendering canvas
  33260. */
  33261. onPointerObservable: Observable<PointerInfo>;
  33262. /**
  33263. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33264. */
  33265. readonly unTranslatedPointer: Vector2;
  33266. /**
  33267. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33268. */
  33269. static DragMovementThreshold: number;
  33270. /**
  33271. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33272. */
  33273. static LongPressDelay: number;
  33274. /**
  33275. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33276. */
  33277. static DoubleClickDelay: number;
  33278. /** If you need to check double click without raising a single click at first click, enable this flag */
  33279. static ExclusiveDoubleClickMode: boolean;
  33280. /** @hidden */
  33281. _mirroredCameraPosition: Nullable<Vector3>;
  33282. /**
  33283. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33284. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33285. */
  33286. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33287. /**
  33288. * Observable event triggered each time an keyboard event is received from the hosting window
  33289. */
  33290. onKeyboardObservable: Observable<KeyboardInfo>;
  33291. private _useRightHandedSystem;
  33292. /**
  33293. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33294. */
  33295. useRightHandedSystem: boolean;
  33296. private _timeAccumulator;
  33297. private _currentStepId;
  33298. private _currentInternalStep;
  33299. /**
  33300. * Sets the step Id used by deterministic lock step
  33301. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33302. * @param newStepId defines the step Id
  33303. */
  33304. setStepId(newStepId: number): void;
  33305. /**
  33306. * Gets the step Id used by deterministic lock step
  33307. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33308. * @returns the step Id
  33309. */
  33310. getStepId(): number;
  33311. /**
  33312. * Gets the internal step used by deterministic lock step
  33313. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33314. * @returns the internal step
  33315. */
  33316. getInternalStep(): number;
  33317. private _fogEnabled;
  33318. /**
  33319. * Gets or sets a boolean indicating if fog is enabled on this scene
  33320. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33321. * (Default is true)
  33322. */
  33323. fogEnabled: boolean;
  33324. private _fogMode;
  33325. /**
  33326. * Gets or sets the fog mode to use
  33327. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33328. * | mode | value |
  33329. * | --- | --- |
  33330. * | FOGMODE_NONE | 0 |
  33331. * | FOGMODE_EXP | 1 |
  33332. * | FOGMODE_EXP2 | 2 |
  33333. * | FOGMODE_LINEAR | 3 |
  33334. */
  33335. fogMode: number;
  33336. /**
  33337. * Gets or sets the fog color to use
  33338. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33339. * (Default is Color3(0.2, 0.2, 0.3))
  33340. */
  33341. fogColor: Color3;
  33342. /**
  33343. * Gets or sets the fog density to use
  33344. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33345. * (Default is 0.1)
  33346. */
  33347. fogDensity: number;
  33348. /**
  33349. * Gets or sets the fog start distance to use
  33350. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33351. * (Default is 0)
  33352. */
  33353. fogStart: number;
  33354. /**
  33355. * Gets or sets the fog end distance to use
  33356. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33357. * (Default is 1000)
  33358. */
  33359. fogEnd: number;
  33360. private _shadowsEnabled;
  33361. /**
  33362. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33363. */
  33364. shadowsEnabled: boolean;
  33365. private _lightsEnabled;
  33366. /**
  33367. * Gets or sets a boolean indicating if lights are enabled on this scene
  33368. */
  33369. lightsEnabled: boolean;
  33370. /** All of the active cameras added to this scene. */
  33371. activeCameras: Camera[];
  33372. /** @hidden */
  33373. _activeCamera: Nullable<Camera>;
  33374. /** Gets or sets the current active camera */
  33375. activeCamera: Nullable<Camera>;
  33376. private _defaultMaterial;
  33377. /** The default material used on meshes when no material is affected */
  33378. /** The default material used on meshes when no material is affected */
  33379. defaultMaterial: Material;
  33380. private _texturesEnabled;
  33381. /**
  33382. * Gets or sets a boolean indicating if textures are enabled on this scene
  33383. */
  33384. texturesEnabled: boolean;
  33385. /**
  33386. * Gets or sets a boolean indicating if particles are enabled on this scene
  33387. */
  33388. particlesEnabled: boolean;
  33389. /**
  33390. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33391. */
  33392. spritesEnabled: boolean;
  33393. private _skeletonsEnabled;
  33394. /**
  33395. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33396. */
  33397. skeletonsEnabled: boolean;
  33398. /**
  33399. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33400. */
  33401. lensFlaresEnabled: boolean;
  33402. /**
  33403. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33405. */
  33406. collisionsEnabled: boolean;
  33407. private _collisionCoordinator;
  33408. /** @hidden */
  33409. readonly collisionCoordinator: ICollisionCoordinator;
  33410. /**
  33411. * Defines the gravity applied to this scene (used only for collisions)
  33412. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33413. */
  33414. gravity: Vector3;
  33415. /**
  33416. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33417. */
  33418. postProcessesEnabled: boolean;
  33419. /**
  33420. * The list of postprocesses added to the scene
  33421. */
  33422. postProcesses: PostProcess[];
  33423. /**
  33424. * Gets the current postprocess manager
  33425. */
  33426. postProcessManager: PostProcessManager;
  33427. /**
  33428. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33429. */
  33430. renderTargetsEnabled: boolean;
  33431. /**
  33432. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33433. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33434. */
  33435. dumpNextRenderTargets: boolean;
  33436. /**
  33437. * The list of user defined render targets added to the scene
  33438. */
  33439. customRenderTargets: RenderTargetTexture[];
  33440. /**
  33441. * Defines if texture loading must be delayed
  33442. * If true, textures will only be loaded when they need to be rendered
  33443. */
  33444. useDelayedTextureLoading: boolean;
  33445. /**
  33446. * Gets the list of meshes imported to the scene through SceneLoader
  33447. */
  33448. importedMeshesFiles: String[];
  33449. /**
  33450. * Gets or sets a boolean indicating if probes are enabled on this scene
  33451. */
  33452. probesEnabled: boolean;
  33453. /**
  33454. * Gets or sets the current offline provider to use to store scene data
  33455. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33456. */
  33457. offlineProvider: IOfflineProvider;
  33458. /**
  33459. * Gets or sets the action manager associated with the scene
  33460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33461. */
  33462. actionManager: AbstractActionManager;
  33463. private _meshesForIntersections;
  33464. /**
  33465. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33466. */
  33467. proceduralTexturesEnabled: boolean;
  33468. private _engine;
  33469. private _totalVertices;
  33470. /** @hidden */
  33471. _activeIndices: PerfCounter;
  33472. /** @hidden */
  33473. _activeParticles: PerfCounter;
  33474. /** @hidden */
  33475. _activeBones: PerfCounter;
  33476. private _animationRatio;
  33477. /** @hidden */
  33478. _animationTimeLast: number;
  33479. /** @hidden */
  33480. _animationTime: number;
  33481. /**
  33482. * Gets or sets a general scale for animation speed
  33483. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33484. */
  33485. animationTimeScale: number;
  33486. /** @hidden */
  33487. _cachedMaterial: Nullable<Material>;
  33488. /** @hidden */
  33489. _cachedEffect: Nullable<Effect>;
  33490. /** @hidden */
  33491. _cachedVisibility: Nullable<number>;
  33492. private _renderId;
  33493. private _frameId;
  33494. private _executeWhenReadyTimeoutId;
  33495. private _intermediateRendering;
  33496. private _viewUpdateFlag;
  33497. private _projectionUpdateFlag;
  33498. /** @hidden */
  33499. _toBeDisposed: Nullable<IDisposable>[];
  33500. private _activeRequests;
  33501. /** @hidden */
  33502. _pendingData: any[];
  33503. private _isDisposed;
  33504. /**
  33505. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33506. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33507. */
  33508. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33509. private _activeMeshes;
  33510. private _processedMaterials;
  33511. private _renderTargets;
  33512. /** @hidden */
  33513. _activeParticleSystems: SmartArray<IParticleSystem>;
  33514. private _activeSkeletons;
  33515. private _softwareSkinnedMeshes;
  33516. private _renderingManager;
  33517. /** @hidden */
  33518. _activeAnimatables: Animatable[];
  33519. private _transformMatrix;
  33520. private _sceneUbo;
  33521. /** @hidden */
  33522. _viewMatrix: Matrix;
  33523. private _projectionMatrix;
  33524. /** @hidden */
  33525. _forcedViewPosition: Nullable<Vector3>;
  33526. /** @hidden */
  33527. _frustumPlanes: Plane[];
  33528. /**
  33529. * Gets the list of frustum planes (built from the active camera)
  33530. */
  33531. readonly frustumPlanes: Plane[];
  33532. /**
  33533. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33534. * This is useful if there are more lights that the maximum simulteanous authorized
  33535. */
  33536. requireLightSorting: boolean;
  33537. /** @hidden */
  33538. readonly useMaterialMeshMap: boolean;
  33539. /** @hidden */
  33540. readonly useClonedMeshhMap: boolean;
  33541. private _externalData;
  33542. private _uid;
  33543. /**
  33544. * @hidden
  33545. * Backing store of defined scene components.
  33546. */
  33547. _components: ISceneComponent[];
  33548. /**
  33549. * @hidden
  33550. * Backing store of defined scene components.
  33551. */
  33552. _serializableComponents: ISceneSerializableComponent[];
  33553. /**
  33554. * List of components to register on the next registration step.
  33555. */
  33556. private _transientComponents;
  33557. /**
  33558. * Registers the transient components if needed.
  33559. */
  33560. private _registerTransientComponents;
  33561. /**
  33562. * @hidden
  33563. * Add a component to the scene.
  33564. * Note that the ccomponent could be registered on th next frame if this is called after
  33565. * the register component stage.
  33566. * @param component Defines the component to add to the scene
  33567. */
  33568. _addComponent(component: ISceneComponent): void;
  33569. /**
  33570. * @hidden
  33571. * Gets a component from the scene.
  33572. * @param name defines the name of the component to retrieve
  33573. * @returns the component or null if not present
  33574. */
  33575. _getComponent(name: string): Nullable<ISceneComponent>;
  33576. /**
  33577. * @hidden
  33578. * Defines the actions happening before camera updates.
  33579. */
  33580. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33581. /**
  33582. * @hidden
  33583. * Defines the actions happening before clear the canvas.
  33584. */
  33585. _beforeClearStage: Stage<SimpleStageAction>;
  33586. /**
  33587. * @hidden
  33588. * Defines the actions when collecting render targets for the frame.
  33589. */
  33590. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33591. /**
  33592. * @hidden
  33593. * Defines the actions happening for one camera in the frame.
  33594. */
  33595. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33596. /**
  33597. * @hidden
  33598. * Defines the actions happening during the per mesh ready checks.
  33599. */
  33600. _isReadyForMeshStage: Stage<MeshStageAction>;
  33601. /**
  33602. * @hidden
  33603. * Defines the actions happening before evaluate active mesh checks.
  33604. */
  33605. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33606. /**
  33607. * @hidden
  33608. * Defines the actions happening during the evaluate sub mesh checks.
  33609. */
  33610. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33611. /**
  33612. * @hidden
  33613. * Defines the actions happening during the active mesh stage.
  33614. */
  33615. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33616. /**
  33617. * @hidden
  33618. * Defines the actions happening during the per camera render target step.
  33619. */
  33620. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33621. /**
  33622. * @hidden
  33623. * Defines the actions happening just before the active camera is drawing.
  33624. */
  33625. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33626. /**
  33627. * @hidden
  33628. * Defines the actions happening just before a render target is drawing.
  33629. */
  33630. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33631. /**
  33632. * @hidden
  33633. * Defines the actions happening just before a rendering group is drawing.
  33634. */
  33635. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33636. /**
  33637. * @hidden
  33638. * Defines the actions happening just before a mesh is drawing.
  33639. */
  33640. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33641. /**
  33642. * @hidden
  33643. * Defines the actions happening just after a mesh has been drawn.
  33644. */
  33645. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33646. /**
  33647. * @hidden
  33648. * Defines the actions happening just after a rendering group has been drawn.
  33649. */
  33650. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33651. /**
  33652. * @hidden
  33653. * Defines the actions happening just after the active camera has been drawn.
  33654. */
  33655. _afterCameraDrawStage: Stage<CameraStageAction>;
  33656. /**
  33657. * @hidden
  33658. * Defines the actions happening just after a render target has been drawn.
  33659. */
  33660. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33661. /**
  33662. * @hidden
  33663. * Defines the actions happening just after rendering all cameras and computing intersections.
  33664. */
  33665. _afterRenderStage: Stage<SimpleStageAction>;
  33666. /**
  33667. * @hidden
  33668. * Defines the actions happening when a pointer move event happens.
  33669. */
  33670. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33671. /**
  33672. * @hidden
  33673. * Defines the actions happening when a pointer down event happens.
  33674. */
  33675. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33676. /**
  33677. * @hidden
  33678. * Defines the actions happening when a pointer up event happens.
  33679. */
  33680. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33681. /**
  33682. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33683. */
  33684. private geometriesByUniqueId;
  33685. /**
  33686. * Creates a new Scene
  33687. * @param engine defines the engine to use to render this scene
  33688. * @param options defines the scene options
  33689. */
  33690. constructor(engine: Engine, options?: SceneOptions);
  33691. /**
  33692. * Gets a string idenfifying the name of the class
  33693. * @returns "Scene" string
  33694. */
  33695. getClassName(): string;
  33696. private _defaultMeshCandidates;
  33697. /**
  33698. * @hidden
  33699. */
  33700. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33701. private _defaultSubMeshCandidates;
  33702. /**
  33703. * @hidden
  33704. */
  33705. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33706. /**
  33707. * Sets the default candidate providers for the scene.
  33708. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33709. * and getCollidingSubMeshCandidates to their default function
  33710. */
  33711. setDefaultCandidateProviders(): void;
  33712. /**
  33713. * Gets the mesh that is currently under the pointer
  33714. */
  33715. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33716. /**
  33717. * Gets or sets the current on-screen X position of the pointer
  33718. */
  33719. pointerX: number;
  33720. /**
  33721. * Gets or sets the current on-screen Y position of the pointer
  33722. */
  33723. pointerY: number;
  33724. /**
  33725. * Gets the cached material (ie. the latest rendered one)
  33726. * @returns the cached material
  33727. */
  33728. getCachedMaterial(): Nullable<Material>;
  33729. /**
  33730. * Gets the cached effect (ie. the latest rendered one)
  33731. * @returns the cached effect
  33732. */
  33733. getCachedEffect(): Nullable<Effect>;
  33734. /**
  33735. * Gets the cached visibility state (ie. the latest rendered one)
  33736. * @returns the cached visibility state
  33737. */
  33738. getCachedVisibility(): Nullable<number>;
  33739. /**
  33740. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33741. * @param material defines the current material
  33742. * @param effect defines the current effect
  33743. * @param visibility defines the current visibility state
  33744. * @returns true if one parameter is not cached
  33745. */
  33746. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33747. /**
  33748. * Gets the engine associated with the scene
  33749. * @returns an Engine
  33750. */
  33751. getEngine(): Engine;
  33752. /**
  33753. * Gets the total number of vertices rendered per frame
  33754. * @returns the total number of vertices rendered per frame
  33755. */
  33756. getTotalVertices(): number;
  33757. /**
  33758. * Gets the performance counter for total vertices
  33759. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33760. */
  33761. readonly totalVerticesPerfCounter: PerfCounter;
  33762. /**
  33763. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33764. * @returns the total number of active indices rendered per frame
  33765. */
  33766. getActiveIndices(): number;
  33767. /**
  33768. * Gets the performance counter for active indices
  33769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33770. */
  33771. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33772. /**
  33773. * Gets the total number of active particles rendered per frame
  33774. * @returns the total number of active particles rendered per frame
  33775. */
  33776. getActiveParticles(): number;
  33777. /**
  33778. * Gets the performance counter for active particles
  33779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33780. */
  33781. readonly activeParticlesPerfCounter: PerfCounter;
  33782. /**
  33783. * Gets the total number of active bones rendered per frame
  33784. * @returns the total number of active bones rendered per frame
  33785. */
  33786. getActiveBones(): number;
  33787. /**
  33788. * Gets the performance counter for active bones
  33789. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33790. */
  33791. readonly activeBonesPerfCounter: PerfCounter;
  33792. /**
  33793. * Gets the array of active meshes
  33794. * @returns an array of AbstractMesh
  33795. */
  33796. getActiveMeshes(): SmartArray<AbstractMesh>;
  33797. /**
  33798. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33799. * @returns a number
  33800. */
  33801. getAnimationRatio(): number;
  33802. /**
  33803. * Gets an unique Id for the current render phase
  33804. * @returns a number
  33805. */
  33806. getRenderId(): number;
  33807. /**
  33808. * Gets an unique Id for the current frame
  33809. * @returns a number
  33810. */
  33811. getFrameId(): number;
  33812. /** Call this function if you want to manually increment the render Id*/
  33813. incrementRenderId(): void;
  33814. private _createUbo;
  33815. /**
  33816. * Use this method to simulate a pointer move on a mesh
  33817. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33818. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33819. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33820. * @returns the current scene
  33821. */
  33822. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33823. /**
  33824. * Use this method to simulate a pointer down on a mesh
  33825. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33826. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33827. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33828. * @returns the current scene
  33829. */
  33830. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33831. /**
  33832. * Use this method to simulate a pointer up on a mesh
  33833. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33834. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33835. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33836. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33837. * @returns the current scene
  33838. */
  33839. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33840. /**
  33841. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33842. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33843. * @returns true if the pointer was captured
  33844. */
  33845. isPointerCaptured(pointerId?: number): boolean;
  33846. /**
  33847. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33848. * @param attachUp defines if you want to attach events to pointerup
  33849. * @param attachDown defines if you want to attach events to pointerdown
  33850. * @param attachMove defines if you want to attach events to pointermove
  33851. */
  33852. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33853. /** Detaches all event handlers*/
  33854. detachControl(): void;
  33855. /**
  33856. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33857. * Delay loaded resources are not taking in account
  33858. * @return true if all required resources are ready
  33859. */
  33860. isReady(): boolean;
  33861. /** Resets all cached information relative to material (including effect and visibility) */
  33862. resetCachedMaterial(): void;
  33863. /**
  33864. * Registers a function to be called before every frame render
  33865. * @param func defines the function to register
  33866. */
  33867. registerBeforeRender(func: () => void): void;
  33868. /**
  33869. * Unregisters a function called before every frame render
  33870. * @param func defines the function to unregister
  33871. */
  33872. unregisterBeforeRender(func: () => void): void;
  33873. /**
  33874. * Registers a function to be called after every frame render
  33875. * @param func defines the function to register
  33876. */
  33877. registerAfterRender(func: () => void): void;
  33878. /**
  33879. * Unregisters a function called after every frame render
  33880. * @param func defines the function to unregister
  33881. */
  33882. unregisterAfterRender(func: () => void): void;
  33883. private _executeOnceBeforeRender;
  33884. /**
  33885. * The provided function will run before render once and will be disposed afterwards.
  33886. * A timeout delay can be provided so that the function will be executed in N ms.
  33887. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33888. * @param func The function to be executed.
  33889. * @param timeout optional delay in ms
  33890. */
  33891. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33892. /** @hidden */
  33893. _addPendingData(data: any): void;
  33894. /** @hidden */
  33895. _removePendingData(data: any): void;
  33896. /**
  33897. * Returns the number of items waiting to be loaded
  33898. * @returns the number of items waiting to be loaded
  33899. */
  33900. getWaitingItemsCount(): number;
  33901. /**
  33902. * Returns a boolean indicating if the scene is still loading data
  33903. */
  33904. readonly isLoading: boolean;
  33905. /**
  33906. * Registers a function to be executed when the scene is ready
  33907. * @param {Function} func - the function to be executed
  33908. */
  33909. executeWhenReady(func: () => void): void;
  33910. /**
  33911. * Returns a promise that resolves when the scene is ready
  33912. * @returns A promise that resolves when the scene is ready
  33913. */
  33914. whenReadyAsync(): Promise<void>;
  33915. /** @hidden */
  33916. _checkIsReady(): void;
  33917. /**
  33918. * Gets all animatable attached to the scene
  33919. */
  33920. readonly animatables: Animatable[];
  33921. /**
  33922. * Resets the last animation time frame.
  33923. * Useful to override when animations start running when loading a scene for the first time.
  33924. */
  33925. resetLastAnimationTimeFrame(): void;
  33926. /**
  33927. * Gets the current view matrix
  33928. * @returns a Matrix
  33929. */
  33930. getViewMatrix(): Matrix;
  33931. /**
  33932. * Gets the current projection matrix
  33933. * @returns a Matrix
  33934. */
  33935. getProjectionMatrix(): Matrix;
  33936. /**
  33937. * Gets the current transform matrix
  33938. * @returns a Matrix made of View * Projection
  33939. */
  33940. getTransformMatrix(): Matrix;
  33941. /**
  33942. * Sets the current transform matrix
  33943. * @param viewL defines the View matrix to use
  33944. * @param projectionL defines the Projection matrix to use
  33945. * @param viewR defines the right View matrix to use (if provided)
  33946. * @param projectionR defines the right Projection matrix to use (if provided)
  33947. */
  33948. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33949. /**
  33950. * Gets the uniform buffer used to store scene data
  33951. * @returns a UniformBuffer
  33952. */
  33953. getSceneUniformBuffer(): UniformBuffer;
  33954. /**
  33955. * Gets an unique (relatively to the current scene) Id
  33956. * @returns an unique number for the scene
  33957. */
  33958. getUniqueId(): number;
  33959. /**
  33960. * Add a mesh to the list of scene's meshes
  33961. * @param newMesh defines the mesh to add
  33962. * @param recursive if all child meshes should also be added to the scene
  33963. */
  33964. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33965. /**
  33966. * Remove a mesh for the list of scene's meshes
  33967. * @param toRemove defines the mesh to remove
  33968. * @param recursive if all child meshes should also be removed from the scene
  33969. * @returns the index where the mesh was in the mesh list
  33970. */
  33971. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33972. /**
  33973. * Add a transform node to the list of scene's transform nodes
  33974. * @param newTransformNode defines the transform node to add
  33975. */
  33976. addTransformNode(newTransformNode: TransformNode): void;
  33977. /**
  33978. * Remove a transform node for the list of scene's transform nodes
  33979. * @param toRemove defines the transform node to remove
  33980. * @returns the index where the transform node was in the transform node list
  33981. */
  33982. removeTransformNode(toRemove: TransformNode): number;
  33983. /**
  33984. * Remove a skeleton for the list of scene's skeletons
  33985. * @param toRemove defines the skeleton to remove
  33986. * @returns the index where the skeleton was in the skeleton list
  33987. */
  33988. removeSkeleton(toRemove: Skeleton): number;
  33989. /**
  33990. * Remove a morph target for the list of scene's morph targets
  33991. * @param toRemove defines the morph target to remove
  33992. * @returns the index where the morph target was in the morph target list
  33993. */
  33994. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33995. /**
  33996. * Remove a light for the list of scene's lights
  33997. * @param toRemove defines the light to remove
  33998. * @returns the index where the light was in the light list
  33999. */
  34000. removeLight(toRemove: Light): number;
  34001. /**
  34002. * Remove a camera for the list of scene's cameras
  34003. * @param toRemove defines the camera to remove
  34004. * @returns the index where the camera was in the camera list
  34005. */
  34006. removeCamera(toRemove: Camera): number;
  34007. /**
  34008. * Remove a particle system for the list of scene's particle systems
  34009. * @param toRemove defines the particle system to remove
  34010. * @returns the index where the particle system was in the particle system list
  34011. */
  34012. removeParticleSystem(toRemove: IParticleSystem): number;
  34013. /**
  34014. * Remove a animation for the list of scene's animations
  34015. * @param toRemove defines the animation to remove
  34016. * @returns the index where the animation was in the animation list
  34017. */
  34018. removeAnimation(toRemove: Animation): number;
  34019. /**
  34020. * Will stop the animation of the given target
  34021. * @param target - the target
  34022. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34023. * @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)
  34024. */
  34025. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34026. /**
  34027. * Removes the given animation group from this scene.
  34028. * @param toRemove The animation group to remove
  34029. * @returns The index of the removed animation group
  34030. */
  34031. removeAnimationGroup(toRemove: AnimationGroup): number;
  34032. /**
  34033. * Removes the given multi-material from this scene.
  34034. * @param toRemove The multi-material to remove
  34035. * @returns The index of the removed multi-material
  34036. */
  34037. removeMultiMaterial(toRemove: MultiMaterial): number;
  34038. /**
  34039. * Removes the given material from this scene.
  34040. * @param toRemove The material to remove
  34041. * @returns The index of the removed material
  34042. */
  34043. removeMaterial(toRemove: Material): number;
  34044. /**
  34045. * Removes the given action manager from this scene.
  34046. * @param toRemove The action manager to remove
  34047. * @returns The index of the removed action manager
  34048. */
  34049. removeActionManager(toRemove: AbstractActionManager): number;
  34050. /**
  34051. * Removes the given texture from this scene.
  34052. * @param toRemove The texture to remove
  34053. * @returns The index of the removed texture
  34054. */
  34055. removeTexture(toRemove: BaseTexture): number;
  34056. /**
  34057. * Adds the given light to this scene
  34058. * @param newLight The light to add
  34059. */
  34060. addLight(newLight: Light): void;
  34061. /**
  34062. * Sorts the list list based on light priorities
  34063. */
  34064. sortLightsByPriority(): void;
  34065. /**
  34066. * Adds the given camera to this scene
  34067. * @param newCamera The camera to add
  34068. */
  34069. addCamera(newCamera: Camera): void;
  34070. /**
  34071. * Adds the given skeleton to this scene
  34072. * @param newSkeleton The skeleton to add
  34073. */
  34074. addSkeleton(newSkeleton: Skeleton): void;
  34075. /**
  34076. * Adds the given particle system to this scene
  34077. * @param newParticleSystem The particle system to add
  34078. */
  34079. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34080. /**
  34081. * Adds the given animation to this scene
  34082. * @param newAnimation The animation to add
  34083. */
  34084. addAnimation(newAnimation: Animation): void;
  34085. /**
  34086. * Adds the given animation group to this scene.
  34087. * @param newAnimationGroup The animation group to add
  34088. */
  34089. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34090. /**
  34091. * Adds the given multi-material to this scene
  34092. * @param newMultiMaterial The multi-material to add
  34093. */
  34094. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34095. /**
  34096. * Adds the given material to this scene
  34097. * @param newMaterial The material to add
  34098. */
  34099. addMaterial(newMaterial: Material): void;
  34100. /**
  34101. * Adds the given morph target to this scene
  34102. * @param newMorphTargetManager The morph target to add
  34103. */
  34104. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34105. /**
  34106. * Adds the given geometry to this scene
  34107. * @param newGeometry The geometry to add
  34108. */
  34109. addGeometry(newGeometry: Geometry): void;
  34110. /**
  34111. * Adds the given action manager to this scene
  34112. * @param newActionManager The action manager to add
  34113. */
  34114. addActionManager(newActionManager: AbstractActionManager): void;
  34115. /**
  34116. * Adds the given texture to this scene.
  34117. * @param newTexture The texture to add
  34118. */
  34119. addTexture(newTexture: BaseTexture): void;
  34120. /**
  34121. * Switch active camera
  34122. * @param newCamera defines the new active camera
  34123. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34124. */
  34125. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34126. /**
  34127. * sets the active camera of the scene using its ID
  34128. * @param id defines the camera's ID
  34129. * @return the new active camera or null if none found.
  34130. */
  34131. setActiveCameraByID(id: string): Nullable<Camera>;
  34132. /**
  34133. * sets the active camera of the scene using its name
  34134. * @param name defines the camera's name
  34135. * @returns the new active camera or null if none found.
  34136. */
  34137. setActiveCameraByName(name: string): Nullable<Camera>;
  34138. /**
  34139. * get an animation group using its name
  34140. * @param name defines the material's name
  34141. * @return the animation group or null if none found.
  34142. */
  34143. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34144. /**
  34145. * Get a material using its unique id
  34146. * @param uniqueId defines the material's unique id
  34147. * @return the material or null if none found.
  34148. */
  34149. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34150. /**
  34151. * get a material using its id
  34152. * @param id defines the material's ID
  34153. * @return the material or null if none found.
  34154. */
  34155. getMaterialByID(id: string): Nullable<Material>;
  34156. /**
  34157. * Gets a the last added material using a given id
  34158. * @param id defines the material's ID
  34159. * @return the last material with the given id or null if none found.
  34160. */
  34161. getLastMaterialByID(id: string): Nullable<Material>;
  34162. /**
  34163. * Gets a material using its name
  34164. * @param name defines the material's name
  34165. * @return the material or null if none found.
  34166. */
  34167. getMaterialByName(name: string): Nullable<Material>;
  34168. /**
  34169. * Get a texture using its unique id
  34170. * @param uniqueId defines the texture's unique id
  34171. * @return the texture or null if none found.
  34172. */
  34173. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34174. /**
  34175. * Gets a camera using its id
  34176. * @param id defines the id to look for
  34177. * @returns the camera or null if not found
  34178. */
  34179. getCameraByID(id: string): Nullable<Camera>;
  34180. /**
  34181. * Gets a camera using its unique id
  34182. * @param uniqueId defines the unique id to look for
  34183. * @returns the camera or null if not found
  34184. */
  34185. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34186. /**
  34187. * Gets a camera using its name
  34188. * @param name defines the camera's name
  34189. * @return the camera or null if none found.
  34190. */
  34191. getCameraByName(name: string): Nullable<Camera>;
  34192. /**
  34193. * Gets a bone using its id
  34194. * @param id defines the bone's id
  34195. * @return the bone or null if not found
  34196. */
  34197. getBoneByID(id: string): Nullable<Bone>;
  34198. /**
  34199. * Gets a bone using its id
  34200. * @param name defines the bone's name
  34201. * @return the bone or null if not found
  34202. */
  34203. getBoneByName(name: string): Nullable<Bone>;
  34204. /**
  34205. * Gets a light node using its name
  34206. * @param name defines the the light's name
  34207. * @return the light or null if none found.
  34208. */
  34209. getLightByName(name: string): Nullable<Light>;
  34210. /**
  34211. * Gets a light node using its id
  34212. * @param id defines the light's id
  34213. * @return the light or null if none found.
  34214. */
  34215. getLightByID(id: string): Nullable<Light>;
  34216. /**
  34217. * Gets a light node using its scene-generated unique ID
  34218. * @param uniqueId defines the light's unique id
  34219. * @return the light or null if none found.
  34220. */
  34221. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34222. /**
  34223. * Gets a particle system by id
  34224. * @param id defines the particle system id
  34225. * @return the corresponding system or null if none found
  34226. */
  34227. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34228. /**
  34229. * Gets a geometry using its ID
  34230. * @param id defines the geometry's id
  34231. * @return the geometry or null if none found.
  34232. */
  34233. getGeometryByID(id: string): Nullable<Geometry>;
  34234. private _getGeometryByUniqueID;
  34235. /**
  34236. * Add a new geometry to this scene
  34237. * @param geometry defines the geometry to be added to the scene.
  34238. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34239. * @return a boolean defining if the geometry was added or not
  34240. */
  34241. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34242. /**
  34243. * Removes an existing geometry
  34244. * @param geometry defines the geometry to be removed from the scene
  34245. * @return a boolean defining if the geometry was removed or not
  34246. */
  34247. removeGeometry(geometry: Geometry): boolean;
  34248. /**
  34249. * Gets the list of geometries attached to the scene
  34250. * @returns an array of Geometry
  34251. */
  34252. getGeometries(): Geometry[];
  34253. /**
  34254. * Gets the first added mesh found of a given ID
  34255. * @param id defines the id to search for
  34256. * @return the mesh found or null if not found at all
  34257. */
  34258. getMeshByID(id: string): Nullable<AbstractMesh>;
  34259. /**
  34260. * Gets a list of meshes using their id
  34261. * @param id defines the id to search for
  34262. * @returns a list of meshes
  34263. */
  34264. getMeshesByID(id: string): Array<AbstractMesh>;
  34265. /**
  34266. * Gets the first added transform node found of a given ID
  34267. * @param id defines the id to search for
  34268. * @return the found transform node or null if not found at all.
  34269. */
  34270. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34271. /**
  34272. * Gets a transform node with its auto-generated unique id
  34273. * @param uniqueId efines the unique id to search for
  34274. * @return the found transform node or null if not found at all.
  34275. */
  34276. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34277. /**
  34278. * Gets a list of transform nodes using their id
  34279. * @param id defines the id to search for
  34280. * @returns a list of transform nodes
  34281. */
  34282. getTransformNodesByID(id: string): Array<TransformNode>;
  34283. /**
  34284. * Gets a mesh with its auto-generated unique id
  34285. * @param uniqueId defines the unique id to search for
  34286. * @return the found mesh or null if not found at all.
  34287. */
  34288. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34289. /**
  34290. * Gets a the last added mesh using a given id
  34291. * @param id defines the id to search for
  34292. * @return the found mesh or null if not found at all.
  34293. */
  34294. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34295. /**
  34296. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34297. * @param id defines the id to search for
  34298. * @return the found node or null if not found at all
  34299. */
  34300. getLastEntryByID(id: string): Nullable<Node>;
  34301. /**
  34302. * Gets a node (Mesh, Camera, Light) using a given id
  34303. * @param id defines the id to search for
  34304. * @return the found node or null if not found at all
  34305. */
  34306. getNodeByID(id: string): Nullable<Node>;
  34307. /**
  34308. * Gets a node (Mesh, Camera, Light) using a given name
  34309. * @param name defines the name to search for
  34310. * @return the found node or null if not found at all.
  34311. */
  34312. getNodeByName(name: string): Nullable<Node>;
  34313. /**
  34314. * Gets a mesh using a given name
  34315. * @param name defines the name to search for
  34316. * @return the found mesh or null if not found at all.
  34317. */
  34318. getMeshByName(name: string): Nullable<AbstractMesh>;
  34319. /**
  34320. * Gets a transform node using a given name
  34321. * @param name defines the name to search for
  34322. * @return the found transform node or null if not found at all.
  34323. */
  34324. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34325. /**
  34326. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34327. * @param id defines the id to search for
  34328. * @return the found skeleton or null if not found at all.
  34329. */
  34330. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34331. /**
  34332. * Gets a skeleton using a given auto generated unique id
  34333. * @param uniqueId defines the unique id to search for
  34334. * @return the found skeleton or null if not found at all.
  34335. */
  34336. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34337. /**
  34338. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34339. * @param id defines the id to search for
  34340. * @return the found skeleton or null if not found at all.
  34341. */
  34342. getSkeletonById(id: string): Nullable<Skeleton>;
  34343. /**
  34344. * Gets a skeleton using a given name
  34345. * @param name defines the name to search for
  34346. * @return the found skeleton or null if not found at all.
  34347. */
  34348. getSkeletonByName(name: string): Nullable<Skeleton>;
  34349. /**
  34350. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34351. * @param id defines the id to search for
  34352. * @return the found morph target manager or null if not found at all.
  34353. */
  34354. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34355. /**
  34356. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34357. * @param id defines the id to search for
  34358. * @return the found morph target or null if not found at all.
  34359. */
  34360. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34361. /**
  34362. * Gets a boolean indicating if the given mesh is active
  34363. * @param mesh defines the mesh to look for
  34364. * @returns true if the mesh is in the active list
  34365. */
  34366. isActiveMesh(mesh: AbstractMesh): boolean;
  34367. /**
  34368. * Return a unique id as a string which can serve as an identifier for the scene
  34369. */
  34370. readonly uid: string;
  34371. /**
  34372. * Add an externaly attached data from its key.
  34373. * This method call will fail and return false, if such key already exists.
  34374. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34375. * @param key the unique key that identifies the data
  34376. * @param data the data object to associate to the key for this Engine instance
  34377. * @return true if no such key were already present and the data was added successfully, false otherwise
  34378. */
  34379. addExternalData<T>(key: string, data: T): boolean;
  34380. /**
  34381. * Get an externaly attached data from its key
  34382. * @param key the unique key that identifies the data
  34383. * @return the associated data, if present (can be null), or undefined if not present
  34384. */
  34385. getExternalData<T>(key: string): Nullable<T>;
  34386. /**
  34387. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34388. * @param key the unique key that identifies the data
  34389. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34390. * @return the associated data, can be null if the factory returned null.
  34391. */
  34392. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34393. /**
  34394. * Remove an externaly attached data from the Engine instance
  34395. * @param key the unique key that identifies the data
  34396. * @return true if the data was successfully removed, false if it doesn't exist
  34397. */
  34398. removeExternalData(key: string): boolean;
  34399. private _evaluateSubMesh;
  34400. /**
  34401. * Clear the processed materials smart array preventing retention point in material dispose.
  34402. */
  34403. freeProcessedMaterials(): void;
  34404. private _preventFreeActiveMeshesAndRenderingGroups;
  34405. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34406. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34407. * when disposing several meshes in a row or a hierarchy of meshes.
  34408. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34409. */
  34410. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34411. /**
  34412. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34413. */
  34414. freeActiveMeshes(): void;
  34415. /**
  34416. * Clear the info related to rendering groups preventing retention points during dispose.
  34417. */
  34418. freeRenderingGroups(): void;
  34419. /** @hidden */
  34420. _isInIntermediateRendering(): boolean;
  34421. /**
  34422. * Lambda returning the list of potentially active meshes.
  34423. */
  34424. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34425. /**
  34426. * Lambda returning the list of potentially active sub meshes.
  34427. */
  34428. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34429. /**
  34430. * Lambda returning the list of potentially intersecting sub meshes.
  34431. */
  34432. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34433. /**
  34434. * Lambda returning the list of potentially colliding sub meshes.
  34435. */
  34436. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34437. private _activeMeshesFrozen;
  34438. /**
  34439. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34440. * @returns the current scene
  34441. */
  34442. freezeActiveMeshes(): Scene;
  34443. /**
  34444. * Use this function to restart evaluating active meshes on every frame
  34445. * @returns the current scene
  34446. */
  34447. unfreezeActiveMeshes(): Scene;
  34448. private _evaluateActiveMeshes;
  34449. private _activeMesh;
  34450. /**
  34451. * Update the transform matrix to update from the current active camera
  34452. * @param force defines a boolean used to force the update even if cache is up to date
  34453. */
  34454. updateTransformMatrix(force?: boolean): void;
  34455. private _bindFrameBuffer;
  34456. /** @hidden */
  34457. _allowPostProcessClearColor: boolean;
  34458. /** @hidden */
  34459. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34460. private _processSubCameras;
  34461. private _checkIntersections;
  34462. /** @hidden */
  34463. _advancePhysicsEngineStep(step: number): void;
  34464. /**
  34465. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34466. */
  34467. getDeterministicFrameTime: () => number;
  34468. /** @hidden */
  34469. _animate(): void;
  34470. /** Execute all animations (for a frame) */
  34471. animate(): void;
  34472. /**
  34473. * Render the scene
  34474. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34475. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34476. */
  34477. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34478. /**
  34479. * Freeze all materials
  34480. * A frozen material will not be updatable but should be faster to render
  34481. */
  34482. freezeMaterials(): void;
  34483. /**
  34484. * Unfreeze all materials
  34485. * A frozen material will not be updatable but should be faster to render
  34486. */
  34487. unfreezeMaterials(): void;
  34488. /**
  34489. * Releases all held ressources
  34490. */
  34491. dispose(): void;
  34492. /**
  34493. * Gets if the scene is already disposed
  34494. */
  34495. readonly isDisposed: boolean;
  34496. /**
  34497. * Call this function to reduce memory footprint of the scene.
  34498. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34499. */
  34500. clearCachedVertexData(): void;
  34501. /**
  34502. * This function will remove the local cached buffer data from texture.
  34503. * It will save memory but will prevent the texture from being rebuilt
  34504. */
  34505. cleanCachedTextureBuffer(): void;
  34506. /**
  34507. * Get the world extend vectors with an optional filter
  34508. *
  34509. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34510. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34511. */
  34512. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34513. min: Vector3;
  34514. max: Vector3;
  34515. };
  34516. /**
  34517. * Creates a ray that can be used to pick in the scene
  34518. * @param x defines the x coordinate of the origin (on-screen)
  34519. * @param y defines the y coordinate of the origin (on-screen)
  34520. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34521. * @param camera defines the camera to use for the picking
  34522. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34523. * @returns a Ray
  34524. */
  34525. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34526. /**
  34527. * Creates a ray that can be used to pick in the scene
  34528. * @param x defines the x coordinate of the origin (on-screen)
  34529. * @param y defines the y coordinate of the origin (on-screen)
  34530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34531. * @param result defines the ray where to store the picking ray
  34532. * @param camera defines the camera to use for the picking
  34533. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34534. * @returns the current scene
  34535. */
  34536. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34537. /**
  34538. * Creates a ray that can be used to pick in the scene
  34539. * @param x defines the x coordinate of the origin (on-screen)
  34540. * @param y defines the y coordinate of the origin (on-screen)
  34541. * @param camera defines the camera to use for the picking
  34542. * @returns a Ray
  34543. */
  34544. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34545. /**
  34546. * Creates a ray that can be used to pick in the scene
  34547. * @param x defines the x coordinate of the origin (on-screen)
  34548. * @param y defines the y coordinate of the origin (on-screen)
  34549. * @param result defines the ray where to store the picking ray
  34550. * @param camera defines the camera to use for the picking
  34551. * @returns the current scene
  34552. */
  34553. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34554. /** Launch a ray to try to pick a mesh in the scene
  34555. * @param x position on screen
  34556. * @param y position on screen
  34557. * @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
  34558. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34559. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34560. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34561. * @returns a PickingInfo
  34562. */
  34563. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34564. /** Use the given ray to pick a mesh in the scene
  34565. * @param ray The ray to use to pick meshes
  34566. * @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
  34567. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34568. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34569. * @returns a PickingInfo
  34570. */
  34571. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34572. /**
  34573. * Launch a ray to try to pick a mesh in the scene
  34574. * @param x X position on screen
  34575. * @param y Y position on screen
  34576. * @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
  34577. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34578. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34579. * @returns an array of PickingInfo
  34580. */
  34581. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34582. /**
  34583. * Launch a ray to try to pick a mesh in the scene
  34584. * @param ray Ray to use
  34585. * @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
  34586. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34587. * @returns an array of PickingInfo
  34588. */
  34589. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34590. /**
  34591. * Force the value of meshUnderPointer
  34592. * @param mesh defines the mesh to use
  34593. */
  34594. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34595. /**
  34596. * Gets the mesh under the pointer
  34597. * @returns a Mesh or null if no mesh is under the pointer
  34598. */
  34599. getPointerOverMesh(): Nullable<AbstractMesh>;
  34600. /** @hidden */
  34601. _rebuildGeometries(): void;
  34602. /** @hidden */
  34603. _rebuildTextures(): void;
  34604. private _getByTags;
  34605. /**
  34606. * Get a list of meshes by tags
  34607. * @param tagsQuery defines the tags query to use
  34608. * @param forEach defines a predicate used to filter results
  34609. * @returns an array of Mesh
  34610. */
  34611. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34612. /**
  34613. * Get a list of cameras by tags
  34614. * @param tagsQuery defines the tags query to use
  34615. * @param forEach defines a predicate used to filter results
  34616. * @returns an array of Camera
  34617. */
  34618. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34619. /**
  34620. * Get a list of lights by tags
  34621. * @param tagsQuery defines the tags query to use
  34622. * @param forEach defines a predicate used to filter results
  34623. * @returns an array of Light
  34624. */
  34625. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34626. /**
  34627. * Get a list of materials by tags
  34628. * @param tagsQuery defines the tags query to use
  34629. * @param forEach defines a predicate used to filter results
  34630. * @returns an array of Material
  34631. */
  34632. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34633. /**
  34634. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34635. * This allowed control for front to back rendering or reversly depending of the special needs.
  34636. *
  34637. * @param renderingGroupId The rendering group id corresponding to its index
  34638. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34639. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34640. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34641. */
  34642. 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;
  34643. /**
  34644. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34645. *
  34646. * @param renderingGroupId The rendering group id corresponding to its index
  34647. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34648. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34649. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34650. */
  34651. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34652. /**
  34653. * Gets the current auto clear configuration for one rendering group of the rendering
  34654. * manager.
  34655. * @param index the rendering group index to get the information for
  34656. * @returns The auto clear setup for the requested rendering group
  34657. */
  34658. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34659. private _blockMaterialDirtyMechanism;
  34660. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34661. blockMaterialDirtyMechanism: boolean;
  34662. /**
  34663. * Will flag all materials as dirty to trigger new shader compilation
  34664. * @param flag defines the flag used to specify which material part must be marked as dirty
  34665. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34666. */
  34667. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34668. /** @hidden */
  34669. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34670. /** @hidden */
  34671. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34672. }
  34673. }
  34674. declare module BABYLON {
  34675. /**
  34676. * Set of assets to keep when moving a scene into an asset container.
  34677. */
  34678. export class KeepAssets extends AbstractScene {
  34679. }
  34680. /**
  34681. * Container with a set of assets that can be added or removed from a scene.
  34682. */
  34683. export class AssetContainer extends AbstractScene {
  34684. /**
  34685. * The scene the AssetContainer belongs to.
  34686. */
  34687. scene: Scene;
  34688. /**
  34689. * Instantiates an AssetContainer.
  34690. * @param scene The scene the AssetContainer belongs to.
  34691. */
  34692. constructor(scene: Scene);
  34693. /**
  34694. * Adds all the assets from the container to the scene.
  34695. */
  34696. addAllToScene(): void;
  34697. /**
  34698. * Removes all the assets in the container from the scene
  34699. */
  34700. removeAllFromScene(): void;
  34701. /**
  34702. * Disposes all the assets in the container
  34703. */
  34704. dispose(): void;
  34705. private _moveAssets;
  34706. /**
  34707. * Removes all the assets contained in the scene and adds them to the container.
  34708. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34709. */
  34710. moveAllFromScene(keepAssets?: KeepAssets): void;
  34711. /**
  34712. * 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.
  34713. * @returns the root mesh
  34714. */
  34715. createRootMesh(): Mesh;
  34716. }
  34717. }
  34718. declare module BABYLON {
  34719. /**
  34720. * Defines how the parser contract is defined.
  34721. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34722. */
  34723. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34724. /**
  34725. * Defines how the individual parser contract is defined.
  34726. * These parser can parse an individual asset
  34727. */
  34728. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34729. /**
  34730. * Base class of the scene acting as a container for the different elements composing a scene.
  34731. * This class is dynamically extended by the different components of the scene increasing
  34732. * flexibility and reducing coupling
  34733. */
  34734. export abstract class AbstractScene {
  34735. /**
  34736. * Stores the list of available parsers in the application.
  34737. */
  34738. private static _BabylonFileParsers;
  34739. /**
  34740. * Stores the list of available individual parsers in the application.
  34741. */
  34742. private static _IndividualBabylonFileParsers;
  34743. /**
  34744. * Adds a parser in the list of available ones
  34745. * @param name Defines the name of the parser
  34746. * @param parser Defines the parser to add
  34747. */
  34748. static AddParser(name: string, parser: BabylonFileParser): void;
  34749. /**
  34750. * Gets a general parser from the list of avaialble ones
  34751. * @param name Defines the name of the parser
  34752. * @returns the requested parser or null
  34753. */
  34754. static GetParser(name: string): Nullable<BabylonFileParser>;
  34755. /**
  34756. * Adds n individual parser in the list of available ones
  34757. * @param name Defines the name of the parser
  34758. * @param parser Defines the parser to add
  34759. */
  34760. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34761. /**
  34762. * Gets an individual parser from the list of avaialble ones
  34763. * @param name Defines the name of the parser
  34764. * @returns the requested parser or null
  34765. */
  34766. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34767. /**
  34768. * Parser json data and populate both a scene and its associated container object
  34769. * @param jsonData Defines the data to parse
  34770. * @param scene Defines the scene to parse the data for
  34771. * @param container Defines the container attached to the parsing sequence
  34772. * @param rootUrl Defines the root url of the data
  34773. */
  34774. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34775. /**
  34776. * Gets the list of root nodes (ie. nodes with no parent)
  34777. */
  34778. rootNodes: Node[];
  34779. /** All of the cameras added to this scene
  34780. * @see http://doc.babylonjs.com/babylon101/cameras
  34781. */
  34782. cameras: Camera[];
  34783. /**
  34784. * All of the lights added to this scene
  34785. * @see http://doc.babylonjs.com/babylon101/lights
  34786. */
  34787. lights: Light[];
  34788. /**
  34789. * All of the (abstract) meshes added to this scene
  34790. */
  34791. meshes: AbstractMesh[];
  34792. /**
  34793. * The list of skeletons added to the scene
  34794. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34795. */
  34796. skeletons: Skeleton[];
  34797. /**
  34798. * All of the particle systems added to this scene
  34799. * @see http://doc.babylonjs.com/babylon101/particles
  34800. */
  34801. particleSystems: IParticleSystem[];
  34802. /**
  34803. * Gets a list of Animations associated with the scene
  34804. */
  34805. animations: Animation[];
  34806. /**
  34807. * All of the animation groups added to this scene
  34808. * @see http://doc.babylonjs.com/how_to/group
  34809. */
  34810. animationGroups: AnimationGroup[];
  34811. /**
  34812. * All of the multi-materials added to this scene
  34813. * @see http://doc.babylonjs.com/how_to/multi_materials
  34814. */
  34815. multiMaterials: MultiMaterial[];
  34816. /**
  34817. * All of the materials added to this scene
  34818. * In the context of a Scene, it is not supposed to be modified manually.
  34819. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34820. * Note also that the order of the Material wihin the array is not significant and might change.
  34821. * @see http://doc.babylonjs.com/babylon101/materials
  34822. */
  34823. materials: Material[];
  34824. /**
  34825. * The list of morph target managers added to the scene
  34826. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34827. */
  34828. morphTargetManagers: MorphTargetManager[];
  34829. /**
  34830. * The list of geometries used in the scene.
  34831. */
  34832. geometries: Geometry[];
  34833. /**
  34834. * All of the tranform nodes added to this scene
  34835. * In the context of a Scene, it is not supposed to be modified manually.
  34836. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34837. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34838. * @see http://doc.babylonjs.com/how_to/transformnode
  34839. */
  34840. transformNodes: TransformNode[];
  34841. /**
  34842. * ActionManagers available on the scene.
  34843. */
  34844. actionManagers: AbstractActionManager[];
  34845. /**
  34846. * Textures to keep.
  34847. */
  34848. textures: BaseTexture[];
  34849. /**
  34850. * Environment texture for the scene
  34851. */
  34852. environmentTexture: Nullable<BaseTexture>;
  34853. }
  34854. }
  34855. declare module BABYLON {
  34856. /**
  34857. * Interface used to define options for Sound class
  34858. */
  34859. export interface ISoundOptions {
  34860. /**
  34861. * Does the sound autoplay once loaded.
  34862. */
  34863. autoplay?: boolean;
  34864. /**
  34865. * Does the sound loop after it finishes playing once.
  34866. */
  34867. loop?: boolean;
  34868. /**
  34869. * Sound's volume
  34870. */
  34871. volume?: number;
  34872. /**
  34873. * Is it a spatial sound?
  34874. */
  34875. spatialSound?: boolean;
  34876. /**
  34877. * Maximum distance to hear that sound
  34878. */
  34879. maxDistance?: number;
  34880. /**
  34881. * Uses user defined attenuation function
  34882. */
  34883. useCustomAttenuation?: boolean;
  34884. /**
  34885. * Define the roll off factor of spatial sounds.
  34886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34887. */
  34888. rolloffFactor?: number;
  34889. /**
  34890. * Define the reference distance the sound should be heard perfectly.
  34891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34892. */
  34893. refDistance?: number;
  34894. /**
  34895. * Define the distance attenuation model the sound will follow.
  34896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34897. */
  34898. distanceModel?: string;
  34899. /**
  34900. * Defines the playback speed (1 by default)
  34901. */
  34902. playbackRate?: number;
  34903. /**
  34904. * Defines if the sound is from a streaming source
  34905. */
  34906. streaming?: boolean;
  34907. /**
  34908. * Defines an optional length (in seconds) inside the sound file
  34909. */
  34910. length?: number;
  34911. /**
  34912. * Defines an optional offset (in seconds) inside the sound file
  34913. */
  34914. offset?: number;
  34915. /**
  34916. * If true, URLs will not be required to state the audio file codec to use.
  34917. */
  34918. skipCodecCheck?: boolean;
  34919. }
  34920. /**
  34921. * Defines a sound that can be played in the application.
  34922. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34924. */
  34925. export class Sound {
  34926. /**
  34927. * The name of the sound in the scene.
  34928. */
  34929. name: string;
  34930. /**
  34931. * Does the sound autoplay once loaded.
  34932. */
  34933. autoplay: boolean;
  34934. /**
  34935. * Does the sound loop after it finishes playing once.
  34936. */
  34937. loop: boolean;
  34938. /**
  34939. * Does the sound use a custom attenuation curve to simulate the falloff
  34940. * happening when the source gets further away from the camera.
  34941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34942. */
  34943. useCustomAttenuation: boolean;
  34944. /**
  34945. * The sound track id this sound belongs to.
  34946. */
  34947. soundTrackId: number;
  34948. /**
  34949. * Is this sound currently played.
  34950. */
  34951. isPlaying: boolean;
  34952. /**
  34953. * Is this sound currently paused.
  34954. */
  34955. isPaused: boolean;
  34956. /**
  34957. * Does this sound enables spatial sound.
  34958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34959. */
  34960. spatialSound: boolean;
  34961. /**
  34962. * Define the reference distance the sound should be heard perfectly.
  34963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34964. */
  34965. refDistance: number;
  34966. /**
  34967. * Define the roll off factor of spatial sounds.
  34968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34969. */
  34970. rolloffFactor: number;
  34971. /**
  34972. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34974. */
  34975. maxDistance: number;
  34976. /**
  34977. * Define the distance attenuation model the sound will follow.
  34978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34979. */
  34980. distanceModel: string;
  34981. /**
  34982. * @hidden
  34983. * Back Compat
  34984. **/
  34985. onended: () => any;
  34986. /**
  34987. * Observable event when the current playing sound finishes.
  34988. */
  34989. onEndedObservable: Observable<Sound>;
  34990. private _panningModel;
  34991. private _playbackRate;
  34992. private _streaming;
  34993. private _startTime;
  34994. private _startOffset;
  34995. private _position;
  34996. /** @hidden */
  34997. _positionInEmitterSpace: boolean;
  34998. private _localDirection;
  34999. private _volume;
  35000. private _isReadyToPlay;
  35001. private _isDirectional;
  35002. private _readyToPlayCallback;
  35003. private _audioBuffer;
  35004. private _soundSource;
  35005. private _streamingSource;
  35006. private _soundPanner;
  35007. private _soundGain;
  35008. private _inputAudioNode;
  35009. private _outputAudioNode;
  35010. private _coneInnerAngle;
  35011. private _coneOuterAngle;
  35012. private _coneOuterGain;
  35013. private _scene;
  35014. private _connectedTransformNode;
  35015. private _customAttenuationFunction;
  35016. private _registerFunc;
  35017. private _isOutputConnected;
  35018. private _htmlAudioElement;
  35019. private _urlType;
  35020. private _length?;
  35021. private _offset?;
  35022. /** @hidden */
  35023. static _SceneComponentInitialization: (scene: Scene) => void;
  35024. /**
  35025. * Create a sound and attach it to a scene
  35026. * @param name Name of your sound
  35027. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35028. * @param scene defines the scene the sound belongs to
  35029. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35030. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35031. */
  35032. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35033. /**
  35034. * Release the sound and its associated resources
  35035. */
  35036. dispose(): void;
  35037. /**
  35038. * Gets if the sounds is ready to be played or not.
  35039. * @returns true if ready, otherwise false
  35040. */
  35041. isReady(): boolean;
  35042. private _soundLoaded;
  35043. /**
  35044. * Sets the data of the sound from an audiobuffer
  35045. * @param audioBuffer The audioBuffer containing the data
  35046. */
  35047. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35048. /**
  35049. * Updates the current sounds options such as maxdistance, loop...
  35050. * @param options A JSON object containing values named as the object properties
  35051. */
  35052. updateOptions(options: ISoundOptions): void;
  35053. private _createSpatialParameters;
  35054. private _updateSpatialParameters;
  35055. /**
  35056. * Switch the panning model to HRTF:
  35057. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35059. */
  35060. switchPanningModelToHRTF(): void;
  35061. /**
  35062. * Switch the panning model to Equal Power:
  35063. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35065. */
  35066. switchPanningModelToEqualPower(): void;
  35067. private _switchPanningModel;
  35068. /**
  35069. * Connect this sound to a sound track audio node like gain...
  35070. * @param soundTrackAudioNode the sound track audio node to connect to
  35071. */
  35072. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35073. /**
  35074. * Transform this sound into a directional source
  35075. * @param coneInnerAngle Size of the inner cone in degree
  35076. * @param coneOuterAngle Size of the outer cone in degree
  35077. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35078. */
  35079. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35080. /**
  35081. * Gets or sets the inner angle for the directional cone.
  35082. */
  35083. /**
  35084. * Gets or sets the inner angle for the directional cone.
  35085. */
  35086. directionalConeInnerAngle: number;
  35087. /**
  35088. * Gets or sets the outer angle for the directional cone.
  35089. */
  35090. /**
  35091. * Gets or sets the outer angle for the directional cone.
  35092. */
  35093. directionalConeOuterAngle: number;
  35094. /**
  35095. * Sets the position of the emitter if spatial sound is enabled
  35096. * @param newPosition Defines the new posisiton
  35097. */
  35098. setPosition(newPosition: Vector3): void;
  35099. /**
  35100. * Sets the local direction of the emitter if spatial sound is enabled
  35101. * @param newLocalDirection Defines the new local direction
  35102. */
  35103. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35104. private _updateDirection;
  35105. /** @hidden */
  35106. updateDistanceFromListener(): void;
  35107. /**
  35108. * Sets a new custom attenuation function for the sound.
  35109. * @param callback Defines the function used for the attenuation
  35110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35111. */
  35112. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35113. /**
  35114. * Play the sound
  35115. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35116. * @param offset (optional) Start the sound at a specific time in seconds
  35117. * @param length (optional) Sound duration (in seconds)
  35118. */
  35119. play(time?: number, offset?: number, length?: number): void;
  35120. private _onended;
  35121. /**
  35122. * Stop the sound
  35123. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35124. */
  35125. stop(time?: number): void;
  35126. /**
  35127. * Put the sound in pause
  35128. */
  35129. pause(): void;
  35130. /**
  35131. * Sets a dedicated volume for this sounds
  35132. * @param newVolume Define the new volume of the sound
  35133. * @param time Define time for gradual change to new volume
  35134. */
  35135. setVolume(newVolume: number, time?: number): void;
  35136. /**
  35137. * Set the sound play back rate
  35138. * @param newPlaybackRate Define the playback rate the sound should be played at
  35139. */
  35140. setPlaybackRate(newPlaybackRate: number): void;
  35141. /**
  35142. * Gets the volume of the sound.
  35143. * @returns the volume of the sound
  35144. */
  35145. getVolume(): number;
  35146. /**
  35147. * Attach the sound to a dedicated mesh
  35148. * @param transformNode The transform node to connect the sound with
  35149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35150. */
  35151. attachToMesh(transformNode: TransformNode): void;
  35152. /**
  35153. * Detach the sound from the previously attached mesh
  35154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35155. */
  35156. detachFromMesh(): void;
  35157. private _onRegisterAfterWorldMatrixUpdate;
  35158. /**
  35159. * Clone the current sound in the scene.
  35160. * @returns the new sound clone
  35161. */
  35162. clone(): Nullable<Sound>;
  35163. /**
  35164. * Gets the current underlying audio buffer containing the data
  35165. * @returns the audio buffer
  35166. */
  35167. getAudioBuffer(): Nullable<AudioBuffer>;
  35168. /**
  35169. * Serializes the Sound in a JSON representation
  35170. * @returns the JSON representation of the sound
  35171. */
  35172. serialize(): any;
  35173. /**
  35174. * Parse a JSON representation of a sound to innstantiate in a given scene
  35175. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35176. * @param scene Define the scene the new parsed sound should be created in
  35177. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35178. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35179. * @returns the newly parsed sound
  35180. */
  35181. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35182. }
  35183. }
  35184. declare module BABYLON {
  35185. /**
  35186. * This defines an action helpful to play a defined sound on a triggered action.
  35187. */
  35188. export class PlaySoundAction extends Action {
  35189. private _sound;
  35190. /**
  35191. * Instantiate the action
  35192. * @param triggerOptions defines the trigger options
  35193. * @param sound defines the sound to play
  35194. * @param condition defines the trigger related conditions
  35195. */
  35196. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35197. /** @hidden */
  35198. _prepare(): void;
  35199. /**
  35200. * Execute the action and play the sound.
  35201. */
  35202. execute(): void;
  35203. /**
  35204. * Serializes the actions and its related information.
  35205. * @param parent defines the object to serialize in
  35206. * @returns the serialized object
  35207. */
  35208. serialize(parent: any): any;
  35209. }
  35210. /**
  35211. * This defines an action helpful to stop a defined sound on a triggered action.
  35212. */
  35213. export class StopSoundAction extends Action {
  35214. private _sound;
  35215. /**
  35216. * Instantiate the action
  35217. * @param triggerOptions defines the trigger options
  35218. * @param sound defines the sound to stop
  35219. * @param condition defines the trigger related conditions
  35220. */
  35221. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35222. /** @hidden */
  35223. _prepare(): void;
  35224. /**
  35225. * Execute the action and stop the sound.
  35226. */
  35227. execute(): void;
  35228. /**
  35229. * Serializes the actions and its related information.
  35230. * @param parent defines the object to serialize in
  35231. * @returns the serialized object
  35232. */
  35233. serialize(parent: any): any;
  35234. }
  35235. }
  35236. declare module BABYLON {
  35237. /**
  35238. * This defines an action responsible to change the value of a property
  35239. * by interpolating between its current value and the newly set one once triggered.
  35240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35241. */
  35242. export class InterpolateValueAction extends Action {
  35243. /**
  35244. * Defines the path of the property where the value should be interpolated
  35245. */
  35246. propertyPath: string;
  35247. /**
  35248. * Defines the target value at the end of the interpolation.
  35249. */
  35250. value: any;
  35251. /**
  35252. * Defines the time it will take for the property to interpolate to the value.
  35253. */
  35254. duration: number;
  35255. /**
  35256. * Defines if the other scene animations should be stopped when the action has been triggered
  35257. */
  35258. stopOtherAnimations?: boolean;
  35259. /**
  35260. * Defines a callback raised once the interpolation animation has been done.
  35261. */
  35262. onInterpolationDone?: () => void;
  35263. /**
  35264. * Observable triggered once the interpolation animation has been done.
  35265. */
  35266. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35267. private _target;
  35268. private _effectiveTarget;
  35269. private _property;
  35270. /**
  35271. * Instantiate the action
  35272. * @param triggerOptions defines the trigger options
  35273. * @param target defines the object containing the value to interpolate
  35274. * @param propertyPath defines the path to the property in the target object
  35275. * @param value defines the target value at the end of the interpolation
  35276. * @param duration deines the time it will take for the property to interpolate to the value.
  35277. * @param condition defines the trigger related conditions
  35278. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35279. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35280. */
  35281. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35282. /** @hidden */
  35283. _prepare(): void;
  35284. /**
  35285. * Execute the action starts the value interpolation.
  35286. */
  35287. execute(): void;
  35288. /**
  35289. * Serializes the actions and its related information.
  35290. * @param parent defines the object to serialize in
  35291. * @returns the serialized object
  35292. */
  35293. serialize(parent: any): any;
  35294. }
  35295. }
  35296. declare module BABYLON {
  35297. /**
  35298. * Options allowed during the creation of a sound track.
  35299. */
  35300. export interface ISoundTrackOptions {
  35301. /**
  35302. * The volume the sound track should take during creation
  35303. */
  35304. volume?: number;
  35305. /**
  35306. * Define if the sound track is the main sound track of the scene
  35307. */
  35308. mainTrack?: boolean;
  35309. }
  35310. /**
  35311. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35312. * It will be also used in a future release to apply effects on a specific track.
  35313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35314. */
  35315. export class SoundTrack {
  35316. /**
  35317. * The unique identifier of the sound track in the scene.
  35318. */
  35319. id: number;
  35320. /**
  35321. * The list of sounds included in the sound track.
  35322. */
  35323. soundCollection: Array<Sound>;
  35324. private _outputAudioNode;
  35325. private _scene;
  35326. private _isMainTrack;
  35327. private _connectedAnalyser;
  35328. private _options;
  35329. private _isInitialized;
  35330. /**
  35331. * Creates a new sound track.
  35332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35333. * @param scene Define the scene the sound track belongs to
  35334. * @param options
  35335. */
  35336. constructor(scene: Scene, options?: ISoundTrackOptions);
  35337. private _initializeSoundTrackAudioGraph;
  35338. /**
  35339. * Release the sound track and its associated resources
  35340. */
  35341. dispose(): void;
  35342. /**
  35343. * Adds a sound to this sound track
  35344. * @param sound define the cound to add
  35345. * @ignoreNaming
  35346. */
  35347. AddSound(sound: Sound): void;
  35348. /**
  35349. * Removes a sound to this sound track
  35350. * @param sound define the cound to remove
  35351. * @ignoreNaming
  35352. */
  35353. RemoveSound(sound: Sound): void;
  35354. /**
  35355. * Set a global volume for the full sound track.
  35356. * @param newVolume Define the new volume of the sound track
  35357. */
  35358. setVolume(newVolume: number): void;
  35359. /**
  35360. * Switch the panning model to HRTF:
  35361. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35363. */
  35364. switchPanningModelToHRTF(): void;
  35365. /**
  35366. * Switch the panning model to Equal Power:
  35367. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35369. */
  35370. switchPanningModelToEqualPower(): void;
  35371. /**
  35372. * Connect the sound track to an audio analyser allowing some amazing
  35373. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35375. * @param analyser The analyser to connect to the engine
  35376. */
  35377. connectToAnalyser(analyser: Analyser): void;
  35378. }
  35379. }
  35380. declare module BABYLON {
  35381. interface AbstractScene {
  35382. /**
  35383. * The list of sounds used in the scene.
  35384. */
  35385. sounds: Nullable<Array<Sound>>;
  35386. }
  35387. interface Scene {
  35388. /**
  35389. * @hidden
  35390. * Backing field
  35391. */
  35392. _mainSoundTrack: SoundTrack;
  35393. /**
  35394. * The main sound track played by the scene.
  35395. * It cotains your primary collection of sounds.
  35396. */
  35397. mainSoundTrack: SoundTrack;
  35398. /**
  35399. * The list of sound tracks added to the scene
  35400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35401. */
  35402. soundTracks: Nullable<Array<SoundTrack>>;
  35403. /**
  35404. * Gets a sound using a given name
  35405. * @param name defines the name to search for
  35406. * @return the found sound or null if not found at all.
  35407. */
  35408. getSoundByName(name: string): Nullable<Sound>;
  35409. /**
  35410. * Gets or sets if audio support is enabled
  35411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35412. */
  35413. audioEnabled: boolean;
  35414. /**
  35415. * Gets or sets if audio will be output to headphones
  35416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35417. */
  35418. headphone: boolean;
  35419. /**
  35420. * Gets or sets custom audio listener position provider
  35421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35422. */
  35423. audioListenerPositionProvider: Nullable<() => Vector3>;
  35424. }
  35425. /**
  35426. * Defines the sound scene component responsible to manage any sounds
  35427. * in a given scene.
  35428. */
  35429. export class AudioSceneComponent implements ISceneSerializableComponent {
  35430. /**
  35431. * The component name helpfull to identify the component in the list of scene components.
  35432. */
  35433. readonly name: string;
  35434. /**
  35435. * The scene the component belongs to.
  35436. */
  35437. scene: Scene;
  35438. private _audioEnabled;
  35439. /**
  35440. * Gets whether audio is enabled or not.
  35441. * Please use related enable/disable method to switch state.
  35442. */
  35443. readonly audioEnabled: boolean;
  35444. private _headphone;
  35445. /**
  35446. * Gets whether audio is outputing to headphone or not.
  35447. * Please use the according Switch methods to change output.
  35448. */
  35449. readonly headphone: boolean;
  35450. private _audioListenerPositionProvider;
  35451. /**
  35452. * Gets the current audio listener position provider
  35453. */
  35454. /**
  35455. * Sets a custom listener position for all sounds in the scene
  35456. * By default, this is the position of the first active camera
  35457. */
  35458. audioListenerPositionProvider: Nullable<() => Vector3>;
  35459. /**
  35460. * Creates a new instance of the component for the given scene
  35461. * @param scene Defines the scene to register the component in
  35462. */
  35463. constructor(scene: Scene);
  35464. /**
  35465. * Registers the component in a given scene
  35466. */
  35467. register(): void;
  35468. /**
  35469. * Rebuilds the elements related to this component in case of
  35470. * context lost for instance.
  35471. */
  35472. rebuild(): void;
  35473. /**
  35474. * Serializes the component data to the specified json object
  35475. * @param serializationObject The object to serialize to
  35476. */
  35477. serialize(serializationObject: any): void;
  35478. /**
  35479. * Adds all the elements from the container to the scene
  35480. * @param container the container holding the elements
  35481. */
  35482. addFromContainer(container: AbstractScene): void;
  35483. /**
  35484. * Removes all the elements in the container from the scene
  35485. * @param container contains the elements to remove
  35486. * @param dispose if the removed element should be disposed (default: false)
  35487. */
  35488. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35489. /**
  35490. * Disposes the component and the associated ressources.
  35491. */
  35492. dispose(): void;
  35493. /**
  35494. * Disables audio in the associated scene.
  35495. */
  35496. disableAudio(): void;
  35497. /**
  35498. * Enables audio in the associated scene.
  35499. */
  35500. enableAudio(): void;
  35501. /**
  35502. * Switch audio to headphone output.
  35503. */
  35504. switchAudioModeForHeadphones(): void;
  35505. /**
  35506. * Switch audio to normal speakers.
  35507. */
  35508. switchAudioModeForNormalSpeakers(): void;
  35509. private _afterRender;
  35510. }
  35511. }
  35512. declare module BABYLON {
  35513. /**
  35514. * Wraps one or more Sound objects and selects one with random weight for playback.
  35515. */
  35516. export class WeightedSound {
  35517. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35518. loop: boolean;
  35519. private _coneInnerAngle;
  35520. private _coneOuterAngle;
  35521. private _volume;
  35522. /** A Sound is currently playing. */
  35523. isPlaying: boolean;
  35524. /** A Sound is currently paused. */
  35525. isPaused: boolean;
  35526. private _sounds;
  35527. private _weights;
  35528. private _currentIndex?;
  35529. /**
  35530. * Creates a new WeightedSound from the list of sounds given.
  35531. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35532. * @param sounds Array of Sounds that will be selected from.
  35533. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35534. */
  35535. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35536. /**
  35537. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35538. */
  35539. /**
  35540. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35541. */
  35542. directionalConeInnerAngle: number;
  35543. /**
  35544. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35545. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35546. */
  35547. /**
  35548. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35549. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35550. */
  35551. directionalConeOuterAngle: number;
  35552. /**
  35553. * Playback volume.
  35554. */
  35555. /**
  35556. * Playback volume.
  35557. */
  35558. volume: number;
  35559. private _onended;
  35560. /**
  35561. * Suspend playback
  35562. */
  35563. pause(): void;
  35564. /**
  35565. * Stop playback
  35566. */
  35567. stop(): void;
  35568. /**
  35569. * Start playback.
  35570. * @param startOffset Position the clip head at a specific time in seconds.
  35571. */
  35572. play(startOffset?: number): void;
  35573. }
  35574. }
  35575. declare module BABYLON {
  35576. /**
  35577. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35578. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35579. */
  35580. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35581. /**
  35582. * Gets the name of the behavior.
  35583. */
  35584. readonly name: string;
  35585. /**
  35586. * The easing function used by animations
  35587. */
  35588. static EasingFunction: BackEase;
  35589. /**
  35590. * The easing mode used by animations
  35591. */
  35592. static EasingMode: number;
  35593. /**
  35594. * The duration of the animation, in milliseconds
  35595. */
  35596. transitionDuration: number;
  35597. /**
  35598. * Length of the distance animated by the transition when lower radius is reached
  35599. */
  35600. lowerRadiusTransitionRange: number;
  35601. /**
  35602. * Length of the distance animated by the transition when upper radius is reached
  35603. */
  35604. upperRadiusTransitionRange: number;
  35605. private _autoTransitionRange;
  35606. /**
  35607. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35608. */
  35609. /**
  35610. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35611. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35612. */
  35613. autoTransitionRange: boolean;
  35614. private _attachedCamera;
  35615. private _onAfterCheckInputsObserver;
  35616. private _onMeshTargetChangedObserver;
  35617. /**
  35618. * Initializes the behavior.
  35619. */
  35620. init(): void;
  35621. /**
  35622. * Attaches the behavior to its arc rotate camera.
  35623. * @param camera Defines the camera to attach the behavior to
  35624. */
  35625. attach(camera: ArcRotateCamera): void;
  35626. /**
  35627. * Detaches the behavior from its current arc rotate camera.
  35628. */
  35629. detach(): void;
  35630. private _radiusIsAnimating;
  35631. private _radiusBounceTransition;
  35632. private _animatables;
  35633. private _cachedWheelPrecision;
  35634. /**
  35635. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35636. * @param radiusLimit The limit to check against.
  35637. * @return Bool to indicate if at limit.
  35638. */
  35639. private _isRadiusAtLimit;
  35640. /**
  35641. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35642. * @param radiusDelta The delta by which to animate to. Can be negative.
  35643. */
  35644. private _applyBoundRadiusAnimation;
  35645. /**
  35646. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35647. */
  35648. protected _clearAnimationLocks(): void;
  35649. /**
  35650. * Stops and removes all animations that have been applied to the camera
  35651. */
  35652. stopAllAnimations(): void;
  35653. }
  35654. }
  35655. declare module BABYLON {
  35656. /**
  35657. * 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.
  35658. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35659. */
  35660. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35661. /**
  35662. * Gets the name of the behavior.
  35663. */
  35664. readonly name: string;
  35665. private _mode;
  35666. private _radiusScale;
  35667. private _positionScale;
  35668. private _defaultElevation;
  35669. private _elevationReturnTime;
  35670. private _elevationReturnWaitTime;
  35671. private _zoomStopsAnimation;
  35672. private _framingTime;
  35673. /**
  35674. * The easing function used by animations
  35675. */
  35676. static EasingFunction: ExponentialEase;
  35677. /**
  35678. * The easing mode used by animations
  35679. */
  35680. static EasingMode: number;
  35681. /**
  35682. * Sets the current mode used by the behavior
  35683. */
  35684. /**
  35685. * Gets current mode used by the behavior.
  35686. */
  35687. mode: number;
  35688. /**
  35689. * Sets the scale applied to the radius (1 by default)
  35690. */
  35691. /**
  35692. * Gets the scale applied to the radius
  35693. */
  35694. radiusScale: number;
  35695. /**
  35696. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35697. */
  35698. /**
  35699. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35700. */
  35701. positionScale: number;
  35702. /**
  35703. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35704. * behaviour is triggered, in radians.
  35705. */
  35706. /**
  35707. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35708. * behaviour is triggered, in radians.
  35709. */
  35710. defaultElevation: number;
  35711. /**
  35712. * Sets the time (in milliseconds) taken to return to the default beta position.
  35713. * Negative value indicates camera should not return to default.
  35714. */
  35715. /**
  35716. * Gets the time (in milliseconds) taken to return to the default beta position.
  35717. * Negative value indicates camera should not return to default.
  35718. */
  35719. elevationReturnTime: number;
  35720. /**
  35721. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35722. */
  35723. /**
  35724. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35725. */
  35726. elevationReturnWaitTime: number;
  35727. /**
  35728. * Sets the flag that indicates if user zooming should stop animation.
  35729. */
  35730. /**
  35731. * Gets the flag that indicates if user zooming should stop animation.
  35732. */
  35733. zoomStopsAnimation: boolean;
  35734. /**
  35735. * Sets the transition time when framing the mesh, in milliseconds
  35736. */
  35737. /**
  35738. * Gets the transition time when framing the mesh, in milliseconds
  35739. */
  35740. framingTime: number;
  35741. /**
  35742. * Define if the behavior should automatically change the configured
  35743. * camera limits and sensibilities.
  35744. */
  35745. autoCorrectCameraLimitsAndSensibility: boolean;
  35746. private _onPrePointerObservableObserver;
  35747. private _onAfterCheckInputsObserver;
  35748. private _onMeshTargetChangedObserver;
  35749. private _attachedCamera;
  35750. private _isPointerDown;
  35751. private _lastInteractionTime;
  35752. /**
  35753. * Initializes the behavior.
  35754. */
  35755. init(): void;
  35756. /**
  35757. * Attaches the behavior to its arc rotate camera.
  35758. * @param camera Defines the camera to attach the behavior to
  35759. */
  35760. attach(camera: ArcRotateCamera): void;
  35761. /**
  35762. * Detaches the behavior from its current arc rotate camera.
  35763. */
  35764. detach(): void;
  35765. private _animatables;
  35766. private _betaIsAnimating;
  35767. private _betaTransition;
  35768. private _radiusTransition;
  35769. private _vectorTransition;
  35770. /**
  35771. * Targets the given mesh and updates zoom level accordingly.
  35772. * @param mesh The mesh to target.
  35773. * @param radius Optional. If a cached radius position already exists, overrides default.
  35774. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35775. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35776. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35777. */
  35778. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35779. /**
  35780. * Targets the given mesh with its children and updates zoom level accordingly.
  35781. * @param mesh The mesh to target.
  35782. * @param radius Optional. If a cached radius position already exists, overrides default.
  35783. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35786. */
  35787. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35788. /**
  35789. * Targets the given meshes with their children and updates zoom level accordingly.
  35790. * @param meshes The mesh to target.
  35791. * @param radius Optional. If a cached radius position already exists, overrides default.
  35792. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35795. */
  35796. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35797. /**
  35798. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35799. * @param minimumWorld Determines the smaller position of the bounding box extend
  35800. * @param maximumWorld Determines the bigger position of the bounding box extend
  35801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35803. */
  35804. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35805. /**
  35806. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35807. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35808. * frustum width.
  35809. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35810. * to fully enclose the mesh in the viewing frustum.
  35811. */
  35812. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35813. /**
  35814. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35815. * is automatically returned to its default position (expected to be above ground plane).
  35816. */
  35817. private _maintainCameraAboveGround;
  35818. /**
  35819. * Returns the frustum slope based on the canvas ratio and camera FOV
  35820. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35821. */
  35822. private _getFrustumSlope;
  35823. /**
  35824. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35825. */
  35826. private _clearAnimationLocks;
  35827. /**
  35828. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35829. */
  35830. private _applyUserInteraction;
  35831. /**
  35832. * Stops and removes all animations that have been applied to the camera
  35833. */
  35834. stopAllAnimations(): void;
  35835. /**
  35836. * Gets a value indicating if the user is moving the camera
  35837. */
  35838. readonly isUserIsMoving: boolean;
  35839. /**
  35840. * The camera can move all the way towards the mesh.
  35841. */
  35842. static IgnoreBoundsSizeMode: number;
  35843. /**
  35844. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35845. */
  35846. static FitFrustumSidesMode: number;
  35847. }
  35848. }
  35849. declare module BABYLON {
  35850. /**
  35851. * Base class for Camera Pointer Inputs.
  35852. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35853. * for example usage.
  35854. */
  35855. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35856. /**
  35857. * Defines the camera the input is attached to.
  35858. */
  35859. abstract camera: Camera;
  35860. /**
  35861. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35862. */
  35863. protected _altKey: boolean;
  35864. protected _ctrlKey: boolean;
  35865. protected _metaKey: boolean;
  35866. protected _shiftKey: boolean;
  35867. /**
  35868. * Which mouse buttons were pressed at time of last mouse event.
  35869. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35870. */
  35871. protected _buttonsPressed: number;
  35872. /**
  35873. * Defines the buttons associated with the input to handle camera move.
  35874. */
  35875. buttons: number[];
  35876. /**
  35877. * Attach the input controls to a specific dom element to get the input from.
  35878. * @param element Defines the element the controls should be listened from
  35879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35880. */
  35881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35882. /**
  35883. * Detach the current controls from the specified dom element.
  35884. * @param element Defines the element to stop listening the inputs from
  35885. */
  35886. detachControl(element: Nullable<HTMLElement>): void;
  35887. /**
  35888. * Gets the class name of the current input.
  35889. * @returns the class name
  35890. */
  35891. getClassName(): string;
  35892. /**
  35893. * Get the friendly name associated with the input class.
  35894. * @returns the input friendly name
  35895. */
  35896. getSimpleName(): string;
  35897. /**
  35898. * Called on pointer POINTERDOUBLETAP event.
  35899. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35900. */
  35901. protected onDoubleTap(type: string): void;
  35902. /**
  35903. * Called on pointer POINTERMOVE event if only a single touch is active.
  35904. * Override this method to provide functionality.
  35905. */
  35906. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35907. /**
  35908. * Called on pointer POINTERMOVE event if multiple touches are active.
  35909. * Override this method to provide functionality.
  35910. */
  35911. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35912. /**
  35913. * Called on JS contextmenu event.
  35914. * Override this method to provide functionality.
  35915. */
  35916. protected onContextMenu(evt: PointerEvent): void;
  35917. /**
  35918. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35919. * press.
  35920. * Override this method to provide functionality.
  35921. */
  35922. protected onButtonDown(evt: PointerEvent): void;
  35923. /**
  35924. * Called each time a new POINTERUP event occurs. Ie, for each button
  35925. * release.
  35926. * Override this method to provide functionality.
  35927. */
  35928. protected onButtonUp(evt: PointerEvent): void;
  35929. /**
  35930. * Called when window becomes inactive.
  35931. * Override this method to provide functionality.
  35932. */
  35933. protected onLostFocus(): void;
  35934. private _pointerInput;
  35935. private _observer;
  35936. private _onLostFocus;
  35937. private pointA;
  35938. private pointB;
  35939. }
  35940. }
  35941. declare module BABYLON {
  35942. /**
  35943. * Manage the pointers inputs to control an arc rotate camera.
  35944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35945. */
  35946. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35947. /**
  35948. * Defines the camera the input is attached to.
  35949. */
  35950. camera: ArcRotateCamera;
  35951. /**
  35952. * Gets the class name of the current input.
  35953. * @returns the class name
  35954. */
  35955. getClassName(): string;
  35956. /**
  35957. * Defines the buttons associated with the input to handle camera move.
  35958. */
  35959. buttons: number[];
  35960. /**
  35961. * Defines the pointer angular sensibility along the X axis or how fast is
  35962. * the camera rotating.
  35963. */
  35964. angularSensibilityX: number;
  35965. /**
  35966. * Defines the pointer angular sensibility along the Y axis or how fast is
  35967. * the camera rotating.
  35968. */
  35969. angularSensibilityY: number;
  35970. /**
  35971. * Defines the pointer pinch precision or how fast is the camera zooming.
  35972. */
  35973. pinchPrecision: number;
  35974. /**
  35975. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35976. * from 0.
  35977. * It defines the percentage of current camera.radius to use as delta when
  35978. * pinch zoom is used.
  35979. */
  35980. pinchDeltaPercentage: number;
  35981. /**
  35982. * Defines the pointer panning sensibility or how fast is the camera moving.
  35983. */
  35984. panningSensibility: number;
  35985. /**
  35986. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35987. */
  35988. multiTouchPanning: boolean;
  35989. /**
  35990. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35991. * zoom (pinch) through multitouch.
  35992. */
  35993. multiTouchPanAndZoom: boolean;
  35994. /**
  35995. * Revers pinch action direction.
  35996. */
  35997. pinchInwards: boolean;
  35998. private _isPanClick;
  35999. private _twoFingerActivityCount;
  36000. private _isPinching;
  36001. /**
  36002. * Called on pointer POINTERMOVE event if only a single touch is active.
  36003. */
  36004. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36005. /**
  36006. * Called on pointer POINTERDOUBLETAP event.
  36007. */
  36008. protected onDoubleTap(type: string): void;
  36009. /**
  36010. * Called on pointer POINTERMOVE event if multiple touches are active.
  36011. */
  36012. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36013. /**
  36014. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36015. * press.
  36016. */
  36017. protected onButtonDown(evt: PointerEvent): void;
  36018. /**
  36019. * Called each time a new POINTERUP event occurs. Ie, for each button
  36020. * release.
  36021. */
  36022. protected onButtonUp(evt: PointerEvent): void;
  36023. /**
  36024. * Called when window becomes inactive.
  36025. */
  36026. protected onLostFocus(): void;
  36027. }
  36028. }
  36029. declare module BABYLON {
  36030. /**
  36031. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36033. */
  36034. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36035. /**
  36036. * Defines the camera the input is attached to.
  36037. */
  36038. camera: ArcRotateCamera;
  36039. /**
  36040. * Defines the list of key codes associated with the up action (increase alpha)
  36041. */
  36042. keysUp: number[];
  36043. /**
  36044. * Defines the list of key codes associated with the down action (decrease alpha)
  36045. */
  36046. keysDown: number[];
  36047. /**
  36048. * Defines the list of key codes associated with the left action (increase beta)
  36049. */
  36050. keysLeft: number[];
  36051. /**
  36052. * Defines the list of key codes associated with the right action (decrease beta)
  36053. */
  36054. keysRight: number[];
  36055. /**
  36056. * Defines the list of key codes associated with the reset action.
  36057. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36058. */
  36059. keysReset: number[];
  36060. /**
  36061. * Defines the panning sensibility of the inputs.
  36062. * (How fast is the camera paning)
  36063. */
  36064. panningSensibility: number;
  36065. /**
  36066. * Defines the zooming sensibility of the inputs.
  36067. * (How fast is the camera zooming)
  36068. */
  36069. zoomingSensibility: number;
  36070. /**
  36071. * Defines wether maintaining the alt key down switch the movement mode from
  36072. * orientation to zoom.
  36073. */
  36074. useAltToZoom: boolean;
  36075. /**
  36076. * Rotation speed of the camera
  36077. */
  36078. angularSpeed: number;
  36079. private _keys;
  36080. private _ctrlPressed;
  36081. private _altPressed;
  36082. private _onCanvasBlurObserver;
  36083. private _onKeyboardObserver;
  36084. private _engine;
  36085. private _scene;
  36086. /**
  36087. * Attach the input controls to a specific dom element to get the input from.
  36088. * @param element Defines the element the controls should be listened from
  36089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36090. */
  36091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36092. /**
  36093. * Detach the current controls from the specified dom element.
  36094. * @param element Defines the element to stop listening the inputs from
  36095. */
  36096. detachControl(element: Nullable<HTMLElement>): void;
  36097. /**
  36098. * Update the current camera state depending on the inputs that have been used this frame.
  36099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36100. */
  36101. checkInputs(): void;
  36102. /**
  36103. * Gets the class name of the current intput.
  36104. * @returns the class name
  36105. */
  36106. getClassName(): string;
  36107. /**
  36108. * Get the friendly name associated with the input class.
  36109. * @returns the input friendly name
  36110. */
  36111. getSimpleName(): string;
  36112. }
  36113. }
  36114. declare module BABYLON {
  36115. /**
  36116. * Manage the mouse wheel inputs to control an arc rotate camera.
  36117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36118. */
  36119. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36120. /**
  36121. * Defines the camera the input is attached to.
  36122. */
  36123. camera: ArcRotateCamera;
  36124. /**
  36125. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36126. */
  36127. wheelPrecision: number;
  36128. /**
  36129. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36130. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36131. */
  36132. wheelDeltaPercentage: number;
  36133. private _wheel;
  36134. private _observer;
  36135. private computeDeltaFromMouseWheelLegacyEvent;
  36136. /**
  36137. * Attach the input controls to a specific dom element to get the input from.
  36138. * @param element Defines the element the controls should be listened from
  36139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36140. */
  36141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36142. /**
  36143. * Detach the current controls from the specified dom element.
  36144. * @param element Defines the element to stop listening the inputs from
  36145. */
  36146. detachControl(element: Nullable<HTMLElement>): void;
  36147. /**
  36148. * Gets the class name of the current intput.
  36149. * @returns the class name
  36150. */
  36151. getClassName(): string;
  36152. /**
  36153. * Get the friendly name associated with the input class.
  36154. * @returns the input friendly name
  36155. */
  36156. getSimpleName(): string;
  36157. }
  36158. }
  36159. declare module BABYLON {
  36160. /**
  36161. * Default Inputs manager for the ArcRotateCamera.
  36162. * It groups all the default supported inputs for ease of use.
  36163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36164. */
  36165. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36166. /**
  36167. * Instantiates a new ArcRotateCameraInputsManager.
  36168. * @param camera Defines the camera the inputs belong to
  36169. */
  36170. constructor(camera: ArcRotateCamera);
  36171. /**
  36172. * Add mouse wheel input support to the input manager.
  36173. * @returns the current input manager
  36174. */
  36175. addMouseWheel(): ArcRotateCameraInputsManager;
  36176. /**
  36177. * Add pointers input support to the input manager.
  36178. * @returns the current input manager
  36179. */
  36180. addPointers(): ArcRotateCameraInputsManager;
  36181. /**
  36182. * Add keyboard input support to the input manager.
  36183. * @returns the current input manager
  36184. */
  36185. addKeyboard(): ArcRotateCameraInputsManager;
  36186. }
  36187. }
  36188. declare module BABYLON {
  36189. /**
  36190. * This represents an orbital type of camera.
  36191. *
  36192. * 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.
  36193. * 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.
  36194. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36195. */
  36196. export class ArcRotateCamera extends TargetCamera {
  36197. /**
  36198. * Defines the rotation angle of the camera along the longitudinal axis.
  36199. */
  36200. alpha: number;
  36201. /**
  36202. * Defines the rotation angle of the camera along the latitudinal axis.
  36203. */
  36204. beta: number;
  36205. /**
  36206. * Defines the radius of the camera from it s target point.
  36207. */
  36208. radius: number;
  36209. protected _target: Vector3;
  36210. protected _targetHost: Nullable<AbstractMesh>;
  36211. /**
  36212. * Defines the target point of the camera.
  36213. * The camera looks towards it form the radius distance.
  36214. */
  36215. target: Vector3;
  36216. /**
  36217. * Define the current local position of the camera in the scene
  36218. */
  36219. position: Vector3;
  36220. protected _upVector: Vector3;
  36221. protected _upToYMatrix: Matrix;
  36222. protected _YToUpMatrix: Matrix;
  36223. /**
  36224. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36225. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36226. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36227. */
  36228. upVector: Vector3;
  36229. /**
  36230. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36231. */
  36232. setMatUp(): void;
  36233. /**
  36234. * Current inertia value on the longitudinal axis.
  36235. * The bigger this number the longer it will take for the camera to stop.
  36236. */
  36237. inertialAlphaOffset: number;
  36238. /**
  36239. * Current inertia value on the latitudinal axis.
  36240. * The bigger this number the longer it will take for the camera to stop.
  36241. */
  36242. inertialBetaOffset: number;
  36243. /**
  36244. * Current inertia value on the radius axis.
  36245. * The bigger this number the longer it will take for the camera to stop.
  36246. */
  36247. inertialRadiusOffset: number;
  36248. /**
  36249. * Minimum allowed angle on the longitudinal axis.
  36250. * This can help limiting how the Camera is able to move in the scene.
  36251. */
  36252. lowerAlphaLimit: Nullable<number>;
  36253. /**
  36254. * Maximum allowed angle on the longitudinal axis.
  36255. * This can help limiting how the Camera is able to move in the scene.
  36256. */
  36257. upperAlphaLimit: Nullable<number>;
  36258. /**
  36259. * Minimum allowed angle on the latitudinal axis.
  36260. * This can help limiting how the Camera is able to move in the scene.
  36261. */
  36262. lowerBetaLimit: number;
  36263. /**
  36264. * Maximum allowed angle on the latitudinal axis.
  36265. * This can help limiting how the Camera is able to move in the scene.
  36266. */
  36267. upperBetaLimit: number;
  36268. /**
  36269. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36270. * This can help limiting how the Camera is able to move in the scene.
  36271. */
  36272. lowerRadiusLimit: Nullable<number>;
  36273. /**
  36274. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36275. * This can help limiting how the Camera is able to move in the scene.
  36276. */
  36277. upperRadiusLimit: Nullable<number>;
  36278. /**
  36279. * Defines the current inertia value used during panning of the camera along the X axis.
  36280. */
  36281. inertialPanningX: number;
  36282. /**
  36283. * Defines the current inertia value used during panning of the camera along the Y axis.
  36284. */
  36285. inertialPanningY: number;
  36286. /**
  36287. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36288. * Basically if your fingers moves away from more than this distance you will be considered
  36289. * in pinch mode.
  36290. */
  36291. pinchToPanMaxDistance: number;
  36292. /**
  36293. * Defines the maximum distance the camera can pan.
  36294. * This could help keeping the cammera always in your scene.
  36295. */
  36296. panningDistanceLimit: Nullable<number>;
  36297. /**
  36298. * Defines the target of the camera before paning.
  36299. */
  36300. panningOriginTarget: Vector3;
  36301. /**
  36302. * Defines the value of the inertia used during panning.
  36303. * 0 would mean stop inertia and one would mean no decelleration at all.
  36304. */
  36305. panningInertia: number;
  36306. /**
  36307. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36308. */
  36309. angularSensibilityX: number;
  36310. /**
  36311. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36312. */
  36313. angularSensibilityY: number;
  36314. /**
  36315. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36316. */
  36317. pinchPrecision: number;
  36318. /**
  36319. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36320. * It will be used instead of pinchDeltaPrecision if different from 0.
  36321. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36322. */
  36323. pinchDeltaPercentage: number;
  36324. /**
  36325. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36326. */
  36327. panningSensibility: number;
  36328. /**
  36329. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36330. */
  36331. keysUp: number[];
  36332. /**
  36333. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36334. */
  36335. keysDown: number[];
  36336. /**
  36337. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36338. */
  36339. keysLeft: number[];
  36340. /**
  36341. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36342. */
  36343. keysRight: number[];
  36344. /**
  36345. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36346. */
  36347. wheelPrecision: number;
  36348. /**
  36349. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36350. * It will be used instead of pinchDeltaPrecision if different from 0.
  36351. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36352. */
  36353. wheelDeltaPercentage: number;
  36354. /**
  36355. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36356. */
  36357. zoomOnFactor: number;
  36358. /**
  36359. * Defines a screen offset for the camera position.
  36360. */
  36361. targetScreenOffset: Vector2;
  36362. /**
  36363. * Allows the camera to be completely reversed.
  36364. * If false the camera can not arrive upside down.
  36365. */
  36366. allowUpsideDown: boolean;
  36367. /**
  36368. * Define if double tap/click is used to restore the previously saved state of the camera.
  36369. */
  36370. useInputToRestoreState: boolean;
  36371. /** @hidden */
  36372. _viewMatrix: Matrix;
  36373. /** @hidden */
  36374. _useCtrlForPanning: boolean;
  36375. /** @hidden */
  36376. _panningMouseButton: number;
  36377. /**
  36378. * Defines the input associated to the camera.
  36379. */
  36380. inputs: ArcRotateCameraInputsManager;
  36381. /** @hidden */
  36382. _reset: () => void;
  36383. /**
  36384. * Defines the allowed panning axis.
  36385. */
  36386. panningAxis: Vector3;
  36387. protected _localDirection: Vector3;
  36388. protected _transformedDirection: Vector3;
  36389. private _bouncingBehavior;
  36390. /**
  36391. * Gets the bouncing behavior of the camera if it has been enabled.
  36392. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36393. */
  36394. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36395. /**
  36396. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36398. */
  36399. useBouncingBehavior: boolean;
  36400. private _framingBehavior;
  36401. /**
  36402. * Gets the framing behavior of the camera if it has been enabled.
  36403. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36404. */
  36405. readonly framingBehavior: Nullable<FramingBehavior>;
  36406. /**
  36407. * Defines if the framing behavior of the camera is enabled on the camera.
  36408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36409. */
  36410. useFramingBehavior: boolean;
  36411. private _autoRotationBehavior;
  36412. /**
  36413. * Gets the auto rotation behavior of the camera if it has been enabled.
  36414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36415. */
  36416. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36417. /**
  36418. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36420. */
  36421. useAutoRotationBehavior: boolean;
  36422. /**
  36423. * Observable triggered when the mesh target has been changed on the camera.
  36424. */
  36425. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36426. /**
  36427. * Event raised when the camera is colliding with a mesh.
  36428. */
  36429. onCollide: (collidedMesh: AbstractMesh) => void;
  36430. /**
  36431. * Defines whether the camera should check collision with the objects oh the scene.
  36432. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36433. */
  36434. checkCollisions: boolean;
  36435. /**
  36436. * Defines the collision radius of the camera.
  36437. * This simulates a sphere around the camera.
  36438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36439. */
  36440. collisionRadius: Vector3;
  36441. protected _collider: Collider;
  36442. protected _previousPosition: Vector3;
  36443. protected _collisionVelocity: Vector3;
  36444. protected _newPosition: Vector3;
  36445. protected _previousAlpha: number;
  36446. protected _previousBeta: number;
  36447. protected _previousRadius: number;
  36448. protected _collisionTriggered: boolean;
  36449. protected _targetBoundingCenter: Nullable<Vector3>;
  36450. private _computationVector;
  36451. /**
  36452. * Instantiates a new ArcRotateCamera in a given scene
  36453. * @param name Defines the name of the camera
  36454. * @param alpha Defines the camera rotation along the logitudinal axis
  36455. * @param beta Defines the camera rotation along the latitudinal axis
  36456. * @param radius Defines the camera distance from its target
  36457. * @param target Defines the camera target
  36458. * @param scene Defines the scene the camera belongs to
  36459. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36460. */
  36461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36462. /** @hidden */
  36463. _initCache(): void;
  36464. /** @hidden */
  36465. _updateCache(ignoreParentClass?: boolean): void;
  36466. protected _getTargetPosition(): Vector3;
  36467. private _storedAlpha;
  36468. private _storedBeta;
  36469. private _storedRadius;
  36470. private _storedTarget;
  36471. private _storedTargetScreenOffset;
  36472. /**
  36473. * Stores the current state of the camera (alpha, beta, radius and target)
  36474. * @returns the camera itself
  36475. */
  36476. storeState(): Camera;
  36477. /**
  36478. * @hidden
  36479. * Restored camera state. You must call storeState() first
  36480. */
  36481. _restoreStateValues(): boolean;
  36482. /** @hidden */
  36483. _isSynchronizedViewMatrix(): boolean;
  36484. /**
  36485. * Attached controls to the current camera.
  36486. * @param element Defines the element the controls should be listened from
  36487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36488. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36489. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36490. */
  36491. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36492. /**
  36493. * Detach the current controls from the camera.
  36494. * The camera will stop reacting to inputs.
  36495. * @param element Defines the element to stop listening the inputs from
  36496. */
  36497. detachControl(element: HTMLElement): void;
  36498. /** @hidden */
  36499. _checkInputs(): void;
  36500. protected _checkLimits(): void;
  36501. /**
  36502. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36503. */
  36504. rebuildAnglesAndRadius(): void;
  36505. /**
  36506. * Use a position to define the current camera related information like aplha, beta and radius
  36507. * @param position Defines the position to set the camera at
  36508. */
  36509. setPosition(position: Vector3): void;
  36510. /**
  36511. * Defines the target the camera should look at.
  36512. * This will automatically adapt alpha beta and radius to fit within the new target.
  36513. * @param target Defines the new target as a Vector or a mesh
  36514. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36515. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36516. */
  36517. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36518. /** @hidden */
  36519. _getViewMatrix(): Matrix;
  36520. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36521. /**
  36522. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36523. * @param meshes Defines the mesh to zoom on
  36524. * @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)
  36525. */
  36526. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36527. /**
  36528. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36529. * The target will be changed but the radius
  36530. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36531. * @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)
  36532. */
  36533. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36534. min: Vector3;
  36535. max: Vector3;
  36536. distance: number;
  36537. }, doNotUpdateMaxZ?: boolean): void;
  36538. /**
  36539. * @override
  36540. * Override Camera.createRigCamera
  36541. */
  36542. createRigCamera(name: string, cameraIndex: number): Camera;
  36543. /**
  36544. * @hidden
  36545. * @override
  36546. * Override Camera._updateRigCameras
  36547. */
  36548. _updateRigCameras(): void;
  36549. /**
  36550. * Destroy the camera and release the current resources hold by it.
  36551. */
  36552. dispose(): void;
  36553. /**
  36554. * Gets the current object class name.
  36555. * @return the class name
  36556. */
  36557. getClassName(): string;
  36558. }
  36559. }
  36560. declare module BABYLON {
  36561. /**
  36562. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36563. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36564. */
  36565. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36566. /**
  36567. * Gets the name of the behavior.
  36568. */
  36569. readonly name: string;
  36570. private _zoomStopsAnimation;
  36571. private _idleRotationSpeed;
  36572. private _idleRotationWaitTime;
  36573. private _idleRotationSpinupTime;
  36574. /**
  36575. * Sets the flag that indicates if user zooming should stop animation.
  36576. */
  36577. /**
  36578. * Gets the flag that indicates if user zooming should stop animation.
  36579. */
  36580. zoomStopsAnimation: boolean;
  36581. /**
  36582. * Sets the default speed at which the camera rotates around the model.
  36583. */
  36584. /**
  36585. * Gets the default speed at which the camera rotates around the model.
  36586. */
  36587. idleRotationSpeed: number;
  36588. /**
  36589. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36590. */
  36591. /**
  36592. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36593. */
  36594. idleRotationWaitTime: number;
  36595. /**
  36596. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36597. */
  36598. /**
  36599. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36600. */
  36601. idleRotationSpinupTime: number;
  36602. /**
  36603. * Gets a value indicating if the camera is currently rotating because of this behavior
  36604. */
  36605. readonly rotationInProgress: boolean;
  36606. private _onPrePointerObservableObserver;
  36607. private _onAfterCheckInputsObserver;
  36608. private _attachedCamera;
  36609. private _isPointerDown;
  36610. private _lastFrameTime;
  36611. private _lastInteractionTime;
  36612. private _cameraRotationSpeed;
  36613. /**
  36614. * Initializes the behavior.
  36615. */
  36616. init(): void;
  36617. /**
  36618. * Attaches the behavior to its arc rotate camera.
  36619. * @param camera Defines the camera to attach the behavior to
  36620. */
  36621. attach(camera: ArcRotateCamera): void;
  36622. /**
  36623. * Detaches the behavior from its current arc rotate camera.
  36624. */
  36625. detach(): void;
  36626. /**
  36627. * Returns true if user is scrolling.
  36628. * @return true if user is scrolling.
  36629. */
  36630. private _userIsZooming;
  36631. private _lastFrameRadius;
  36632. private _shouldAnimationStopForInteraction;
  36633. /**
  36634. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36635. */
  36636. private _applyUserInteraction;
  36637. private _userIsMoving;
  36638. }
  36639. }
  36640. declare module BABYLON {
  36641. /**
  36642. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36643. */
  36644. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36645. private ui;
  36646. /**
  36647. * The name of the behavior
  36648. */
  36649. name: string;
  36650. /**
  36651. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36652. */
  36653. distanceAwayFromFace: number;
  36654. /**
  36655. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36656. */
  36657. distanceAwayFromBottomOfFace: number;
  36658. private _faceVectors;
  36659. private _target;
  36660. private _scene;
  36661. private _onRenderObserver;
  36662. private _tmpMatrix;
  36663. private _tmpVector;
  36664. /**
  36665. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36666. * @param ui The transform node that should be attched to the mesh
  36667. */
  36668. constructor(ui: TransformNode);
  36669. /**
  36670. * Initializes the behavior
  36671. */
  36672. init(): void;
  36673. private _closestFace;
  36674. private _zeroVector;
  36675. private _lookAtTmpMatrix;
  36676. private _lookAtToRef;
  36677. /**
  36678. * Attaches the AttachToBoxBehavior to the passed in mesh
  36679. * @param target The mesh that the specified node will be attached to
  36680. */
  36681. attach(target: Mesh): void;
  36682. /**
  36683. * Detaches the behavior from the mesh
  36684. */
  36685. detach(): void;
  36686. }
  36687. }
  36688. declare module BABYLON {
  36689. /**
  36690. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36691. */
  36692. export class FadeInOutBehavior implements Behavior<Mesh> {
  36693. /**
  36694. * Time in milliseconds to delay before fading in (Default: 0)
  36695. */
  36696. delay: number;
  36697. /**
  36698. * Time in milliseconds for the mesh to fade in (Default: 300)
  36699. */
  36700. fadeInTime: number;
  36701. private _millisecondsPerFrame;
  36702. private _hovered;
  36703. private _hoverValue;
  36704. private _ownerNode;
  36705. /**
  36706. * Instatiates the FadeInOutBehavior
  36707. */
  36708. constructor();
  36709. /**
  36710. * The name of the behavior
  36711. */
  36712. readonly name: string;
  36713. /**
  36714. * Initializes the behavior
  36715. */
  36716. init(): void;
  36717. /**
  36718. * Attaches the fade behavior on the passed in mesh
  36719. * @param ownerNode The mesh that will be faded in/out once attached
  36720. */
  36721. attach(ownerNode: Mesh): void;
  36722. /**
  36723. * Detaches the behavior from the mesh
  36724. */
  36725. detach(): void;
  36726. /**
  36727. * Triggers the mesh to begin fading in or out
  36728. * @param value if the object should fade in or out (true to fade in)
  36729. */
  36730. fadeIn(value: boolean): void;
  36731. private _update;
  36732. private _setAllVisibility;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * Class containing a set of static utilities functions for managing Pivots
  36738. * @hidden
  36739. */
  36740. export class PivotTools {
  36741. private static _PivotCached;
  36742. private static _OldPivotPoint;
  36743. private static _PivotTranslation;
  36744. private static _PivotTmpVector;
  36745. /** @hidden */
  36746. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36747. /** @hidden */
  36748. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36749. }
  36750. }
  36751. declare module BABYLON {
  36752. /**
  36753. * Class containing static functions to help procedurally build meshes
  36754. */
  36755. export class PlaneBuilder {
  36756. /**
  36757. * Creates a plane mesh
  36758. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36759. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36760. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36762. * * 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
  36763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36764. * @param name defines the name of the mesh
  36765. * @param options defines the options used to create the mesh
  36766. * @param scene defines the hosting scene
  36767. * @returns the plane mesh
  36768. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36769. */
  36770. static CreatePlane(name: string, options: {
  36771. size?: number;
  36772. width?: number;
  36773. height?: number;
  36774. sideOrientation?: number;
  36775. frontUVs?: Vector4;
  36776. backUVs?: Vector4;
  36777. updatable?: boolean;
  36778. sourcePlane?: Plane;
  36779. }, scene?: Nullable<Scene>): Mesh;
  36780. }
  36781. }
  36782. declare module BABYLON {
  36783. /**
  36784. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36785. */
  36786. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36787. private static _AnyMouseID;
  36788. /**
  36789. * Abstract mesh the behavior is set on
  36790. */
  36791. attachedNode: AbstractMesh;
  36792. private _dragPlane;
  36793. private _scene;
  36794. private _pointerObserver;
  36795. private _beforeRenderObserver;
  36796. private static _planeScene;
  36797. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36798. /**
  36799. * 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)
  36800. */
  36801. maxDragAngle: number;
  36802. /**
  36803. * @hidden
  36804. */
  36805. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36806. /**
  36807. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36808. */
  36809. currentDraggingPointerID: number;
  36810. /**
  36811. * The last position where the pointer hit the drag plane in world space
  36812. */
  36813. lastDragPosition: Vector3;
  36814. /**
  36815. * If the behavior is currently in a dragging state
  36816. */
  36817. dragging: boolean;
  36818. /**
  36819. * 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)
  36820. */
  36821. dragDeltaRatio: number;
  36822. /**
  36823. * If the drag plane orientation should be updated during the dragging (Default: true)
  36824. */
  36825. updateDragPlane: boolean;
  36826. private _debugMode;
  36827. private _moving;
  36828. /**
  36829. * Fires each time the attached mesh is dragged with the pointer
  36830. * * delta between last drag position and current drag position in world space
  36831. * * dragDistance along the drag axis
  36832. * * dragPlaneNormal normal of the current drag plane used during the drag
  36833. * * dragPlanePoint in world space where the drag intersects the drag plane
  36834. */
  36835. onDragObservable: Observable<{
  36836. delta: Vector3;
  36837. dragPlanePoint: Vector3;
  36838. dragPlaneNormal: Vector3;
  36839. dragDistance: number;
  36840. pointerId: number;
  36841. }>;
  36842. /**
  36843. * Fires each time a drag begins (eg. mouse down on mesh)
  36844. */
  36845. onDragStartObservable: Observable<{
  36846. dragPlanePoint: Vector3;
  36847. pointerId: number;
  36848. }>;
  36849. /**
  36850. * Fires each time a drag ends (eg. mouse release after drag)
  36851. */
  36852. onDragEndObservable: Observable<{
  36853. dragPlanePoint: Vector3;
  36854. pointerId: number;
  36855. }>;
  36856. /**
  36857. * If the attached mesh should be moved when dragged
  36858. */
  36859. moveAttached: boolean;
  36860. /**
  36861. * If the drag behavior will react to drag events (Default: true)
  36862. */
  36863. enabled: boolean;
  36864. /**
  36865. * If pointer events should start and release the drag (Default: true)
  36866. */
  36867. startAndReleaseDragOnPointerEvents: boolean;
  36868. /**
  36869. * If camera controls should be detached during the drag
  36870. */
  36871. detachCameraControls: boolean;
  36872. /**
  36873. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36874. */
  36875. useObjectOrienationForDragging: boolean;
  36876. private _options;
  36877. /**
  36878. * Creates a pointer drag behavior that can be attached to a mesh
  36879. * @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)
  36880. */
  36881. constructor(options?: {
  36882. dragAxis?: Vector3;
  36883. dragPlaneNormal?: Vector3;
  36884. });
  36885. /**
  36886. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36887. */
  36888. validateDrag: (targetPosition: Vector3) => boolean;
  36889. /**
  36890. * The name of the behavior
  36891. */
  36892. readonly name: string;
  36893. /**
  36894. * Initializes the behavior
  36895. */
  36896. init(): void;
  36897. private _tmpVector;
  36898. private _alternatePickedPoint;
  36899. private _worldDragAxis;
  36900. private _targetPosition;
  36901. private _attachedElement;
  36902. /**
  36903. * Attaches the drag behavior the passed in mesh
  36904. * @param ownerNode The mesh that will be dragged around once attached
  36905. * @param predicate Predicate to use for pick filtering
  36906. */
  36907. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36908. /**
  36909. * Force relase the drag action by code.
  36910. */
  36911. releaseDrag(): void;
  36912. private _startDragRay;
  36913. private _lastPointerRay;
  36914. /**
  36915. * Simulates the start of a pointer drag event on the behavior
  36916. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36917. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36918. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36919. */
  36920. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36921. private _startDrag;
  36922. private _dragDelta;
  36923. private _moveDrag;
  36924. private _pickWithRayOnDragPlane;
  36925. private _pointA;
  36926. private _pointB;
  36927. private _pointC;
  36928. private _lineA;
  36929. private _lineB;
  36930. private _localAxis;
  36931. private _lookAt;
  36932. private _updateDragPlanePosition;
  36933. /**
  36934. * Detaches the behavior from the mesh
  36935. */
  36936. detach(): void;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36942. */
  36943. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36944. private _dragBehaviorA;
  36945. private _dragBehaviorB;
  36946. private _startDistance;
  36947. private _initialScale;
  36948. private _targetScale;
  36949. private _ownerNode;
  36950. private _sceneRenderObserver;
  36951. /**
  36952. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36953. */
  36954. constructor();
  36955. /**
  36956. * The name of the behavior
  36957. */
  36958. readonly name: string;
  36959. /**
  36960. * Initializes the behavior
  36961. */
  36962. init(): void;
  36963. private _getCurrentDistance;
  36964. /**
  36965. * Attaches the scale behavior the passed in mesh
  36966. * @param ownerNode The mesh that will be scaled around once attached
  36967. */
  36968. attach(ownerNode: Mesh): void;
  36969. /**
  36970. * Detaches the behavior from the mesh
  36971. */
  36972. detach(): void;
  36973. }
  36974. }
  36975. declare module BABYLON {
  36976. /**
  36977. * 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
  36978. */
  36979. export class SixDofDragBehavior implements Behavior<Mesh> {
  36980. private static _virtualScene;
  36981. private _ownerNode;
  36982. private _sceneRenderObserver;
  36983. private _scene;
  36984. private _targetPosition;
  36985. private _virtualOriginMesh;
  36986. private _virtualDragMesh;
  36987. private _pointerObserver;
  36988. private _moving;
  36989. private _startingOrientation;
  36990. /**
  36991. * 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)
  36992. */
  36993. private zDragFactor;
  36994. /**
  36995. * If the object should rotate to face the drag origin
  36996. */
  36997. rotateDraggedObject: boolean;
  36998. /**
  36999. * If the behavior is currently in a dragging state
  37000. */
  37001. dragging: boolean;
  37002. /**
  37003. * 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)
  37004. */
  37005. dragDeltaRatio: number;
  37006. /**
  37007. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37008. */
  37009. currentDraggingPointerID: number;
  37010. /**
  37011. * If camera controls should be detached during the drag
  37012. */
  37013. detachCameraControls: boolean;
  37014. /**
  37015. * Fires each time a drag starts
  37016. */
  37017. onDragStartObservable: Observable<{}>;
  37018. /**
  37019. * Fires each time a drag ends (eg. mouse release after drag)
  37020. */
  37021. onDragEndObservable: Observable<{}>;
  37022. /**
  37023. * 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
  37024. */
  37025. constructor();
  37026. /**
  37027. * The name of the behavior
  37028. */
  37029. readonly name: string;
  37030. /**
  37031. * Initializes the behavior
  37032. */
  37033. init(): void;
  37034. /**
  37035. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37036. */
  37037. private readonly _pointerCamera;
  37038. /**
  37039. * Attaches the scale behavior the passed in mesh
  37040. * @param ownerNode The mesh that will be scaled around once attached
  37041. */
  37042. attach(ownerNode: Mesh): void;
  37043. /**
  37044. * Detaches the behavior from the mesh
  37045. */
  37046. detach(): void;
  37047. }
  37048. }
  37049. declare module BABYLON {
  37050. /**
  37051. * Class used to apply inverse kinematics to bones
  37052. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37053. */
  37054. export class BoneIKController {
  37055. private static _tmpVecs;
  37056. private static _tmpQuat;
  37057. private static _tmpMats;
  37058. /**
  37059. * Gets or sets the target mesh
  37060. */
  37061. targetMesh: AbstractMesh;
  37062. /** Gets or sets the mesh used as pole */
  37063. poleTargetMesh: AbstractMesh;
  37064. /**
  37065. * Gets or sets the bone used as pole
  37066. */
  37067. poleTargetBone: Nullable<Bone>;
  37068. /**
  37069. * Gets or sets the target position
  37070. */
  37071. targetPosition: Vector3;
  37072. /**
  37073. * Gets or sets the pole target position
  37074. */
  37075. poleTargetPosition: Vector3;
  37076. /**
  37077. * Gets or sets the pole target local offset
  37078. */
  37079. poleTargetLocalOffset: Vector3;
  37080. /**
  37081. * Gets or sets the pole angle
  37082. */
  37083. poleAngle: number;
  37084. /**
  37085. * Gets or sets the mesh associated with the controller
  37086. */
  37087. mesh: AbstractMesh;
  37088. /**
  37089. * 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)
  37090. */
  37091. slerpAmount: number;
  37092. private _bone1Quat;
  37093. private _bone1Mat;
  37094. private _bone2Ang;
  37095. private _bone1;
  37096. private _bone2;
  37097. private _bone1Length;
  37098. private _bone2Length;
  37099. private _maxAngle;
  37100. private _maxReach;
  37101. private _rightHandedSystem;
  37102. private _bendAxis;
  37103. private _slerping;
  37104. private _adjustRoll;
  37105. /**
  37106. * Gets or sets maximum allowed angle
  37107. */
  37108. maxAngle: number;
  37109. /**
  37110. * Creates a new BoneIKController
  37111. * @param mesh defines the mesh to control
  37112. * @param bone defines the bone to control
  37113. * @param options defines options to set up the controller
  37114. */
  37115. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37116. targetMesh?: AbstractMesh;
  37117. poleTargetMesh?: AbstractMesh;
  37118. poleTargetBone?: Bone;
  37119. poleTargetLocalOffset?: Vector3;
  37120. poleAngle?: number;
  37121. bendAxis?: Vector3;
  37122. maxAngle?: number;
  37123. slerpAmount?: number;
  37124. });
  37125. private _setMaxAngle;
  37126. /**
  37127. * Force the controller to update the bones
  37128. */
  37129. update(): void;
  37130. }
  37131. }
  37132. declare module BABYLON {
  37133. /**
  37134. * Class used to make a bone look toward a point in space
  37135. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37136. */
  37137. export class BoneLookController {
  37138. private static _tmpVecs;
  37139. private static _tmpQuat;
  37140. private static _tmpMats;
  37141. /**
  37142. * The target Vector3 that the bone will look at
  37143. */
  37144. target: Vector3;
  37145. /**
  37146. * The mesh that the bone is attached to
  37147. */
  37148. mesh: AbstractMesh;
  37149. /**
  37150. * The bone that will be looking to the target
  37151. */
  37152. bone: Bone;
  37153. /**
  37154. * The up axis of the coordinate system that is used when the bone is rotated
  37155. */
  37156. upAxis: Vector3;
  37157. /**
  37158. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37159. */
  37160. upAxisSpace: Space;
  37161. /**
  37162. * Used to make an adjustment to the yaw of the bone
  37163. */
  37164. adjustYaw: number;
  37165. /**
  37166. * Used to make an adjustment to the pitch of the bone
  37167. */
  37168. adjustPitch: number;
  37169. /**
  37170. * Used to make an adjustment to the roll of the bone
  37171. */
  37172. adjustRoll: number;
  37173. /**
  37174. * 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)
  37175. */
  37176. slerpAmount: number;
  37177. private _minYaw;
  37178. private _maxYaw;
  37179. private _minPitch;
  37180. private _maxPitch;
  37181. private _minYawSin;
  37182. private _minYawCos;
  37183. private _maxYawSin;
  37184. private _maxYawCos;
  37185. private _midYawConstraint;
  37186. private _minPitchTan;
  37187. private _maxPitchTan;
  37188. private _boneQuat;
  37189. private _slerping;
  37190. private _transformYawPitch;
  37191. private _transformYawPitchInv;
  37192. private _firstFrameSkipped;
  37193. private _yawRange;
  37194. private _fowardAxis;
  37195. /**
  37196. * Gets or sets the minimum yaw angle that the bone can look to
  37197. */
  37198. minYaw: number;
  37199. /**
  37200. * Gets or sets the maximum yaw angle that the bone can look to
  37201. */
  37202. maxYaw: number;
  37203. /**
  37204. * Gets or sets the minimum pitch angle that the bone can look to
  37205. */
  37206. minPitch: number;
  37207. /**
  37208. * Gets or sets the maximum pitch angle that the bone can look to
  37209. */
  37210. maxPitch: number;
  37211. /**
  37212. * Create a BoneLookController
  37213. * @param mesh the mesh that the bone belongs to
  37214. * @param bone the bone that will be looking to the target
  37215. * @param target the target Vector3 to look at
  37216. * @param options optional settings:
  37217. * * maxYaw: the maximum angle the bone will yaw to
  37218. * * minYaw: the minimum angle the bone will yaw to
  37219. * * maxPitch: the maximum angle the bone will pitch to
  37220. * * minPitch: the minimum angle the bone will yaw to
  37221. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37222. * * upAxis: the up axis of the coordinate system
  37223. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37224. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37225. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37226. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37227. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37228. * * adjustRoll: used to make an adjustment to the roll of the bone
  37229. **/
  37230. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37231. maxYaw?: number;
  37232. minYaw?: number;
  37233. maxPitch?: number;
  37234. minPitch?: number;
  37235. slerpAmount?: number;
  37236. upAxis?: Vector3;
  37237. upAxisSpace?: Space;
  37238. yawAxis?: Vector3;
  37239. pitchAxis?: Vector3;
  37240. adjustYaw?: number;
  37241. adjustPitch?: number;
  37242. adjustRoll?: number;
  37243. });
  37244. /**
  37245. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37246. */
  37247. update(): void;
  37248. private _getAngleDiff;
  37249. private _getAngleBetween;
  37250. private _isAngleBetween;
  37251. }
  37252. }
  37253. declare module BABYLON {
  37254. /**
  37255. * Manage the gamepad inputs to control an arc rotate camera.
  37256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37257. */
  37258. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37259. /**
  37260. * Defines the camera the input is attached to.
  37261. */
  37262. camera: ArcRotateCamera;
  37263. /**
  37264. * Defines the gamepad the input is gathering event from.
  37265. */
  37266. gamepad: Nullable<Gamepad>;
  37267. /**
  37268. * Defines the gamepad rotation sensiblity.
  37269. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37270. */
  37271. gamepadRotationSensibility: number;
  37272. /**
  37273. * Defines the gamepad move sensiblity.
  37274. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37275. */
  37276. gamepadMoveSensibility: number;
  37277. private _onGamepadConnectedObserver;
  37278. private _onGamepadDisconnectedObserver;
  37279. /**
  37280. * Attach the input controls to a specific dom element to get the input from.
  37281. * @param element Defines the element the controls should be listened from
  37282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37283. */
  37284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37285. /**
  37286. * Detach the current controls from the specified dom element.
  37287. * @param element Defines the element to stop listening the inputs from
  37288. */
  37289. detachControl(element: Nullable<HTMLElement>): void;
  37290. /**
  37291. * Update the current camera state depending on the inputs that have been used this frame.
  37292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37293. */
  37294. checkInputs(): void;
  37295. /**
  37296. * Gets the class name of the current intput.
  37297. * @returns the class name
  37298. */
  37299. getClassName(): string;
  37300. /**
  37301. * Get the friendly name associated with the input class.
  37302. * @returns the input friendly name
  37303. */
  37304. getSimpleName(): string;
  37305. }
  37306. }
  37307. declare module BABYLON {
  37308. interface ArcRotateCameraInputsManager {
  37309. /**
  37310. * Add orientation input support to the input manager.
  37311. * @returns the current input manager
  37312. */
  37313. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37314. }
  37315. /**
  37316. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37318. */
  37319. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37320. /**
  37321. * Defines the camera the input is attached to.
  37322. */
  37323. camera: ArcRotateCamera;
  37324. /**
  37325. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37326. */
  37327. alphaCorrection: number;
  37328. /**
  37329. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37330. */
  37331. gammaCorrection: number;
  37332. private _alpha;
  37333. private _gamma;
  37334. private _dirty;
  37335. private _deviceOrientationHandler;
  37336. /**
  37337. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37338. */
  37339. constructor();
  37340. /**
  37341. * Attach the input controls to a specific dom element to get the input from.
  37342. * @param element Defines the element the controls should be listened from
  37343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37344. */
  37345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37346. /** @hidden */
  37347. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37348. /**
  37349. * Update the current camera state depending on the inputs that have been used this frame.
  37350. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37351. */
  37352. checkInputs(): void;
  37353. /**
  37354. * Detach the current controls from the specified dom element.
  37355. * @param element Defines the element to stop listening the inputs from
  37356. */
  37357. detachControl(element: Nullable<HTMLElement>): void;
  37358. /**
  37359. * Gets the class name of the current intput.
  37360. * @returns the class name
  37361. */
  37362. getClassName(): string;
  37363. /**
  37364. * Get the friendly name associated with the input class.
  37365. * @returns the input friendly name
  37366. */
  37367. getSimpleName(): string;
  37368. }
  37369. }
  37370. declare module BABYLON {
  37371. /**
  37372. * Listen to mouse events to control the camera.
  37373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37374. */
  37375. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37376. /**
  37377. * Defines the camera the input is attached to.
  37378. */
  37379. camera: FlyCamera;
  37380. /**
  37381. * Defines if touch is enabled. (Default is true.)
  37382. */
  37383. touchEnabled: boolean;
  37384. /**
  37385. * Defines the buttons associated with the input to handle camera rotation.
  37386. */
  37387. buttons: number[];
  37388. /**
  37389. * Assign buttons for Yaw control.
  37390. */
  37391. buttonsYaw: number[];
  37392. /**
  37393. * Assign buttons for Pitch control.
  37394. */
  37395. buttonsPitch: number[];
  37396. /**
  37397. * Assign buttons for Roll control.
  37398. */
  37399. buttonsRoll: number[];
  37400. /**
  37401. * Detect if any button is being pressed while mouse is moved.
  37402. * -1 = Mouse locked.
  37403. * 0 = Left button.
  37404. * 1 = Middle Button.
  37405. * 2 = Right Button.
  37406. */
  37407. activeButton: number;
  37408. /**
  37409. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37410. * Higher values reduce its sensitivity.
  37411. */
  37412. angularSensibility: number;
  37413. private _mousemoveCallback;
  37414. private _observer;
  37415. private _rollObserver;
  37416. private previousPosition;
  37417. private noPreventDefault;
  37418. private element;
  37419. /**
  37420. * Listen to mouse events to control the camera.
  37421. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37423. */
  37424. constructor(touchEnabled?: boolean);
  37425. /**
  37426. * Attach the mouse control to the HTML DOM element.
  37427. * @param element Defines the element that listens to the input events.
  37428. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37429. */
  37430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37431. /**
  37432. * Detach the current controls from the specified dom element.
  37433. * @param element Defines the element to stop listening the inputs from
  37434. */
  37435. detachControl(element: Nullable<HTMLElement>): void;
  37436. /**
  37437. * Gets the class name of the current input.
  37438. * @returns the class name.
  37439. */
  37440. getClassName(): string;
  37441. /**
  37442. * Get the friendly name associated with the input class.
  37443. * @returns the input's friendly name.
  37444. */
  37445. getSimpleName(): string;
  37446. private _pointerInput;
  37447. private _onMouseMove;
  37448. /**
  37449. * Rotate camera by mouse offset.
  37450. */
  37451. private rotateCamera;
  37452. }
  37453. }
  37454. declare module BABYLON {
  37455. /**
  37456. * Default Inputs manager for the FlyCamera.
  37457. * It groups all the default supported inputs for ease of use.
  37458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37459. */
  37460. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37461. /**
  37462. * Instantiates a new FlyCameraInputsManager.
  37463. * @param camera Defines the camera the inputs belong to.
  37464. */
  37465. constructor(camera: FlyCamera);
  37466. /**
  37467. * Add keyboard input support to the input manager.
  37468. * @returns the new FlyCameraKeyboardMoveInput().
  37469. */
  37470. addKeyboard(): FlyCameraInputsManager;
  37471. /**
  37472. * Add mouse input support to the input manager.
  37473. * @param touchEnabled Enable touch screen support.
  37474. * @returns the new FlyCameraMouseInput().
  37475. */
  37476. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37477. }
  37478. }
  37479. declare module BABYLON {
  37480. /**
  37481. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37482. * such as in a 3D Space Shooter or a Flight Simulator.
  37483. */
  37484. export class FlyCamera extends TargetCamera {
  37485. /**
  37486. * Define the collision ellipsoid of the camera.
  37487. * This is helpful for simulating a camera body, like a player's body.
  37488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37489. */
  37490. ellipsoid: Vector3;
  37491. /**
  37492. * Define an offset for the position of the ellipsoid around the camera.
  37493. * This can be helpful if the camera is attached away from the player's body center,
  37494. * such as at its head.
  37495. */
  37496. ellipsoidOffset: Vector3;
  37497. /**
  37498. * Enable or disable collisions of the camera with the rest of the scene objects.
  37499. */
  37500. checkCollisions: boolean;
  37501. /**
  37502. * Enable or disable gravity on the camera.
  37503. */
  37504. applyGravity: boolean;
  37505. /**
  37506. * Define the current direction the camera is moving to.
  37507. */
  37508. cameraDirection: Vector3;
  37509. /**
  37510. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37511. * This overrides and empties cameraRotation.
  37512. */
  37513. rotationQuaternion: Quaternion;
  37514. /**
  37515. * Track Roll to maintain the wanted Rolling when looking around.
  37516. */
  37517. _trackRoll: number;
  37518. /**
  37519. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37520. */
  37521. rollCorrect: number;
  37522. /**
  37523. * Mimic a banked turn, Rolling the camera when Yawing.
  37524. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37525. */
  37526. bankedTurn: boolean;
  37527. /**
  37528. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37529. */
  37530. bankedTurnLimit: number;
  37531. /**
  37532. * Value of 0 disables the banked Roll.
  37533. * Value of 1 is equal to the Yaw angle in radians.
  37534. */
  37535. bankedTurnMultiplier: number;
  37536. /**
  37537. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37538. */
  37539. inputs: FlyCameraInputsManager;
  37540. /**
  37541. * Gets the input sensibility for mouse input.
  37542. * Higher values reduce sensitivity.
  37543. */
  37544. /**
  37545. * Sets the input sensibility for a mouse input.
  37546. * Higher values reduce sensitivity.
  37547. */
  37548. angularSensibility: number;
  37549. /**
  37550. * Get the keys for camera movement forward.
  37551. */
  37552. /**
  37553. * Set the keys for camera movement forward.
  37554. */
  37555. keysForward: number[];
  37556. /**
  37557. * Get the keys for camera movement backward.
  37558. */
  37559. keysBackward: number[];
  37560. /**
  37561. * Get the keys for camera movement up.
  37562. */
  37563. /**
  37564. * Set the keys for camera movement up.
  37565. */
  37566. keysUp: number[];
  37567. /**
  37568. * Get the keys for camera movement down.
  37569. */
  37570. /**
  37571. * Set the keys for camera movement down.
  37572. */
  37573. keysDown: number[];
  37574. /**
  37575. * Get the keys for camera movement left.
  37576. */
  37577. /**
  37578. * Set the keys for camera movement left.
  37579. */
  37580. keysLeft: number[];
  37581. /**
  37582. * Set the keys for camera movement right.
  37583. */
  37584. /**
  37585. * Set the keys for camera movement right.
  37586. */
  37587. keysRight: number[];
  37588. /**
  37589. * Event raised when the camera collides with a mesh in the scene.
  37590. */
  37591. onCollide: (collidedMesh: AbstractMesh) => void;
  37592. private _collider;
  37593. private _needMoveForGravity;
  37594. private _oldPosition;
  37595. private _diffPosition;
  37596. private _newPosition;
  37597. /** @hidden */
  37598. _localDirection: Vector3;
  37599. /** @hidden */
  37600. _transformedDirection: Vector3;
  37601. /**
  37602. * Instantiates a FlyCamera.
  37603. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37604. * such as in a 3D Space Shooter or a Flight Simulator.
  37605. * @param name Define the name of the camera in the scene.
  37606. * @param position Define the starting position of the camera in the scene.
  37607. * @param scene Define the scene the camera belongs to.
  37608. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37609. */
  37610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37611. /**
  37612. * Attach a control to the HTML DOM element.
  37613. * @param element Defines the element that listens to the input events.
  37614. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37615. */
  37616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37617. /**
  37618. * Detach a control from the HTML DOM element.
  37619. * The camera will stop reacting to that input.
  37620. * @param element Defines the element that listens to the input events.
  37621. */
  37622. detachControl(element: HTMLElement): void;
  37623. private _collisionMask;
  37624. /**
  37625. * Get the mask that the camera ignores in collision events.
  37626. */
  37627. /**
  37628. * Set the mask that the camera ignores in collision events.
  37629. */
  37630. collisionMask: number;
  37631. /** @hidden */
  37632. _collideWithWorld(displacement: Vector3): void;
  37633. /** @hidden */
  37634. private _onCollisionPositionChange;
  37635. /** @hidden */
  37636. _checkInputs(): void;
  37637. /** @hidden */
  37638. _decideIfNeedsToMove(): boolean;
  37639. /** @hidden */
  37640. _updatePosition(): void;
  37641. /**
  37642. * Restore the Roll to its target value at the rate specified.
  37643. * @param rate - Higher means slower restoring.
  37644. * @hidden
  37645. */
  37646. restoreRoll(rate: number): void;
  37647. /**
  37648. * Destroy the camera and release the current resources held by it.
  37649. */
  37650. dispose(): void;
  37651. /**
  37652. * Get the current object class name.
  37653. * @returns the class name.
  37654. */
  37655. getClassName(): string;
  37656. }
  37657. }
  37658. declare module BABYLON {
  37659. /**
  37660. * Listen to keyboard events to control the camera.
  37661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37662. */
  37663. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37664. /**
  37665. * Defines the camera the input is attached to.
  37666. */
  37667. camera: FlyCamera;
  37668. /**
  37669. * The list of keyboard keys used to control the forward move of the camera.
  37670. */
  37671. keysForward: number[];
  37672. /**
  37673. * The list of keyboard keys used to control the backward move of the camera.
  37674. */
  37675. keysBackward: number[];
  37676. /**
  37677. * The list of keyboard keys used to control the forward move of the camera.
  37678. */
  37679. keysUp: number[];
  37680. /**
  37681. * The list of keyboard keys used to control the backward move of the camera.
  37682. */
  37683. keysDown: number[];
  37684. /**
  37685. * The list of keyboard keys used to control the right strafe move of the camera.
  37686. */
  37687. keysRight: number[];
  37688. /**
  37689. * The list of keyboard keys used to control the left strafe move of the camera.
  37690. */
  37691. keysLeft: number[];
  37692. private _keys;
  37693. private _onCanvasBlurObserver;
  37694. private _onKeyboardObserver;
  37695. private _engine;
  37696. private _scene;
  37697. /**
  37698. * Attach the input controls to a specific dom element to get the input from.
  37699. * @param element Defines the element the controls should be listened from
  37700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37701. */
  37702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37703. /**
  37704. * Detach the current controls from the specified dom element.
  37705. * @param element Defines the element to stop listening the inputs from
  37706. */
  37707. detachControl(element: Nullable<HTMLElement>): void;
  37708. /**
  37709. * Gets the class name of the current intput.
  37710. * @returns the class name
  37711. */
  37712. getClassName(): string;
  37713. /** @hidden */
  37714. _onLostFocus(e: FocusEvent): void;
  37715. /**
  37716. * Get the friendly name associated with the input class.
  37717. * @returns the input friendly name
  37718. */
  37719. getSimpleName(): string;
  37720. /**
  37721. * Update the current camera state depending on the inputs that have been used this frame.
  37722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37723. */
  37724. checkInputs(): void;
  37725. }
  37726. }
  37727. declare module BABYLON {
  37728. /**
  37729. * Manage the mouse wheel inputs to control a follow camera.
  37730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37731. */
  37732. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37733. /**
  37734. * Defines the camera the input is attached to.
  37735. */
  37736. camera: FollowCamera;
  37737. /**
  37738. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37739. */
  37740. axisControlRadius: boolean;
  37741. /**
  37742. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37743. */
  37744. axisControlHeight: boolean;
  37745. /**
  37746. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37747. */
  37748. axisControlRotation: boolean;
  37749. /**
  37750. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37751. * relation to mouseWheel events.
  37752. */
  37753. wheelPrecision: number;
  37754. /**
  37755. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37756. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37757. */
  37758. wheelDeltaPercentage: number;
  37759. private _wheel;
  37760. private _observer;
  37761. /**
  37762. * Attach the input controls to a specific dom element to get the input from.
  37763. * @param element Defines the element the controls should be listened from
  37764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37765. */
  37766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37767. /**
  37768. * Detach the current controls from the specified dom element.
  37769. * @param element Defines the element to stop listening the inputs from
  37770. */
  37771. detachControl(element: Nullable<HTMLElement>): void;
  37772. /**
  37773. * Gets the class name of the current intput.
  37774. * @returns the class name
  37775. */
  37776. getClassName(): string;
  37777. /**
  37778. * Get the friendly name associated with the input class.
  37779. * @returns the input friendly name
  37780. */
  37781. getSimpleName(): string;
  37782. }
  37783. }
  37784. declare module BABYLON {
  37785. /**
  37786. * Manage the pointers inputs to control an follow camera.
  37787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37788. */
  37789. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37790. /**
  37791. * Defines the camera the input is attached to.
  37792. */
  37793. camera: FollowCamera;
  37794. /**
  37795. * Gets the class name of the current input.
  37796. * @returns the class name
  37797. */
  37798. getClassName(): string;
  37799. /**
  37800. * Defines the pointer angular sensibility along the X axis or how fast is
  37801. * the camera rotating.
  37802. * A negative number will reverse the axis direction.
  37803. */
  37804. angularSensibilityX: number;
  37805. /**
  37806. * Defines the pointer angular sensibility along the Y axis or how fast is
  37807. * the camera rotating.
  37808. * A negative number will reverse the axis direction.
  37809. */
  37810. angularSensibilityY: number;
  37811. /**
  37812. * Defines the pointer pinch precision or how fast is the camera zooming.
  37813. * A negative number will reverse the axis direction.
  37814. */
  37815. pinchPrecision: number;
  37816. /**
  37817. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37818. * from 0.
  37819. * It defines the percentage of current camera.radius to use as delta when
  37820. * pinch zoom is used.
  37821. */
  37822. pinchDeltaPercentage: number;
  37823. /**
  37824. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37825. */
  37826. axisXControlRadius: boolean;
  37827. /**
  37828. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37829. */
  37830. axisXControlHeight: boolean;
  37831. /**
  37832. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37833. */
  37834. axisXControlRotation: boolean;
  37835. /**
  37836. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37837. */
  37838. axisYControlRadius: boolean;
  37839. /**
  37840. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37841. */
  37842. axisYControlHeight: boolean;
  37843. /**
  37844. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37845. */
  37846. axisYControlRotation: boolean;
  37847. /**
  37848. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37849. */
  37850. axisPinchControlRadius: boolean;
  37851. /**
  37852. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37853. */
  37854. axisPinchControlHeight: boolean;
  37855. /**
  37856. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37857. */
  37858. axisPinchControlRotation: boolean;
  37859. /**
  37860. * Log error messages if basic misconfiguration has occurred.
  37861. */
  37862. warningEnable: boolean;
  37863. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37864. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37865. private _warningCounter;
  37866. private _warning;
  37867. }
  37868. }
  37869. declare module BABYLON {
  37870. /**
  37871. * Default Inputs manager for the FollowCamera.
  37872. * It groups all the default supported inputs for ease of use.
  37873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37874. */
  37875. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37876. /**
  37877. * Instantiates a new FollowCameraInputsManager.
  37878. * @param camera Defines the camera the inputs belong to
  37879. */
  37880. constructor(camera: FollowCamera);
  37881. /**
  37882. * Add keyboard input support to the input manager.
  37883. * @returns the current input manager
  37884. */
  37885. addKeyboard(): FollowCameraInputsManager;
  37886. /**
  37887. * Add mouse wheel input support to the input manager.
  37888. * @returns the current input manager
  37889. */
  37890. addMouseWheel(): FollowCameraInputsManager;
  37891. /**
  37892. * Add pointers input support to the input manager.
  37893. * @returns the current input manager
  37894. */
  37895. addPointers(): FollowCameraInputsManager;
  37896. /**
  37897. * Add orientation input support to the input manager.
  37898. * @returns the current input manager
  37899. */
  37900. addVRDeviceOrientation(): FollowCameraInputsManager;
  37901. }
  37902. }
  37903. declare module BABYLON {
  37904. /**
  37905. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37906. * an arc rotate version arcFollowCamera are available.
  37907. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37908. */
  37909. export class FollowCamera extends TargetCamera {
  37910. /**
  37911. * Distance the follow camera should follow an object at
  37912. */
  37913. radius: number;
  37914. /**
  37915. * Minimum allowed distance of the camera to the axis of rotation
  37916. * (The camera can not get closer).
  37917. * This can help limiting how the Camera is able to move in the scene.
  37918. */
  37919. lowerRadiusLimit: Nullable<number>;
  37920. /**
  37921. * Maximum allowed distance of the camera to the axis of rotation
  37922. * (The camera can not get further).
  37923. * This can help limiting how the Camera is able to move in the scene.
  37924. */
  37925. upperRadiusLimit: Nullable<number>;
  37926. /**
  37927. * Define a rotation offset between the camera and the object it follows
  37928. */
  37929. rotationOffset: number;
  37930. /**
  37931. * Minimum allowed angle to camera position relative to target object.
  37932. * This can help limiting how the Camera is able to move in the scene.
  37933. */
  37934. lowerRotationOffsetLimit: Nullable<number>;
  37935. /**
  37936. * Maximum allowed angle to camera position relative to target object.
  37937. * This can help limiting how the Camera is able to move in the scene.
  37938. */
  37939. upperRotationOffsetLimit: Nullable<number>;
  37940. /**
  37941. * Define a height offset between the camera and the object it follows.
  37942. * It can help following an object from the top (like a car chaing a plane)
  37943. */
  37944. heightOffset: number;
  37945. /**
  37946. * Minimum allowed height of camera position relative to target object.
  37947. * This can help limiting how the Camera is able to move in the scene.
  37948. */
  37949. lowerHeightOffsetLimit: Nullable<number>;
  37950. /**
  37951. * Maximum allowed height of camera position relative to target object.
  37952. * This can help limiting how the Camera is able to move in the scene.
  37953. */
  37954. upperHeightOffsetLimit: Nullable<number>;
  37955. /**
  37956. * Define how fast the camera can accelerate to follow it s target.
  37957. */
  37958. cameraAcceleration: number;
  37959. /**
  37960. * Define the speed limit of the camera following an object.
  37961. */
  37962. maxCameraSpeed: number;
  37963. /**
  37964. * Define the target of the camera.
  37965. */
  37966. lockedTarget: Nullable<AbstractMesh>;
  37967. /**
  37968. * Defines the input associated with the camera.
  37969. */
  37970. inputs: FollowCameraInputsManager;
  37971. /**
  37972. * Instantiates the follow camera.
  37973. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37974. * @param name Define the name of the camera in the scene
  37975. * @param position Define the position of the camera
  37976. * @param scene Define the scene the camera belong to
  37977. * @param lockedTarget Define the target of the camera
  37978. */
  37979. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37980. private _follow;
  37981. /**
  37982. * Attached controls to the current camera.
  37983. * @param element Defines the element the controls should be listened from
  37984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37985. */
  37986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37987. /**
  37988. * Detach the current controls from the camera.
  37989. * The camera will stop reacting to inputs.
  37990. * @param element Defines the element to stop listening the inputs from
  37991. */
  37992. detachControl(element: HTMLElement): void;
  37993. /** @hidden */
  37994. _checkInputs(): void;
  37995. private _checkLimits;
  37996. /**
  37997. * Gets the camera class name.
  37998. * @returns the class name
  37999. */
  38000. getClassName(): string;
  38001. }
  38002. /**
  38003. * Arc Rotate version of the follow camera.
  38004. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38005. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38006. */
  38007. export class ArcFollowCamera extends TargetCamera {
  38008. /** The longitudinal angle of the camera */
  38009. alpha: number;
  38010. /** The latitudinal angle of the camera */
  38011. beta: number;
  38012. /** The radius of the camera from its target */
  38013. radius: number;
  38014. /** Define the camera target (the messh it should follow) */
  38015. target: Nullable<AbstractMesh>;
  38016. private _cartesianCoordinates;
  38017. /**
  38018. * Instantiates a new ArcFollowCamera
  38019. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38020. * @param name Define the name of the camera
  38021. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38022. * @param beta Define the rotation angle of the camera around the elevation axis
  38023. * @param radius Define the radius of the camera from its target point
  38024. * @param target Define the target of the camera
  38025. * @param scene Define the scene the camera belongs to
  38026. */
  38027. constructor(name: string,
  38028. /** The longitudinal angle of the camera */
  38029. alpha: number,
  38030. /** The latitudinal angle of the camera */
  38031. beta: number,
  38032. /** The radius of the camera from its target */
  38033. radius: number,
  38034. /** Define the camera target (the messh it should follow) */
  38035. target: Nullable<AbstractMesh>, scene: Scene);
  38036. private _follow;
  38037. /** @hidden */
  38038. _checkInputs(): void;
  38039. /**
  38040. * Returns the class name of the object.
  38041. * It is mostly used internally for serialization purposes.
  38042. */
  38043. getClassName(): string;
  38044. }
  38045. }
  38046. declare module BABYLON {
  38047. /**
  38048. * Manage the keyboard inputs to control the movement of a follow camera.
  38049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38050. */
  38051. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38052. /**
  38053. * Defines the camera the input is attached to.
  38054. */
  38055. camera: FollowCamera;
  38056. /**
  38057. * Defines the list of key codes associated with the up action (increase heightOffset)
  38058. */
  38059. keysHeightOffsetIncr: number[];
  38060. /**
  38061. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38062. */
  38063. keysHeightOffsetDecr: number[];
  38064. /**
  38065. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38066. */
  38067. keysHeightOffsetModifierAlt: boolean;
  38068. /**
  38069. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38070. */
  38071. keysHeightOffsetModifierCtrl: boolean;
  38072. /**
  38073. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38074. */
  38075. keysHeightOffsetModifierShift: boolean;
  38076. /**
  38077. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38078. */
  38079. keysRotationOffsetIncr: number[];
  38080. /**
  38081. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38082. */
  38083. keysRotationOffsetDecr: number[];
  38084. /**
  38085. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38086. */
  38087. keysRotationOffsetModifierAlt: boolean;
  38088. /**
  38089. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38090. */
  38091. keysRotationOffsetModifierCtrl: boolean;
  38092. /**
  38093. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38094. */
  38095. keysRotationOffsetModifierShift: boolean;
  38096. /**
  38097. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38098. */
  38099. keysRadiusIncr: number[];
  38100. /**
  38101. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38102. */
  38103. keysRadiusDecr: number[];
  38104. /**
  38105. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38106. */
  38107. keysRadiusModifierAlt: boolean;
  38108. /**
  38109. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38110. */
  38111. keysRadiusModifierCtrl: boolean;
  38112. /**
  38113. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38114. */
  38115. keysRadiusModifierShift: boolean;
  38116. /**
  38117. * Defines the rate of change of heightOffset.
  38118. */
  38119. heightSensibility: number;
  38120. /**
  38121. * Defines the rate of change of rotationOffset.
  38122. */
  38123. rotationSensibility: number;
  38124. /**
  38125. * Defines the rate of change of radius.
  38126. */
  38127. radiusSensibility: number;
  38128. private _keys;
  38129. private _ctrlPressed;
  38130. private _altPressed;
  38131. private _shiftPressed;
  38132. private _onCanvasBlurObserver;
  38133. private _onKeyboardObserver;
  38134. private _engine;
  38135. private _scene;
  38136. /**
  38137. * Attach the input controls to a specific dom element to get the input from.
  38138. * @param element Defines the element the controls should be listened from
  38139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38140. */
  38141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38142. /**
  38143. * Detach the current controls from the specified dom element.
  38144. * @param element Defines the element to stop listening the inputs from
  38145. */
  38146. detachControl(element: Nullable<HTMLElement>): void;
  38147. /**
  38148. * Update the current camera state depending on the inputs that have been used this frame.
  38149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38150. */
  38151. checkInputs(): void;
  38152. /**
  38153. * Gets the class name of the current input.
  38154. * @returns the class name
  38155. */
  38156. getClassName(): string;
  38157. /**
  38158. * Get the friendly name associated with the input class.
  38159. * @returns the input friendly name
  38160. */
  38161. getSimpleName(): string;
  38162. /**
  38163. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38164. * allow modification of the heightOffset value.
  38165. */
  38166. private _modifierHeightOffset;
  38167. /**
  38168. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38169. * allow modification of the rotationOffset value.
  38170. */
  38171. private _modifierRotationOffset;
  38172. /**
  38173. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38174. * allow modification of the radius value.
  38175. */
  38176. private _modifierRadius;
  38177. }
  38178. }
  38179. declare module BABYLON {
  38180. interface FreeCameraInputsManager {
  38181. /**
  38182. * @hidden
  38183. */
  38184. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38185. /**
  38186. * Add orientation input support to the input manager.
  38187. * @returns the current input manager
  38188. */
  38189. addDeviceOrientation(): FreeCameraInputsManager;
  38190. }
  38191. /**
  38192. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38193. * Screen rotation is taken into account.
  38194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38195. */
  38196. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38197. private _camera;
  38198. private _screenOrientationAngle;
  38199. private _constantTranform;
  38200. private _screenQuaternion;
  38201. private _alpha;
  38202. private _beta;
  38203. private _gamma;
  38204. /**
  38205. * Can be used to detect if a device orientation sensor is availible on a device
  38206. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38207. * @returns a promise that will resolve on orientation change
  38208. */
  38209. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38210. /**
  38211. * @hidden
  38212. */
  38213. _onDeviceOrientationChangedObservable: Observable<void>;
  38214. /**
  38215. * Instantiates a new input
  38216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38217. */
  38218. constructor();
  38219. /**
  38220. * Define the camera controlled by the input.
  38221. */
  38222. camera: FreeCamera;
  38223. /**
  38224. * Attach the input controls to a specific dom element to get the input from.
  38225. * @param element Defines the element the controls should be listened from
  38226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38227. */
  38228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38229. private _orientationChanged;
  38230. private _deviceOrientation;
  38231. /**
  38232. * Detach the current controls from the specified dom element.
  38233. * @param element Defines the element to stop listening the inputs from
  38234. */
  38235. detachControl(element: Nullable<HTMLElement>): void;
  38236. /**
  38237. * Update the current camera state depending on the inputs that have been used this frame.
  38238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38239. */
  38240. checkInputs(): void;
  38241. /**
  38242. * Gets the class name of the current intput.
  38243. * @returns the class name
  38244. */
  38245. getClassName(): string;
  38246. /**
  38247. * Get the friendly name associated with the input class.
  38248. * @returns the input friendly name
  38249. */
  38250. getSimpleName(): string;
  38251. }
  38252. }
  38253. declare module BABYLON {
  38254. /**
  38255. * Manage the gamepad inputs to control a free camera.
  38256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38257. */
  38258. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38259. /**
  38260. * Define the camera the input is attached to.
  38261. */
  38262. camera: FreeCamera;
  38263. /**
  38264. * Define the Gamepad controlling the input
  38265. */
  38266. gamepad: Nullable<Gamepad>;
  38267. /**
  38268. * Defines the gamepad rotation sensiblity.
  38269. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38270. */
  38271. gamepadAngularSensibility: number;
  38272. /**
  38273. * Defines the gamepad move sensiblity.
  38274. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38275. */
  38276. gamepadMoveSensibility: number;
  38277. private _onGamepadConnectedObserver;
  38278. private _onGamepadDisconnectedObserver;
  38279. private _cameraTransform;
  38280. private _deltaTransform;
  38281. private _vector3;
  38282. private _vector2;
  38283. /**
  38284. * Attach the input controls to a specific dom element to get the input from.
  38285. * @param element Defines the element the controls should be listened from
  38286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38287. */
  38288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38289. /**
  38290. * Detach the current controls from the specified dom element.
  38291. * @param element Defines the element to stop listening the inputs from
  38292. */
  38293. detachControl(element: Nullable<HTMLElement>): void;
  38294. /**
  38295. * Update the current camera state depending on the inputs that have been used this frame.
  38296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38297. */
  38298. checkInputs(): void;
  38299. /**
  38300. * Gets the class name of the current intput.
  38301. * @returns the class name
  38302. */
  38303. getClassName(): string;
  38304. /**
  38305. * Get the friendly name associated with the input class.
  38306. * @returns the input friendly name
  38307. */
  38308. getSimpleName(): string;
  38309. }
  38310. }
  38311. declare module BABYLON {
  38312. /**
  38313. * Defines the potential axis of a Joystick
  38314. */
  38315. export enum JoystickAxis {
  38316. /** X axis */
  38317. X = 0,
  38318. /** Y axis */
  38319. Y = 1,
  38320. /** Z axis */
  38321. Z = 2
  38322. }
  38323. /**
  38324. * Class used to define virtual joystick (used in touch mode)
  38325. */
  38326. export class VirtualJoystick {
  38327. /**
  38328. * Gets or sets a boolean indicating that left and right values must be inverted
  38329. */
  38330. reverseLeftRight: boolean;
  38331. /**
  38332. * Gets or sets a boolean indicating that up and down values must be inverted
  38333. */
  38334. reverseUpDown: boolean;
  38335. /**
  38336. * Gets the offset value for the position (ie. the change of the position value)
  38337. */
  38338. deltaPosition: Vector3;
  38339. /**
  38340. * Gets a boolean indicating if the virtual joystick was pressed
  38341. */
  38342. pressed: boolean;
  38343. /**
  38344. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38345. */
  38346. static Canvas: Nullable<HTMLCanvasElement>;
  38347. private static _globalJoystickIndex;
  38348. private static vjCanvasContext;
  38349. private static vjCanvasWidth;
  38350. private static vjCanvasHeight;
  38351. private static halfWidth;
  38352. private _action;
  38353. private _axisTargetedByLeftAndRight;
  38354. private _axisTargetedByUpAndDown;
  38355. private _joystickSensibility;
  38356. private _inversedSensibility;
  38357. private _joystickPointerID;
  38358. private _joystickColor;
  38359. private _joystickPointerPos;
  38360. private _joystickPreviousPointerPos;
  38361. private _joystickPointerStartPos;
  38362. private _deltaJoystickVector;
  38363. private _leftJoystick;
  38364. private _touches;
  38365. private _onPointerDownHandlerRef;
  38366. private _onPointerMoveHandlerRef;
  38367. private _onPointerUpHandlerRef;
  38368. private _onResize;
  38369. /**
  38370. * Creates a new virtual joystick
  38371. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38372. */
  38373. constructor(leftJoystick?: boolean);
  38374. /**
  38375. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38376. * @param newJoystickSensibility defines the new sensibility
  38377. */
  38378. setJoystickSensibility(newJoystickSensibility: number): void;
  38379. private _onPointerDown;
  38380. private _onPointerMove;
  38381. private _onPointerUp;
  38382. /**
  38383. * Change the color of the virtual joystick
  38384. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38385. */
  38386. setJoystickColor(newColor: string): void;
  38387. /**
  38388. * Defines a callback to call when the joystick is touched
  38389. * @param action defines the callback
  38390. */
  38391. setActionOnTouch(action: () => any): void;
  38392. /**
  38393. * Defines which axis you'd like to control for left & right
  38394. * @param axis defines the axis to use
  38395. */
  38396. setAxisForLeftRight(axis: JoystickAxis): void;
  38397. /**
  38398. * Defines which axis you'd like to control for up & down
  38399. * @param axis defines the axis to use
  38400. */
  38401. setAxisForUpDown(axis: JoystickAxis): void;
  38402. private _drawVirtualJoystick;
  38403. /**
  38404. * Release internal HTML canvas
  38405. */
  38406. releaseCanvas(): void;
  38407. }
  38408. }
  38409. declare module BABYLON {
  38410. interface FreeCameraInputsManager {
  38411. /**
  38412. * Add virtual joystick input support to the input manager.
  38413. * @returns the current input manager
  38414. */
  38415. addVirtualJoystick(): FreeCameraInputsManager;
  38416. }
  38417. /**
  38418. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38420. */
  38421. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38422. /**
  38423. * Defines the camera the input is attached to.
  38424. */
  38425. camera: FreeCamera;
  38426. private _leftjoystick;
  38427. private _rightjoystick;
  38428. /**
  38429. * Gets the left stick of the virtual joystick.
  38430. * @returns The virtual Joystick
  38431. */
  38432. getLeftJoystick(): VirtualJoystick;
  38433. /**
  38434. * Gets the right stick of the virtual joystick.
  38435. * @returns The virtual Joystick
  38436. */
  38437. getRightJoystick(): VirtualJoystick;
  38438. /**
  38439. * Update the current camera state depending on the inputs that have been used this frame.
  38440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38441. */
  38442. checkInputs(): void;
  38443. /**
  38444. * Attach the input controls to a specific dom element to get the input from.
  38445. * @param element Defines the element the controls should be listened from
  38446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38447. */
  38448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38449. /**
  38450. * Detach the current controls from the specified dom element.
  38451. * @param element Defines the element to stop listening the inputs from
  38452. */
  38453. detachControl(element: Nullable<HTMLElement>): void;
  38454. /**
  38455. * Gets the class name of the current intput.
  38456. * @returns the class name
  38457. */
  38458. getClassName(): string;
  38459. /**
  38460. * Get the friendly name associated with the input class.
  38461. * @returns the input friendly name
  38462. */
  38463. getSimpleName(): string;
  38464. }
  38465. }
  38466. declare module BABYLON {
  38467. /**
  38468. * This represents a FPS type of camera controlled by touch.
  38469. * This is like a universal camera minus the Gamepad controls.
  38470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38471. */
  38472. export class TouchCamera extends FreeCamera {
  38473. /**
  38474. * Defines the touch sensibility for rotation.
  38475. * The higher the faster.
  38476. */
  38477. touchAngularSensibility: number;
  38478. /**
  38479. * Defines the touch sensibility for move.
  38480. * The higher the faster.
  38481. */
  38482. touchMoveSensibility: number;
  38483. /**
  38484. * Instantiates a new touch camera.
  38485. * This represents a FPS type of camera controlled by touch.
  38486. * This is like a universal camera minus the Gamepad controls.
  38487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38488. * @param name Define the name of the camera in the scene
  38489. * @param position Define the start position of the camera in the scene
  38490. * @param scene Define the scene the camera belongs to
  38491. */
  38492. constructor(name: string, position: Vector3, scene: Scene);
  38493. /**
  38494. * Gets the current object class name.
  38495. * @return the class name
  38496. */
  38497. getClassName(): string;
  38498. /** @hidden */
  38499. _setupInputs(): void;
  38500. }
  38501. }
  38502. declare module BABYLON {
  38503. /**
  38504. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38505. * being tilted forward or back and left or right.
  38506. */
  38507. export class DeviceOrientationCamera extends FreeCamera {
  38508. private _initialQuaternion;
  38509. private _quaternionCache;
  38510. private _tmpDragQuaternion;
  38511. private _disablePointerInputWhenUsingDeviceOrientation;
  38512. /**
  38513. * Creates a new device orientation camera
  38514. * @param name The name of the camera
  38515. * @param position The start position camera
  38516. * @param scene The scene the camera belongs to
  38517. */
  38518. constructor(name: string, position: Vector3, scene: Scene);
  38519. /**
  38520. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38521. */
  38522. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38523. private _dragFactor;
  38524. /**
  38525. * Enabled turning on the y axis when the orientation sensor is active
  38526. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38527. */
  38528. enableHorizontalDragging(dragFactor?: number): void;
  38529. /**
  38530. * Gets the current instance class name ("DeviceOrientationCamera").
  38531. * This helps avoiding instanceof at run time.
  38532. * @returns the class name
  38533. */
  38534. getClassName(): string;
  38535. /**
  38536. * @hidden
  38537. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38538. */
  38539. _checkInputs(): void;
  38540. /**
  38541. * Reset the camera to its default orientation on the specified axis only.
  38542. * @param axis The axis to reset
  38543. */
  38544. resetToCurrentRotation(axis?: Axis): void;
  38545. }
  38546. }
  38547. declare module BABYLON {
  38548. /**
  38549. * Defines supported buttons for XBox360 compatible gamepads
  38550. */
  38551. export enum Xbox360Button {
  38552. /** A */
  38553. A = 0,
  38554. /** B */
  38555. B = 1,
  38556. /** X */
  38557. X = 2,
  38558. /** Y */
  38559. Y = 3,
  38560. /** Start */
  38561. Start = 4,
  38562. /** Back */
  38563. Back = 5,
  38564. /** Left button */
  38565. LB = 6,
  38566. /** Right button */
  38567. RB = 7,
  38568. /** Left stick */
  38569. LeftStick = 8,
  38570. /** Right stick */
  38571. RightStick = 9
  38572. }
  38573. /** Defines values for XBox360 DPad */
  38574. export enum Xbox360Dpad {
  38575. /** Up */
  38576. Up = 0,
  38577. /** Down */
  38578. Down = 1,
  38579. /** Left */
  38580. Left = 2,
  38581. /** Right */
  38582. Right = 3
  38583. }
  38584. /**
  38585. * Defines a XBox360 gamepad
  38586. */
  38587. export class Xbox360Pad extends Gamepad {
  38588. private _leftTrigger;
  38589. private _rightTrigger;
  38590. private _onlefttriggerchanged;
  38591. private _onrighttriggerchanged;
  38592. private _onbuttondown;
  38593. private _onbuttonup;
  38594. private _ondpaddown;
  38595. private _ondpadup;
  38596. /** Observable raised when a button is pressed */
  38597. onButtonDownObservable: Observable<Xbox360Button>;
  38598. /** Observable raised when a button is released */
  38599. onButtonUpObservable: Observable<Xbox360Button>;
  38600. /** Observable raised when a pad is pressed */
  38601. onPadDownObservable: Observable<Xbox360Dpad>;
  38602. /** Observable raised when a pad is released */
  38603. onPadUpObservable: Observable<Xbox360Dpad>;
  38604. private _buttonA;
  38605. private _buttonB;
  38606. private _buttonX;
  38607. private _buttonY;
  38608. private _buttonBack;
  38609. private _buttonStart;
  38610. private _buttonLB;
  38611. private _buttonRB;
  38612. private _buttonLeftStick;
  38613. private _buttonRightStick;
  38614. private _dPadUp;
  38615. private _dPadDown;
  38616. private _dPadLeft;
  38617. private _dPadRight;
  38618. private _isXboxOnePad;
  38619. /**
  38620. * Creates a new XBox360 gamepad object
  38621. * @param id defines the id of this gamepad
  38622. * @param index defines its index
  38623. * @param gamepad defines the internal HTML gamepad object
  38624. * @param xboxOne defines if it is a XBox One gamepad
  38625. */
  38626. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38627. /**
  38628. * Defines the callback to call when left trigger is pressed
  38629. * @param callback defines the callback to use
  38630. */
  38631. onlefttriggerchanged(callback: (value: number) => void): void;
  38632. /**
  38633. * Defines the callback to call when right trigger is pressed
  38634. * @param callback defines the callback to use
  38635. */
  38636. onrighttriggerchanged(callback: (value: number) => void): void;
  38637. /**
  38638. * Gets the left trigger value
  38639. */
  38640. /**
  38641. * Sets the left trigger value
  38642. */
  38643. leftTrigger: number;
  38644. /**
  38645. * Gets the right trigger value
  38646. */
  38647. /**
  38648. * Sets the right trigger value
  38649. */
  38650. rightTrigger: number;
  38651. /**
  38652. * Defines the callback to call when a button is pressed
  38653. * @param callback defines the callback to use
  38654. */
  38655. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38656. /**
  38657. * Defines the callback to call when a button is released
  38658. * @param callback defines the callback to use
  38659. */
  38660. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38661. /**
  38662. * Defines the callback to call when a pad is pressed
  38663. * @param callback defines the callback to use
  38664. */
  38665. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38666. /**
  38667. * Defines the callback to call when a pad is released
  38668. * @param callback defines the callback to use
  38669. */
  38670. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38671. private _setButtonValue;
  38672. private _setDPadValue;
  38673. /**
  38674. * Gets the value of the `A` button
  38675. */
  38676. /**
  38677. * Sets the value of the `A` button
  38678. */
  38679. buttonA: number;
  38680. /**
  38681. * Gets the value of the `B` button
  38682. */
  38683. /**
  38684. * Sets the value of the `B` button
  38685. */
  38686. buttonB: number;
  38687. /**
  38688. * Gets the value of the `X` button
  38689. */
  38690. /**
  38691. * Sets the value of the `X` button
  38692. */
  38693. buttonX: number;
  38694. /**
  38695. * Gets the value of the `Y` button
  38696. */
  38697. /**
  38698. * Sets the value of the `Y` button
  38699. */
  38700. buttonY: number;
  38701. /**
  38702. * Gets the value of the `Start` button
  38703. */
  38704. /**
  38705. * Sets the value of the `Start` button
  38706. */
  38707. buttonStart: number;
  38708. /**
  38709. * Gets the value of the `Back` button
  38710. */
  38711. /**
  38712. * Sets the value of the `Back` button
  38713. */
  38714. buttonBack: number;
  38715. /**
  38716. * Gets the value of the `Left` button
  38717. */
  38718. /**
  38719. * Sets the value of the `Left` button
  38720. */
  38721. buttonLB: number;
  38722. /**
  38723. * Gets the value of the `Right` button
  38724. */
  38725. /**
  38726. * Sets the value of the `Right` button
  38727. */
  38728. buttonRB: number;
  38729. /**
  38730. * Gets the value of the Left joystick
  38731. */
  38732. /**
  38733. * Sets the value of the Left joystick
  38734. */
  38735. buttonLeftStick: number;
  38736. /**
  38737. * Gets the value of the Right joystick
  38738. */
  38739. /**
  38740. * Sets the value of the Right joystick
  38741. */
  38742. buttonRightStick: number;
  38743. /**
  38744. * Gets the value of D-pad up
  38745. */
  38746. /**
  38747. * Sets the value of D-pad up
  38748. */
  38749. dPadUp: number;
  38750. /**
  38751. * Gets the value of D-pad down
  38752. */
  38753. /**
  38754. * Sets the value of D-pad down
  38755. */
  38756. dPadDown: number;
  38757. /**
  38758. * Gets the value of D-pad left
  38759. */
  38760. /**
  38761. * Sets the value of D-pad left
  38762. */
  38763. dPadLeft: number;
  38764. /**
  38765. * Gets the value of D-pad right
  38766. */
  38767. /**
  38768. * Sets the value of D-pad right
  38769. */
  38770. dPadRight: number;
  38771. /**
  38772. * Force the gamepad to synchronize with device values
  38773. */
  38774. update(): void;
  38775. /**
  38776. * Disposes the gamepad
  38777. */
  38778. dispose(): void;
  38779. }
  38780. }
  38781. declare module BABYLON {
  38782. /**
  38783. * Defines supported buttons for DualShock compatible gamepads
  38784. */
  38785. export enum DualShockButton {
  38786. /** Cross */
  38787. Cross = 0,
  38788. /** Circle */
  38789. Circle = 1,
  38790. /** Square */
  38791. Square = 2,
  38792. /** Triangle */
  38793. Triangle = 3,
  38794. /** Options */
  38795. Options = 4,
  38796. /** Share */
  38797. Share = 5,
  38798. /** L1 */
  38799. L1 = 6,
  38800. /** R1 */
  38801. R1 = 7,
  38802. /** Left stick */
  38803. LeftStick = 8,
  38804. /** Right stick */
  38805. RightStick = 9
  38806. }
  38807. /** Defines values for DualShock DPad */
  38808. export enum DualShockDpad {
  38809. /** Up */
  38810. Up = 0,
  38811. /** Down */
  38812. Down = 1,
  38813. /** Left */
  38814. Left = 2,
  38815. /** Right */
  38816. Right = 3
  38817. }
  38818. /**
  38819. * Defines a DualShock gamepad
  38820. */
  38821. export class DualShockPad extends Gamepad {
  38822. private _leftTrigger;
  38823. private _rightTrigger;
  38824. private _onlefttriggerchanged;
  38825. private _onrighttriggerchanged;
  38826. private _onbuttondown;
  38827. private _onbuttonup;
  38828. private _ondpaddown;
  38829. private _ondpadup;
  38830. /** Observable raised when a button is pressed */
  38831. onButtonDownObservable: Observable<DualShockButton>;
  38832. /** Observable raised when a button is released */
  38833. onButtonUpObservable: Observable<DualShockButton>;
  38834. /** Observable raised when a pad is pressed */
  38835. onPadDownObservable: Observable<DualShockDpad>;
  38836. /** Observable raised when a pad is released */
  38837. onPadUpObservable: Observable<DualShockDpad>;
  38838. private _buttonCross;
  38839. private _buttonCircle;
  38840. private _buttonSquare;
  38841. private _buttonTriangle;
  38842. private _buttonShare;
  38843. private _buttonOptions;
  38844. private _buttonL1;
  38845. private _buttonR1;
  38846. private _buttonLeftStick;
  38847. private _buttonRightStick;
  38848. private _dPadUp;
  38849. private _dPadDown;
  38850. private _dPadLeft;
  38851. private _dPadRight;
  38852. /**
  38853. * Creates a new DualShock gamepad object
  38854. * @param id defines the id of this gamepad
  38855. * @param index defines its index
  38856. * @param gamepad defines the internal HTML gamepad object
  38857. */
  38858. constructor(id: string, index: number, gamepad: any);
  38859. /**
  38860. * Defines the callback to call when left trigger is pressed
  38861. * @param callback defines the callback to use
  38862. */
  38863. onlefttriggerchanged(callback: (value: number) => void): void;
  38864. /**
  38865. * Defines the callback to call when right trigger is pressed
  38866. * @param callback defines the callback to use
  38867. */
  38868. onrighttriggerchanged(callback: (value: number) => void): void;
  38869. /**
  38870. * Gets the left trigger value
  38871. */
  38872. /**
  38873. * Sets the left trigger value
  38874. */
  38875. leftTrigger: number;
  38876. /**
  38877. * Gets the right trigger value
  38878. */
  38879. /**
  38880. * Sets the right trigger value
  38881. */
  38882. rightTrigger: number;
  38883. /**
  38884. * Defines the callback to call when a button is pressed
  38885. * @param callback defines the callback to use
  38886. */
  38887. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38888. /**
  38889. * Defines the callback to call when a button is released
  38890. * @param callback defines the callback to use
  38891. */
  38892. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38893. /**
  38894. * Defines the callback to call when a pad is pressed
  38895. * @param callback defines the callback to use
  38896. */
  38897. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38898. /**
  38899. * Defines the callback to call when a pad is released
  38900. * @param callback defines the callback to use
  38901. */
  38902. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38903. private _setButtonValue;
  38904. private _setDPadValue;
  38905. /**
  38906. * Gets the value of the `Cross` button
  38907. */
  38908. /**
  38909. * Sets the value of the `Cross` button
  38910. */
  38911. buttonCross: number;
  38912. /**
  38913. * Gets the value of the `Circle` button
  38914. */
  38915. /**
  38916. * Sets the value of the `Circle` button
  38917. */
  38918. buttonCircle: number;
  38919. /**
  38920. * Gets the value of the `Square` button
  38921. */
  38922. /**
  38923. * Sets the value of the `Square` button
  38924. */
  38925. buttonSquare: number;
  38926. /**
  38927. * Gets the value of the `Triangle` button
  38928. */
  38929. /**
  38930. * Sets the value of the `Triangle` button
  38931. */
  38932. buttonTriangle: number;
  38933. /**
  38934. * Gets the value of the `Options` button
  38935. */
  38936. /**
  38937. * Sets the value of the `Options` button
  38938. */
  38939. buttonOptions: number;
  38940. /**
  38941. * Gets the value of the `Share` button
  38942. */
  38943. /**
  38944. * Sets the value of the `Share` button
  38945. */
  38946. buttonShare: number;
  38947. /**
  38948. * Gets the value of the `L1` button
  38949. */
  38950. /**
  38951. * Sets the value of the `L1` button
  38952. */
  38953. buttonL1: number;
  38954. /**
  38955. * Gets the value of the `R1` button
  38956. */
  38957. /**
  38958. * Sets the value of the `R1` button
  38959. */
  38960. buttonR1: number;
  38961. /**
  38962. * Gets the value of the Left joystick
  38963. */
  38964. /**
  38965. * Sets the value of the Left joystick
  38966. */
  38967. buttonLeftStick: number;
  38968. /**
  38969. * Gets the value of the Right joystick
  38970. */
  38971. /**
  38972. * Sets the value of the Right joystick
  38973. */
  38974. buttonRightStick: number;
  38975. /**
  38976. * Gets the value of D-pad up
  38977. */
  38978. /**
  38979. * Sets the value of D-pad up
  38980. */
  38981. dPadUp: number;
  38982. /**
  38983. * Gets the value of D-pad down
  38984. */
  38985. /**
  38986. * Sets the value of D-pad down
  38987. */
  38988. dPadDown: number;
  38989. /**
  38990. * Gets the value of D-pad left
  38991. */
  38992. /**
  38993. * Sets the value of D-pad left
  38994. */
  38995. dPadLeft: number;
  38996. /**
  38997. * Gets the value of D-pad right
  38998. */
  38999. /**
  39000. * Sets the value of D-pad right
  39001. */
  39002. dPadRight: number;
  39003. /**
  39004. * Force the gamepad to synchronize with device values
  39005. */
  39006. update(): void;
  39007. /**
  39008. * Disposes the gamepad
  39009. */
  39010. dispose(): void;
  39011. }
  39012. }
  39013. declare module BABYLON {
  39014. /**
  39015. * Manager for handling gamepads
  39016. */
  39017. export class GamepadManager {
  39018. private _scene?;
  39019. private _babylonGamepads;
  39020. private _oneGamepadConnected;
  39021. /** @hidden */
  39022. _isMonitoring: boolean;
  39023. private _gamepadEventSupported;
  39024. private _gamepadSupport;
  39025. /**
  39026. * observable to be triggered when the gamepad controller has been connected
  39027. */
  39028. onGamepadConnectedObservable: Observable<Gamepad>;
  39029. /**
  39030. * observable to be triggered when the gamepad controller has been disconnected
  39031. */
  39032. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39033. private _onGamepadConnectedEvent;
  39034. private _onGamepadDisconnectedEvent;
  39035. /**
  39036. * Initializes the gamepad manager
  39037. * @param _scene BabylonJS scene
  39038. */
  39039. constructor(_scene?: Scene | undefined);
  39040. /**
  39041. * The gamepads in the game pad manager
  39042. */
  39043. readonly gamepads: Gamepad[];
  39044. /**
  39045. * Get the gamepad controllers based on type
  39046. * @param type The type of gamepad controller
  39047. * @returns Nullable gamepad
  39048. */
  39049. getGamepadByType(type?: number): Nullable<Gamepad>;
  39050. /**
  39051. * Disposes the gamepad manager
  39052. */
  39053. dispose(): void;
  39054. private _addNewGamepad;
  39055. private _startMonitoringGamepads;
  39056. private _stopMonitoringGamepads;
  39057. /** @hidden */
  39058. _checkGamepadsStatus(): void;
  39059. private _updateGamepadObjects;
  39060. }
  39061. }
  39062. declare module BABYLON {
  39063. interface Scene {
  39064. /** @hidden */
  39065. _gamepadManager: Nullable<GamepadManager>;
  39066. /**
  39067. * Gets the gamepad manager associated with the scene
  39068. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39069. */
  39070. gamepadManager: GamepadManager;
  39071. }
  39072. /**
  39073. * Interface representing a free camera inputs manager
  39074. */
  39075. interface FreeCameraInputsManager {
  39076. /**
  39077. * Adds gamepad input support to the FreeCameraInputsManager.
  39078. * @returns the FreeCameraInputsManager
  39079. */
  39080. addGamepad(): FreeCameraInputsManager;
  39081. }
  39082. /**
  39083. * Interface representing an arc rotate camera inputs manager
  39084. */
  39085. interface ArcRotateCameraInputsManager {
  39086. /**
  39087. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39088. * @returns the camera inputs manager
  39089. */
  39090. addGamepad(): ArcRotateCameraInputsManager;
  39091. }
  39092. /**
  39093. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39094. */
  39095. export class GamepadSystemSceneComponent implements ISceneComponent {
  39096. /**
  39097. * The component name helpfull to identify the component in the list of scene components.
  39098. */
  39099. readonly name: string;
  39100. /**
  39101. * The scene the component belongs to.
  39102. */
  39103. scene: Scene;
  39104. /**
  39105. * Creates a new instance of the component for the given scene
  39106. * @param scene Defines the scene to register the component in
  39107. */
  39108. constructor(scene: Scene);
  39109. /**
  39110. * Registers the component in a given scene
  39111. */
  39112. register(): void;
  39113. /**
  39114. * Rebuilds the elements related to this component in case of
  39115. * context lost for instance.
  39116. */
  39117. rebuild(): void;
  39118. /**
  39119. * Disposes the component and the associated ressources
  39120. */
  39121. dispose(): void;
  39122. private _beforeCameraUpdate;
  39123. }
  39124. }
  39125. declare module BABYLON {
  39126. /**
  39127. * 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,
  39128. * which still works and will still be found in many Playgrounds.
  39129. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39130. */
  39131. export class UniversalCamera extends TouchCamera {
  39132. /**
  39133. * Defines the gamepad rotation sensiblity.
  39134. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39135. */
  39136. gamepadAngularSensibility: number;
  39137. /**
  39138. * Defines the gamepad move sensiblity.
  39139. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39140. */
  39141. gamepadMoveSensibility: number;
  39142. /**
  39143. * 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,
  39144. * which still works and will still be found in many Playgrounds.
  39145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39146. * @param name Define the name of the camera in the scene
  39147. * @param position Define the start position of the camera in the scene
  39148. * @param scene Define the scene the camera belongs to
  39149. */
  39150. constructor(name: string, position: Vector3, scene: Scene);
  39151. /**
  39152. * Gets the current object class name.
  39153. * @return the class name
  39154. */
  39155. getClassName(): string;
  39156. }
  39157. }
  39158. declare module BABYLON {
  39159. /**
  39160. * This represents a FPS type of camera. This is only here for back compat purpose.
  39161. * Please use the UniversalCamera instead as both are identical.
  39162. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39163. */
  39164. export class GamepadCamera extends UniversalCamera {
  39165. /**
  39166. * Instantiates a new Gamepad Camera
  39167. * This represents a FPS type of camera. This is only here for back compat purpose.
  39168. * Please use the UniversalCamera instead as both are identical.
  39169. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39170. * @param name Define the name of the camera in the scene
  39171. * @param position Define the start position of the camera in the scene
  39172. * @param scene Define the scene the camera belongs to
  39173. */
  39174. constructor(name: string, position: Vector3, scene: Scene);
  39175. /**
  39176. * Gets the current object class name.
  39177. * @return the class name
  39178. */
  39179. getClassName(): string;
  39180. }
  39181. }
  39182. declare module BABYLON {
  39183. /** @hidden */
  39184. export var passPixelShader: {
  39185. name: string;
  39186. shader: string;
  39187. };
  39188. }
  39189. declare module BABYLON {
  39190. /** @hidden */
  39191. export var passCubePixelShader: {
  39192. name: string;
  39193. shader: string;
  39194. };
  39195. }
  39196. declare module BABYLON {
  39197. /**
  39198. * PassPostProcess which produces an output the same as it's input
  39199. */
  39200. export class PassPostProcess extends PostProcess {
  39201. /**
  39202. * Creates the PassPostProcess
  39203. * @param name The name of the effect.
  39204. * @param options The required width/height ratio to downsize to before computing the render pass.
  39205. * @param camera The camera to apply the render pass to.
  39206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39207. * @param engine The engine which the post process will be applied. (default: current engine)
  39208. * @param reusable If the post process can be reused on the same frame. (default: false)
  39209. * @param textureType The type of texture to be used when performing the post processing.
  39210. * @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)
  39211. */
  39212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39213. }
  39214. /**
  39215. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39216. */
  39217. export class PassCubePostProcess extends PostProcess {
  39218. private _face;
  39219. /**
  39220. * Gets or sets the cube face to display.
  39221. * * 0 is +X
  39222. * * 1 is -X
  39223. * * 2 is +Y
  39224. * * 3 is -Y
  39225. * * 4 is +Z
  39226. * * 5 is -Z
  39227. */
  39228. face: number;
  39229. /**
  39230. * Creates the PassCubePostProcess
  39231. * @param name The name of the effect.
  39232. * @param options The required width/height ratio to downsize to before computing the render pass.
  39233. * @param camera The camera to apply the render pass to.
  39234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39235. * @param engine The engine which the post process will be applied. (default: current engine)
  39236. * @param reusable If the post process can be reused on the same frame. (default: false)
  39237. * @param textureType The type of texture to be used when performing the post processing.
  39238. * @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)
  39239. */
  39240. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39241. }
  39242. }
  39243. declare module BABYLON {
  39244. /** @hidden */
  39245. export var anaglyphPixelShader: {
  39246. name: string;
  39247. shader: string;
  39248. };
  39249. }
  39250. declare module BABYLON {
  39251. /**
  39252. * Postprocess used to generate anaglyphic rendering
  39253. */
  39254. export class AnaglyphPostProcess extends PostProcess {
  39255. private _passedProcess;
  39256. /**
  39257. * Creates a new AnaglyphPostProcess
  39258. * @param name defines postprocess name
  39259. * @param options defines creation options or target ratio scale
  39260. * @param rigCameras defines cameras using this postprocess
  39261. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39262. * @param engine defines hosting engine
  39263. * @param reusable defines if the postprocess will be reused multiple times per frame
  39264. */
  39265. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39266. }
  39267. }
  39268. declare module BABYLON {
  39269. /**
  39270. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39271. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39272. */
  39273. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39274. /**
  39275. * Creates a new AnaglyphArcRotateCamera
  39276. * @param name defines camera name
  39277. * @param alpha defines alpha angle (in radians)
  39278. * @param beta defines beta angle (in radians)
  39279. * @param radius defines radius
  39280. * @param target defines camera target
  39281. * @param interaxialDistance defines distance between each color axis
  39282. * @param scene defines the hosting scene
  39283. */
  39284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39285. /**
  39286. * Gets camera class name
  39287. * @returns AnaglyphArcRotateCamera
  39288. */
  39289. getClassName(): string;
  39290. }
  39291. }
  39292. declare module BABYLON {
  39293. /**
  39294. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39295. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39296. */
  39297. export class AnaglyphFreeCamera extends FreeCamera {
  39298. /**
  39299. * Creates a new AnaglyphFreeCamera
  39300. * @param name defines camera name
  39301. * @param position defines initial position
  39302. * @param interaxialDistance defines distance between each color axis
  39303. * @param scene defines the hosting scene
  39304. */
  39305. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39306. /**
  39307. * Gets camera class name
  39308. * @returns AnaglyphFreeCamera
  39309. */
  39310. getClassName(): string;
  39311. }
  39312. }
  39313. declare module BABYLON {
  39314. /**
  39315. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39316. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39317. */
  39318. export class AnaglyphGamepadCamera extends GamepadCamera {
  39319. /**
  39320. * Creates a new AnaglyphGamepadCamera
  39321. * @param name defines camera name
  39322. * @param position defines initial position
  39323. * @param interaxialDistance defines distance between each color axis
  39324. * @param scene defines the hosting scene
  39325. */
  39326. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39327. /**
  39328. * Gets camera class name
  39329. * @returns AnaglyphGamepadCamera
  39330. */
  39331. getClassName(): string;
  39332. }
  39333. }
  39334. declare module BABYLON {
  39335. /**
  39336. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39337. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39338. */
  39339. export class AnaglyphUniversalCamera extends UniversalCamera {
  39340. /**
  39341. * Creates a new AnaglyphUniversalCamera
  39342. * @param name defines camera name
  39343. * @param position defines initial position
  39344. * @param interaxialDistance defines distance between each color axis
  39345. * @param scene defines the hosting scene
  39346. */
  39347. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39348. /**
  39349. * Gets camera class name
  39350. * @returns AnaglyphUniversalCamera
  39351. */
  39352. getClassName(): string;
  39353. }
  39354. }
  39355. declare module BABYLON {
  39356. /** @hidden */
  39357. export var stereoscopicInterlacePixelShader: {
  39358. name: string;
  39359. shader: string;
  39360. };
  39361. }
  39362. declare module BABYLON {
  39363. /**
  39364. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39365. */
  39366. export class StereoscopicInterlacePostProcess extends PostProcess {
  39367. private _stepSize;
  39368. private _passedProcess;
  39369. /**
  39370. * Initializes a StereoscopicInterlacePostProcess
  39371. * @param name The name of the effect.
  39372. * @param rigCameras The rig cameras to be appled to the post process
  39373. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39374. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39375. * @param engine The engine which the post process will be applied. (default: current engine)
  39376. * @param reusable If the post process can be reused on the same frame. (default: false)
  39377. */
  39378. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39379. }
  39380. }
  39381. declare module BABYLON {
  39382. /**
  39383. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39384. * @see http://doc.babylonjs.com/features/cameras
  39385. */
  39386. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39387. /**
  39388. * Creates a new StereoscopicArcRotateCamera
  39389. * @param name defines camera name
  39390. * @param alpha defines alpha angle (in radians)
  39391. * @param beta defines beta angle (in radians)
  39392. * @param radius defines radius
  39393. * @param target defines camera target
  39394. * @param interaxialDistance defines distance between each color axis
  39395. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39396. * @param scene defines the hosting scene
  39397. */
  39398. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39399. /**
  39400. * Gets camera class name
  39401. * @returns StereoscopicArcRotateCamera
  39402. */
  39403. getClassName(): string;
  39404. }
  39405. }
  39406. declare module BABYLON {
  39407. /**
  39408. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39409. * @see http://doc.babylonjs.com/features/cameras
  39410. */
  39411. export class StereoscopicFreeCamera extends FreeCamera {
  39412. /**
  39413. * Creates a new StereoscopicFreeCamera
  39414. * @param name defines camera name
  39415. * @param position defines initial position
  39416. * @param interaxialDistance defines distance between each color axis
  39417. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39418. * @param scene defines the hosting scene
  39419. */
  39420. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39421. /**
  39422. * Gets camera class name
  39423. * @returns StereoscopicFreeCamera
  39424. */
  39425. getClassName(): string;
  39426. }
  39427. }
  39428. declare module BABYLON {
  39429. /**
  39430. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39431. * @see http://doc.babylonjs.com/features/cameras
  39432. */
  39433. export class StereoscopicGamepadCamera extends GamepadCamera {
  39434. /**
  39435. * Creates a new StereoscopicGamepadCamera
  39436. * @param name defines camera name
  39437. * @param position defines initial position
  39438. * @param interaxialDistance defines distance between each color axis
  39439. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39440. * @param scene defines the hosting scene
  39441. */
  39442. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39443. /**
  39444. * Gets camera class name
  39445. * @returns StereoscopicGamepadCamera
  39446. */
  39447. getClassName(): string;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /**
  39452. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39453. * @see http://doc.babylonjs.com/features/cameras
  39454. */
  39455. export class StereoscopicUniversalCamera extends UniversalCamera {
  39456. /**
  39457. * Creates a new StereoscopicUniversalCamera
  39458. * @param name defines camera name
  39459. * @param position defines initial position
  39460. * @param interaxialDistance defines distance between each color axis
  39461. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39462. * @param scene defines the hosting scene
  39463. */
  39464. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39465. /**
  39466. * Gets camera class name
  39467. * @returns StereoscopicUniversalCamera
  39468. */
  39469. getClassName(): string;
  39470. }
  39471. }
  39472. declare module BABYLON {
  39473. /**
  39474. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39475. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39476. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39477. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39478. */
  39479. export class VirtualJoysticksCamera extends FreeCamera {
  39480. /**
  39481. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39482. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39483. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39484. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39485. * @param name Define the name of the camera in the scene
  39486. * @param position Define the start position of the camera in the scene
  39487. * @param scene Define the scene the camera belongs to
  39488. */
  39489. constructor(name: string, position: Vector3, scene: Scene);
  39490. /**
  39491. * Gets the current object class name.
  39492. * @return the class name
  39493. */
  39494. getClassName(): string;
  39495. }
  39496. }
  39497. declare module BABYLON {
  39498. /**
  39499. * This represents all the required metrics to create a VR camera.
  39500. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39501. */
  39502. export class VRCameraMetrics {
  39503. /**
  39504. * Define the horizontal resolution off the screen.
  39505. */
  39506. hResolution: number;
  39507. /**
  39508. * Define the vertical resolution off the screen.
  39509. */
  39510. vResolution: number;
  39511. /**
  39512. * Define the horizontal screen size.
  39513. */
  39514. hScreenSize: number;
  39515. /**
  39516. * Define the vertical screen size.
  39517. */
  39518. vScreenSize: number;
  39519. /**
  39520. * Define the vertical screen center position.
  39521. */
  39522. vScreenCenter: number;
  39523. /**
  39524. * Define the distance of the eyes to the screen.
  39525. */
  39526. eyeToScreenDistance: number;
  39527. /**
  39528. * Define the distance between both lenses
  39529. */
  39530. lensSeparationDistance: number;
  39531. /**
  39532. * Define the distance between both viewer's eyes.
  39533. */
  39534. interpupillaryDistance: number;
  39535. /**
  39536. * Define the distortion factor of the VR postprocess.
  39537. * Please, touch with care.
  39538. */
  39539. distortionK: number[];
  39540. /**
  39541. * Define the chromatic aberration correction factors for the VR post process.
  39542. */
  39543. chromaAbCorrection: number[];
  39544. /**
  39545. * Define the scale factor of the post process.
  39546. * The smaller the better but the slower.
  39547. */
  39548. postProcessScaleFactor: number;
  39549. /**
  39550. * Define an offset for the lens center.
  39551. */
  39552. lensCenterOffset: number;
  39553. /**
  39554. * Define if the current vr camera should compensate the distortion of the lense or not.
  39555. */
  39556. compensateDistortion: boolean;
  39557. /**
  39558. * Defines if multiview should be enabled when rendering (Default: false)
  39559. */
  39560. multiviewEnabled: boolean;
  39561. /**
  39562. * Gets the rendering aspect ratio based on the provided resolutions.
  39563. */
  39564. readonly aspectRatio: number;
  39565. /**
  39566. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39567. */
  39568. readonly aspectRatioFov: number;
  39569. /**
  39570. * @hidden
  39571. */
  39572. readonly leftHMatrix: Matrix;
  39573. /**
  39574. * @hidden
  39575. */
  39576. readonly rightHMatrix: Matrix;
  39577. /**
  39578. * @hidden
  39579. */
  39580. readonly leftPreViewMatrix: Matrix;
  39581. /**
  39582. * @hidden
  39583. */
  39584. readonly rightPreViewMatrix: Matrix;
  39585. /**
  39586. * Get the default VRMetrics based on the most generic setup.
  39587. * @returns the default vr metrics
  39588. */
  39589. static GetDefault(): VRCameraMetrics;
  39590. }
  39591. }
  39592. declare module BABYLON {
  39593. /** @hidden */
  39594. export var vrDistortionCorrectionPixelShader: {
  39595. name: string;
  39596. shader: string;
  39597. };
  39598. }
  39599. declare module BABYLON {
  39600. /**
  39601. * VRDistortionCorrectionPostProcess used for mobile VR
  39602. */
  39603. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39604. private _isRightEye;
  39605. private _distortionFactors;
  39606. private _postProcessScaleFactor;
  39607. private _lensCenterOffset;
  39608. private _scaleIn;
  39609. private _scaleFactor;
  39610. private _lensCenter;
  39611. /**
  39612. * Initializes the VRDistortionCorrectionPostProcess
  39613. * @param name The name of the effect.
  39614. * @param camera The camera to apply the render pass to.
  39615. * @param isRightEye If this is for the right eye distortion
  39616. * @param vrMetrics All the required metrics for the VR camera
  39617. */
  39618. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39619. }
  39620. }
  39621. declare module BABYLON {
  39622. /**
  39623. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39624. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39625. */
  39626. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39627. /**
  39628. * Creates a new VRDeviceOrientationArcRotateCamera
  39629. * @param name defines camera name
  39630. * @param alpha defines the camera rotation along the logitudinal axis
  39631. * @param beta defines the camera rotation along the latitudinal axis
  39632. * @param radius defines the camera distance from its target
  39633. * @param target defines the camera target
  39634. * @param scene defines the scene the camera belongs to
  39635. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39636. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39637. */
  39638. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39639. /**
  39640. * Gets camera class name
  39641. * @returns VRDeviceOrientationArcRotateCamera
  39642. */
  39643. getClassName(): string;
  39644. }
  39645. }
  39646. declare module BABYLON {
  39647. /**
  39648. * Camera used to simulate VR rendering (based on FreeCamera)
  39649. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39650. */
  39651. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39652. /**
  39653. * Creates a new VRDeviceOrientationFreeCamera
  39654. * @param name defines camera name
  39655. * @param position defines the start position of the camera
  39656. * @param scene defines the scene the camera belongs to
  39657. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39658. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39659. */
  39660. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39661. /**
  39662. * Gets camera class name
  39663. * @returns VRDeviceOrientationFreeCamera
  39664. */
  39665. getClassName(): string;
  39666. }
  39667. }
  39668. declare module BABYLON {
  39669. /**
  39670. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39671. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39672. */
  39673. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39674. /**
  39675. * Creates a new VRDeviceOrientationGamepadCamera
  39676. * @param name defines camera name
  39677. * @param position defines the start position of the camera
  39678. * @param scene defines the scene the camera belongs to
  39679. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39681. */
  39682. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39683. /**
  39684. * Gets camera class name
  39685. * @returns VRDeviceOrientationGamepadCamera
  39686. */
  39687. getClassName(): string;
  39688. }
  39689. }
  39690. declare module BABYLON {
  39691. /**
  39692. * Base class of materials working in push mode in babylon JS
  39693. * @hidden
  39694. */
  39695. export class PushMaterial extends Material {
  39696. protected _activeEffect: Effect;
  39697. protected _normalMatrix: Matrix;
  39698. /**
  39699. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39700. * This means that the material can keep using a previous shader while a new one is being compiled.
  39701. * This is mostly used when shader parallel compilation is supported (true by default)
  39702. */
  39703. allowShaderHotSwapping: boolean;
  39704. constructor(name: string, scene: Scene);
  39705. getEffect(): Effect;
  39706. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39707. /**
  39708. * Binds the given world matrix to the active effect
  39709. *
  39710. * @param world the matrix to bind
  39711. */
  39712. bindOnlyWorldMatrix(world: Matrix): void;
  39713. /**
  39714. * Binds the given normal matrix to the active effect
  39715. *
  39716. * @param normalMatrix the matrix to bind
  39717. */
  39718. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39719. bind(world: Matrix, mesh?: Mesh): void;
  39720. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39721. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39722. }
  39723. }
  39724. declare module BABYLON {
  39725. /**
  39726. * This groups all the flags used to control the materials channel.
  39727. */
  39728. export class MaterialFlags {
  39729. private static _DiffuseTextureEnabled;
  39730. /**
  39731. * Are diffuse textures enabled in the application.
  39732. */
  39733. static DiffuseTextureEnabled: boolean;
  39734. private static _AmbientTextureEnabled;
  39735. /**
  39736. * Are ambient textures enabled in the application.
  39737. */
  39738. static AmbientTextureEnabled: boolean;
  39739. private static _OpacityTextureEnabled;
  39740. /**
  39741. * Are opacity textures enabled in the application.
  39742. */
  39743. static OpacityTextureEnabled: boolean;
  39744. private static _ReflectionTextureEnabled;
  39745. /**
  39746. * Are reflection textures enabled in the application.
  39747. */
  39748. static ReflectionTextureEnabled: boolean;
  39749. private static _EmissiveTextureEnabled;
  39750. /**
  39751. * Are emissive textures enabled in the application.
  39752. */
  39753. static EmissiveTextureEnabled: boolean;
  39754. private static _SpecularTextureEnabled;
  39755. /**
  39756. * Are specular textures enabled in the application.
  39757. */
  39758. static SpecularTextureEnabled: boolean;
  39759. private static _BumpTextureEnabled;
  39760. /**
  39761. * Are bump textures enabled in the application.
  39762. */
  39763. static BumpTextureEnabled: boolean;
  39764. private static _LightmapTextureEnabled;
  39765. /**
  39766. * Are lightmap textures enabled in the application.
  39767. */
  39768. static LightmapTextureEnabled: boolean;
  39769. private static _RefractionTextureEnabled;
  39770. /**
  39771. * Are refraction textures enabled in the application.
  39772. */
  39773. static RefractionTextureEnabled: boolean;
  39774. private static _ColorGradingTextureEnabled;
  39775. /**
  39776. * Are color grading textures enabled in the application.
  39777. */
  39778. static ColorGradingTextureEnabled: boolean;
  39779. private static _FresnelEnabled;
  39780. /**
  39781. * Are fresnels enabled in the application.
  39782. */
  39783. static FresnelEnabled: boolean;
  39784. private static _ClearCoatTextureEnabled;
  39785. /**
  39786. * Are clear coat textures enabled in the application.
  39787. */
  39788. static ClearCoatTextureEnabled: boolean;
  39789. private static _ClearCoatBumpTextureEnabled;
  39790. /**
  39791. * Are clear coat bump textures enabled in the application.
  39792. */
  39793. static ClearCoatBumpTextureEnabled: boolean;
  39794. private static _ClearCoatTintTextureEnabled;
  39795. /**
  39796. * Are clear coat tint textures enabled in the application.
  39797. */
  39798. static ClearCoatTintTextureEnabled: boolean;
  39799. private static _SheenTextureEnabled;
  39800. /**
  39801. * Are sheen textures enabled in the application.
  39802. */
  39803. static SheenTextureEnabled: boolean;
  39804. private static _AnisotropicTextureEnabled;
  39805. /**
  39806. * Are anisotropic textures enabled in the application.
  39807. */
  39808. static AnisotropicTextureEnabled: boolean;
  39809. private static _ThicknessTextureEnabled;
  39810. /**
  39811. * Are thickness textures enabled in the application.
  39812. */
  39813. static ThicknessTextureEnabled: boolean;
  39814. }
  39815. }
  39816. declare module BABYLON {
  39817. /** @hidden */
  39818. export var defaultFragmentDeclaration: {
  39819. name: string;
  39820. shader: string;
  39821. };
  39822. }
  39823. declare module BABYLON {
  39824. /** @hidden */
  39825. export var defaultUboDeclaration: {
  39826. name: string;
  39827. shader: string;
  39828. };
  39829. }
  39830. declare module BABYLON {
  39831. /** @hidden */
  39832. export var lightFragmentDeclaration: {
  39833. name: string;
  39834. shader: string;
  39835. };
  39836. }
  39837. declare module BABYLON {
  39838. /** @hidden */
  39839. export var lightUboDeclaration: {
  39840. name: string;
  39841. shader: string;
  39842. };
  39843. }
  39844. declare module BABYLON {
  39845. /** @hidden */
  39846. export var lightsFragmentFunctions: {
  39847. name: string;
  39848. shader: string;
  39849. };
  39850. }
  39851. declare module BABYLON {
  39852. /** @hidden */
  39853. export var shadowsFragmentFunctions: {
  39854. name: string;
  39855. shader: string;
  39856. };
  39857. }
  39858. declare module BABYLON {
  39859. /** @hidden */
  39860. export var fresnelFunction: {
  39861. name: string;
  39862. shader: string;
  39863. };
  39864. }
  39865. declare module BABYLON {
  39866. /** @hidden */
  39867. export var reflectionFunction: {
  39868. name: string;
  39869. shader: string;
  39870. };
  39871. }
  39872. declare module BABYLON {
  39873. /** @hidden */
  39874. export var bumpFragmentFunctions: {
  39875. name: string;
  39876. shader: string;
  39877. };
  39878. }
  39879. declare module BABYLON {
  39880. /** @hidden */
  39881. export var logDepthDeclaration: {
  39882. name: string;
  39883. shader: string;
  39884. };
  39885. }
  39886. declare module BABYLON {
  39887. /** @hidden */
  39888. export var bumpFragment: {
  39889. name: string;
  39890. shader: string;
  39891. };
  39892. }
  39893. declare module BABYLON {
  39894. /** @hidden */
  39895. export var depthPrePass: {
  39896. name: string;
  39897. shader: string;
  39898. };
  39899. }
  39900. declare module BABYLON {
  39901. /** @hidden */
  39902. export var lightFragment: {
  39903. name: string;
  39904. shader: string;
  39905. };
  39906. }
  39907. declare module BABYLON {
  39908. /** @hidden */
  39909. export var logDepthFragment: {
  39910. name: string;
  39911. shader: string;
  39912. };
  39913. }
  39914. declare module BABYLON {
  39915. /** @hidden */
  39916. export var defaultPixelShader: {
  39917. name: string;
  39918. shader: string;
  39919. };
  39920. }
  39921. declare module BABYLON {
  39922. /** @hidden */
  39923. export var defaultVertexDeclaration: {
  39924. name: string;
  39925. shader: string;
  39926. };
  39927. }
  39928. declare module BABYLON {
  39929. /** @hidden */
  39930. export var bumpVertexDeclaration: {
  39931. name: string;
  39932. shader: string;
  39933. };
  39934. }
  39935. declare module BABYLON {
  39936. /** @hidden */
  39937. export var bumpVertex: {
  39938. name: string;
  39939. shader: string;
  39940. };
  39941. }
  39942. declare module BABYLON {
  39943. /** @hidden */
  39944. export var fogVertex: {
  39945. name: string;
  39946. shader: string;
  39947. };
  39948. }
  39949. declare module BABYLON {
  39950. /** @hidden */
  39951. export var shadowsVertex: {
  39952. name: string;
  39953. shader: string;
  39954. };
  39955. }
  39956. declare module BABYLON {
  39957. /** @hidden */
  39958. export var pointCloudVertex: {
  39959. name: string;
  39960. shader: string;
  39961. };
  39962. }
  39963. declare module BABYLON {
  39964. /** @hidden */
  39965. export var logDepthVertex: {
  39966. name: string;
  39967. shader: string;
  39968. };
  39969. }
  39970. declare module BABYLON {
  39971. /** @hidden */
  39972. export var defaultVertexShader: {
  39973. name: string;
  39974. shader: string;
  39975. };
  39976. }
  39977. declare module BABYLON {
  39978. /** @hidden */
  39979. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39980. MAINUV1: boolean;
  39981. MAINUV2: boolean;
  39982. DIFFUSE: boolean;
  39983. DIFFUSEDIRECTUV: number;
  39984. AMBIENT: boolean;
  39985. AMBIENTDIRECTUV: number;
  39986. OPACITY: boolean;
  39987. OPACITYDIRECTUV: number;
  39988. OPACITYRGB: boolean;
  39989. REFLECTION: boolean;
  39990. EMISSIVE: boolean;
  39991. EMISSIVEDIRECTUV: number;
  39992. SPECULAR: boolean;
  39993. SPECULARDIRECTUV: number;
  39994. BUMP: boolean;
  39995. BUMPDIRECTUV: number;
  39996. PARALLAX: boolean;
  39997. PARALLAXOCCLUSION: boolean;
  39998. SPECULAROVERALPHA: boolean;
  39999. CLIPPLANE: boolean;
  40000. CLIPPLANE2: boolean;
  40001. CLIPPLANE3: boolean;
  40002. CLIPPLANE4: boolean;
  40003. ALPHATEST: boolean;
  40004. DEPTHPREPASS: boolean;
  40005. ALPHAFROMDIFFUSE: boolean;
  40006. POINTSIZE: boolean;
  40007. FOG: boolean;
  40008. SPECULARTERM: boolean;
  40009. DIFFUSEFRESNEL: boolean;
  40010. OPACITYFRESNEL: boolean;
  40011. REFLECTIONFRESNEL: boolean;
  40012. REFRACTIONFRESNEL: boolean;
  40013. EMISSIVEFRESNEL: boolean;
  40014. FRESNEL: boolean;
  40015. NORMAL: boolean;
  40016. UV1: boolean;
  40017. UV2: boolean;
  40018. VERTEXCOLOR: boolean;
  40019. VERTEXALPHA: boolean;
  40020. NUM_BONE_INFLUENCERS: number;
  40021. BonesPerMesh: number;
  40022. BONETEXTURE: boolean;
  40023. INSTANCES: boolean;
  40024. GLOSSINESS: boolean;
  40025. ROUGHNESS: boolean;
  40026. EMISSIVEASILLUMINATION: boolean;
  40027. LINKEMISSIVEWITHDIFFUSE: boolean;
  40028. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40029. LIGHTMAP: boolean;
  40030. LIGHTMAPDIRECTUV: number;
  40031. OBJECTSPACE_NORMALMAP: boolean;
  40032. USELIGHTMAPASSHADOWMAP: boolean;
  40033. REFLECTIONMAP_3D: boolean;
  40034. REFLECTIONMAP_SPHERICAL: boolean;
  40035. REFLECTIONMAP_PLANAR: boolean;
  40036. REFLECTIONMAP_CUBIC: boolean;
  40037. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40038. REFLECTIONMAP_PROJECTION: boolean;
  40039. REFLECTIONMAP_SKYBOX: boolean;
  40040. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40041. REFLECTIONMAP_EXPLICIT: boolean;
  40042. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40043. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40044. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40045. INVERTCUBICMAP: boolean;
  40046. LOGARITHMICDEPTH: boolean;
  40047. REFRACTION: boolean;
  40048. REFRACTIONMAP_3D: boolean;
  40049. REFLECTIONOVERALPHA: boolean;
  40050. TWOSIDEDLIGHTING: boolean;
  40051. SHADOWFLOAT: boolean;
  40052. MORPHTARGETS: boolean;
  40053. MORPHTARGETS_NORMAL: boolean;
  40054. MORPHTARGETS_TANGENT: boolean;
  40055. MORPHTARGETS_UV: boolean;
  40056. NUM_MORPH_INFLUENCERS: number;
  40057. NONUNIFORMSCALING: boolean;
  40058. PREMULTIPLYALPHA: boolean;
  40059. IMAGEPROCESSING: boolean;
  40060. VIGNETTE: boolean;
  40061. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40062. VIGNETTEBLENDMODEOPAQUE: boolean;
  40063. TONEMAPPING: boolean;
  40064. TONEMAPPING_ACES: boolean;
  40065. CONTRAST: boolean;
  40066. COLORCURVES: boolean;
  40067. COLORGRADING: boolean;
  40068. COLORGRADING3D: boolean;
  40069. SAMPLER3DGREENDEPTH: boolean;
  40070. SAMPLER3DBGRMAP: boolean;
  40071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40072. MULTIVIEW: boolean;
  40073. /**
  40074. * If the reflection texture on this material is in linear color space
  40075. * @hidden
  40076. */
  40077. IS_REFLECTION_LINEAR: boolean;
  40078. /**
  40079. * If the refraction texture on this material is in linear color space
  40080. * @hidden
  40081. */
  40082. IS_REFRACTION_LINEAR: boolean;
  40083. EXPOSURE: boolean;
  40084. constructor();
  40085. setReflectionMode(modeToEnable: string): void;
  40086. }
  40087. /**
  40088. * This is the default material used in Babylon. It is the best trade off between quality
  40089. * and performances.
  40090. * @see http://doc.babylonjs.com/babylon101/materials
  40091. */
  40092. export class StandardMaterial extends PushMaterial {
  40093. private _diffuseTexture;
  40094. /**
  40095. * The basic texture of the material as viewed under a light.
  40096. */
  40097. diffuseTexture: Nullable<BaseTexture>;
  40098. private _ambientTexture;
  40099. /**
  40100. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40101. */
  40102. ambientTexture: Nullable<BaseTexture>;
  40103. private _opacityTexture;
  40104. /**
  40105. * Define the transparency of the material from a texture.
  40106. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40107. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40108. */
  40109. opacityTexture: Nullable<BaseTexture>;
  40110. private _reflectionTexture;
  40111. /**
  40112. * Define the texture used to display the reflection.
  40113. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40114. */
  40115. reflectionTexture: Nullable<BaseTexture>;
  40116. private _emissiveTexture;
  40117. /**
  40118. * Define texture of the material as if self lit.
  40119. * This will be mixed in the final result even in the absence of light.
  40120. */
  40121. emissiveTexture: Nullable<BaseTexture>;
  40122. private _specularTexture;
  40123. /**
  40124. * Define how the color and intensity of the highlight given by the light in the material.
  40125. */
  40126. specularTexture: Nullable<BaseTexture>;
  40127. private _bumpTexture;
  40128. /**
  40129. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40130. * 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.
  40131. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40132. */
  40133. bumpTexture: Nullable<BaseTexture>;
  40134. private _lightmapTexture;
  40135. /**
  40136. * Complex lighting can be computationally expensive to compute at runtime.
  40137. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40138. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40139. */
  40140. lightmapTexture: Nullable<BaseTexture>;
  40141. private _refractionTexture;
  40142. /**
  40143. * Define the texture used to display the refraction.
  40144. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40145. */
  40146. refractionTexture: Nullable<BaseTexture>;
  40147. /**
  40148. * The color of the material lit by the environmental background lighting.
  40149. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40150. */
  40151. ambientColor: Color3;
  40152. /**
  40153. * The basic color of the material as viewed under a light.
  40154. */
  40155. diffuseColor: Color3;
  40156. /**
  40157. * Define how the color and intensity of the highlight given by the light in the material.
  40158. */
  40159. specularColor: Color3;
  40160. /**
  40161. * Define the color of the material as if self lit.
  40162. * This will be mixed in the final result even in the absence of light.
  40163. */
  40164. emissiveColor: Color3;
  40165. /**
  40166. * Defines how sharp are the highlights in the material.
  40167. * The bigger the value the sharper giving a more glossy feeling to the result.
  40168. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40169. */
  40170. specularPower: number;
  40171. private _useAlphaFromDiffuseTexture;
  40172. /**
  40173. * Does the transparency come from the diffuse texture alpha channel.
  40174. */
  40175. useAlphaFromDiffuseTexture: boolean;
  40176. private _useEmissiveAsIllumination;
  40177. /**
  40178. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40179. */
  40180. useEmissiveAsIllumination: boolean;
  40181. private _linkEmissiveWithDiffuse;
  40182. /**
  40183. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40184. * the emissive level when the final color is close to one.
  40185. */
  40186. linkEmissiveWithDiffuse: boolean;
  40187. private _useSpecularOverAlpha;
  40188. /**
  40189. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40190. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40191. */
  40192. useSpecularOverAlpha: boolean;
  40193. private _useReflectionOverAlpha;
  40194. /**
  40195. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40196. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40197. */
  40198. useReflectionOverAlpha: boolean;
  40199. private _disableLighting;
  40200. /**
  40201. * Does lights from the scene impacts this material.
  40202. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40203. */
  40204. disableLighting: boolean;
  40205. private _useObjectSpaceNormalMap;
  40206. /**
  40207. * Allows using an object space normal map (instead of tangent space).
  40208. */
  40209. useObjectSpaceNormalMap: boolean;
  40210. private _useParallax;
  40211. /**
  40212. * Is parallax enabled or not.
  40213. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40214. */
  40215. useParallax: boolean;
  40216. private _useParallaxOcclusion;
  40217. /**
  40218. * Is parallax occlusion enabled or not.
  40219. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40220. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40221. */
  40222. useParallaxOcclusion: boolean;
  40223. /**
  40224. * 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.
  40225. */
  40226. parallaxScaleBias: number;
  40227. private _roughness;
  40228. /**
  40229. * Helps to define how blurry the reflections should appears in the material.
  40230. */
  40231. roughness: number;
  40232. /**
  40233. * In case of refraction, define the value of the index of refraction.
  40234. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40235. */
  40236. indexOfRefraction: number;
  40237. /**
  40238. * Invert the refraction texture alongside the y axis.
  40239. * It can be useful with procedural textures or probe for instance.
  40240. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40241. */
  40242. invertRefractionY: boolean;
  40243. /**
  40244. * Defines the alpha limits in alpha test mode.
  40245. */
  40246. alphaCutOff: number;
  40247. private _useLightmapAsShadowmap;
  40248. /**
  40249. * In case of light mapping, define whether the map contains light or shadow informations.
  40250. */
  40251. useLightmapAsShadowmap: boolean;
  40252. private _diffuseFresnelParameters;
  40253. /**
  40254. * Define the diffuse fresnel parameters of the material.
  40255. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40256. */
  40257. diffuseFresnelParameters: FresnelParameters;
  40258. private _opacityFresnelParameters;
  40259. /**
  40260. * Define the opacity fresnel parameters of the material.
  40261. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40262. */
  40263. opacityFresnelParameters: FresnelParameters;
  40264. private _reflectionFresnelParameters;
  40265. /**
  40266. * Define the reflection fresnel parameters of the material.
  40267. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40268. */
  40269. reflectionFresnelParameters: FresnelParameters;
  40270. private _refractionFresnelParameters;
  40271. /**
  40272. * Define the refraction fresnel parameters of the material.
  40273. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40274. */
  40275. refractionFresnelParameters: FresnelParameters;
  40276. private _emissiveFresnelParameters;
  40277. /**
  40278. * Define the emissive fresnel parameters of the material.
  40279. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40280. */
  40281. emissiveFresnelParameters: FresnelParameters;
  40282. private _useReflectionFresnelFromSpecular;
  40283. /**
  40284. * If true automatically deducts the fresnels values from the material specularity.
  40285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40286. */
  40287. useReflectionFresnelFromSpecular: boolean;
  40288. private _useGlossinessFromSpecularMapAlpha;
  40289. /**
  40290. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40291. */
  40292. useGlossinessFromSpecularMapAlpha: boolean;
  40293. private _maxSimultaneousLights;
  40294. /**
  40295. * Defines the maximum number of lights that can be used in the material
  40296. */
  40297. maxSimultaneousLights: number;
  40298. private _invertNormalMapX;
  40299. /**
  40300. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40301. */
  40302. invertNormalMapX: boolean;
  40303. private _invertNormalMapY;
  40304. /**
  40305. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40306. */
  40307. invertNormalMapY: boolean;
  40308. private _twoSidedLighting;
  40309. /**
  40310. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40311. */
  40312. twoSidedLighting: boolean;
  40313. /**
  40314. * Default configuration related to image processing available in the standard Material.
  40315. */
  40316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40317. /**
  40318. * Gets the image processing configuration used either in this material.
  40319. */
  40320. /**
  40321. * Sets the Default image processing configuration used either in the this material.
  40322. *
  40323. * If sets to null, the scene one is in use.
  40324. */
  40325. imageProcessingConfiguration: ImageProcessingConfiguration;
  40326. /**
  40327. * Keep track of the image processing observer to allow dispose and replace.
  40328. */
  40329. private _imageProcessingObserver;
  40330. /**
  40331. * Attaches a new image processing configuration to the Standard Material.
  40332. * @param configuration
  40333. */
  40334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40335. /**
  40336. * Gets wether the color curves effect is enabled.
  40337. */
  40338. /**
  40339. * Sets wether the color curves effect is enabled.
  40340. */
  40341. cameraColorCurvesEnabled: boolean;
  40342. /**
  40343. * Gets wether the color grading effect is enabled.
  40344. */
  40345. /**
  40346. * Gets wether the color grading effect is enabled.
  40347. */
  40348. cameraColorGradingEnabled: boolean;
  40349. /**
  40350. * Gets wether tonemapping is enabled or not.
  40351. */
  40352. /**
  40353. * Sets wether tonemapping is enabled or not
  40354. */
  40355. cameraToneMappingEnabled: boolean;
  40356. /**
  40357. * The camera exposure used on this material.
  40358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40359. * This corresponds to a photographic exposure.
  40360. */
  40361. /**
  40362. * The camera exposure used on this material.
  40363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40364. * This corresponds to a photographic exposure.
  40365. */
  40366. cameraExposure: number;
  40367. /**
  40368. * Gets The camera contrast used on this material.
  40369. */
  40370. /**
  40371. * Sets The camera contrast used on this material.
  40372. */
  40373. cameraContrast: number;
  40374. /**
  40375. * Gets the Color Grading 2D Lookup Texture.
  40376. */
  40377. /**
  40378. * Sets the Color Grading 2D Lookup Texture.
  40379. */
  40380. cameraColorGradingTexture: Nullable<BaseTexture>;
  40381. /**
  40382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40384. * 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;
  40385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40386. */
  40387. /**
  40388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40390. * 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;
  40391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40392. */
  40393. cameraColorCurves: Nullable<ColorCurves>;
  40394. /**
  40395. * Custom callback helping to override the default shader used in the material.
  40396. */
  40397. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40398. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40399. protected _worldViewProjectionMatrix: Matrix;
  40400. protected _globalAmbientColor: Color3;
  40401. protected _useLogarithmicDepth: boolean;
  40402. protected _rebuildInParallel: boolean;
  40403. /**
  40404. * Instantiates a new standard material.
  40405. * This is the default material used in Babylon. It is the best trade off between quality
  40406. * and performances.
  40407. * @see http://doc.babylonjs.com/babylon101/materials
  40408. * @param name Define the name of the material in the scene
  40409. * @param scene Define the scene the material belong to
  40410. */
  40411. constructor(name: string, scene: Scene);
  40412. /**
  40413. * Gets a boolean indicating that current material needs to register RTT
  40414. */
  40415. readonly hasRenderTargetTextures: boolean;
  40416. /**
  40417. * Gets the current class name of the material e.g. "StandardMaterial"
  40418. * Mainly use in serialization.
  40419. * @returns the class name
  40420. */
  40421. getClassName(): string;
  40422. /**
  40423. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40424. * You can try switching to logarithmic depth.
  40425. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40426. */
  40427. useLogarithmicDepth: boolean;
  40428. /**
  40429. * Specifies if the material will require alpha blending
  40430. * @returns a boolean specifying if alpha blending is needed
  40431. */
  40432. needAlphaBlending(): boolean;
  40433. /**
  40434. * Specifies if this material should be rendered in alpha test mode
  40435. * @returns a boolean specifying if an alpha test is needed.
  40436. */
  40437. needAlphaTesting(): boolean;
  40438. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40439. /**
  40440. * Get the texture used for alpha test purpose.
  40441. * @returns the diffuse texture in case of the standard material.
  40442. */
  40443. getAlphaTestTexture(): Nullable<BaseTexture>;
  40444. /**
  40445. * Get if the submesh is ready to be used and all its information available.
  40446. * Child classes can use it to update shaders
  40447. * @param mesh defines the mesh to check
  40448. * @param subMesh defines which submesh to check
  40449. * @param useInstances specifies that instances should be used
  40450. * @returns a boolean indicating that the submesh is ready or not
  40451. */
  40452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40453. /**
  40454. * Builds the material UBO layouts.
  40455. * Used internally during the effect preparation.
  40456. */
  40457. buildUniformLayout(): void;
  40458. /**
  40459. * Unbinds the material from the mesh
  40460. */
  40461. unbind(): void;
  40462. /**
  40463. * Binds the submesh to this material by preparing the effect and shader to draw
  40464. * @param world defines the world transformation matrix
  40465. * @param mesh defines the mesh containing the submesh
  40466. * @param subMesh defines the submesh to bind the material to
  40467. */
  40468. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40469. /**
  40470. * Get the list of animatables in the material.
  40471. * @returns the list of animatables object used in the material
  40472. */
  40473. getAnimatables(): IAnimatable[];
  40474. /**
  40475. * Gets the active textures from the material
  40476. * @returns an array of textures
  40477. */
  40478. getActiveTextures(): BaseTexture[];
  40479. /**
  40480. * Specifies if the material uses a texture
  40481. * @param texture defines the texture to check against the material
  40482. * @returns a boolean specifying if the material uses the texture
  40483. */
  40484. hasTexture(texture: BaseTexture): boolean;
  40485. /**
  40486. * Disposes the material
  40487. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40488. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40489. */
  40490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40491. /**
  40492. * Makes a duplicate of the material, and gives it a new name
  40493. * @param name defines the new name for the duplicated material
  40494. * @returns the cloned material
  40495. */
  40496. clone(name: string): StandardMaterial;
  40497. /**
  40498. * Serializes this material in a JSON representation
  40499. * @returns the serialized material object
  40500. */
  40501. serialize(): any;
  40502. /**
  40503. * Creates a standard material from parsed material data
  40504. * @param source defines the JSON representation of the material
  40505. * @param scene defines the hosting scene
  40506. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40507. * @returns a new standard material
  40508. */
  40509. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40510. /**
  40511. * Are diffuse textures enabled in the application.
  40512. */
  40513. static DiffuseTextureEnabled: boolean;
  40514. /**
  40515. * Are ambient textures enabled in the application.
  40516. */
  40517. static AmbientTextureEnabled: boolean;
  40518. /**
  40519. * Are opacity textures enabled in the application.
  40520. */
  40521. static OpacityTextureEnabled: boolean;
  40522. /**
  40523. * Are reflection textures enabled in the application.
  40524. */
  40525. static ReflectionTextureEnabled: boolean;
  40526. /**
  40527. * Are emissive textures enabled in the application.
  40528. */
  40529. static EmissiveTextureEnabled: boolean;
  40530. /**
  40531. * Are specular textures enabled in the application.
  40532. */
  40533. static SpecularTextureEnabled: boolean;
  40534. /**
  40535. * Are bump textures enabled in the application.
  40536. */
  40537. static BumpTextureEnabled: boolean;
  40538. /**
  40539. * Are lightmap textures enabled in the application.
  40540. */
  40541. static LightmapTextureEnabled: boolean;
  40542. /**
  40543. * Are refraction textures enabled in the application.
  40544. */
  40545. static RefractionTextureEnabled: boolean;
  40546. /**
  40547. * Are color grading textures enabled in the application.
  40548. */
  40549. static ColorGradingTextureEnabled: boolean;
  40550. /**
  40551. * Are fresnels enabled in the application.
  40552. */
  40553. static FresnelEnabled: boolean;
  40554. }
  40555. }
  40556. declare module BABYLON {
  40557. /** @hidden */
  40558. export var imageProcessingPixelShader: {
  40559. name: string;
  40560. shader: string;
  40561. };
  40562. }
  40563. declare module BABYLON {
  40564. /**
  40565. * ImageProcessingPostProcess
  40566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40567. */
  40568. export class ImageProcessingPostProcess extends PostProcess {
  40569. /**
  40570. * Default configuration related to image processing available in the PBR Material.
  40571. */
  40572. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40573. /**
  40574. * Gets the image processing configuration used either in this material.
  40575. */
  40576. /**
  40577. * Sets the Default image processing configuration used either in the this material.
  40578. *
  40579. * If sets to null, the scene one is in use.
  40580. */
  40581. imageProcessingConfiguration: ImageProcessingConfiguration;
  40582. /**
  40583. * Keep track of the image processing observer to allow dispose and replace.
  40584. */
  40585. private _imageProcessingObserver;
  40586. /**
  40587. * Attaches a new image processing configuration to the PBR Material.
  40588. * @param configuration
  40589. */
  40590. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40591. /**
  40592. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40593. */
  40594. /**
  40595. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40596. */
  40597. colorCurves: Nullable<ColorCurves>;
  40598. /**
  40599. * Gets wether the color curves effect is enabled.
  40600. */
  40601. /**
  40602. * Sets wether the color curves effect is enabled.
  40603. */
  40604. colorCurvesEnabled: boolean;
  40605. /**
  40606. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40607. */
  40608. /**
  40609. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40610. */
  40611. colorGradingTexture: Nullable<BaseTexture>;
  40612. /**
  40613. * Gets wether the color grading effect is enabled.
  40614. */
  40615. /**
  40616. * Gets wether the color grading effect is enabled.
  40617. */
  40618. colorGradingEnabled: boolean;
  40619. /**
  40620. * Gets exposure used in the effect.
  40621. */
  40622. /**
  40623. * Sets exposure used in the effect.
  40624. */
  40625. exposure: number;
  40626. /**
  40627. * Gets wether tonemapping is enabled or not.
  40628. */
  40629. /**
  40630. * Sets wether tonemapping is enabled or not
  40631. */
  40632. toneMappingEnabled: boolean;
  40633. /**
  40634. * Gets the type of tone mapping effect.
  40635. */
  40636. /**
  40637. * Sets the type of tone mapping effect.
  40638. */
  40639. toneMappingType: number;
  40640. /**
  40641. * Gets contrast used in the effect.
  40642. */
  40643. /**
  40644. * Sets contrast used in the effect.
  40645. */
  40646. contrast: number;
  40647. /**
  40648. * Gets Vignette stretch size.
  40649. */
  40650. /**
  40651. * Sets Vignette stretch size.
  40652. */
  40653. vignetteStretch: number;
  40654. /**
  40655. * Gets Vignette centre X Offset.
  40656. */
  40657. /**
  40658. * Sets Vignette centre X Offset.
  40659. */
  40660. vignetteCentreX: number;
  40661. /**
  40662. * Gets Vignette centre Y Offset.
  40663. */
  40664. /**
  40665. * Sets Vignette centre Y Offset.
  40666. */
  40667. vignetteCentreY: number;
  40668. /**
  40669. * Gets Vignette weight or intensity of the vignette effect.
  40670. */
  40671. /**
  40672. * Sets Vignette weight or intensity of the vignette effect.
  40673. */
  40674. vignetteWeight: number;
  40675. /**
  40676. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40677. * if vignetteEnabled is set to true.
  40678. */
  40679. /**
  40680. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40681. * if vignetteEnabled is set to true.
  40682. */
  40683. vignetteColor: Color4;
  40684. /**
  40685. * Gets Camera field of view used by the Vignette effect.
  40686. */
  40687. /**
  40688. * Sets Camera field of view used by the Vignette effect.
  40689. */
  40690. vignetteCameraFov: number;
  40691. /**
  40692. * Gets the vignette blend mode allowing different kind of effect.
  40693. */
  40694. /**
  40695. * Sets the vignette blend mode allowing different kind of effect.
  40696. */
  40697. vignetteBlendMode: number;
  40698. /**
  40699. * Gets wether the vignette effect is enabled.
  40700. */
  40701. /**
  40702. * Sets wether the vignette effect is enabled.
  40703. */
  40704. vignetteEnabled: boolean;
  40705. private _fromLinearSpace;
  40706. /**
  40707. * Gets wether the input of the processing is in Gamma or Linear Space.
  40708. */
  40709. /**
  40710. * Sets wether the input of the processing is in Gamma or Linear Space.
  40711. */
  40712. fromLinearSpace: boolean;
  40713. /**
  40714. * Defines cache preventing GC.
  40715. */
  40716. private _defines;
  40717. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40718. /**
  40719. * "ImageProcessingPostProcess"
  40720. * @returns "ImageProcessingPostProcess"
  40721. */
  40722. getClassName(): string;
  40723. protected _updateParameters(): void;
  40724. dispose(camera?: Camera): void;
  40725. }
  40726. }
  40727. declare module BABYLON {
  40728. /**
  40729. * Class containing static functions to help procedurally build meshes
  40730. */
  40731. export class GroundBuilder {
  40732. /**
  40733. * Creates a ground mesh
  40734. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40735. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40737. * @param name defines the name of the mesh
  40738. * @param options defines the options used to create the mesh
  40739. * @param scene defines the hosting scene
  40740. * @returns the ground mesh
  40741. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40742. */
  40743. static CreateGround(name: string, options: {
  40744. width?: number;
  40745. height?: number;
  40746. subdivisions?: number;
  40747. subdivisionsX?: number;
  40748. subdivisionsY?: number;
  40749. updatable?: boolean;
  40750. }, scene: any): Mesh;
  40751. /**
  40752. * Creates a tiled ground mesh
  40753. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40754. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40755. * * 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
  40756. * * 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
  40757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40758. * @param name defines the name of the mesh
  40759. * @param options defines the options used to create the mesh
  40760. * @param scene defines the hosting scene
  40761. * @returns the tiled ground mesh
  40762. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40763. */
  40764. static CreateTiledGround(name: string, options: {
  40765. xmin: number;
  40766. zmin: number;
  40767. xmax: number;
  40768. zmax: number;
  40769. subdivisions?: {
  40770. w: number;
  40771. h: number;
  40772. };
  40773. precision?: {
  40774. w: number;
  40775. h: number;
  40776. };
  40777. updatable?: boolean;
  40778. }, scene?: Nullable<Scene>): Mesh;
  40779. /**
  40780. * Creates a ground mesh from a height map
  40781. * * The parameter `url` sets the URL of the height map image resource.
  40782. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40783. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40784. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40785. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40786. * * 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.
  40787. * * 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).
  40788. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40790. * @param name defines the name of the mesh
  40791. * @param url defines the url to the height map
  40792. * @param options defines the options used to create the mesh
  40793. * @param scene defines the hosting scene
  40794. * @returns the ground mesh
  40795. * @see https://doc.babylonjs.com/babylon101/height_map
  40796. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40797. */
  40798. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40799. width?: number;
  40800. height?: number;
  40801. subdivisions?: number;
  40802. minHeight?: number;
  40803. maxHeight?: number;
  40804. colorFilter?: Color3;
  40805. alphaFilter?: number;
  40806. updatable?: boolean;
  40807. onReady?: (mesh: GroundMesh) => void;
  40808. }, scene?: Nullable<Scene>): GroundMesh;
  40809. }
  40810. }
  40811. declare module BABYLON {
  40812. /**
  40813. * Class containing static functions to help procedurally build meshes
  40814. */
  40815. export class TorusBuilder {
  40816. /**
  40817. * Creates a torus mesh
  40818. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40819. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40820. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40822. * * 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
  40823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40824. * @param name defines the name of the mesh
  40825. * @param options defines the options used to create the mesh
  40826. * @param scene defines the hosting scene
  40827. * @returns the torus mesh
  40828. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40829. */
  40830. static CreateTorus(name: string, options: {
  40831. diameter?: number;
  40832. thickness?: number;
  40833. tessellation?: number;
  40834. updatable?: boolean;
  40835. sideOrientation?: number;
  40836. frontUVs?: Vector4;
  40837. backUVs?: Vector4;
  40838. }, scene: any): Mesh;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * Class containing static functions to help procedurally build meshes
  40844. */
  40845. export class CylinderBuilder {
  40846. /**
  40847. * Creates a cylinder or a cone mesh
  40848. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40849. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40850. * * 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.
  40851. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40852. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40853. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40854. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40855. * * 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).
  40856. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40857. * * 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).
  40858. * * 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
  40859. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40860. * * 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
  40861. * * 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.
  40862. * * If `enclose` is false, a ring surface is one element.
  40863. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40864. * * 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
  40865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40866. * * 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
  40867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40868. * @param name defines the name of the mesh
  40869. * @param options defines the options used to create the mesh
  40870. * @param scene defines the hosting scene
  40871. * @returns the cylinder mesh
  40872. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40873. */
  40874. static CreateCylinder(name: string, options: {
  40875. height?: number;
  40876. diameterTop?: number;
  40877. diameterBottom?: number;
  40878. diameter?: number;
  40879. tessellation?: number;
  40880. subdivisions?: number;
  40881. arc?: number;
  40882. faceColors?: Color4[];
  40883. faceUV?: Vector4[];
  40884. updatable?: boolean;
  40885. hasRings?: boolean;
  40886. enclose?: boolean;
  40887. cap?: number;
  40888. sideOrientation?: number;
  40889. frontUVs?: Vector4;
  40890. backUVs?: Vector4;
  40891. }, scene: any): Mesh;
  40892. }
  40893. }
  40894. declare module BABYLON {
  40895. /**
  40896. * Options to modify the vr teleportation behavior.
  40897. */
  40898. export interface VRTeleportationOptions {
  40899. /**
  40900. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40901. */
  40902. floorMeshName?: string;
  40903. /**
  40904. * A list of meshes to be used as the teleportation floor. (default: empty)
  40905. */
  40906. floorMeshes?: Mesh[];
  40907. }
  40908. /**
  40909. * Options to modify the vr experience helper's behavior.
  40910. */
  40911. export interface VRExperienceHelperOptions extends WebVROptions {
  40912. /**
  40913. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40914. */
  40915. createDeviceOrientationCamera?: boolean;
  40916. /**
  40917. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40918. */
  40919. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40920. /**
  40921. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40922. */
  40923. laserToggle?: boolean;
  40924. /**
  40925. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40926. */
  40927. floorMeshes?: Mesh[];
  40928. /**
  40929. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40930. */
  40931. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40932. }
  40933. /**
  40934. * Event containing information after VR has been entered
  40935. */
  40936. export class OnAfterEnteringVRObservableEvent {
  40937. /**
  40938. * If entering vr was successful
  40939. */
  40940. success: boolean;
  40941. }
  40942. /**
  40943. * Helps to quickly add VR support to an existing scene.
  40944. * See http://doc.babylonjs.com/how_to/webvr_helper
  40945. */
  40946. export class VRExperienceHelper {
  40947. /** Options to modify the vr experience helper's behavior. */
  40948. webVROptions: VRExperienceHelperOptions;
  40949. private _scene;
  40950. private _position;
  40951. private _btnVR;
  40952. private _btnVRDisplayed;
  40953. private _webVRsupported;
  40954. private _webVRready;
  40955. private _webVRrequesting;
  40956. private _webVRpresenting;
  40957. private _hasEnteredVR;
  40958. private _fullscreenVRpresenting;
  40959. private _canvas;
  40960. private _webVRCamera;
  40961. private _vrDeviceOrientationCamera;
  40962. private _deviceOrientationCamera;
  40963. private _existingCamera;
  40964. private _onKeyDown;
  40965. private _onVrDisplayPresentChange;
  40966. private _onVRDisplayChanged;
  40967. private _onVRRequestPresentStart;
  40968. private _onVRRequestPresentComplete;
  40969. /**
  40970. * 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)
  40971. */
  40972. enableGazeEvenWhenNoPointerLock: boolean;
  40973. /**
  40974. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40975. */
  40976. exitVROnDoubleTap: boolean;
  40977. /**
  40978. * Observable raised right before entering VR.
  40979. */
  40980. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40981. /**
  40982. * Observable raised when entering VR has completed.
  40983. */
  40984. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40985. /**
  40986. * Observable raised when exiting VR.
  40987. */
  40988. onExitingVRObservable: Observable<VRExperienceHelper>;
  40989. /**
  40990. * Observable raised when controller mesh is loaded.
  40991. */
  40992. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40993. /** Return this.onEnteringVRObservable
  40994. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40995. */
  40996. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40997. /** Return this.onExitingVRObservable
  40998. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40999. */
  41000. readonly onExitingVR: Observable<VRExperienceHelper>;
  41001. /** Return this.onControllerMeshLoadedObservable
  41002. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41003. */
  41004. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41005. private _rayLength;
  41006. private _useCustomVRButton;
  41007. private _teleportationRequested;
  41008. private _teleportActive;
  41009. private _floorMeshName;
  41010. private _floorMeshesCollection;
  41011. private _rotationAllowed;
  41012. private _teleportBackwardsVector;
  41013. private _teleportationTarget;
  41014. private _isDefaultTeleportationTarget;
  41015. private _postProcessMove;
  41016. private _teleportationFillColor;
  41017. private _teleportationBorderColor;
  41018. private _rotationAngle;
  41019. private _haloCenter;
  41020. private _cameraGazer;
  41021. private _padSensibilityUp;
  41022. private _padSensibilityDown;
  41023. private _leftController;
  41024. private _rightController;
  41025. /**
  41026. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41027. */
  41028. onNewMeshSelected: Observable<AbstractMesh>;
  41029. /**
  41030. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41031. * This observable will provide the mesh and the controller used to select the mesh
  41032. */
  41033. onMeshSelectedWithController: Observable<{
  41034. mesh: AbstractMesh;
  41035. controller: WebVRController;
  41036. }>;
  41037. /**
  41038. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41039. */
  41040. onNewMeshPicked: Observable<PickingInfo>;
  41041. private _circleEase;
  41042. /**
  41043. * Observable raised before camera teleportation
  41044. */
  41045. onBeforeCameraTeleport: Observable<Vector3>;
  41046. /**
  41047. * Observable raised after camera teleportation
  41048. */
  41049. onAfterCameraTeleport: Observable<Vector3>;
  41050. /**
  41051. * Observable raised when current selected mesh gets unselected
  41052. */
  41053. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41054. private _raySelectionPredicate;
  41055. /**
  41056. * To be optionaly changed by user to define custom ray selection
  41057. */
  41058. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41059. /**
  41060. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41061. */
  41062. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41063. /**
  41064. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41065. */
  41066. teleportationEnabled: boolean;
  41067. private _defaultHeight;
  41068. private _teleportationInitialized;
  41069. private _interactionsEnabled;
  41070. private _interactionsRequested;
  41071. private _displayGaze;
  41072. private _displayLaserPointer;
  41073. /**
  41074. * The mesh used to display where the user is going to teleport.
  41075. */
  41076. /**
  41077. * Sets the mesh to be used to display where the user is going to teleport.
  41078. */
  41079. teleportationTarget: Mesh;
  41080. /**
  41081. * 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
  41082. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41083. * See http://doc.babylonjs.com/resources/baking_transformations
  41084. */
  41085. gazeTrackerMesh: Mesh;
  41086. /**
  41087. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41088. */
  41089. updateGazeTrackerScale: boolean;
  41090. /**
  41091. * If the gaze trackers color should be updated when selecting meshes
  41092. */
  41093. updateGazeTrackerColor: boolean;
  41094. /**
  41095. * If the controller laser color should be updated when selecting meshes
  41096. */
  41097. updateControllerLaserColor: boolean;
  41098. /**
  41099. * The gaze tracking mesh corresponding to the left controller
  41100. */
  41101. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41102. /**
  41103. * The gaze tracking mesh corresponding to the right controller
  41104. */
  41105. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41106. /**
  41107. * If the ray of the gaze should be displayed.
  41108. */
  41109. /**
  41110. * Sets if the ray of the gaze should be displayed.
  41111. */
  41112. displayGaze: boolean;
  41113. /**
  41114. * If the ray of the LaserPointer should be displayed.
  41115. */
  41116. /**
  41117. * Sets if the ray of the LaserPointer should be displayed.
  41118. */
  41119. displayLaserPointer: boolean;
  41120. /**
  41121. * The deviceOrientationCamera used as the camera when not in VR.
  41122. */
  41123. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41124. /**
  41125. * Based on the current WebVR support, returns the current VR camera used.
  41126. */
  41127. readonly currentVRCamera: Nullable<Camera>;
  41128. /**
  41129. * The webVRCamera which is used when in VR.
  41130. */
  41131. readonly webVRCamera: WebVRFreeCamera;
  41132. /**
  41133. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41134. */
  41135. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41136. /**
  41137. * The html button that is used to trigger entering into VR.
  41138. */
  41139. readonly vrButton: Nullable<HTMLButtonElement>;
  41140. private readonly _teleportationRequestInitiated;
  41141. /**
  41142. * Defines wether or not Pointer lock should be requested when switching to
  41143. * full screen.
  41144. */
  41145. requestPointerLockOnFullScreen: boolean;
  41146. /**
  41147. * Instantiates a VRExperienceHelper.
  41148. * Helps to quickly add VR support to an existing scene.
  41149. * @param scene The scene the VRExperienceHelper belongs to.
  41150. * @param webVROptions Options to modify the vr experience helper's behavior.
  41151. */
  41152. constructor(scene: Scene,
  41153. /** Options to modify the vr experience helper's behavior. */
  41154. webVROptions?: VRExperienceHelperOptions);
  41155. private _onDefaultMeshLoaded;
  41156. private _onResize;
  41157. private _onFullscreenChange;
  41158. /**
  41159. * Gets a value indicating if we are currently in VR mode.
  41160. */
  41161. readonly isInVRMode: boolean;
  41162. private onVrDisplayPresentChange;
  41163. private onVRDisplayChanged;
  41164. private moveButtonToBottomRight;
  41165. private displayVRButton;
  41166. private updateButtonVisibility;
  41167. private _cachedAngularSensibility;
  41168. /**
  41169. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41170. * Otherwise, will use the fullscreen API.
  41171. */
  41172. enterVR(): void;
  41173. /**
  41174. * Attempt to exit VR, or fullscreen.
  41175. */
  41176. exitVR(): void;
  41177. /**
  41178. * The position of the vr experience helper.
  41179. */
  41180. /**
  41181. * Sets the position of the vr experience helper.
  41182. */
  41183. position: Vector3;
  41184. /**
  41185. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41186. */
  41187. enableInteractions(): void;
  41188. private readonly _noControllerIsActive;
  41189. private beforeRender;
  41190. private _isTeleportationFloor;
  41191. /**
  41192. * Adds a floor mesh to be used for teleportation.
  41193. * @param floorMesh the mesh to be used for teleportation.
  41194. */
  41195. addFloorMesh(floorMesh: Mesh): void;
  41196. /**
  41197. * Removes a floor mesh from being used for teleportation.
  41198. * @param floorMesh the mesh to be removed.
  41199. */
  41200. removeFloorMesh(floorMesh: Mesh): void;
  41201. /**
  41202. * Enables interactions and teleportation using the VR controllers and gaze.
  41203. * @param vrTeleportationOptions options to modify teleportation behavior.
  41204. */
  41205. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41206. private _onNewGamepadConnected;
  41207. private _tryEnableInteractionOnController;
  41208. private _onNewGamepadDisconnected;
  41209. private _enableInteractionOnController;
  41210. private _checkTeleportWithRay;
  41211. private _checkRotate;
  41212. private _checkTeleportBackwards;
  41213. private _enableTeleportationOnController;
  41214. private _createTeleportationCircles;
  41215. private _displayTeleportationTarget;
  41216. private _hideTeleportationTarget;
  41217. private _rotateCamera;
  41218. private _moveTeleportationSelectorTo;
  41219. private _workingVector;
  41220. private _workingQuaternion;
  41221. private _workingMatrix;
  41222. /**
  41223. * Teleports the users feet to the desired location
  41224. * @param location The location where the user's feet should be placed
  41225. */
  41226. teleportCamera(location: Vector3): void;
  41227. private _convertNormalToDirectionOfRay;
  41228. private _castRayAndSelectObject;
  41229. private _notifySelectedMeshUnselected;
  41230. /**
  41231. * Sets the color of the laser ray from the vr controllers.
  41232. * @param color new color for the ray.
  41233. */
  41234. changeLaserColor(color: Color3): void;
  41235. /**
  41236. * Sets the color of the ray from the vr headsets gaze.
  41237. * @param color new color for the ray.
  41238. */
  41239. changeGazeColor(color: Color3): void;
  41240. /**
  41241. * Exits VR and disposes of the vr experience helper
  41242. */
  41243. dispose(): void;
  41244. /**
  41245. * Gets the name of the VRExperienceHelper class
  41246. * @returns "VRExperienceHelper"
  41247. */
  41248. getClassName(): string;
  41249. }
  41250. }
  41251. declare module BABYLON {
  41252. /**
  41253. * Manages an XRSession to work with Babylon's engine
  41254. * @see https://doc.babylonjs.com/how_to/webxr
  41255. */
  41256. export class WebXRSessionManager implements IDisposable {
  41257. private scene;
  41258. /**
  41259. * Fires every time a new xrFrame arrives which can be used to update the camera
  41260. */
  41261. onXRFrameObservable: Observable<any>;
  41262. /**
  41263. * Fires when the xr session is ended either by the device or manually done
  41264. */
  41265. onXRSessionEnded: Observable<any>;
  41266. /**
  41267. * Underlying xr session
  41268. */
  41269. session: XRSession;
  41270. /**
  41271. * Type of reference space used when creating the session
  41272. */
  41273. referenceSpace: XRReferenceSpace;
  41274. /** @hidden */
  41275. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41276. /**
  41277. * Current XR frame
  41278. */
  41279. currentFrame: Nullable<XRFrame>;
  41280. private _xrNavigator;
  41281. private baseLayer;
  41282. /**
  41283. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41284. * @param scene The scene which the session should be created for
  41285. */
  41286. constructor(scene: Scene);
  41287. /**
  41288. * Initializes the manager
  41289. * After initialization enterXR can be called to start an XR session
  41290. * @returns Promise which resolves after it is initialized
  41291. */
  41292. initializeAsync(): Promise<void>;
  41293. /**
  41294. * Initializes an xr session
  41295. * @param xrSessionMode mode to initialize
  41296. * @returns a promise which will resolve once the session has been initialized
  41297. */
  41298. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41299. /**
  41300. * Sets the reference space on the xr session
  41301. * @param referenceSpace space to set
  41302. * @returns a promise that will resolve once the reference space has been set
  41303. */
  41304. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41305. /**
  41306. * Updates the render state of the session
  41307. * @param state state to set
  41308. * @returns a promise that resolves once the render state has been updated
  41309. */
  41310. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41311. /**
  41312. * Starts rendering to the xr layer
  41313. * @returns a promise that will resolve once rendering has started
  41314. */
  41315. startRenderingToXRAsync(): Promise<void>;
  41316. /**
  41317. * Stops the xrSession and restores the renderloop
  41318. * @returns Promise which resolves after it exits XR
  41319. */
  41320. exitXRAsync(): Promise<unknown>;
  41321. /**
  41322. * Checks if a session would be supported for the creation options specified
  41323. * @param sessionMode session mode to check if supported eg. immersive-vr
  41324. * @returns true if supported
  41325. */
  41326. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41327. /**
  41328. * @hidden
  41329. * Converts the render layer of xrSession to a render target
  41330. * @param session session to create render target for
  41331. * @param scene scene the new render target should be created for
  41332. */
  41333. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41334. /**
  41335. * Disposes of the session manager
  41336. */
  41337. dispose(): void;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /**
  41342. * WebXR Camera which holds the views for the xrSession
  41343. * @see https://doc.babylonjs.com/how_to/webxr
  41344. */
  41345. export class WebXRCamera extends FreeCamera {
  41346. private static _TmpMatrix;
  41347. /**
  41348. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41349. * @param name the name of the camera
  41350. * @param scene the scene to add the camera to
  41351. */
  41352. constructor(name: string, scene: Scene);
  41353. private _updateNumberOfRigCameras;
  41354. /** @hidden */
  41355. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41356. /**
  41357. * Updates the cameras position from the current pose information of the XR session
  41358. * @param xrSessionManager the session containing pose information
  41359. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41360. */
  41361. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41362. }
  41363. }
  41364. declare module BABYLON {
  41365. /**
  41366. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41367. */
  41368. export class WebXRManagedOutputCanvas implements IDisposable {
  41369. private helper;
  41370. private _canvas;
  41371. /**
  41372. * xrpresent context of the canvas which can be used to display/mirror xr content
  41373. */
  41374. canvasContext: WebGLRenderingContext;
  41375. /**
  41376. * xr layer for the canvas
  41377. */
  41378. xrLayer: Nullable<XRWebGLLayer>;
  41379. /**
  41380. * Initializes the xr layer for the session
  41381. * @param xrSession xr session
  41382. * @returns a promise that will resolve once the XR Layer has been created
  41383. */
  41384. initializeXRLayerAsync(xrSession: any): any;
  41385. /**
  41386. * Initializes the canvas to be added/removed upon entering/exiting xr
  41387. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41388. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41389. */
  41390. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41391. /**
  41392. * Disposes of the object
  41393. */
  41394. dispose(): void;
  41395. private _setManagedOutputCanvas;
  41396. private _addCanvas;
  41397. private _removeCanvas;
  41398. }
  41399. }
  41400. declare module BABYLON {
  41401. /**
  41402. * States of the webXR experience
  41403. */
  41404. export enum WebXRState {
  41405. /**
  41406. * Transitioning to being in XR mode
  41407. */
  41408. ENTERING_XR = 0,
  41409. /**
  41410. * Transitioning to non XR mode
  41411. */
  41412. EXITING_XR = 1,
  41413. /**
  41414. * In XR mode and presenting
  41415. */
  41416. IN_XR = 2,
  41417. /**
  41418. * Not entered XR mode
  41419. */
  41420. NOT_IN_XR = 3
  41421. }
  41422. /**
  41423. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41424. * @see https://doc.babylonjs.com/how_to/webxr
  41425. */
  41426. export class WebXRExperienceHelper implements IDisposable {
  41427. private scene;
  41428. /**
  41429. * 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
  41430. */
  41431. container: AbstractMesh;
  41432. /**
  41433. * Camera used to render xr content
  41434. */
  41435. camera: WebXRCamera;
  41436. /**
  41437. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41438. */
  41439. state: WebXRState;
  41440. private _setState;
  41441. private static _TmpVector;
  41442. /**
  41443. * Fires when the state of the experience helper has changed
  41444. */
  41445. onStateChangedObservable: Observable<WebXRState>;
  41446. /** Session manager used to keep track of xr session */
  41447. sessionManager: WebXRSessionManager;
  41448. private _nonVRCamera;
  41449. private _originalSceneAutoClear;
  41450. private _supported;
  41451. /**
  41452. * Creates the experience helper
  41453. * @param scene the scene to attach the experience helper to
  41454. * @returns a promise for the experience helper
  41455. */
  41456. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41457. /**
  41458. * Creates a WebXRExperienceHelper
  41459. * @param scene The scene the helper should be created in
  41460. */
  41461. private constructor();
  41462. /**
  41463. * Exits XR mode and returns the scene to its original state
  41464. * @returns promise that resolves after xr mode has exited
  41465. */
  41466. exitXRAsync(): Promise<unknown>;
  41467. /**
  41468. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41469. * @param sessionCreationOptions options for the XR session
  41470. * @param referenceSpaceType frame of reference of the XR session
  41471. * @param outputCanvas the output canvas that will be used to enter XR mode
  41472. * @returns promise that resolves after xr mode has entered
  41473. */
  41474. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41475. /**
  41476. * Updates the global position of the camera by moving the camera's container
  41477. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41478. * @param position The desired global position of the camera
  41479. */
  41480. setPositionOfCameraUsingContainer(position: Vector3): void;
  41481. /**
  41482. * Rotates the xr camera by rotating the camera's container around the camera's position
  41483. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41484. * @param rotation the desired quaternion rotation to apply to the camera
  41485. */
  41486. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41487. /**
  41488. * Disposes of the experience helper
  41489. */
  41490. dispose(): void;
  41491. }
  41492. }
  41493. declare module BABYLON {
  41494. /**
  41495. * Button which can be used to enter a different mode of XR
  41496. */
  41497. export class WebXREnterExitUIButton {
  41498. /** button element */
  41499. element: HTMLElement;
  41500. /** XR initialization options for the button */
  41501. sessionMode: XRSessionMode;
  41502. /** Reference space type */
  41503. referenceSpaceType: XRReferenceSpaceType;
  41504. /**
  41505. * Creates a WebXREnterExitUIButton
  41506. * @param element button element
  41507. * @param sessionMode XR initialization session mode
  41508. * @param referenceSpaceType the type of reference space to be used
  41509. */
  41510. constructor(
  41511. /** button element */
  41512. element: HTMLElement,
  41513. /** XR initialization options for the button */
  41514. sessionMode: XRSessionMode,
  41515. /** Reference space type */
  41516. referenceSpaceType: XRReferenceSpaceType);
  41517. /**
  41518. * Overwritable function which can be used to update the button's visuals when the state changes
  41519. * @param activeButton the current active button in the UI
  41520. */
  41521. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41522. }
  41523. /**
  41524. * Options to create the webXR UI
  41525. */
  41526. export class WebXREnterExitUIOptions {
  41527. /**
  41528. * Context to enter xr with
  41529. */
  41530. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41531. /**
  41532. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41533. */
  41534. customButtons?: Array<WebXREnterExitUIButton>;
  41535. }
  41536. /**
  41537. * UI to allow the user to enter/exit XR mode
  41538. */
  41539. export class WebXREnterExitUI implements IDisposable {
  41540. private scene;
  41541. private _overlay;
  41542. private _buttons;
  41543. private _activeButton;
  41544. /**
  41545. * Fired every time the active button is changed.
  41546. *
  41547. * When xr is entered via a button that launches xr that button will be the callback parameter
  41548. *
  41549. * When exiting xr the callback parameter will be null)
  41550. */
  41551. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41552. /**
  41553. * Creates UI to allow the user to enter/exit XR mode
  41554. * @param scene the scene to add the ui to
  41555. * @param helper the xr experience helper to enter/exit xr with
  41556. * @param options options to configure the UI
  41557. * @returns the created ui
  41558. */
  41559. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41560. private constructor();
  41561. private _updateButtons;
  41562. /**
  41563. * Disposes of the object
  41564. */
  41565. dispose(): void;
  41566. }
  41567. }
  41568. declare module BABYLON {
  41569. /**
  41570. * Represents an XR input
  41571. */
  41572. export class WebXRController {
  41573. private scene;
  41574. /** The underlying input source for the controller */
  41575. inputSource: XRInputSource;
  41576. private parentContainer;
  41577. /**
  41578. * 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
  41579. */
  41580. grip?: AbstractMesh;
  41581. /**
  41582. * Pointer which can be used to select objects or attach a visible laser to
  41583. */
  41584. pointer: AbstractMesh;
  41585. /**
  41586. * Event that fires when the controller is removed/disposed
  41587. */
  41588. onDisposeObservable: Observable<{}>;
  41589. private _tmpMatrix;
  41590. private _tmpQuaternion;
  41591. private _tmpVector;
  41592. /**
  41593. * Creates the controller
  41594. * @see https://doc.babylonjs.com/how_to/webxr
  41595. * @param scene the scene which the controller should be associated to
  41596. * @param inputSource the underlying input source for the controller
  41597. * @param parentContainer parent that the controller meshes should be children of
  41598. */
  41599. constructor(scene: Scene,
  41600. /** The underlying input source for the controller */
  41601. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41602. /**
  41603. * Updates the controller pose based on the given XRFrame
  41604. * @param xrFrame xr frame to update the pose with
  41605. * @param referenceSpace reference space to use
  41606. */
  41607. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41608. /**
  41609. * Gets a world space ray coming from the controller
  41610. * @param result the resulting ray
  41611. */
  41612. getWorldPointerRayToRef(result: Ray): void;
  41613. /**
  41614. * Disposes of the object
  41615. */
  41616. dispose(): void;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * XR input used to track XR inputs such as controllers/rays
  41622. */
  41623. export class WebXRInput implements IDisposable {
  41624. /**
  41625. * Base experience the input listens to
  41626. */
  41627. baseExperience: WebXRExperienceHelper;
  41628. /**
  41629. * XR controllers being tracked
  41630. */
  41631. controllers: Array<WebXRController>;
  41632. private _frameObserver;
  41633. private _stateObserver;
  41634. /**
  41635. * Event when a controller has been connected/added
  41636. */
  41637. onControllerAddedObservable: Observable<WebXRController>;
  41638. /**
  41639. * Event when a controller has been removed/disconnected
  41640. */
  41641. onControllerRemovedObservable: Observable<WebXRController>;
  41642. /**
  41643. * Initializes the WebXRInput
  41644. * @param baseExperience experience helper which the input should be created for
  41645. */
  41646. constructor(
  41647. /**
  41648. * Base experience the input listens to
  41649. */
  41650. baseExperience: WebXRExperienceHelper);
  41651. private _onInputSourcesChange;
  41652. private _addAndRemoveControllers;
  41653. /**
  41654. * Disposes of the object
  41655. */
  41656. dispose(): void;
  41657. }
  41658. }
  41659. declare module BABYLON {
  41660. /**
  41661. * Enables teleportation
  41662. */
  41663. export class WebXRControllerTeleportation {
  41664. private _teleportationFillColor;
  41665. private _teleportationBorderColor;
  41666. private _tmpRay;
  41667. private _tmpVector;
  41668. /**
  41669. * Creates a WebXRControllerTeleportation
  41670. * @param input input manager to add teleportation to
  41671. * @param floorMeshes floormeshes which can be teleported to
  41672. */
  41673. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Handles pointer input automatically for the pointer of XR controllers
  41679. */
  41680. export class WebXRControllerPointerSelection {
  41681. private static _idCounter;
  41682. private _tmpRay;
  41683. /**
  41684. * Creates a WebXRControllerPointerSelection
  41685. * @param input input manager to setup pointer selection
  41686. */
  41687. constructor(input: WebXRInput);
  41688. private _convertNormalToDirectionOfRay;
  41689. private _updatePointerDistance;
  41690. }
  41691. }
  41692. declare module BABYLON {
  41693. /**
  41694. * Class used to represent data loading progression
  41695. */
  41696. export class SceneLoaderProgressEvent {
  41697. /** defines if data length to load can be evaluated */
  41698. readonly lengthComputable: boolean;
  41699. /** defines the loaded data length */
  41700. readonly loaded: number;
  41701. /** defines the data length to load */
  41702. readonly total: number;
  41703. /**
  41704. * Create a new progress event
  41705. * @param lengthComputable defines if data length to load can be evaluated
  41706. * @param loaded defines the loaded data length
  41707. * @param total defines the data length to load
  41708. */
  41709. constructor(
  41710. /** defines if data length to load can be evaluated */
  41711. lengthComputable: boolean,
  41712. /** defines the loaded data length */
  41713. loaded: number,
  41714. /** defines the data length to load */
  41715. total: number);
  41716. /**
  41717. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41718. * @param event defines the source event
  41719. * @returns a new SceneLoaderProgressEvent
  41720. */
  41721. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41722. }
  41723. /**
  41724. * Interface used by SceneLoader plugins to define supported file extensions
  41725. */
  41726. export interface ISceneLoaderPluginExtensions {
  41727. /**
  41728. * Defines the list of supported extensions
  41729. */
  41730. [extension: string]: {
  41731. isBinary: boolean;
  41732. };
  41733. }
  41734. /**
  41735. * Interface used by SceneLoader plugin factory
  41736. */
  41737. export interface ISceneLoaderPluginFactory {
  41738. /**
  41739. * Defines the name of the factory
  41740. */
  41741. name: string;
  41742. /**
  41743. * Function called to create a new plugin
  41744. * @return the new plugin
  41745. */
  41746. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41747. /**
  41748. * Boolean indicating if the plugin can direct load specific data
  41749. */
  41750. canDirectLoad?: (data: string) => boolean;
  41751. }
  41752. /**
  41753. * Interface used to define a SceneLoader plugin
  41754. */
  41755. export interface ISceneLoaderPlugin {
  41756. /**
  41757. * The friendly name of this plugin.
  41758. */
  41759. name: string;
  41760. /**
  41761. * The file extensions supported by this plugin.
  41762. */
  41763. extensions: string | ISceneLoaderPluginExtensions;
  41764. /**
  41765. * Import meshes into a scene.
  41766. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41767. * @param scene The scene to import into
  41768. * @param data The data to import
  41769. * @param rootUrl The root url for scene and resources
  41770. * @param meshes The meshes array to import into
  41771. * @param particleSystems The particle systems array to import into
  41772. * @param skeletons The skeletons array to import into
  41773. * @param onError The callback when import fails
  41774. * @returns True if successful or false otherwise
  41775. */
  41776. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41777. /**
  41778. * Load into a scene.
  41779. * @param scene The scene to load into
  41780. * @param data The data to import
  41781. * @param rootUrl The root url for scene and resources
  41782. * @param onError The callback when import fails
  41783. * @returns true if successful or false otherwise
  41784. */
  41785. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41786. /**
  41787. * The callback that returns true if the data can be directly loaded.
  41788. */
  41789. canDirectLoad?: (data: string) => boolean;
  41790. /**
  41791. * The callback that allows custom handling of the root url based on the response url.
  41792. */
  41793. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41794. /**
  41795. * Load into an asset container.
  41796. * @param scene The scene to load into
  41797. * @param data The data to import
  41798. * @param rootUrl The root url for scene and resources
  41799. * @param onError The callback when import fails
  41800. * @returns The loaded asset container
  41801. */
  41802. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41803. }
  41804. /**
  41805. * Interface used to define an async SceneLoader plugin
  41806. */
  41807. export interface ISceneLoaderPluginAsync {
  41808. /**
  41809. * The friendly name of this plugin.
  41810. */
  41811. name: string;
  41812. /**
  41813. * The file extensions supported by this plugin.
  41814. */
  41815. extensions: string | ISceneLoaderPluginExtensions;
  41816. /**
  41817. * Import meshes into a scene.
  41818. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41819. * @param scene The scene to import into
  41820. * @param data The data to import
  41821. * @param rootUrl The root url for scene and resources
  41822. * @param onProgress The callback when the load progresses
  41823. * @param fileName Defines the name of the file to load
  41824. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41825. */
  41826. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41827. meshes: AbstractMesh[];
  41828. particleSystems: IParticleSystem[];
  41829. skeletons: Skeleton[];
  41830. animationGroups: AnimationGroup[];
  41831. }>;
  41832. /**
  41833. * Load into a scene.
  41834. * @param scene The scene to load into
  41835. * @param data The data to import
  41836. * @param rootUrl The root url for scene and resources
  41837. * @param onProgress The callback when the load progresses
  41838. * @param fileName Defines the name of the file to load
  41839. * @returns Nothing
  41840. */
  41841. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41842. /**
  41843. * The callback that returns true if the data can be directly loaded.
  41844. */
  41845. canDirectLoad?: (data: string) => boolean;
  41846. /**
  41847. * The callback that allows custom handling of the root url based on the response url.
  41848. */
  41849. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41850. /**
  41851. * Load into an asset container.
  41852. * @param scene The scene to load into
  41853. * @param data The data to import
  41854. * @param rootUrl The root url for scene and resources
  41855. * @param onProgress The callback when the load progresses
  41856. * @param fileName Defines the name of the file to load
  41857. * @returns The loaded asset container
  41858. */
  41859. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41860. }
  41861. /**
  41862. * Class used to load scene from various file formats using registered plugins
  41863. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41864. */
  41865. export class SceneLoader {
  41866. /**
  41867. * No logging while loading
  41868. */
  41869. static readonly NO_LOGGING: number;
  41870. /**
  41871. * Minimal logging while loading
  41872. */
  41873. static readonly MINIMAL_LOGGING: number;
  41874. /**
  41875. * Summary logging while loading
  41876. */
  41877. static readonly SUMMARY_LOGGING: number;
  41878. /**
  41879. * Detailled logging while loading
  41880. */
  41881. static readonly DETAILED_LOGGING: number;
  41882. /**
  41883. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41884. */
  41885. static ForceFullSceneLoadingForIncremental: boolean;
  41886. /**
  41887. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41888. */
  41889. static ShowLoadingScreen: boolean;
  41890. /**
  41891. * Defines the current logging level (while loading the scene)
  41892. * @ignorenaming
  41893. */
  41894. static loggingLevel: number;
  41895. /**
  41896. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41897. */
  41898. static CleanBoneMatrixWeights: boolean;
  41899. /**
  41900. * Event raised when a plugin is used to load a scene
  41901. */
  41902. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41903. private static _registeredPlugins;
  41904. private static _getDefaultPlugin;
  41905. private static _getPluginForExtension;
  41906. private static _getPluginForDirectLoad;
  41907. private static _getPluginForFilename;
  41908. private static _getDirectLoad;
  41909. private static _loadData;
  41910. private static _getFileInfo;
  41911. /**
  41912. * Gets a plugin that can load the given extension
  41913. * @param extension defines the extension to load
  41914. * @returns a plugin or null if none works
  41915. */
  41916. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41917. /**
  41918. * Gets a boolean indicating that the given extension can be loaded
  41919. * @param extension defines the extension to load
  41920. * @returns true if the extension is supported
  41921. */
  41922. static IsPluginForExtensionAvailable(extension: string): boolean;
  41923. /**
  41924. * Adds a new plugin to the list of registered plugins
  41925. * @param plugin defines the plugin to add
  41926. */
  41927. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41928. /**
  41929. * Import meshes into a scene
  41930. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41931. * @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)
  41932. * @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)
  41933. * @param scene the instance of BABYLON.Scene to append to
  41934. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41935. * @param onProgress a callback with a progress event for each file being loaded
  41936. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41937. * @param pluginExtension the extension used to determine the plugin
  41938. * @returns The loaded plugin
  41939. */
  41940. 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>;
  41941. /**
  41942. * Import meshes into a scene
  41943. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41944. * @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)
  41945. * @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)
  41946. * @param scene the instance of BABYLON.Scene to append to
  41947. * @param onProgress a callback with a progress event for each file being loaded
  41948. * @param pluginExtension the extension used to determine the plugin
  41949. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41950. */
  41951. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41952. meshes: AbstractMesh[];
  41953. particleSystems: IParticleSystem[];
  41954. skeletons: Skeleton[];
  41955. animationGroups: AnimationGroup[];
  41956. }>;
  41957. /**
  41958. * Load a scene
  41959. * @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)
  41960. * @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)
  41961. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41962. * @param onSuccess a callback with the scene when import succeeds
  41963. * @param onProgress a callback with a progress event for each file being loaded
  41964. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41965. * @param pluginExtension the extension used to determine the plugin
  41966. * @returns The loaded plugin
  41967. */
  41968. 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>;
  41969. /**
  41970. * Load a scene
  41971. * @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)
  41972. * @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)
  41973. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41974. * @param onProgress a callback with a progress event for each file being loaded
  41975. * @param pluginExtension the extension used to determine the plugin
  41976. * @returns The loaded scene
  41977. */
  41978. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41979. /**
  41980. * Append a scene
  41981. * @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)
  41982. * @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)
  41983. * @param scene is the instance of BABYLON.Scene to append to
  41984. * @param onSuccess a callback with the scene when import succeeds
  41985. * @param onProgress a callback with a progress event for each file being loaded
  41986. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41987. * @param pluginExtension the extension used to determine the plugin
  41988. * @returns The loaded plugin
  41989. */
  41990. 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>;
  41991. /**
  41992. * Append a scene
  41993. * @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)
  41994. * @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)
  41995. * @param scene is the instance of BABYLON.Scene to append to
  41996. * @param onProgress a callback with a progress event for each file being loaded
  41997. * @param pluginExtension the extension used to determine the plugin
  41998. * @returns The given scene
  41999. */
  42000. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42001. /**
  42002. * Load a scene into an asset container
  42003. * @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)
  42004. * @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)
  42005. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42006. * @param onSuccess a callback with the scene when import succeeds
  42007. * @param onProgress a callback with a progress event for each file being loaded
  42008. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42009. * @param pluginExtension the extension used to determine the plugin
  42010. * @returns The loaded plugin
  42011. */
  42012. 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>;
  42013. /**
  42014. * Load a scene into an asset container
  42015. * @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)
  42016. * @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)
  42017. * @param scene is the instance of Scene to append to
  42018. * @param onProgress a callback with a progress event for each file being loaded
  42019. * @param pluginExtension the extension used to determine the plugin
  42020. * @returns The loaded asset container
  42021. */
  42022. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * Generic Controller
  42028. */
  42029. export class GenericController extends WebVRController {
  42030. /**
  42031. * Base Url for the controller model.
  42032. */
  42033. static readonly MODEL_BASE_URL: string;
  42034. /**
  42035. * File name for the controller model.
  42036. */
  42037. static readonly MODEL_FILENAME: string;
  42038. /**
  42039. * Creates a new GenericController from a gamepad
  42040. * @param vrGamepad the gamepad that the controller should be created from
  42041. */
  42042. constructor(vrGamepad: any);
  42043. /**
  42044. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42045. * @param scene scene in which to add meshes
  42046. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42047. */
  42048. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42049. /**
  42050. * Called once for each button that changed state since the last frame
  42051. * @param buttonIdx Which button index changed
  42052. * @param state New state of the button
  42053. * @param changes Which properties on the state changed since last frame
  42054. */
  42055. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42056. }
  42057. }
  42058. declare module BABYLON {
  42059. /**
  42060. * Defines the WindowsMotionController object that the state of the windows motion controller
  42061. */
  42062. export class WindowsMotionController extends WebVRController {
  42063. /**
  42064. * The base url used to load the left and right controller models
  42065. */
  42066. static MODEL_BASE_URL: string;
  42067. /**
  42068. * The name of the left controller model file
  42069. */
  42070. static MODEL_LEFT_FILENAME: string;
  42071. /**
  42072. * The name of the right controller model file
  42073. */
  42074. static MODEL_RIGHT_FILENAME: string;
  42075. /**
  42076. * The controller name prefix for this controller type
  42077. */
  42078. static readonly GAMEPAD_ID_PREFIX: string;
  42079. /**
  42080. * The controller id pattern for this controller type
  42081. */
  42082. private static readonly GAMEPAD_ID_PATTERN;
  42083. private _loadedMeshInfo;
  42084. private readonly _mapping;
  42085. /**
  42086. * Fired when the trackpad on this controller is clicked
  42087. */
  42088. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42089. /**
  42090. * Fired when the trackpad on this controller is modified
  42091. */
  42092. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42093. /**
  42094. * The current x and y values of this controller's trackpad
  42095. */
  42096. trackpad: StickValues;
  42097. /**
  42098. * Creates a new WindowsMotionController from a gamepad
  42099. * @param vrGamepad the gamepad that the controller should be created from
  42100. */
  42101. constructor(vrGamepad: any);
  42102. /**
  42103. * Fired when the trigger on this controller is modified
  42104. */
  42105. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42106. /**
  42107. * Fired when the menu button on this controller is modified
  42108. */
  42109. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42110. /**
  42111. * Fired when the grip button on this controller is modified
  42112. */
  42113. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42114. /**
  42115. * Fired when the thumbstick button on this controller is modified
  42116. */
  42117. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42118. /**
  42119. * Fired when the touchpad button on this controller is modified
  42120. */
  42121. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42122. /**
  42123. * Fired when the touchpad values on this controller are modified
  42124. */
  42125. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42126. private _updateTrackpad;
  42127. /**
  42128. * Called once per frame by the engine.
  42129. */
  42130. update(): void;
  42131. /**
  42132. * Called once for each button that changed state since the last frame
  42133. * @param buttonIdx Which button index changed
  42134. * @param state New state of the button
  42135. * @param changes Which properties on the state changed since last frame
  42136. */
  42137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42138. /**
  42139. * Moves the buttons on the controller mesh based on their current state
  42140. * @param buttonName the name of the button to move
  42141. * @param buttonValue the value of the button which determines the buttons new position
  42142. */
  42143. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42144. /**
  42145. * Moves the axis on the controller mesh based on its current state
  42146. * @param axis the index of the axis
  42147. * @param axisValue the value of the axis which determines the meshes new position
  42148. * @hidden
  42149. */
  42150. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42151. /**
  42152. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42153. * @param scene scene in which to add meshes
  42154. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42155. */
  42156. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42157. /**
  42158. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42159. * can be transformed by button presses and axes values, based on this._mapping.
  42160. *
  42161. * @param scene scene in which the meshes exist
  42162. * @param meshes list of meshes that make up the controller model to process
  42163. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42164. */
  42165. private processModel;
  42166. private createMeshInfo;
  42167. /**
  42168. * Gets the ray of the controller in the direction the controller is pointing
  42169. * @param length the length the resulting ray should be
  42170. * @returns a ray in the direction the controller is pointing
  42171. */
  42172. getForwardRay(length?: number): Ray;
  42173. /**
  42174. * Disposes of the controller
  42175. */
  42176. dispose(): void;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Oculus Touch Controller
  42182. */
  42183. export class OculusTouchController extends WebVRController {
  42184. /**
  42185. * Base Url for the controller model.
  42186. */
  42187. static MODEL_BASE_URL: string;
  42188. /**
  42189. * File name for the left controller model.
  42190. */
  42191. static MODEL_LEFT_FILENAME: string;
  42192. /**
  42193. * File name for the right controller model.
  42194. */
  42195. static MODEL_RIGHT_FILENAME: string;
  42196. /**
  42197. * Base Url for the Quest controller model.
  42198. */
  42199. static QUEST_MODEL_BASE_URL: string;
  42200. /**
  42201. * @hidden
  42202. * If the controllers are running on a device that needs the updated Quest controller models
  42203. */
  42204. static _IsQuest: boolean;
  42205. /**
  42206. * Fired when the secondary trigger on this controller is modified
  42207. */
  42208. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42209. /**
  42210. * Fired when the thumb rest on this controller is modified
  42211. */
  42212. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42213. /**
  42214. * Creates a new OculusTouchController from a gamepad
  42215. * @param vrGamepad the gamepad that the controller should be created from
  42216. */
  42217. constructor(vrGamepad: any);
  42218. /**
  42219. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42220. * @param scene scene in which to add meshes
  42221. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42222. */
  42223. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42224. /**
  42225. * Fired when the A button on this controller is modified
  42226. */
  42227. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42228. /**
  42229. * Fired when the B button on this controller is modified
  42230. */
  42231. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42232. /**
  42233. * Fired when the X button on this controller is modified
  42234. */
  42235. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42236. /**
  42237. * Fired when the Y button on this controller is modified
  42238. */
  42239. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42240. /**
  42241. * Called once for each button that changed state since the last frame
  42242. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42243. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42244. * 2) secondary trigger (same)
  42245. * 3) A (right) X (left), touch, pressed = value
  42246. * 4) B / Y
  42247. * 5) thumb rest
  42248. * @param buttonIdx Which button index changed
  42249. * @param state New state of the button
  42250. * @param changes Which properties on the state changed since last frame
  42251. */
  42252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * Vive Controller
  42258. */
  42259. export class ViveController extends WebVRController {
  42260. /**
  42261. * Base Url for the controller model.
  42262. */
  42263. static MODEL_BASE_URL: string;
  42264. /**
  42265. * File name for the controller model.
  42266. */
  42267. static MODEL_FILENAME: string;
  42268. /**
  42269. * Creates a new ViveController from a gamepad
  42270. * @param vrGamepad the gamepad that the controller should be created from
  42271. */
  42272. constructor(vrGamepad: any);
  42273. /**
  42274. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42275. * @param scene scene in which to add meshes
  42276. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42277. */
  42278. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42279. /**
  42280. * Fired when the left button on this controller is modified
  42281. */
  42282. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42283. /**
  42284. * Fired when the right button on this controller is modified
  42285. */
  42286. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42287. /**
  42288. * Fired when the menu button on this controller is modified
  42289. */
  42290. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42291. /**
  42292. * Called once for each button that changed state since the last frame
  42293. * Vive mapping:
  42294. * 0: touchpad
  42295. * 1: trigger
  42296. * 2: left AND right buttons
  42297. * 3: menu button
  42298. * @param buttonIdx Which button index changed
  42299. * @param state New state of the button
  42300. * @param changes Which properties on the state changed since last frame
  42301. */
  42302. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42303. }
  42304. }
  42305. declare module BABYLON {
  42306. /**
  42307. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42308. */
  42309. export class WebXRControllerModelLoader {
  42310. /**
  42311. * Creates the WebXRControllerModelLoader
  42312. * @param input xr input that creates the controllers
  42313. */
  42314. constructor(input: WebXRInput);
  42315. }
  42316. }
  42317. declare module BABYLON {
  42318. /**
  42319. * Contains an array of blocks representing the octree
  42320. */
  42321. export interface IOctreeContainer<T> {
  42322. /**
  42323. * Blocks within the octree
  42324. */
  42325. blocks: Array<OctreeBlock<T>>;
  42326. }
  42327. /**
  42328. * Class used to store a cell in an octree
  42329. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42330. */
  42331. export class OctreeBlock<T> {
  42332. /**
  42333. * Gets the content of the current block
  42334. */
  42335. entries: T[];
  42336. /**
  42337. * Gets the list of block children
  42338. */
  42339. blocks: Array<OctreeBlock<T>>;
  42340. private _depth;
  42341. private _maxDepth;
  42342. private _capacity;
  42343. private _minPoint;
  42344. private _maxPoint;
  42345. private _boundingVectors;
  42346. private _creationFunc;
  42347. /**
  42348. * Creates a new block
  42349. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42350. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42351. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42352. * @param depth defines the current depth of this block in the octree
  42353. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42354. * @param creationFunc defines a callback to call when an element is added to the block
  42355. */
  42356. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42357. /**
  42358. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42359. */
  42360. readonly capacity: number;
  42361. /**
  42362. * Gets the minimum vector (in world space) of the block's bounding box
  42363. */
  42364. readonly minPoint: Vector3;
  42365. /**
  42366. * Gets the maximum vector (in world space) of the block's bounding box
  42367. */
  42368. readonly maxPoint: Vector3;
  42369. /**
  42370. * Add a new element to this block
  42371. * @param entry defines the element to add
  42372. */
  42373. addEntry(entry: T): void;
  42374. /**
  42375. * Remove an element from this block
  42376. * @param entry defines the element to remove
  42377. */
  42378. removeEntry(entry: T): void;
  42379. /**
  42380. * Add an array of elements to this block
  42381. * @param entries defines the array of elements to add
  42382. */
  42383. addEntries(entries: T[]): void;
  42384. /**
  42385. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42386. * @param frustumPlanes defines the frustum planes to test
  42387. * @param selection defines the array to store current content if selection is positive
  42388. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42389. */
  42390. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42391. /**
  42392. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42393. * @param sphereCenter defines the bounding sphere center
  42394. * @param sphereRadius defines the bounding sphere radius
  42395. * @param selection defines the array to store current content if selection is positive
  42396. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42397. */
  42398. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42399. /**
  42400. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42401. * @param ray defines the ray to test with
  42402. * @param selection defines the array to store current content if selection is positive
  42403. */
  42404. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42405. /**
  42406. * Subdivide the content into child blocks (this block will then be empty)
  42407. */
  42408. createInnerBlocks(): void;
  42409. /**
  42410. * @hidden
  42411. */
  42412. 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;
  42413. }
  42414. }
  42415. declare module BABYLON {
  42416. /**
  42417. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42419. */
  42420. export class Octree<T> {
  42421. /** 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.) */
  42422. maxDepth: number;
  42423. /**
  42424. * Blocks within the octree containing objects
  42425. */
  42426. blocks: Array<OctreeBlock<T>>;
  42427. /**
  42428. * Content stored in the octree
  42429. */
  42430. dynamicContent: T[];
  42431. private _maxBlockCapacity;
  42432. private _selectionContent;
  42433. private _creationFunc;
  42434. /**
  42435. * Creates a octree
  42436. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42437. * @param creationFunc function to be used to instatiate the octree
  42438. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42439. * @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.)
  42440. */
  42441. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42442. /** 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.) */
  42443. maxDepth?: number);
  42444. /**
  42445. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42446. * @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);
  42447. * @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);
  42448. * @param entries meshes to be added to the octree blocks
  42449. */
  42450. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42451. /**
  42452. * Adds a mesh to the octree
  42453. * @param entry Mesh to add to the octree
  42454. */
  42455. addMesh(entry: T): void;
  42456. /**
  42457. * Remove an element from the octree
  42458. * @param entry defines the element to remove
  42459. */
  42460. removeMesh(entry: T): void;
  42461. /**
  42462. * Selects an array of meshes within the frustum
  42463. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42464. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42465. * @returns array of meshes within the frustum
  42466. */
  42467. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42468. /**
  42469. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42470. * @param sphereCenter defines the bounding sphere center
  42471. * @param sphereRadius defines the bounding sphere radius
  42472. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42473. * @returns an array of objects that intersect the sphere
  42474. */
  42475. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42476. /**
  42477. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42478. * @param ray defines the ray to test with
  42479. * @returns array of intersected objects
  42480. */
  42481. intersectsRay(ray: Ray): SmartArray<T>;
  42482. /**
  42483. * Adds a mesh into the octree block if it intersects the block
  42484. */
  42485. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42486. /**
  42487. * Adds a submesh into the octree block if it intersects the block
  42488. */
  42489. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42490. }
  42491. }
  42492. declare module BABYLON {
  42493. interface Scene {
  42494. /**
  42495. * @hidden
  42496. * Backing Filed
  42497. */
  42498. _selectionOctree: Octree<AbstractMesh>;
  42499. /**
  42500. * Gets the octree used to boost mesh selection (picking)
  42501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42502. */
  42503. selectionOctree: Octree<AbstractMesh>;
  42504. /**
  42505. * Creates or updates the octree used to boost selection (picking)
  42506. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42507. * @param maxCapacity defines the maximum capacity per leaf
  42508. * @param maxDepth defines the maximum depth of the octree
  42509. * @returns an octree of AbstractMesh
  42510. */
  42511. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42512. }
  42513. interface AbstractMesh {
  42514. /**
  42515. * @hidden
  42516. * Backing Field
  42517. */
  42518. _submeshesOctree: Octree<SubMesh>;
  42519. /**
  42520. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42521. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42522. * @param maxCapacity defines the maximum size of each block (64 by default)
  42523. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42524. * @returns the new octree
  42525. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42527. */
  42528. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42529. }
  42530. /**
  42531. * Defines the octree scene component responsible to manage any octrees
  42532. * in a given scene.
  42533. */
  42534. export class OctreeSceneComponent {
  42535. /**
  42536. * The component name help to identify the component in the list of scene components.
  42537. */
  42538. readonly name: string;
  42539. /**
  42540. * The scene the component belongs to.
  42541. */
  42542. scene: Scene;
  42543. /**
  42544. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42545. */
  42546. readonly checksIsEnabled: boolean;
  42547. /**
  42548. * Creates a new instance of the component for the given scene
  42549. * @param scene Defines the scene to register the component in
  42550. */
  42551. constructor(scene: Scene);
  42552. /**
  42553. * Registers the component in a given scene
  42554. */
  42555. register(): void;
  42556. /**
  42557. * Return the list of active meshes
  42558. * @returns the list of active meshes
  42559. */
  42560. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42561. /**
  42562. * Return the list of active sub meshes
  42563. * @param mesh The mesh to get the candidates sub meshes from
  42564. * @returns the list of active sub meshes
  42565. */
  42566. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42567. private _tempRay;
  42568. /**
  42569. * Return the list of sub meshes intersecting with a given local ray
  42570. * @param mesh defines the mesh to find the submesh for
  42571. * @param localRay defines the ray in local space
  42572. * @returns the list of intersecting sub meshes
  42573. */
  42574. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42575. /**
  42576. * Return the list of sub meshes colliding with a collider
  42577. * @param mesh defines the mesh to find the submesh for
  42578. * @param collider defines the collider to evaluate the collision against
  42579. * @returns the list of colliding sub meshes
  42580. */
  42581. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42582. /**
  42583. * Rebuilds the elements related to this component in case of
  42584. * context lost for instance.
  42585. */
  42586. rebuild(): void;
  42587. /**
  42588. * Disposes the component and the associated ressources.
  42589. */
  42590. dispose(): void;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Renders a layer on top of an existing scene
  42596. */
  42597. export class UtilityLayerRenderer implements IDisposable {
  42598. /** the original scene that will be rendered on top of */
  42599. originalScene: Scene;
  42600. private _pointerCaptures;
  42601. private _lastPointerEvents;
  42602. private static _DefaultUtilityLayer;
  42603. private static _DefaultKeepDepthUtilityLayer;
  42604. private _sharedGizmoLight;
  42605. private _renderCamera;
  42606. /**
  42607. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42608. * @returns the camera that is used when rendering the utility layer
  42609. */
  42610. getRenderCamera(): Nullable<Camera>;
  42611. /**
  42612. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42613. * @param cam the camera that should be used when rendering the utility layer
  42614. */
  42615. setRenderCamera(cam: Nullable<Camera>): void;
  42616. /**
  42617. * @hidden
  42618. * Light which used by gizmos to get light shading
  42619. */
  42620. _getSharedGizmoLight(): HemisphericLight;
  42621. /**
  42622. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42623. */
  42624. pickUtilitySceneFirst: boolean;
  42625. /**
  42626. * 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)
  42627. */
  42628. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42629. /**
  42630. * 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)
  42631. */
  42632. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42633. /**
  42634. * The scene that is rendered on top of the original scene
  42635. */
  42636. utilityLayerScene: Scene;
  42637. /**
  42638. * If the utility layer should automatically be rendered on top of existing scene
  42639. */
  42640. shouldRender: boolean;
  42641. /**
  42642. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42643. */
  42644. onlyCheckPointerDownEvents: boolean;
  42645. /**
  42646. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42647. */
  42648. processAllEvents: boolean;
  42649. /**
  42650. * Observable raised when the pointer move from the utility layer scene to the main scene
  42651. */
  42652. onPointerOutObservable: Observable<number>;
  42653. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42654. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42655. private _afterRenderObserver;
  42656. private _sceneDisposeObserver;
  42657. private _originalPointerObserver;
  42658. /**
  42659. * Instantiates a UtilityLayerRenderer
  42660. * @param originalScene the original scene that will be rendered on top of
  42661. * @param handleEvents boolean indicating if the utility layer should handle events
  42662. */
  42663. constructor(
  42664. /** the original scene that will be rendered on top of */
  42665. originalScene: Scene, handleEvents?: boolean);
  42666. private _notifyObservers;
  42667. /**
  42668. * Renders the utility layers scene on top of the original scene
  42669. */
  42670. render(): void;
  42671. /**
  42672. * Disposes of the renderer
  42673. */
  42674. dispose(): void;
  42675. private _updateCamera;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42681. */
  42682. export class Gizmo implements IDisposable {
  42683. /** The utility layer the gizmo will be added to */
  42684. gizmoLayer: UtilityLayerRenderer;
  42685. /**
  42686. * The root mesh of the gizmo
  42687. */
  42688. _rootMesh: Mesh;
  42689. private _attachedMesh;
  42690. /**
  42691. * Ratio for the scale of the gizmo (Default: 1)
  42692. */
  42693. scaleRatio: number;
  42694. /**
  42695. * If a custom mesh has been set (Default: false)
  42696. */
  42697. protected _customMeshSet: boolean;
  42698. /**
  42699. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42700. * * When set, interactions will be enabled
  42701. */
  42702. attachedMesh: Nullable<AbstractMesh>;
  42703. /**
  42704. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42705. * @param mesh The mesh to replace the default mesh of the gizmo
  42706. */
  42707. setCustomMesh(mesh: Mesh): void;
  42708. /**
  42709. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42710. */
  42711. updateGizmoRotationToMatchAttachedMesh: boolean;
  42712. /**
  42713. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42714. */
  42715. updateGizmoPositionToMatchAttachedMesh: boolean;
  42716. /**
  42717. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42718. */
  42719. updateScale: boolean;
  42720. protected _interactionsEnabled: boolean;
  42721. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42722. private _beforeRenderObserver;
  42723. private _tempVector;
  42724. /**
  42725. * Creates a gizmo
  42726. * @param gizmoLayer The utility layer the gizmo will be added to
  42727. */
  42728. constructor(
  42729. /** The utility layer the gizmo will be added to */
  42730. gizmoLayer?: UtilityLayerRenderer);
  42731. /**
  42732. * Updates the gizmo to match the attached mesh's position/rotation
  42733. */
  42734. protected _update(): void;
  42735. /**
  42736. * Disposes of the gizmo
  42737. */
  42738. dispose(): void;
  42739. }
  42740. }
  42741. declare module BABYLON {
  42742. /**
  42743. * Single plane drag gizmo
  42744. */
  42745. export class PlaneDragGizmo extends Gizmo {
  42746. /**
  42747. * Drag behavior responsible for the gizmos dragging interactions
  42748. */
  42749. dragBehavior: PointerDragBehavior;
  42750. private _pointerObserver;
  42751. /**
  42752. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42753. */
  42754. snapDistance: number;
  42755. /**
  42756. * Event that fires each time the gizmo snaps to a new location.
  42757. * * snapDistance is the the change in distance
  42758. */
  42759. onSnapObservable: Observable<{
  42760. snapDistance: number;
  42761. }>;
  42762. private _plane;
  42763. private _coloredMaterial;
  42764. private _hoverMaterial;
  42765. private _isEnabled;
  42766. private _parent;
  42767. /** @hidden */
  42768. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42769. /** @hidden */
  42770. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42771. /**
  42772. * Creates a PlaneDragGizmo
  42773. * @param gizmoLayer The utility layer the gizmo will be added to
  42774. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42775. * @param color The color of the gizmo
  42776. */
  42777. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42778. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42779. /**
  42780. * If the gizmo is enabled
  42781. */
  42782. isEnabled: boolean;
  42783. /**
  42784. * Disposes of the gizmo
  42785. */
  42786. dispose(): void;
  42787. }
  42788. }
  42789. declare module BABYLON {
  42790. /**
  42791. * Gizmo that enables dragging a mesh along 3 axis
  42792. */
  42793. export class PositionGizmo extends Gizmo {
  42794. /**
  42795. * Internal gizmo used for interactions on the x axis
  42796. */
  42797. xGizmo: AxisDragGizmo;
  42798. /**
  42799. * Internal gizmo used for interactions on the y axis
  42800. */
  42801. yGizmo: AxisDragGizmo;
  42802. /**
  42803. * Internal gizmo used for interactions on the z axis
  42804. */
  42805. zGizmo: AxisDragGizmo;
  42806. /**
  42807. * Internal gizmo used for interactions on the yz plane
  42808. */
  42809. xPlaneGizmo: PlaneDragGizmo;
  42810. /**
  42811. * Internal gizmo used for interactions on the xz plane
  42812. */
  42813. yPlaneGizmo: PlaneDragGizmo;
  42814. /**
  42815. * Internal gizmo used for interactions on the xy plane
  42816. */
  42817. zPlaneGizmo: PlaneDragGizmo;
  42818. /**
  42819. * private variables
  42820. */
  42821. private _meshAttached;
  42822. private _updateGizmoRotationToMatchAttachedMesh;
  42823. private _snapDistance;
  42824. private _scaleRatio;
  42825. /** Fires an event when any of it's sub gizmos are dragged */
  42826. onDragStartObservable: Observable<unknown>;
  42827. /** Fires an event when any of it's sub gizmos are released from dragging */
  42828. onDragEndObservable: Observable<unknown>;
  42829. /**
  42830. * If set to true, planar drag is enabled
  42831. */
  42832. private _planarGizmoEnabled;
  42833. attachedMesh: Nullable<AbstractMesh>;
  42834. /**
  42835. * Creates a PositionGizmo
  42836. * @param gizmoLayer The utility layer the gizmo will be added to
  42837. */
  42838. constructor(gizmoLayer?: UtilityLayerRenderer);
  42839. /**
  42840. * If the planar drag gizmo is enabled
  42841. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42842. */
  42843. planarGizmoEnabled: boolean;
  42844. updateGizmoRotationToMatchAttachedMesh: boolean;
  42845. /**
  42846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42847. */
  42848. snapDistance: number;
  42849. /**
  42850. * Ratio for the scale of the gizmo (Default: 1)
  42851. */
  42852. scaleRatio: number;
  42853. /**
  42854. * Disposes of the gizmo
  42855. */
  42856. dispose(): void;
  42857. /**
  42858. * CustomMeshes are not supported by this gizmo
  42859. * @param mesh The mesh to replace the default mesh of the gizmo
  42860. */
  42861. setCustomMesh(mesh: Mesh): void;
  42862. }
  42863. }
  42864. declare module BABYLON {
  42865. /**
  42866. * Single axis drag gizmo
  42867. */
  42868. export class AxisDragGizmo extends Gizmo {
  42869. /**
  42870. * Drag behavior responsible for the gizmos dragging interactions
  42871. */
  42872. dragBehavior: PointerDragBehavior;
  42873. private _pointerObserver;
  42874. /**
  42875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42876. */
  42877. snapDistance: number;
  42878. /**
  42879. * Event that fires each time the gizmo snaps to a new location.
  42880. * * snapDistance is the the change in distance
  42881. */
  42882. onSnapObservable: Observable<{
  42883. snapDistance: number;
  42884. }>;
  42885. private _isEnabled;
  42886. private _parent;
  42887. private _arrow;
  42888. private _coloredMaterial;
  42889. private _hoverMaterial;
  42890. /** @hidden */
  42891. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42892. /** @hidden */
  42893. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42894. /**
  42895. * Creates an AxisDragGizmo
  42896. * @param gizmoLayer The utility layer the gizmo will be added to
  42897. * @param dragAxis The axis which the gizmo will be able to drag on
  42898. * @param color The color of the gizmo
  42899. */
  42900. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42901. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42902. /**
  42903. * If the gizmo is enabled
  42904. */
  42905. isEnabled: boolean;
  42906. /**
  42907. * Disposes of the gizmo
  42908. */
  42909. dispose(): void;
  42910. }
  42911. }
  42912. declare module BABYLON.Debug {
  42913. /**
  42914. * The Axes viewer will show 3 axes in a specific point in space
  42915. */
  42916. export class AxesViewer {
  42917. private _xAxis;
  42918. private _yAxis;
  42919. private _zAxis;
  42920. private _scaleLinesFactor;
  42921. private _instanced;
  42922. /**
  42923. * Gets the hosting scene
  42924. */
  42925. scene: Scene;
  42926. /**
  42927. * Gets or sets a number used to scale line length
  42928. */
  42929. scaleLines: number;
  42930. /** Gets the node hierarchy used to render x-axis */
  42931. readonly xAxis: TransformNode;
  42932. /** Gets the node hierarchy used to render y-axis */
  42933. readonly yAxis: TransformNode;
  42934. /** Gets the node hierarchy used to render z-axis */
  42935. readonly zAxis: TransformNode;
  42936. /**
  42937. * Creates a new AxesViewer
  42938. * @param scene defines the hosting scene
  42939. * @param scaleLines defines a number used to scale line length (1 by default)
  42940. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42941. * @param xAxis defines the node hierarchy used to render the x-axis
  42942. * @param yAxis defines the node hierarchy used to render the y-axis
  42943. * @param zAxis defines the node hierarchy used to render the z-axis
  42944. */
  42945. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42946. /**
  42947. * Force the viewer to update
  42948. * @param position defines the position of the viewer
  42949. * @param xaxis defines the x axis of the viewer
  42950. * @param yaxis defines the y axis of the viewer
  42951. * @param zaxis defines the z axis of the viewer
  42952. */
  42953. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42954. /**
  42955. * Creates an instance of this axes viewer.
  42956. * @returns a new axes viewer with instanced meshes
  42957. */
  42958. createInstance(): AxesViewer;
  42959. /** Releases resources */
  42960. dispose(): void;
  42961. private static _SetRenderingGroupId;
  42962. }
  42963. }
  42964. declare module BABYLON.Debug {
  42965. /**
  42966. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42967. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42968. */
  42969. export class BoneAxesViewer extends AxesViewer {
  42970. /**
  42971. * Gets or sets the target mesh where to display the axes viewer
  42972. */
  42973. mesh: Nullable<Mesh>;
  42974. /**
  42975. * Gets or sets the target bone where to display the axes viewer
  42976. */
  42977. bone: Nullable<Bone>;
  42978. /** Gets current position */
  42979. pos: Vector3;
  42980. /** Gets direction of X axis */
  42981. xaxis: Vector3;
  42982. /** Gets direction of Y axis */
  42983. yaxis: Vector3;
  42984. /** Gets direction of Z axis */
  42985. zaxis: Vector3;
  42986. /**
  42987. * Creates a new BoneAxesViewer
  42988. * @param scene defines the hosting scene
  42989. * @param bone defines the target bone
  42990. * @param mesh defines the target mesh
  42991. * @param scaleLines defines a scaling factor for line length (1 by default)
  42992. */
  42993. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42994. /**
  42995. * Force the viewer to update
  42996. */
  42997. update(): void;
  42998. /** Releases resources */
  42999. dispose(): void;
  43000. }
  43001. }
  43002. declare module BABYLON {
  43003. /**
  43004. * Interface used to define scene explorer extensibility option
  43005. */
  43006. export interface IExplorerExtensibilityOption {
  43007. /**
  43008. * Define the option label
  43009. */
  43010. label: string;
  43011. /**
  43012. * Defines the action to execute on click
  43013. */
  43014. action: (entity: any) => void;
  43015. }
  43016. /**
  43017. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43018. */
  43019. export interface IExplorerExtensibilityGroup {
  43020. /**
  43021. * Defines a predicate to test if a given type mut be extended
  43022. */
  43023. predicate: (entity: any) => boolean;
  43024. /**
  43025. * Gets the list of options added to a type
  43026. */
  43027. entries: IExplorerExtensibilityOption[];
  43028. }
  43029. /**
  43030. * Interface used to define the options to use to create the Inspector
  43031. */
  43032. export interface IInspectorOptions {
  43033. /**
  43034. * Display in overlay mode (default: false)
  43035. */
  43036. overlay?: boolean;
  43037. /**
  43038. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43039. */
  43040. globalRoot?: HTMLElement;
  43041. /**
  43042. * Display the Scene explorer
  43043. */
  43044. showExplorer?: boolean;
  43045. /**
  43046. * Display the property inspector
  43047. */
  43048. showInspector?: boolean;
  43049. /**
  43050. * Display in embed mode (both panes on the right)
  43051. */
  43052. embedMode?: boolean;
  43053. /**
  43054. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43055. */
  43056. handleResize?: boolean;
  43057. /**
  43058. * Allow the panes to popup (default: true)
  43059. */
  43060. enablePopup?: boolean;
  43061. /**
  43062. * Allow the panes to be closed by users (default: true)
  43063. */
  43064. enableClose?: boolean;
  43065. /**
  43066. * Optional list of extensibility entries
  43067. */
  43068. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43069. /**
  43070. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43071. */
  43072. inspectorURL?: string;
  43073. }
  43074. interface Scene {
  43075. /**
  43076. * @hidden
  43077. * Backing field
  43078. */
  43079. _debugLayer: DebugLayer;
  43080. /**
  43081. * Gets the debug layer (aka Inspector) associated with the scene
  43082. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43083. */
  43084. debugLayer: DebugLayer;
  43085. }
  43086. /**
  43087. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43088. * what is happening in your scene
  43089. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43090. */
  43091. export class DebugLayer {
  43092. /**
  43093. * Define the url to get the inspector script from.
  43094. * By default it uses the babylonjs CDN.
  43095. * @ignoreNaming
  43096. */
  43097. static InspectorURL: string;
  43098. private _scene;
  43099. private BJSINSPECTOR;
  43100. private _onPropertyChangedObservable?;
  43101. /**
  43102. * Observable triggered when a property is changed through the inspector.
  43103. */
  43104. readonly onPropertyChangedObservable: any;
  43105. /**
  43106. * Instantiates a new debug layer.
  43107. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43108. * what is happening in your scene
  43109. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43110. * @param scene Defines the scene to inspect
  43111. */
  43112. constructor(scene: Scene);
  43113. /** Creates the inspector window. */
  43114. private _createInspector;
  43115. /**
  43116. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43117. * @param entity defines the entity to select
  43118. * @param lineContainerTitle defines the specific block to highlight
  43119. */
  43120. select(entity: any, lineContainerTitle?: string): void;
  43121. /** Get the inspector from bundle or global */
  43122. private _getGlobalInspector;
  43123. /**
  43124. * Get if the inspector is visible or not.
  43125. * @returns true if visible otherwise, false
  43126. */
  43127. isVisible(): boolean;
  43128. /**
  43129. * Hide the inspector and close its window.
  43130. */
  43131. hide(): void;
  43132. /**
  43133. * Launch the debugLayer.
  43134. * @param config Define the configuration of the inspector
  43135. * @return a promise fulfilled when the debug layer is visible
  43136. */
  43137. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43138. }
  43139. }
  43140. declare module BABYLON {
  43141. /**
  43142. * Class containing static functions to help procedurally build meshes
  43143. */
  43144. export class BoxBuilder {
  43145. /**
  43146. * Creates a box mesh
  43147. * * The parameter `size` sets the size (float) of each box side (default 1)
  43148. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43149. * * 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)
  43150. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43152. * * 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
  43153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43154. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43155. * @param name defines the name of the mesh
  43156. * @param options defines the options used to create the mesh
  43157. * @param scene defines the hosting scene
  43158. * @returns the box mesh
  43159. */
  43160. static CreateBox(name: string, options: {
  43161. size?: number;
  43162. width?: number;
  43163. height?: number;
  43164. depth?: number;
  43165. faceUV?: Vector4[];
  43166. faceColors?: Color4[];
  43167. sideOrientation?: number;
  43168. frontUVs?: Vector4;
  43169. backUVs?: Vector4;
  43170. wrap?: boolean;
  43171. topBaseAt?: number;
  43172. bottomBaseAt?: number;
  43173. updatable?: boolean;
  43174. }, scene?: Nullable<Scene>): Mesh;
  43175. }
  43176. }
  43177. declare module BABYLON {
  43178. /**
  43179. * Class containing static functions to help procedurally build meshes
  43180. */
  43181. export class SphereBuilder {
  43182. /**
  43183. * Creates a sphere mesh
  43184. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43185. * * 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`)
  43186. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43187. * * 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
  43188. * * 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)
  43189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43190. * * 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
  43191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43192. * @param name defines the name of the mesh
  43193. * @param options defines the options used to create the mesh
  43194. * @param scene defines the hosting scene
  43195. * @returns the sphere mesh
  43196. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43197. */
  43198. static CreateSphere(name: string, options: {
  43199. segments?: number;
  43200. diameter?: number;
  43201. diameterX?: number;
  43202. diameterY?: number;
  43203. diameterZ?: number;
  43204. arc?: number;
  43205. slice?: number;
  43206. sideOrientation?: number;
  43207. frontUVs?: Vector4;
  43208. backUVs?: Vector4;
  43209. updatable?: boolean;
  43210. }, scene?: Nullable<Scene>): Mesh;
  43211. }
  43212. }
  43213. declare module BABYLON.Debug {
  43214. /**
  43215. * Used to show the physics impostor around the specific mesh
  43216. */
  43217. export class PhysicsViewer {
  43218. /** @hidden */
  43219. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43220. /** @hidden */
  43221. protected _meshes: Array<Nullable<AbstractMesh>>;
  43222. /** @hidden */
  43223. protected _scene: Nullable<Scene>;
  43224. /** @hidden */
  43225. protected _numMeshes: number;
  43226. /** @hidden */
  43227. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43228. private _renderFunction;
  43229. private _utilityLayer;
  43230. private _debugBoxMesh;
  43231. private _debugSphereMesh;
  43232. private _debugCylinderMesh;
  43233. private _debugMaterial;
  43234. private _debugMeshMeshes;
  43235. /**
  43236. * Creates a new PhysicsViewer
  43237. * @param scene defines the hosting scene
  43238. */
  43239. constructor(scene: Scene);
  43240. /** @hidden */
  43241. protected _updateDebugMeshes(): void;
  43242. /**
  43243. * Renders a specified physic impostor
  43244. * @param impostor defines the impostor to render
  43245. * @param targetMesh defines the mesh represented by the impostor
  43246. * @returns the new debug mesh used to render the impostor
  43247. */
  43248. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43249. /**
  43250. * Hides a specified physic impostor
  43251. * @param impostor defines the impostor to hide
  43252. */
  43253. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43254. private _getDebugMaterial;
  43255. private _getDebugBoxMesh;
  43256. private _getDebugSphereMesh;
  43257. private _getDebugCylinderMesh;
  43258. private _getDebugMeshMesh;
  43259. private _getDebugMesh;
  43260. /** Releases all resources */
  43261. dispose(): void;
  43262. }
  43263. }
  43264. declare module BABYLON {
  43265. /**
  43266. * Class containing static functions to help procedurally build meshes
  43267. */
  43268. export class LinesBuilder {
  43269. /**
  43270. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43271. * * 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
  43272. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43273. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43274. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43275. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43276. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43277. * * 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
  43278. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43281. * @param name defines the name of the new line system
  43282. * @param options defines the options used to create the line system
  43283. * @param scene defines the hosting scene
  43284. * @returns a new line system mesh
  43285. */
  43286. static CreateLineSystem(name: string, options: {
  43287. lines: Vector3[][];
  43288. updatable?: boolean;
  43289. instance?: Nullable<LinesMesh>;
  43290. colors?: Nullable<Color4[][]>;
  43291. useVertexAlpha?: boolean;
  43292. }, scene: Nullable<Scene>): LinesMesh;
  43293. /**
  43294. * Creates a line mesh
  43295. * 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
  43296. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43297. * * The parameter `points` is an array successive Vector3
  43298. * * 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
  43299. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43300. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43301. * * When updating an instance, remember that only point positions can change, not the number of points
  43302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43304. * @param name defines the name of the new line system
  43305. * @param options defines the options used to create the line system
  43306. * @param scene defines the hosting scene
  43307. * @returns a new line mesh
  43308. */
  43309. static CreateLines(name: string, options: {
  43310. points: Vector3[];
  43311. updatable?: boolean;
  43312. instance?: Nullable<LinesMesh>;
  43313. colors?: Color4[];
  43314. useVertexAlpha?: boolean;
  43315. }, scene?: Nullable<Scene>): LinesMesh;
  43316. /**
  43317. * Creates a dashed line mesh
  43318. * * 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
  43319. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43320. * * The parameter `points` is an array successive Vector3
  43321. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43322. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43323. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43324. * * 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
  43325. * * When updating an instance, remember that only point positions can change, not the number of points
  43326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43327. * @param name defines the name of the mesh
  43328. * @param options defines the options used to create the mesh
  43329. * @param scene defines the hosting scene
  43330. * @returns the dashed line mesh
  43331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43332. */
  43333. static CreateDashedLines(name: string, options: {
  43334. points: Vector3[];
  43335. dashSize?: number;
  43336. gapSize?: number;
  43337. dashNb?: number;
  43338. updatable?: boolean;
  43339. instance?: LinesMesh;
  43340. }, scene?: Nullable<Scene>): LinesMesh;
  43341. }
  43342. }
  43343. declare module BABYLON {
  43344. /**
  43345. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43346. * in order to better appreciate the issue one might have.
  43347. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43348. */
  43349. export class RayHelper {
  43350. /**
  43351. * Defines the ray we are currently tryin to visualize.
  43352. */
  43353. ray: Nullable<Ray>;
  43354. private _renderPoints;
  43355. private _renderLine;
  43356. private _renderFunction;
  43357. private _scene;
  43358. private _updateToMeshFunction;
  43359. private _attachedToMesh;
  43360. private _meshSpaceDirection;
  43361. private _meshSpaceOrigin;
  43362. /**
  43363. * Helper function to create a colored helper in a scene in one line.
  43364. * @param ray Defines the ray we are currently tryin to visualize
  43365. * @param scene Defines the scene the ray is used in
  43366. * @param color Defines the color we want to see the ray in
  43367. * @returns The newly created ray helper.
  43368. */
  43369. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43370. /**
  43371. * Instantiate a new ray helper.
  43372. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43373. * in order to better appreciate the issue one might have.
  43374. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43375. * @param ray Defines the ray we are currently tryin to visualize
  43376. */
  43377. constructor(ray: Ray);
  43378. /**
  43379. * Shows the ray we are willing to debug.
  43380. * @param scene Defines the scene the ray needs to be rendered in
  43381. * @param color Defines the color the ray needs to be rendered in
  43382. */
  43383. show(scene: Scene, color?: Color3): void;
  43384. /**
  43385. * Hides the ray we are debugging.
  43386. */
  43387. hide(): void;
  43388. private _render;
  43389. /**
  43390. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43391. * @param mesh Defines the mesh we want the helper attached to
  43392. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43393. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43394. * @param length Defines the length of the ray
  43395. */
  43396. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43397. /**
  43398. * Detach the ray helper from the mesh it has previously been attached to.
  43399. */
  43400. detachFromMesh(): void;
  43401. private _updateToMesh;
  43402. /**
  43403. * Dispose the helper and release its associated resources.
  43404. */
  43405. dispose(): void;
  43406. }
  43407. }
  43408. declare module BABYLON.Debug {
  43409. /**
  43410. * Class used to render a debug view of a given skeleton
  43411. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43412. */
  43413. export class SkeletonViewer {
  43414. /** defines the skeleton to render */
  43415. skeleton: Skeleton;
  43416. /** defines the mesh attached to the skeleton */
  43417. mesh: AbstractMesh;
  43418. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43419. autoUpdateBonesMatrices: boolean;
  43420. /** defines the rendering group id to use with the viewer */
  43421. renderingGroupId: number;
  43422. /** Gets or sets the color used to render the skeleton */
  43423. color: Color3;
  43424. private _scene;
  43425. private _debugLines;
  43426. private _debugMesh;
  43427. private _isEnabled;
  43428. private _renderFunction;
  43429. private _utilityLayer;
  43430. /**
  43431. * Returns the mesh used to render the bones
  43432. */
  43433. readonly debugMesh: Nullable<LinesMesh>;
  43434. /**
  43435. * Creates a new SkeletonViewer
  43436. * @param skeleton defines the skeleton to render
  43437. * @param mesh defines the mesh attached to the skeleton
  43438. * @param scene defines the hosting scene
  43439. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43440. * @param renderingGroupId defines the rendering group id to use with the viewer
  43441. */
  43442. constructor(
  43443. /** defines the skeleton to render */
  43444. skeleton: Skeleton,
  43445. /** defines the mesh attached to the skeleton */
  43446. mesh: AbstractMesh, scene: Scene,
  43447. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43448. autoUpdateBonesMatrices?: boolean,
  43449. /** defines the rendering group id to use with the viewer */
  43450. renderingGroupId?: number);
  43451. /** Gets or sets a boolean indicating if the viewer is enabled */
  43452. isEnabled: boolean;
  43453. private _getBonePosition;
  43454. private _getLinesForBonesWithLength;
  43455. private _getLinesForBonesNoLength;
  43456. /** Update the viewer to sync with current skeleton state */
  43457. update(): void;
  43458. /** Release associated resources */
  43459. dispose(): void;
  43460. }
  43461. }
  43462. declare module BABYLON {
  43463. /**
  43464. * Options to create the null engine
  43465. */
  43466. export class NullEngineOptions {
  43467. /**
  43468. * Render width (Default: 512)
  43469. */
  43470. renderWidth: number;
  43471. /**
  43472. * Render height (Default: 256)
  43473. */
  43474. renderHeight: number;
  43475. /**
  43476. * Texture size (Default: 512)
  43477. */
  43478. textureSize: number;
  43479. /**
  43480. * If delta time between frames should be constant
  43481. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43482. */
  43483. deterministicLockstep: boolean;
  43484. /**
  43485. * Maximum about of steps between frames (Default: 4)
  43486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43487. */
  43488. lockstepMaxSteps: number;
  43489. }
  43490. /**
  43491. * The null engine class provides support for headless version of babylon.js.
  43492. * This can be used in server side scenario or for testing purposes
  43493. */
  43494. export class NullEngine extends Engine {
  43495. private _options;
  43496. /**
  43497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43498. */
  43499. isDeterministicLockStep(): boolean;
  43500. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43501. getLockstepMaxSteps(): number;
  43502. /**
  43503. * Sets hardware scaling, used to save performance if needed
  43504. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43505. */
  43506. getHardwareScalingLevel(): number;
  43507. constructor(options?: NullEngineOptions);
  43508. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43509. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43510. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43511. getRenderWidth(useScreen?: boolean): number;
  43512. getRenderHeight(useScreen?: boolean): number;
  43513. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43514. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43515. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43516. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43517. bindSamplers(effect: Effect): void;
  43518. enableEffect(effect: Effect): void;
  43519. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43523. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43525. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43526. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43527. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43529. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43530. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43531. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43532. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43533. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43534. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43535. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43536. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43537. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43538. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43539. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43540. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43541. bindBuffers(vertexBuffers: {
  43542. [key: string]: VertexBuffer;
  43543. }, indexBuffer: DataBuffer, effect: Effect): void;
  43544. wipeCaches(bruteForce?: boolean): void;
  43545. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43546. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43547. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43548. /** @hidden */
  43549. _createTexture(): WebGLTexture;
  43550. /** @hidden */
  43551. _releaseTexture(texture: InternalTexture): void;
  43552. 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;
  43553. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43554. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43555. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43556. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43557. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43558. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43559. areAllEffectsReady(): boolean;
  43560. /**
  43561. * @hidden
  43562. * Get the current error code of the webGL context
  43563. * @returns the error code
  43564. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43565. */
  43566. getError(): number;
  43567. /** @hidden */
  43568. _getUnpackAlignement(): number;
  43569. /** @hidden */
  43570. _unpackFlipY(value: boolean): void;
  43571. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43572. /**
  43573. * Updates a dynamic vertex buffer.
  43574. * @param vertexBuffer the vertex buffer to update
  43575. * @param data the data used to update the vertex buffer
  43576. * @param byteOffset the byte offset of the data (optional)
  43577. * @param byteLength the byte length of the data (optional)
  43578. */
  43579. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43580. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43581. /** @hidden */
  43582. _bindTexture(channel: number, texture: InternalTexture): void;
  43583. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43584. releaseEffects(): void;
  43585. displayLoadingUI(): void;
  43586. hideLoadingUI(): void;
  43587. /** @hidden */
  43588. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43589. /** @hidden */
  43590. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43591. /** @hidden */
  43592. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43593. /** @hidden */
  43594. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43595. }
  43596. }
  43597. declare module BABYLON {
  43598. /** @hidden */
  43599. export class _OcclusionDataStorage {
  43600. /** @hidden */
  43601. occlusionInternalRetryCounter: number;
  43602. /** @hidden */
  43603. isOcclusionQueryInProgress: boolean;
  43604. /** @hidden */
  43605. isOccluded: boolean;
  43606. /** @hidden */
  43607. occlusionRetryCount: number;
  43608. /** @hidden */
  43609. occlusionType: number;
  43610. /** @hidden */
  43611. occlusionQueryAlgorithmType: number;
  43612. }
  43613. interface Engine {
  43614. /**
  43615. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43616. * @return the new query
  43617. */
  43618. createQuery(): WebGLQuery;
  43619. /**
  43620. * Delete and release a webGL query
  43621. * @param query defines the query to delete
  43622. * @return the current engine
  43623. */
  43624. deleteQuery(query: WebGLQuery): Engine;
  43625. /**
  43626. * Check if a given query has resolved and got its value
  43627. * @param query defines the query to check
  43628. * @returns true if the query got its value
  43629. */
  43630. isQueryResultAvailable(query: WebGLQuery): boolean;
  43631. /**
  43632. * Gets the value of a given query
  43633. * @param query defines the query to check
  43634. * @returns the value of the query
  43635. */
  43636. getQueryResult(query: WebGLQuery): number;
  43637. /**
  43638. * Initiates an occlusion query
  43639. * @param algorithmType defines the algorithm to use
  43640. * @param query defines the query to use
  43641. * @returns the current engine
  43642. * @see http://doc.babylonjs.com/features/occlusionquery
  43643. */
  43644. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43645. /**
  43646. * Ends an occlusion query
  43647. * @see http://doc.babylonjs.com/features/occlusionquery
  43648. * @param algorithmType defines the algorithm to use
  43649. * @returns the current engine
  43650. */
  43651. endOcclusionQuery(algorithmType: number): Engine;
  43652. /**
  43653. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43654. * Please note that only one query can be issued at a time
  43655. * @returns a time token used to track the time span
  43656. */
  43657. startTimeQuery(): Nullable<_TimeToken>;
  43658. /**
  43659. * Ends a time query
  43660. * @param token defines the token used to measure the time span
  43661. * @returns the time spent (in ns)
  43662. */
  43663. endTimeQuery(token: _TimeToken): int;
  43664. /** @hidden */
  43665. _currentNonTimestampToken: Nullable<_TimeToken>;
  43666. /** @hidden */
  43667. _createTimeQuery(): WebGLQuery;
  43668. /** @hidden */
  43669. _deleteTimeQuery(query: WebGLQuery): void;
  43670. /** @hidden */
  43671. _getGlAlgorithmType(algorithmType: number): number;
  43672. /** @hidden */
  43673. _getTimeQueryResult(query: WebGLQuery): any;
  43674. /** @hidden */
  43675. _getTimeQueryAvailability(query: WebGLQuery): any;
  43676. }
  43677. interface AbstractMesh {
  43678. /**
  43679. * Backing filed
  43680. * @hidden
  43681. */
  43682. __occlusionDataStorage: _OcclusionDataStorage;
  43683. /**
  43684. * Access property
  43685. * @hidden
  43686. */
  43687. _occlusionDataStorage: _OcclusionDataStorage;
  43688. /**
  43689. * 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.
  43690. * The default value is -1 which means don't break the query and wait till the result
  43691. * @see http://doc.babylonjs.com/features/occlusionquery
  43692. */
  43693. occlusionRetryCount: number;
  43694. /**
  43695. * 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:
  43696. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43697. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43698. * * 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.
  43699. * @see http://doc.babylonjs.com/features/occlusionquery
  43700. */
  43701. occlusionType: number;
  43702. /**
  43703. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43704. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43705. * * 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.
  43706. * @see http://doc.babylonjs.com/features/occlusionquery
  43707. */
  43708. occlusionQueryAlgorithmType: number;
  43709. /**
  43710. * 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
  43711. * @see http://doc.babylonjs.com/features/occlusionquery
  43712. */
  43713. isOccluded: boolean;
  43714. /**
  43715. * Flag to check the progress status of the query
  43716. * @see http://doc.babylonjs.com/features/occlusionquery
  43717. */
  43718. isOcclusionQueryInProgress: boolean;
  43719. }
  43720. }
  43721. declare module BABYLON {
  43722. /** @hidden */
  43723. export var _forceTransformFeedbackToBundle: boolean;
  43724. interface Engine {
  43725. /**
  43726. * Creates a webGL transform feedback object
  43727. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43728. * @returns the webGL transform feedback object
  43729. */
  43730. createTransformFeedback(): WebGLTransformFeedback;
  43731. /**
  43732. * Delete a webGL transform feedback object
  43733. * @param value defines the webGL transform feedback object to delete
  43734. */
  43735. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43736. /**
  43737. * Bind a webGL transform feedback object to the webgl context
  43738. * @param value defines the webGL transform feedback object to bind
  43739. */
  43740. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43741. /**
  43742. * Begins a transform feedback operation
  43743. * @param usePoints defines if points or triangles must be used
  43744. */
  43745. beginTransformFeedback(usePoints: boolean): void;
  43746. /**
  43747. * Ends a transform feedback operation
  43748. */
  43749. endTransformFeedback(): void;
  43750. /**
  43751. * Specify the varyings to use with transform feedback
  43752. * @param program defines the associated webGL program
  43753. * @param value defines the list of strings representing the varying names
  43754. */
  43755. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43756. /**
  43757. * Bind a webGL buffer for a transform feedback operation
  43758. * @param value defines the webGL buffer to bind
  43759. */
  43760. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43761. }
  43762. }
  43763. declare module BABYLON {
  43764. /**
  43765. * Creation options of the multi render target texture.
  43766. */
  43767. export interface IMultiRenderTargetOptions {
  43768. /**
  43769. * Define if the texture needs to create mip maps after render.
  43770. */
  43771. generateMipMaps?: boolean;
  43772. /**
  43773. * Define the types of all the draw buffers we want to create
  43774. */
  43775. types?: number[];
  43776. /**
  43777. * Define the sampling modes of all the draw buffers we want to create
  43778. */
  43779. samplingModes?: number[];
  43780. /**
  43781. * Define if a depth buffer is required
  43782. */
  43783. generateDepthBuffer?: boolean;
  43784. /**
  43785. * Define if a stencil buffer is required
  43786. */
  43787. generateStencilBuffer?: boolean;
  43788. /**
  43789. * Define if a depth texture is required instead of a depth buffer
  43790. */
  43791. generateDepthTexture?: boolean;
  43792. /**
  43793. * Define the number of desired draw buffers
  43794. */
  43795. textureCount?: number;
  43796. /**
  43797. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43798. */
  43799. doNotChangeAspectRatio?: boolean;
  43800. /**
  43801. * Define the default type of the buffers we are creating
  43802. */
  43803. defaultType?: number;
  43804. }
  43805. /**
  43806. * A multi render target, like a render target provides the ability to render to a texture.
  43807. * Unlike the render target, it can render to several draw buffers in one draw.
  43808. * This is specially interesting in deferred rendering or for any effects requiring more than
  43809. * just one color from a single pass.
  43810. */
  43811. export class MultiRenderTarget extends RenderTargetTexture {
  43812. private _internalTextures;
  43813. private _textures;
  43814. private _multiRenderTargetOptions;
  43815. /**
  43816. * Get if draw buffers are currently supported by the used hardware and browser.
  43817. */
  43818. readonly isSupported: boolean;
  43819. /**
  43820. * Get the list of textures generated by the multi render target.
  43821. */
  43822. readonly textures: Texture[];
  43823. /**
  43824. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43825. */
  43826. readonly depthTexture: Texture;
  43827. /**
  43828. * Set the wrapping mode on U of all the textures we are rendering to.
  43829. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43830. */
  43831. wrapU: number;
  43832. /**
  43833. * Set the wrapping mode on V of all the textures we are rendering to.
  43834. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43835. */
  43836. wrapV: number;
  43837. /**
  43838. * Instantiate a new multi render target texture.
  43839. * A multi render target, like a render target provides the ability to render to a texture.
  43840. * Unlike the render target, it can render to several draw buffers in one draw.
  43841. * This is specially interesting in deferred rendering or for any effects requiring more than
  43842. * just one color from a single pass.
  43843. * @param name Define the name of the texture
  43844. * @param size Define the size of the buffers to render to
  43845. * @param count Define the number of target we are rendering into
  43846. * @param scene Define the scene the texture belongs to
  43847. * @param options Define the options used to create the multi render target
  43848. */
  43849. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43850. /** @hidden */
  43851. _rebuild(): void;
  43852. private _createInternalTextures;
  43853. private _createTextures;
  43854. /**
  43855. * Define the number of samples used if MSAA is enabled.
  43856. */
  43857. samples: number;
  43858. /**
  43859. * Resize all the textures in the multi render target.
  43860. * Be carrefull as it will recreate all the data in the new texture.
  43861. * @param size Define the new size
  43862. */
  43863. resize(size: any): void;
  43864. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43865. /**
  43866. * Dispose the render targets and their associated resources
  43867. */
  43868. dispose(): void;
  43869. /**
  43870. * Release all the underlying texture used as draw buffers.
  43871. */
  43872. releaseInternalTextures(): void;
  43873. }
  43874. }
  43875. declare module BABYLON {
  43876. interface Engine {
  43877. /**
  43878. * Unbind a list of render target textures from the webGL context
  43879. * This is used only when drawBuffer extension or webGL2 are active
  43880. * @param textures defines the render target textures to unbind
  43881. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43882. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43883. */
  43884. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43885. /**
  43886. * Create a multi render target texture
  43887. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43888. * @param size defines the size of the texture
  43889. * @param options defines the creation options
  43890. * @returns the cube texture as an InternalTexture
  43891. */
  43892. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43893. /**
  43894. * Update the sample count for a given multiple render target texture
  43895. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43896. * @param textures defines the textures to update
  43897. * @param samples defines the sample count to set
  43898. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43899. */
  43900. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43901. }
  43902. }
  43903. declare module BABYLON {
  43904. /** @hidden */
  43905. export var rgbdEncodePixelShader: {
  43906. name: string;
  43907. shader: string;
  43908. };
  43909. }
  43910. declare module BABYLON {
  43911. /** @hidden */
  43912. export var rgbdDecodePixelShader: {
  43913. name: string;
  43914. shader: string;
  43915. };
  43916. }
  43917. declare module BABYLON {
  43918. /**
  43919. * Raw texture data and descriptor sufficient for WebGL texture upload
  43920. */
  43921. export interface EnvironmentTextureInfo {
  43922. /**
  43923. * Version of the environment map
  43924. */
  43925. version: number;
  43926. /**
  43927. * Width of image
  43928. */
  43929. width: number;
  43930. /**
  43931. * Irradiance information stored in the file.
  43932. */
  43933. irradiance: any;
  43934. /**
  43935. * Specular information stored in the file.
  43936. */
  43937. specular: any;
  43938. }
  43939. /**
  43940. * Defines One Image in the file. It requires only the position in the file
  43941. * as well as the length.
  43942. */
  43943. interface BufferImageData {
  43944. /**
  43945. * Length of the image data.
  43946. */
  43947. length: number;
  43948. /**
  43949. * Position of the data from the null terminator delimiting the end of the JSON.
  43950. */
  43951. position: number;
  43952. }
  43953. /**
  43954. * Defines the specular data enclosed in the file.
  43955. * This corresponds to the version 1 of the data.
  43956. */
  43957. export interface EnvironmentTextureSpecularInfoV1 {
  43958. /**
  43959. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43960. */
  43961. specularDataPosition?: number;
  43962. /**
  43963. * This contains all the images data needed to reconstruct the cubemap.
  43964. */
  43965. mipmaps: Array<BufferImageData>;
  43966. /**
  43967. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43968. */
  43969. lodGenerationScale: number;
  43970. }
  43971. /**
  43972. * Sets of helpers addressing the serialization and deserialization of environment texture
  43973. * stored in a BabylonJS env file.
  43974. * Those files are usually stored as .env files.
  43975. */
  43976. export class EnvironmentTextureTools {
  43977. /**
  43978. * Magic number identifying the env file.
  43979. */
  43980. private static _MagicBytes;
  43981. /**
  43982. * Gets the environment info from an env file.
  43983. * @param data The array buffer containing the .env bytes.
  43984. * @returns the environment file info (the json header) if successfully parsed.
  43985. */
  43986. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43987. /**
  43988. * Creates an environment texture from a loaded cube texture.
  43989. * @param texture defines the cube texture to convert in env file
  43990. * @return a promise containing the environment data if succesfull.
  43991. */
  43992. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43993. /**
  43994. * Creates a JSON representation of the spherical data.
  43995. * @param texture defines the texture containing the polynomials
  43996. * @return the JSON representation of the spherical info
  43997. */
  43998. private static _CreateEnvTextureIrradiance;
  43999. /**
  44000. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44001. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44002. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44003. * @return the views described by info providing access to the underlying buffer
  44004. */
  44005. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44006. /**
  44007. * Uploads the texture info contained in the env file to the GPU.
  44008. * @param texture defines the internal texture to upload to
  44009. * @param arrayBuffer defines the buffer cotaining the data to load
  44010. * @param info defines the texture info retrieved through the GetEnvInfo method
  44011. * @returns a promise
  44012. */
  44013. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44014. /**
  44015. * Uploads the levels of image data to the GPU.
  44016. * @param texture defines the internal texture to upload to
  44017. * @param imageData defines the array buffer views of image data [mipmap][face]
  44018. * @returns a promise
  44019. */
  44020. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44021. /**
  44022. * Uploads spherical polynomials information to the texture.
  44023. * @param texture defines the texture we are trying to upload the information to
  44024. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44025. */
  44026. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44027. /** @hidden */
  44028. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44029. }
  44030. }
  44031. declare module BABYLON {
  44032. /**
  44033. * Contains position and normal vectors for a vertex
  44034. */
  44035. export class PositionNormalVertex {
  44036. /** the position of the vertex (defaut: 0,0,0) */
  44037. position: Vector3;
  44038. /** the normal of the vertex (defaut: 0,1,0) */
  44039. normal: Vector3;
  44040. /**
  44041. * Creates a PositionNormalVertex
  44042. * @param position the position of the vertex (defaut: 0,0,0)
  44043. * @param normal the normal of the vertex (defaut: 0,1,0)
  44044. */
  44045. constructor(
  44046. /** the position of the vertex (defaut: 0,0,0) */
  44047. position?: Vector3,
  44048. /** the normal of the vertex (defaut: 0,1,0) */
  44049. normal?: Vector3);
  44050. /**
  44051. * Clones the PositionNormalVertex
  44052. * @returns the cloned PositionNormalVertex
  44053. */
  44054. clone(): PositionNormalVertex;
  44055. }
  44056. /**
  44057. * Contains position, normal and uv vectors for a vertex
  44058. */
  44059. export class PositionNormalTextureVertex {
  44060. /** the position of the vertex (defaut: 0,0,0) */
  44061. position: Vector3;
  44062. /** the normal of the vertex (defaut: 0,1,0) */
  44063. normal: Vector3;
  44064. /** the uv of the vertex (default: 0,0) */
  44065. uv: Vector2;
  44066. /**
  44067. * Creates a PositionNormalTextureVertex
  44068. * @param position the position of the vertex (defaut: 0,0,0)
  44069. * @param normal the normal of the vertex (defaut: 0,1,0)
  44070. * @param uv the uv of the vertex (default: 0,0)
  44071. */
  44072. constructor(
  44073. /** the position of the vertex (defaut: 0,0,0) */
  44074. position?: Vector3,
  44075. /** the normal of the vertex (defaut: 0,1,0) */
  44076. normal?: Vector3,
  44077. /** the uv of the vertex (default: 0,0) */
  44078. uv?: Vector2);
  44079. /**
  44080. * Clones the PositionNormalTextureVertex
  44081. * @returns the cloned PositionNormalTextureVertex
  44082. */
  44083. clone(): PositionNormalTextureVertex;
  44084. }
  44085. }
  44086. declare module BABYLON {
  44087. /** @hidden */
  44088. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44089. private _genericAttributeLocation;
  44090. private _varyingLocationCount;
  44091. private _varyingLocationMap;
  44092. private _replacements;
  44093. private _textureCount;
  44094. private _uniforms;
  44095. lineProcessor(line: string): string;
  44096. attributeProcessor(attribute: string): string;
  44097. varyingProcessor(varying: string, isFragment: boolean): string;
  44098. uniformProcessor(uniform: string): string;
  44099. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44100. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44101. }
  44102. }
  44103. declare module BABYLON {
  44104. /**
  44105. * Container for accessors for natively-stored mesh data buffers.
  44106. */
  44107. class NativeDataBuffer extends DataBuffer {
  44108. /**
  44109. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44110. */
  44111. nativeIndexBuffer?: any;
  44112. /**
  44113. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44114. */
  44115. nativeVertexBuffer?: any;
  44116. }
  44117. /** @hidden */
  44118. export class NativeEngine extends Engine {
  44119. private readonly _native;
  44120. getHardwareScalingLevel(): number;
  44121. constructor();
  44122. /**
  44123. * Can be used to override the current requestAnimationFrame requester.
  44124. * @hidden
  44125. */
  44126. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44127. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44128. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44129. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44130. recordVertexArrayObject(vertexBuffers: {
  44131. [key: string]: VertexBuffer;
  44132. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44133. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44134. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44135. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44136. /**
  44137. * Draw a list of indexed primitives
  44138. * @param fillMode defines the primitive to use
  44139. * @param indexStart defines the starting index
  44140. * @param indexCount defines the number of index to draw
  44141. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44142. */
  44143. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44144. /**
  44145. * Draw a list of unindexed primitives
  44146. * @param fillMode defines the primitive to use
  44147. * @param verticesStart defines the index of first vertex to draw
  44148. * @param verticesCount defines the count of vertices to draw
  44149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44150. */
  44151. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44152. createPipelineContext(): IPipelineContext;
  44153. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44154. /** @hidden */
  44155. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44156. /** @hidden */
  44157. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44158. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44159. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44160. protected _setProgram(program: WebGLProgram): void;
  44161. _releaseEffect(effect: Effect): void;
  44162. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44163. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44164. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44165. bindSamplers(effect: Effect): void;
  44166. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44167. getRenderWidth(useScreen?: boolean): number;
  44168. getRenderHeight(useScreen?: boolean): number;
  44169. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44170. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44171. /**
  44172. * Set the z offset to apply to current rendering
  44173. * @param value defines the offset to apply
  44174. */
  44175. setZOffset(value: number): void;
  44176. /**
  44177. * Gets the current value of the zOffset
  44178. * @returns the current zOffset state
  44179. */
  44180. getZOffset(): number;
  44181. /**
  44182. * Enable or disable depth buffering
  44183. * @param enable defines the state to set
  44184. */
  44185. setDepthBuffer(enable: boolean): void;
  44186. /**
  44187. * Gets a boolean indicating if depth writing is enabled
  44188. * @returns the current depth writing state
  44189. */
  44190. getDepthWrite(): boolean;
  44191. /**
  44192. * Enable or disable depth writing
  44193. * @param enable defines the state to set
  44194. */
  44195. setDepthWrite(enable: boolean): void;
  44196. /**
  44197. * Enable or disable color writing
  44198. * @param enable defines the state to set
  44199. */
  44200. setColorWrite(enable: boolean): void;
  44201. /**
  44202. * Gets a boolean indicating if color writing is enabled
  44203. * @returns the current color writing state
  44204. */
  44205. getColorWrite(): boolean;
  44206. /**
  44207. * Sets alpha constants used by some alpha blending modes
  44208. * @param r defines the red component
  44209. * @param g defines the green component
  44210. * @param b defines the blue component
  44211. * @param a defines the alpha component
  44212. */
  44213. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44214. /**
  44215. * Sets the current alpha mode
  44216. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44217. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44218. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44219. */
  44220. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44221. /**
  44222. * Gets the current alpha mode
  44223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44224. * @returns the current alpha mode
  44225. */
  44226. getAlphaMode(): number;
  44227. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44228. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44229. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44230. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44231. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44232. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44233. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44234. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44235. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44236. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44237. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44238. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44239. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44240. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44241. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44242. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44243. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44244. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44245. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44246. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44247. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44248. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44249. wipeCaches(bruteForce?: boolean): void;
  44250. _createTexture(): WebGLTexture;
  44251. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44252. /**
  44253. * Usually called from BABYLON.Texture.ts.
  44254. * Passed information to create a WebGLTexture
  44255. * @param urlArg defines a value which contains one of the following:
  44256. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44257. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44258. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44260. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44261. * @param scene needed for loading to the correct scene
  44262. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44263. * @param onLoad optional callback to be called upon successful completion
  44264. * @param onError optional callback to be called upon failure
  44265. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44266. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44267. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44268. * @param forcedExtension defines the extension to use to pick the right loader
  44269. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44270. */
  44271. 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;
  44272. /**
  44273. * Creates a cube texture
  44274. * @param rootUrl defines the url where the files to load is located
  44275. * @param scene defines the current scene
  44276. * @param files defines the list of files to load (1 per face)
  44277. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44278. * @param onLoad defines an optional callback raised when the texture is loaded
  44279. * @param onError defines an optional callback raised if there is an issue to load the texture
  44280. * @param format defines the format of the data
  44281. * @param forcedExtension defines the extension to use to pick the right loader
  44282. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44283. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44284. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44285. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44286. * @returns the cube texture as an InternalTexture
  44287. */
  44288. 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;
  44289. private _getSamplingFilter;
  44290. private static _GetNativeTextureFormat;
  44291. createRenderTargetTexture(size: number | {
  44292. width: number;
  44293. height: number;
  44294. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44295. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44296. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44297. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44298. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44299. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44300. /**
  44301. * Updates a dynamic vertex buffer.
  44302. * @param vertexBuffer the vertex buffer to update
  44303. * @param data the data used to update the vertex buffer
  44304. * @param byteOffset the byte offset of the data (optional)
  44305. * @param byteLength the byte length of the data (optional)
  44306. */
  44307. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44308. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44309. private _updateAnisotropicLevel;
  44310. private _getAddressMode;
  44311. /** @hidden */
  44312. _bindTexture(channel: number, texture: InternalTexture): void;
  44313. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44314. releaseEffects(): void;
  44315. /** @hidden */
  44316. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44317. /** @hidden */
  44318. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44319. /** @hidden */
  44320. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44321. /** @hidden */
  44322. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44323. }
  44324. }
  44325. declare module BABYLON {
  44326. /**
  44327. * Gather the list of clipboard event types as constants.
  44328. */
  44329. export class ClipboardEventTypes {
  44330. /**
  44331. * The clipboard event is fired when a copy command is active (pressed).
  44332. */
  44333. static readonly COPY: number;
  44334. /**
  44335. * The clipboard event is fired when a cut command is active (pressed).
  44336. */
  44337. static readonly CUT: number;
  44338. /**
  44339. * The clipboard event is fired when a paste command is active (pressed).
  44340. */
  44341. static readonly PASTE: number;
  44342. }
  44343. /**
  44344. * This class is used to store clipboard related info for the onClipboardObservable event.
  44345. */
  44346. export class ClipboardInfo {
  44347. /**
  44348. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44349. */
  44350. type: number;
  44351. /**
  44352. * Defines the related dom event
  44353. */
  44354. event: ClipboardEvent;
  44355. /**
  44356. *Creates an instance of ClipboardInfo.
  44357. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44358. * @param event Defines the related dom event
  44359. */
  44360. constructor(
  44361. /**
  44362. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44363. */
  44364. type: number,
  44365. /**
  44366. * Defines the related dom event
  44367. */
  44368. event: ClipboardEvent);
  44369. /**
  44370. * Get the clipboard event's type from the keycode.
  44371. * @param keyCode Defines the keyCode for the current keyboard event.
  44372. * @return {number}
  44373. */
  44374. static GetTypeFromCharacter(keyCode: number): number;
  44375. }
  44376. }
  44377. declare module BABYLON {
  44378. /**
  44379. * Google Daydream controller
  44380. */
  44381. export class DaydreamController extends WebVRController {
  44382. /**
  44383. * Base Url for the controller model.
  44384. */
  44385. static MODEL_BASE_URL: string;
  44386. /**
  44387. * File name for the controller model.
  44388. */
  44389. static MODEL_FILENAME: string;
  44390. /**
  44391. * Gamepad Id prefix used to identify Daydream Controller.
  44392. */
  44393. static readonly GAMEPAD_ID_PREFIX: string;
  44394. /**
  44395. * Creates a new DaydreamController from a gamepad
  44396. * @param vrGamepad the gamepad that the controller should be created from
  44397. */
  44398. constructor(vrGamepad: any);
  44399. /**
  44400. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44401. * @param scene scene in which to add meshes
  44402. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44403. */
  44404. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44405. /**
  44406. * Called once for each button that changed state since the last frame
  44407. * @param buttonIdx Which button index changed
  44408. * @param state New state of the button
  44409. * @param changes Which properties on the state changed since last frame
  44410. */
  44411. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44412. }
  44413. }
  44414. declare module BABYLON {
  44415. /**
  44416. * Gear VR Controller
  44417. */
  44418. export class GearVRController extends WebVRController {
  44419. /**
  44420. * Base Url for the controller model.
  44421. */
  44422. static MODEL_BASE_URL: string;
  44423. /**
  44424. * File name for the controller model.
  44425. */
  44426. static MODEL_FILENAME: string;
  44427. /**
  44428. * Gamepad Id prefix used to identify this controller.
  44429. */
  44430. static readonly GAMEPAD_ID_PREFIX: string;
  44431. private readonly _buttonIndexToObservableNameMap;
  44432. /**
  44433. * Creates a new GearVRController from a gamepad
  44434. * @param vrGamepad the gamepad that the controller should be created from
  44435. */
  44436. constructor(vrGamepad: any);
  44437. /**
  44438. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44439. * @param scene scene in which to add meshes
  44440. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44441. */
  44442. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44443. /**
  44444. * Called once for each button that changed state since the last frame
  44445. * @param buttonIdx Which button index changed
  44446. * @param state New state of the button
  44447. * @param changes Which properties on the state changed since last frame
  44448. */
  44449. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44450. }
  44451. }
  44452. declare module BABYLON {
  44453. /**
  44454. * Class containing static functions to help procedurally build meshes
  44455. */
  44456. export class PolyhedronBuilder {
  44457. /**
  44458. * Creates a polyhedron mesh
  44459. * * 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
  44460. * * The parameter `size` (positive float, default 1) sets the polygon size
  44461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44462. * * 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`
  44463. * * 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
  44464. * * 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)`)
  44465. * * 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
  44466. * * 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
  44467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44468. * * 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
  44469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44470. * @param name defines the name of the mesh
  44471. * @param options defines the options used to create the mesh
  44472. * @param scene defines the hosting scene
  44473. * @returns the polyhedron mesh
  44474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44475. */
  44476. static CreatePolyhedron(name: string, options: {
  44477. type?: number;
  44478. size?: number;
  44479. sizeX?: number;
  44480. sizeY?: number;
  44481. sizeZ?: number;
  44482. custom?: any;
  44483. faceUV?: Vector4[];
  44484. faceColors?: Color4[];
  44485. flat?: boolean;
  44486. updatable?: boolean;
  44487. sideOrientation?: number;
  44488. frontUVs?: Vector4;
  44489. backUVs?: Vector4;
  44490. }, scene?: Nullable<Scene>): Mesh;
  44491. }
  44492. }
  44493. declare module BABYLON {
  44494. /**
  44495. * Gizmo that enables scaling a mesh along 3 axis
  44496. */
  44497. export class ScaleGizmo extends Gizmo {
  44498. /**
  44499. * Internal gizmo used for interactions on the x axis
  44500. */
  44501. xGizmo: AxisScaleGizmo;
  44502. /**
  44503. * Internal gizmo used for interactions on the y axis
  44504. */
  44505. yGizmo: AxisScaleGizmo;
  44506. /**
  44507. * Internal gizmo used for interactions on the z axis
  44508. */
  44509. zGizmo: AxisScaleGizmo;
  44510. /**
  44511. * Internal gizmo used to scale all axis equally
  44512. */
  44513. uniformScaleGizmo: AxisScaleGizmo;
  44514. private _meshAttached;
  44515. private _updateGizmoRotationToMatchAttachedMesh;
  44516. private _snapDistance;
  44517. private _scaleRatio;
  44518. private _uniformScalingMesh;
  44519. private _octahedron;
  44520. /** Fires an event when any of it's sub gizmos are dragged */
  44521. onDragStartObservable: Observable<unknown>;
  44522. /** Fires an event when any of it's sub gizmos are released from dragging */
  44523. onDragEndObservable: Observable<unknown>;
  44524. attachedMesh: Nullable<AbstractMesh>;
  44525. /**
  44526. * Creates a ScaleGizmo
  44527. * @param gizmoLayer The utility layer the gizmo will be added to
  44528. */
  44529. constructor(gizmoLayer?: UtilityLayerRenderer);
  44530. updateGizmoRotationToMatchAttachedMesh: boolean;
  44531. /**
  44532. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44533. */
  44534. snapDistance: number;
  44535. /**
  44536. * Ratio for the scale of the gizmo (Default: 1)
  44537. */
  44538. scaleRatio: number;
  44539. /**
  44540. * Disposes of the gizmo
  44541. */
  44542. dispose(): void;
  44543. }
  44544. }
  44545. declare module BABYLON {
  44546. /**
  44547. * Single axis scale gizmo
  44548. */
  44549. export class AxisScaleGizmo extends Gizmo {
  44550. /**
  44551. * Drag behavior responsible for the gizmos dragging interactions
  44552. */
  44553. dragBehavior: PointerDragBehavior;
  44554. private _pointerObserver;
  44555. /**
  44556. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44557. */
  44558. snapDistance: number;
  44559. /**
  44560. * Event that fires each time the gizmo snaps to a new location.
  44561. * * snapDistance is the the change in distance
  44562. */
  44563. onSnapObservable: Observable<{
  44564. snapDistance: number;
  44565. }>;
  44566. /**
  44567. * If the scaling operation should be done on all axis (default: false)
  44568. */
  44569. uniformScaling: boolean;
  44570. private _isEnabled;
  44571. private _parent;
  44572. private _arrow;
  44573. private _coloredMaterial;
  44574. private _hoverMaterial;
  44575. /**
  44576. * Creates an AxisScaleGizmo
  44577. * @param gizmoLayer The utility layer the gizmo will be added to
  44578. * @param dragAxis The axis which the gizmo will be able to scale on
  44579. * @param color The color of the gizmo
  44580. */
  44581. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44583. /**
  44584. * If the gizmo is enabled
  44585. */
  44586. isEnabled: boolean;
  44587. /**
  44588. * Disposes of the gizmo
  44589. */
  44590. dispose(): void;
  44591. /**
  44592. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44593. * @param mesh The mesh to replace the default mesh of the gizmo
  44594. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44595. */
  44596. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44597. }
  44598. }
  44599. declare module BABYLON {
  44600. /**
  44601. * Bounding box gizmo
  44602. */
  44603. export class BoundingBoxGizmo extends Gizmo {
  44604. private _lineBoundingBox;
  44605. private _rotateSpheresParent;
  44606. private _scaleBoxesParent;
  44607. private _boundingDimensions;
  44608. private _renderObserver;
  44609. private _pointerObserver;
  44610. private _scaleDragSpeed;
  44611. private _tmpQuaternion;
  44612. private _tmpVector;
  44613. private _tmpRotationMatrix;
  44614. /**
  44615. * 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)
  44616. */
  44617. ignoreChildren: boolean;
  44618. /**
  44619. * 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)
  44620. */
  44621. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44622. /**
  44623. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44624. */
  44625. rotationSphereSize: number;
  44626. /**
  44627. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44628. */
  44629. scaleBoxSize: number;
  44630. /**
  44631. * 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)
  44632. */
  44633. fixedDragMeshScreenSize: boolean;
  44634. /**
  44635. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44636. */
  44637. fixedDragMeshScreenSizeDistanceFactor: number;
  44638. /**
  44639. * Fired when a rotation sphere or scale box is dragged
  44640. */
  44641. onDragStartObservable: Observable<{}>;
  44642. /**
  44643. * Fired when a scale box is dragged
  44644. */
  44645. onScaleBoxDragObservable: Observable<{}>;
  44646. /**
  44647. * Fired when a scale box drag is ended
  44648. */
  44649. onScaleBoxDragEndObservable: Observable<{}>;
  44650. /**
  44651. * Fired when a rotation sphere is dragged
  44652. */
  44653. onRotationSphereDragObservable: Observable<{}>;
  44654. /**
  44655. * Fired when a rotation sphere drag is ended
  44656. */
  44657. onRotationSphereDragEndObservable: Observable<{}>;
  44658. /**
  44659. * 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)
  44660. */
  44661. scalePivot: Nullable<Vector3>;
  44662. /**
  44663. * Mesh used as a pivot to rotate the attached mesh
  44664. */
  44665. private _anchorMesh;
  44666. private _existingMeshScale;
  44667. private _dragMesh;
  44668. private pointerDragBehavior;
  44669. private coloredMaterial;
  44670. private hoverColoredMaterial;
  44671. /**
  44672. * Sets the color of the bounding box gizmo
  44673. * @param color the color to set
  44674. */
  44675. setColor(color: Color3): void;
  44676. /**
  44677. * Creates an BoundingBoxGizmo
  44678. * @param gizmoLayer The utility layer the gizmo will be added to
  44679. * @param color The color of the gizmo
  44680. */
  44681. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44682. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44683. private _selectNode;
  44684. /**
  44685. * Updates the bounding box information for the Gizmo
  44686. */
  44687. updateBoundingBox(): void;
  44688. private _updateRotationSpheres;
  44689. private _updateScaleBoxes;
  44690. /**
  44691. * Enables rotation on the specified axis and disables rotation on the others
  44692. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44693. */
  44694. setEnabledRotationAxis(axis: string): void;
  44695. /**
  44696. * Enables/disables scaling
  44697. * @param enable if scaling should be enabled
  44698. */
  44699. setEnabledScaling(enable: boolean): void;
  44700. private _updateDummy;
  44701. /**
  44702. * Enables a pointer drag behavior on the bounding box of the gizmo
  44703. */
  44704. enableDragBehavior(): void;
  44705. /**
  44706. * Disposes of the gizmo
  44707. */
  44708. dispose(): void;
  44709. /**
  44710. * 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)
  44711. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44712. * @returns the bounding box mesh with the passed in mesh as a child
  44713. */
  44714. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44715. /**
  44716. * CustomMeshes are not supported by this gizmo
  44717. * @param mesh The mesh to replace the default mesh of the gizmo
  44718. */
  44719. setCustomMesh(mesh: Mesh): void;
  44720. }
  44721. }
  44722. declare module BABYLON {
  44723. /**
  44724. * Single plane rotation gizmo
  44725. */
  44726. export class PlaneRotationGizmo extends Gizmo {
  44727. /**
  44728. * Drag behavior responsible for the gizmos dragging interactions
  44729. */
  44730. dragBehavior: PointerDragBehavior;
  44731. private _pointerObserver;
  44732. /**
  44733. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44734. */
  44735. snapDistance: number;
  44736. /**
  44737. * Event that fires each time the gizmo snaps to a new location.
  44738. * * snapDistance is the the change in distance
  44739. */
  44740. onSnapObservable: Observable<{
  44741. snapDistance: number;
  44742. }>;
  44743. private _isEnabled;
  44744. private _parent;
  44745. /**
  44746. * Creates a PlaneRotationGizmo
  44747. * @param gizmoLayer The utility layer the gizmo will be added to
  44748. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44749. * @param color The color of the gizmo
  44750. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44751. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44752. */
  44753. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44755. /**
  44756. * If the gizmo is enabled
  44757. */
  44758. isEnabled: boolean;
  44759. /**
  44760. * Disposes of the gizmo
  44761. */
  44762. dispose(): void;
  44763. }
  44764. }
  44765. declare module BABYLON {
  44766. /**
  44767. * Gizmo that enables rotating a mesh along 3 axis
  44768. */
  44769. export class RotationGizmo extends Gizmo {
  44770. /**
  44771. * Internal gizmo used for interactions on the x axis
  44772. */
  44773. xGizmo: PlaneRotationGizmo;
  44774. /**
  44775. * Internal gizmo used for interactions on the y axis
  44776. */
  44777. yGizmo: PlaneRotationGizmo;
  44778. /**
  44779. * Internal gizmo used for interactions on the z axis
  44780. */
  44781. zGizmo: PlaneRotationGizmo;
  44782. /** Fires an event when any of it's sub gizmos are dragged */
  44783. onDragStartObservable: Observable<unknown>;
  44784. /** Fires an event when any of it's sub gizmos are released from dragging */
  44785. onDragEndObservable: Observable<unknown>;
  44786. private _meshAttached;
  44787. attachedMesh: Nullable<AbstractMesh>;
  44788. /**
  44789. * Creates a RotationGizmo
  44790. * @param gizmoLayer The utility layer the gizmo will be added to
  44791. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44792. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44793. */
  44794. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44795. updateGizmoRotationToMatchAttachedMesh: boolean;
  44796. /**
  44797. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44798. */
  44799. snapDistance: number;
  44800. /**
  44801. * Ratio for the scale of the gizmo (Default: 1)
  44802. */
  44803. scaleRatio: number;
  44804. /**
  44805. * Disposes of the gizmo
  44806. */
  44807. dispose(): void;
  44808. /**
  44809. * CustomMeshes are not supported by this gizmo
  44810. * @param mesh The mesh to replace the default mesh of the gizmo
  44811. */
  44812. setCustomMesh(mesh: Mesh): void;
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44818. */
  44819. export class GizmoManager implements IDisposable {
  44820. private scene;
  44821. /**
  44822. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44823. */
  44824. gizmos: {
  44825. positionGizmo: Nullable<PositionGizmo>;
  44826. rotationGizmo: Nullable<RotationGizmo>;
  44827. scaleGizmo: Nullable<ScaleGizmo>;
  44828. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44829. };
  44830. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44831. clearGizmoOnEmptyPointerEvent: boolean;
  44832. /** Fires an event when the manager is attached to a mesh */
  44833. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44834. private _gizmosEnabled;
  44835. private _pointerObserver;
  44836. private _attachedMesh;
  44837. private _boundingBoxColor;
  44838. private _defaultUtilityLayer;
  44839. private _defaultKeepDepthUtilityLayer;
  44840. /**
  44841. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44842. */
  44843. boundingBoxDragBehavior: SixDofDragBehavior;
  44844. /**
  44845. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44846. */
  44847. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44848. /**
  44849. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44850. */
  44851. usePointerToAttachGizmos: boolean;
  44852. /**
  44853. * Utility layer that the bounding box gizmo belongs to
  44854. */
  44855. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44856. /**
  44857. * Utility layer that all gizmos besides bounding box belong to
  44858. */
  44859. readonly utilityLayer: UtilityLayerRenderer;
  44860. /**
  44861. * Instatiates a gizmo manager
  44862. * @param scene the scene to overlay the gizmos on top of
  44863. */
  44864. constructor(scene: Scene);
  44865. /**
  44866. * Attaches a set of gizmos to the specified mesh
  44867. * @param mesh The mesh the gizmo's should be attached to
  44868. */
  44869. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44870. /**
  44871. * If the position gizmo is enabled
  44872. */
  44873. positionGizmoEnabled: boolean;
  44874. /**
  44875. * If the rotation gizmo is enabled
  44876. */
  44877. rotationGizmoEnabled: boolean;
  44878. /**
  44879. * If the scale gizmo is enabled
  44880. */
  44881. scaleGizmoEnabled: boolean;
  44882. /**
  44883. * If the boundingBox gizmo is enabled
  44884. */
  44885. boundingBoxGizmoEnabled: boolean;
  44886. /**
  44887. * Disposes of the gizmo manager
  44888. */
  44889. dispose(): void;
  44890. }
  44891. }
  44892. declare module BABYLON {
  44893. /**
  44894. * A directional light is defined by a direction (what a surprise!).
  44895. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44896. * 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.
  44897. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44898. */
  44899. export class DirectionalLight extends ShadowLight {
  44900. private _shadowFrustumSize;
  44901. /**
  44902. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44903. */
  44904. /**
  44905. * Specifies a fix frustum size for the shadow generation.
  44906. */
  44907. shadowFrustumSize: number;
  44908. private _shadowOrthoScale;
  44909. /**
  44910. * Gets the shadow projection scale against the optimal computed one.
  44911. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44912. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44913. */
  44914. /**
  44915. * Sets the shadow projection scale against the optimal computed one.
  44916. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44917. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44918. */
  44919. shadowOrthoScale: number;
  44920. /**
  44921. * Automatically compute the projection matrix to best fit (including all the casters)
  44922. * on each frame.
  44923. */
  44924. autoUpdateExtends: boolean;
  44925. private _orthoLeft;
  44926. private _orthoRight;
  44927. private _orthoTop;
  44928. private _orthoBottom;
  44929. /**
  44930. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44931. * The directional light is emitted from everywhere in the given direction.
  44932. * It can cast shadows.
  44933. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44934. * @param name The friendly name of the light
  44935. * @param direction The direction of the light
  44936. * @param scene The scene the light belongs to
  44937. */
  44938. constructor(name: string, direction: Vector3, scene: Scene);
  44939. /**
  44940. * Returns the string "DirectionalLight".
  44941. * @return The class name
  44942. */
  44943. getClassName(): string;
  44944. /**
  44945. * Returns the integer 1.
  44946. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44947. */
  44948. getTypeID(): number;
  44949. /**
  44950. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44951. * Returns the DirectionalLight Shadow projection matrix.
  44952. */
  44953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44954. /**
  44955. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44956. * Returns the DirectionalLight Shadow projection matrix.
  44957. */
  44958. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44959. /**
  44960. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44961. * Returns the DirectionalLight Shadow projection matrix.
  44962. */
  44963. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44964. protected _buildUniformLayout(): void;
  44965. /**
  44966. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44967. * @param effect The effect to update
  44968. * @param lightIndex The index of the light in the effect to update
  44969. * @returns The directional light
  44970. */
  44971. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44972. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44973. /**
  44974. * Gets the minZ used for shadow according to both the scene and the light.
  44975. *
  44976. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44977. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44978. * @param activeCamera The camera we are returning the min for
  44979. * @returns the depth min z
  44980. */
  44981. getDepthMinZ(activeCamera: Camera): number;
  44982. /**
  44983. * Gets the maxZ used for shadow according to both the scene and the light.
  44984. *
  44985. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44986. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44987. * @param activeCamera The camera we are returning the max for
  44988. * @returns the depth max z
  44989. */
  44990. getDepthMaxZ(activeCamera: Camera): number;
  44991. /**
  44992. * Prepares the list of defines specific to the light type.
  44993. * @param defines the list of defines
  44994. * @param lightIndex defines the index of the light for the effect
  44995. */
  44996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44997. }
  44998. }
  44999. declare module BABYLON {
  45000. /**
  45001. * Class containing static functions to help procedurally build meshes
  45002. */
  45003. export class HemisphereBuilder {
  45004. /**
  45005. * Creates a hemisphere mesh
  45006. * @param name defines the name of the mesh
  45007. * @param options defines the options used to create the mesh
  45008. * @param scene defines the hosting scene
  45009. * @returns the hemisphere mesh
  45010. */
  45011. static CreateHemisphere(name: string, options: {
  45012. segments?: number;
  45013. diameter?: number;
  45014. sideOrientation?: number;
  45015. }, scene: any): Mesh;
  45016. }
  45017. }
  45018. declare module BABYLON {
  45019. /**
  45020. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45021. * These values define a cone of light starting from the position, emitting toward the direction.
  45022. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45023. * and the exponent defines the speed of the decay of the light with distance (reach).
  45024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45025. */
  45026. export class SpotLight extends ShadowLight {
  45027. private _angle;
  45028. private _innerAngle;
  45029. private _cosHalfAngle;
  45030. private _lightAngleScale;
  45031. private _lightAngleOffset;
  45032. /**
  45033. * Gets the cone angle of the spot light in Radians.
  45034. */
  45035. /**
  45036. * Sets the cone angle of the spot light in Radians.
  45037. */
  45038. angle: number;
  45039. /**
  45040. * Only used in gltf falloff mode, this defines the angle where
  45041. * the directional falloff will start before cutting at angle which could be seen
  45042. * as outer angle.
  45043. */
  45044. /**
  45045. * Only used in gltf falloff mode, this defines the angle where
  45046. * the directional falloff will start before cutting at angle which could be seen
  45047. * as outer angle.
  45048. */
  45049. innerAngle: number;
  45050. private _shadowAngleScale;
  45051. /**
  45052. * Allows scaling the angle of the light for shadow generation only.
  45053. */
  45054. /**
  45055. * Allows scaling the angle of the light for shadow generation only.
  45056. */
  45057. shadowAngleScale: number;
  45058. /**
  45059. * The light decay speed with the distance from the emission spot.
  45060. */
  45061. exponent: number;
  45062. private _projectionTextureMatrix;
  45063. /**
  45064. * Allows reading the projecton texture
  45065. */
  45066. readonly projectionTextureMatrix: Matrix;
  45067. protected _projectionTextureLightNear: number;
  45068. /**
  45069. * Gets the near clip of the Spotlight for texture projection.
  45070. */
  45071. /**
  45072. * Sets the near clip of the Spotlight for texture projection.
  45073. */
  45074. projectionTextureLightNear: number;
  45075. protected _projectionTextureLightFar: number;
  45076. /**
  45077. * Gets the far clip of the Spotlight for texture projection.
  45078. */
  45079. /**
  45080. * Sets the far clip of the Spotlight for texture projection.
  45081. */
  45082. projectionTextureLightFar: number;
  45083. protected _projectionTextureUpDirection: Vector3;
  45084. /**
  45085. * Gets the Up vector of the Spotlight for texture projection.
  45086. */
  45087. /**
  45088. * Sets the Up vector of the Spotlight for texture projection.
  45089. */
  45090. projectionTextureUpDirection: Vector3;
  45091. private _projectionTexture;
  45092. /**
  45093. * Gets the projection texture of the light.
  45094. */
  45095. /**
  45096. * Sets the projection texture of the light.
  45097. */
  45098. projectionTexture: Nullable<BaseTexture>;
  45099. private _projectionTextureViewLightDirty;
  45100. private _projectionTextureProjectionLightDirty;
  45101. private _projectionTextureDirty;
  45102. private _projectionTextureViewTargetVector;
  45103. private _projectionTextureViewLightMatrix;
  45104. private _projectionTextureProjectionLightMatrix;
  45105. private _projectionTextureScalingMatrix;
  45106. /**
  45107. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45108. * It can cast shadows.
  45109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45110. * @param name The light friendly name
  45111. * @param position The position of the spot light in the scene
  45112. * @param direction The direction of the light in the scene
  45113. * @param angle The cone angle of the light in Radians
  45114. * @param exponent The light decay speed with the distance from the emission spot
  45115. * @param scene The scene the lights belongs to
  45116. */
  45117. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45118. /**
  45119. * Returns the string "SpotLight".
  45120. * @returns the class name
  45121. */
  45122. getClassName(): string;
  45123. /**
  45124. * Returns the integer 2.
  45125. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45126. */
  45127. getTypeID(): number;
  45128. /**
  45129. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45130. */
  45131. protected _setDirection(value: Vector3): void;
  45132. /**
  45133. * Overrides the position setter to recompute the projection texture view light Matrix.
  45134. */
  45135. protected _setPosition(value: Vector3): void;
  45136. /**
  45137. * 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.
  45138. * Returns the SpotLight.
  45139. */
  45140. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45141. protected _computeProjectionTextureViewLightMatrix(): void;
  45142. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45143. /**
  45144. * Main function for light texture projection matrix computing.
  45145. */
  45146. protected _computeProjectionTextureMatrix(): void;
  45147. protected _buildUniformLayout(): void;
  45148. private _computeAngleValues;
  45149. /**
  45150. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45151. * @param effect The effect to update
  45152. * @param lightIndex The index of the light in the effect to update
  45153. * @returns The spot light
  45154. */
  45155. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45156. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45157. /**
  45158. * Disposes the light and the associated resources.
  45159. */
  45160. dispose(): void;
  45161. /**
  45162. * Prepares the list of defines specific to the light type.
  45163. * @param defines the list of defines
  45164. * @param lightIndex defines the index of the light for the effect
  45165. */
  45166. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45167. }
  45168. }
  45169. declare module BABYLON {
  45170. /**
  45171. * Gizmo that enables viewing a light
  45172. */
  45173. export class LightGizmo extends Gizmo {
  45174. private _lightMesh;
  45175. private _material;
  45176. private cachedPosition;
  45177. private cachedForward;
  45178. /**
  45179. * Creates a LightGizmo
  45180. * @param gizmoLayer The utility layer the gizmo will be added to
  45181. */
  45182. constructor(gizmoLayer?: UtilityLayerRenderer);
  45183. private _light;
  45184. /**
  45185. * The light that the gizmo is attached to
  45186. */
  45187. light: Nullable<Light>;
  45188. /**
  45189. * Gets the material used to render the light gizmo
  45190. */
  45191. readonly material: StandardMaterial;
  45192. /**
  45193. * @hidden
  45194. * Updates the gizmo to match the attached mesh's position/rotation
  45195. */
  45196. protected _update(): void;
  45197. private static _Scale;
  45198. /**
  45199. * Creates the lines for a light mesh
  45200. */
  45201. private static _createLightLines;
  45202. /**
  45203. * Disposes of the light gizmo
  45204. */
  45205. dispose(): void;
  45206. private static _CreateHemisphericLightMesh;
  45207. private static _CreatePointLightMesh;
  45208. private static _CreateSpotLightMesh;
  45209. private static _CreateDirectionalLightMesh;
  45210. }
  45211. }
  45212. declare module BABYLON {
  45213. /** @hidden */
  45214. export var backgroundFragmentDeclaration: {
  45215. name: string;
  45216. shader: string;
  45217. };
  45218. }
  45219. declare module BABYLON {
  45220. /** @hidden */
  45221. export var backgroundUboDeclaration: {
  45222. name: string;
  45223. shader: string;
  45224. };
  45225. }
  45226. declare module BABYLON {
  45227. /** @hidden */
  45228. export var backgroundPixelShader: {
  45229. name: string;
  45230. shader: string;
  45231. };
  45232. }
  45233. declare module BABYLON {
  45234. /** @hidden */
  45235. export var backgroundVertexDeclaration: {
  45236. name: string;
  45237. shader: string;
  45238. };
  45239. }
  45240. declare module BABYLON {
  45241. /** @hidden */
  45242. export var backgroundVertexShader: {
  45243. name: string;
  45244. shader: string;
  45245. };
  45246. }
  45247. declare module BABYLON {
  45248. /**
  45249. * Background material used to create an efficient environement around your scene.
  45250. */
  45251. export class BackgroundMaterial extends PushMaterial {
  45252. /**
  45253. * Standard reflectance value at parallel view angle.
  45254. */
  45255. static StandardReflectance0: number;
  45256. /**
  45257. * Standard reflectance value at grazing angle.
  45258. */
  45259. static StandardReflectance90: number;
  45260. protected _primaryColor: Color3;
  45261. /**
  45262. * Key light Color (multiply against the environement texture)
  45263. */
  45264. primaryColor: Color3;
  45265. protected __perceptualColor: Nullable<Color3>;
  45266. /**
  45267. * Experimental Internal Use Only.
  45268. *
  45269. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45270. * This acts as a helper to set the primary color to a more "human friendly" value.
  45271. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45272. * output color as close as possible from the chosen value.
  45273. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45274. * part of lighting setup.)
  45275. */
  45276. _perceptualColor: Nullable<Color3>;
  45277. protected _primaryColorShadowLevel: float;
  45278. /**
  45279. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45280. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45281. */
  45282. primaryColorShadowLevel: float;
  45283. protected _primaryColorHighlightLevel: float;
  45284. /**
  45285. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45286. * The primary color is used at the level chosen to define what the white area would look.
  45287. */
  45288. primaryColorHighlightLevel: float;
  45289. protected _reflectionTexture: Nullable<BaseTexture>;
  45290. /**
  45291. * Reflection Texture used in the material.
  45292. * Should be author in a specific way for the best result (refer to the documentation).
  45293. */
  45294. reflectionTexture: Nullable<BaseTexture>;
  45295. protected _reflectionBlur: float;
  45296. /**
  45297. * Reflection Texture level of blur.
  45298. *
  45299. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45300. * texture twice.
  45301. */
  45302. reflectionBlur: float;
  45303. protected _diffuseTexture: Nullable<BaseTexture>;
  45304. /**
  45305. * Diffuse Texture used in the material.
  45306. * Should be author in a specific way for the best result (refer to the documentation).
  45307. */
  45308. diffuseTexture: Nullable<BaseTexture>;
  45309. protected _shadowLights: Nullable<IShadowLight[]>;
  45310. /**
  45311. * Specify the list of lights casting shadow on the material.
  45312. * All scene shadow lights will be included if null.
  45313. */
  45314. shadowLights: Nullable<IShadowLight[]>;
  45315. protected _shadowLevel: float;
  45316. /**
  45317. * Helps adjusting the shadow to a softer level if required.
  45318. * 0 means black shadows and 1 means no shadows.
  45319. */
  45320. shadowLevel: float;
  45321. protected _sceneCenter: Vector3;
  45322. /**
  45323. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45324. * It is usually zero but might be interesting to modify according to your setup.
  45325. */
  45326. sceneCenter: Vector3;
  45327. protected _opacityFresnel: boolean;
  45328. /**
  45329. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45330. * This helps ensuring a nice transition when the camera goes under the ground.
  45331. */
  45332. opacityFresnel: boolean;
  45333. protected _reflectionFresnel: boolean;
  45334. /**
  45335. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45336. * This helps adding a mirror texture on the ground.
  45337. */
  45338. reflectionFresnel: boolean;
  45339. protected _reflectionFalloffDistance: number;
  45340. /**
  45341. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45342. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45343. */
  45344. reflectionFalloffDistance: number;
  45345. protected _reflectionAmount: number;
  45346. /**
  45347. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45348. */
  45349. reflectionAmount: number;
  45350. protected _reflectionReflectance0: number;
  45351. /**
  45352. * This specifies the weight of the reflection at grazing angle.
  45353. */
  45354. reflectionReflectance0: number;
  45355. protected _reflectionReflectance90: number;
  45356. /**
  45357. * This specifies the weight of the reflection at a perpendicular point of view.
  45358. */
  45359. reflectionReflectance90: number;
  45360. /**
  45361. * Sets the reflection reflectance fresnel values according to the default standard
  45362. * empirically know to work well :-)
  45363. */
  45364. reflectionStandardFresnelWeight: number;
  45365. protected _useRGBColor: boolean;
  45366. /**
  45367. * Helps to directly use the maps channels instead of their level.
  45368. */
  45369. useRGBColor: boolean;
  45370. protected _enableNoise: boolean;
  45371. /**
  45372. * This helps reducing the banding effect that could occur on the background.
  45373. */
  45374. enableNoise: boolean;
  45375. /**
  45376. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45377. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45378. * Recommended to be keep at 1.0 except for special cases.
  45379. */
  45380. fovMultiplier: number;
  45381. private _fovMultiplier;
  45382. /**
  45383. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45384. */
  45385. useEquirectangularFOV: boolean;
  45386. private _maxSimultaneousLights;
  45387. /**
  45388. * Number of Simultaneous lights allowed on the material.
  45389. */
  45390. maxSimultaneousLights: int;
  45391. /**
  45392. * Default configuration related to image processing available in the Background Material.
  45393. */
  45394. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45395. /**
  45396. * Keep track of the image processing observer to allow dispose and replace.
  45397. */
  45398. private _imageProcessingObserver;
  45399. /**
  45400. * Attaches a new image processing configuration to the PBR Material.
  45401. * @param configuration (if null the scene configuration will be use)
  45402. */
  45403. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45404. /**
  45405. * Gets the image processing configuration used either in this material.
  45406. */
  45407. /**
  45408. * Sets the Default image processing configuration used either in the this material.
  45409. *
  45410. * If sets to null, the scene one is in use.
  45411. */
  45412. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45413. /**
  45414. * Gets wether the color curves effect is enabled.
  45415. */
  45416. /**
  45417. * Sets wether the color curves effect is enabled.
  45418. */
  45419. cameraColorCurvesEnabled: boolean;
  45420. /**
  45421. * Gets wether the color grading effect is enabled.
  45422. */
  45423. /**
  45424. * Gets wether the color grading effect is enabled.
  45425. */
  45426. cameraColorGradingEnabled: boolean;
  45427. /**
  45428. * Gets wether tonemapping is enabled or not.
  45429. */
  45430. /**
  45431. * Sets wether tonemapping is enabled or not
  45432. */
  45433. cameraToneMappingEnabled: boolean;
  45434. /**
  45435. * The camera exposure used on this material.
  45436. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45437. * This corresponds to a photographic exposure.
  45438. */
  45439. /**
  45440. * The camera exposure used on this material.
  45441. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45442. * This corresponds to a photographic exposure.
  45443. */
  45444. cameraExposure: float;
  45445. /**
  45446. * Gets The camera contrast used on this material.
  45447. */
  45448. /**
  45449. * Sets The camera contrast used on this material.
  45450. */
  45451. cameraContrast: float;
  45452. /**
  45453. * Gets the Color Grading 2D Lookup Texture.
  45454. */
  45455. /**
  45456. * Sets the Color Grading 2D Lookup Texture.
  45457. */
  45458. cameraColorGradingTexture: Nullable<BaseTexture>;
  45459. /**
  45460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45462. * 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;
  45463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45464. */
  45465. /**
  45466. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45467. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45468. * 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;
  45469. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45470. */
  45471. cameraColorCurves: Nullable<ColorCurves>;
  45472. /**
  45473. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45474. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45475. */
  45476. switchToBGR: boolean;
  45477. private _renderTargets;
  45478. private _reflectionControls;
  45479. private _white;
  45480. private _primaryShadowColor;
  45481. private _primaryHighlightColor;
  45482. /**
  45483. * Instantiates a Background Material in the given scene
  45484. * @param name The friendly name of the material
  45485. * @param scene The scene to add the material to
  45486. */
  45487. constructor(name: string, scene: Scene);
  45488. /**
  45489. * Gets a boolean indicating that current material needs to register RTT
  45490. */
  45491. readonly hasRenderTargetTextures: boolean;
  45492. /**
  45493. * The entire material has been created in order to prevent overdraw.
  45494. * @returns false
  45495. */
  45496. needAlphaTesting(): boolean;
  45497. /**
  45498. * The entire material has been created in order to prevent overdraw.
  45499. * @returns true if blending is enable
  45500. */
  45501. needAlphaBlending(): boolean;
  45502. /**
  45503. * Checks wether the material is ready to be rendered for a given mesh.
  45504. * @param mesh The mesh to render
  45505. * @param subMesh The submesh to check against
  45506. * @param useInstances Specify wether or not the material is used with instances
  45507. * @returns true if all the dependencies are ready (Textures, Effects...)
  45508. */
  45509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45510. /**
  45511. * Compute the primary color according to the chosen perceptual color.
  45512. */
  45513. private _computePrimaryColorFromPerceptualColor;
  45514. /**
  45515. * Compute the highlights and shadow colors according to their chosen levels.
  45516. */
  45517. private _computePrimaryColors;
  45518. /**
  45519. * Build the uniform buffer used in the material.
  45520. */
  45521. buildUniformLayout(): void;
  45522. /**
  45523. * Unbind the material.
  45524. */
  45525. unbind(): void;
  45526. /**
  45527. * Bind only the world matrix to the material.
  45528. * @param world The world matrix to bind.
  45529. */
  45530. bindOnlyWorldMatrix(world: Matrix): void;
  45531. /**
  45532. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45533. * @param world The world matrix to bind.
  45534. * @param subMesh The submesh to bind for.
  45535. */
  45536. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45537. /**
  45538. * Checks to see if a texture is used in the material.
  45539. * @param texture - Base texture to use.
  45540. * @returns - Boolean specifying if a texture is used in the material.
  45541. */
  45542. hasTexture(texture: BaseTexture): boolean;
  45543. /**
  45544. * Dispose the material.
  45545. * @param forceDisposeEffect Force disposal of the associated effect.
  45546. * @param forceDisposeTextures Force disposal of the associated textures.
  45547. */
  45548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45549. /**
  45550. * Clones the material.
  45551. * @param name The cloned name.
  45552. * @returns The cloned material.
  45553. */
  45554. clone(name: string): BackgroundMaterial;
  45555. /**
  45556. * Serializes the current material to its JSON representation.
  45557. * @returns The JSON representation.
  45558. */
  45559. serialize(): any;
  45560. /**
  45561. * Gets the class name of the material
  45562. * @returns "BackgroundMaterial"
  45563. */
  45564. getClassName(): string;
  45565. /**
  45566. * Parse a JSON input to create back a background material.
  45567. * @param source The JSON data to parse
  45568. * @param scene The scene to create the parsed material in
  45569. * @param rootUrl The root url of the assets the material depends upon
  45570. * @returns the instantiated BackgroundMaterial.
  45571. */
  45572. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45573. }
  45574. }
  45575. declare module BABYLON {
  45576. /**
  45577. * Represents the different options available during the creation of
  45578. * a Environment helper.
  45579. *
  45580. * This can control the default ground, skybox and image processing setup of your scene.
  45581. */
  45582. export interface IEnvironmentHelperOptions {
  45583. /**
  45584. * Specifies wether or not to create a ground.
  45585. * True by default.
  45586. */
  45587. createGround: boolean;
  45588. /**
  45589. * Specifies the ground size.
  45590. * 15 by default.
  45591. */
  45592. groundSize: number;
  45593. /**
  45594. * The texture used on the ground for the main color.
  45595. * Comes from the BabylonJS CDN by default.
  45596. *
  45597. * Remarks: Can be either a texture or a url.
  45598. */
  45599. groundTexture: string | BaseTexture;
  45600. /**
  45601. * The color mixed in the ground texture by default.
  45602. * BabylonJS clearColor by default.
  45603. */
  45604. groundColor: Color3;
  45605. /**
  45606. * Specifies the ground opacity.
  45607. * 1 by default.
  45608. */
  45609. groundOpacity: number;
  45610. /**
  45611. * Enables the ground to receive shadows.
  45612. * True by default.
  45613. */
  45614. enableGroundShadow: boolean;
  45615. /**
  45616. * Helps preventing the shadow to be fully black on the ground.
  45617. * 0.5 by default.
  45618. */
  45619. groundShadowLevel: number;
  45620. /**
  45621. * Creates a mirror texture attach to the ground.
  45622. * false by default.
  45623. */
  45624. enableGroundMirror: boolean;
  45625. /**
  45626. * Specifies the ground mirror size ratio.
  45627. * 0.3 by default as the default kernel is 64.
  45628. */
  45629. groundMirrorSizeRatio: number;
  45630. /**
  45631. * Specifies the ground mirror blur kernel size.
  45632. * 64 by default.
  45633. */
  45634. groundMirrorBlurKernel: number;
  45635. /**
  45636. * Specifies the ground mirror visibility amount.
  45637. * 1 by default
  45638. */
  45639. groundMirrorAmount: number;
  45640. /**
  45641. * Specifies the ground mirror reflectance weight.
  45642. * This uses the standard weight of the background material to setup the fresnel effect
  45643. * of the mirror.
  45644. * 1 by default.
  45645. */
  45646. groundMirrorFresnelWeight: number;
  45647. /**
  45648. * Specifies the ground mirror Falloff distance.
  45649. * This can helps reducing the size of the reflection.
  45650. * 0 by Default.
  45651. */
  45652. groundMirrorFallOffDistance: number;
  45653. /**
  45654. * Specifies the ground mirror texture type.
  45655. * Unsigned Int by Default.
  45656. */
  45657. groundMirrorTextureType: number;
  45658. /**
  45659. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45660. * the shown objects.
  45661. */
  45662. groundYBias: number;
  45663. /**
  45664. * Specifies wether or not to create a skybox.
  45665. * True by default.
  45666. */
  45667. createSkybox: boolean;
  45668. /**
  45669. * Specifies the skybox size.
  45670. * 20 by default.
  45671. */
  45672. skyboxSize: number;
  45673. /**
  45674. * The texture used on the skybox for the main color.
  45675. * Comes from the BabylonJS CDN by default.
  45676. *
  45677. * Remarks: Can be either a texture or a url.
  45678. */
  45679. skyboxTexture: string | BaseTexture;
  45680. /**
  45681. * The color mixed in the skybox texture by default.
  45682. * BabylonJS clearColor by default.
  45683. */
  45684. skyboxColor: Color3;
  45685. /**
  45686. * The background rotation around the Y axis of the scene.
  45687. * This helps aligning the key lights of your scene with the background.
  45688. * 0 by default.
  45689. */
  45690. backgroundYRotation: number;
  45691. /**
  45692. * Compute automatically the size of the elements to best fit with the scene.
  45693. */
  45694. sizeAuto: boolean;
  45695. /**
  45696. * Default position of the rootMesh if autoSize is not true.
  45697. */
  45698. rootPosition: Vector3;
  45699. /**
  45700. * Sets up the image processing in the scene.
  45701. * true by default.
  45702. */
  45703. setupImageProcessing: boolean;
  45704. /**
  45705. * The texture used as your environment texture in the scene.
  45706. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45707. *
  45708. * Remarks: Can be either a texture or a url.
  45709. */
  45710. environmentTexture: string | BaseTexture;
  45711. /**
  45712. * The value of the exposure to apply to the scene.
  45713. * 0.6 by default if setupImageProcessing is true.
  45714. */
  45715. cameraExposure: number;
  45716. /**
  45717. * The value of the contrast to apply to the scene.
  45718. * 1.6 by default if setupImageProcessing is true.
  45719. */
  45720. cameraContrast: number;
  45721. /**
  45722. * Specifies wether or not tonemapping should be enabled in the scene.
  45723. * true by default if setupImageProcessing is true.
  45724. */
  45725. toneMappingEnabled: boolean;
  45726. }
  45727. /**
  45728. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45729. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45730. * It also helps with the default setup of your imageProcessing configuration.
  45731. */
  45732. export class EnvironmentHelper {
  45733. /**
  45734. * Default ground texture URL.
  45735. */
  45736. private static _groundTextureCDNUrl;
  45737. /**
  45738. * Default skybox texture URL.
  45739. */
  45740. private static _skyboxTextureCDNUrl;
  45741. /**
  45742. * Default environment texture URL.
  45743. */
  45744. private static _environmentTextureCDNUrl;
  45745. /**
  45746. * Creates the default options for the helper.
  45747. */
  45748. private static _getDefaultOptions;
  45749. private _rootMesh;
  45750. /**
  45751. * Gets the root mesh created by the helper.
  45752. */
  45753. readonly rootMesh: Mesh;
  45754. private _skybox;
  45755. /**
  45756. * Gets the skybox created by the helper.
  45757. */
  45758. readonly skybox: Nullable<Mesh>;
  45759. private _skyboxTexture;
  45760. /**
  45761. * Gets the skybox texture created by the helper.
  45762. */
  45763. readonly skyboxTexture: Nullable<BaseTexture>;
  45764. private _skyboxMaterial;
  45765. /**
  45766. * Gets the skybox material created by the helper.
  45767. */
  45768. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45769. private _ground;
  45770. /**
  45771. * Gets the ground mesh created by the helper.
  45772. */
  45773. readonly ground: Nullable<Mesh>;
  45774. private _groundTexture;
  45775. /**
  45776. * Gets the ground texture created by the helper.
  45777. */
  45778. readonly groundTexture: Nullable<BaseTexture>;
  45779. private _groundMirror;
  45780. /**
  45781. * Gets the ground mirror created by the helper.
  45782. */
  45783. readonly groundMirror: Nullable<MirrorTexture>;
  45784. /**
  45785. * Gets the ground mirror render list to helps pushing the meshes
  45786. * you wish in the ground reflection.
  45787. */
  45788. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45789. private _groundMaterial;
  45790. /**
  45791. * Gets the ground material created by the helper.
  45792. */
  45793. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45794. /**
  45795. * Stores the creation options.
  45796. */
  45797. private readonly _scene;
  45798. private _options;
  45799. /**
  45800. * This observable will be notified with any error during the creation of the environment,
  45801. * mainly texture creation errors.
  45802. */
  45803. onErrorObservable: Observable<{
  45804. message?: string;
  45805. exception?: any;
  45806. }>;
  45807. /**
  45808. * constructor
  45809. * @param options Defines the options we want to customize the helper
  45810. * @param scene The scene to add the material to
  45811. */
  45812. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45813. /**
  45814. * Updates the background according to the new options
  45815. * @param options
  45816. */
  45817. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45818. /**
  45819. * Sets the primary color of all the available elements.
  45820. * @param color the main color to affect to the ground and the background
  45821. */
  45822. setMainColor(color: Color3): void;
  45823. /**
  45824. * Setup the image processing according to the specified options.
  45825. */
  45826. private _setupImageProcessing;
  45827. /**
  45828. * Setup the environment texture according to the specified options.
  45829. */
  45830. private _setupEnvironmentTexture;
  45831. /**
  45832. * Setup the background according to the specified options.
  45833. */
  45834. private _setupBackground;
  45835. /**
  45836. * Get the scene sizes according to the setup.
  45837. */
  45838. private _getSceneSize;
  45839. /**
  45840. * Setup the ground according to the specified options.
  45841. */
  45842. private _setupGround;
  45843. /**
  45844. * Setup the ground material according to the specified options.
  45845. */
  45846. private _setupGroundMaterial;
  45847. /**
  45848. * Setup the ground diffuse texture according to the specified options.
  45849. */
  45850. private _setupGroundDiffuseTexture;
  45851. /**
  45852. * Setup the ground mirror texture according to the specified options.
  45853. */
  45854. private _setupGroundMirrorTexture;
  45855. /**
  45856. * Setup the ground to receive the mirror texture.
  45857. */
  45858. private _setupMirrorInGroundMaterial;
  45859. /**
  45860. * Setup the skybox according to the specified options.
  45861. */
  45862. private _setupSkybox;
  45863. /**
  45864. * Setup the skybox material according to the specified options.
  45865. */
  45866. private _setupSkyboxMaterial;
  45867. /**
  45868. * Setup the skybox reflection texture according to the specified options.
  45869. */
  45870. private _setupSkyboxReflectionTexture;
  45871. private _errorHandler;
  45872. /**
  45873. * Dispose all the elements created by the Helper.
  45874. */
  45875. dispose(): void;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45881. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45882. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45883. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45884. */
  45885. export class PhotoDome extends TransformNode {
  45886. /**
  45887. * Define the image as a Monoscopic panoramic 360 image.
  45888. */
  45889. static readonly MODE_MONOSCOPIC: number;
  45890. /**
  45891. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45892. */
  45893. static readonly MODE_TOPBOTTOM: number;
  45894. /**
  45895. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45896. */
  45897. static readonly MODE_SIDEBYSIDE: number;
  45898. private _useDirectMapping;
  45899. /**
  45900. * The texture being displayed on the sphere
  45901. */
  45902. protected _photoTexture: Texture;
  45903. /**
  45904. * Gets or sets the texture being displayed on the sphere
  45905. */
  45906. photoTexture: Texture;
  45907. /**
  45908. * Observable raised when an error occured while loading the 360 image
  45909. */
  45910. onLoadErrorObservable: Observable<string>;
  45911. /**
  45912. * The skybox material
  45913. */
  45914. protected _material: BackgroundMaterial;
  45915. /**
  45916. * The surface used for the skybox
  45917. */
  45918. protected _mesh: Mesh;
  45919. /**
  45920. * Gets the mesh used for the skybox.
  45921. */
  45922. readonly mesh: Mesh;
  45923. /**
  45924. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45925. * Also see the options.resolution property.
  45926. */
  45927. fovMultiplier: number;
  45928. private _imageMode;
  45929. /**
  45930. * Gets or set the current video mode for the video. It can be:
  45931. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45932. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45933. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45934. */
  45935. imageMode: number;
  45936. /**
  45937. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45938. * @param name Element's name, child elements will append suffixes for their own names.
  45939. * @param urlsOfPhoto defines the url of the photo to display
  45940. * @param options defines an object containing optional or exposed sub element properties
  45941. * @param onError defines a callback called when an error occured while loading the texture
  45942. */
  45943. constructor(name: string, urlOfPhoto: string, options: {
  45944. resolution?: number;
  45945. size?: number;
  45946. useDirectMapping?: boolean;
  45947. faceForward?: boolean;
  45948. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45949. private _onBeforeCameraRenderObserver;
  45950. private _changeImageMode;
  45951. /**
  45952. * Releases resources associated with this node.
  45953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45955. */
  45956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * Class used to host RGBD texture specific utilities
  45962. */
  45963. export class RGBDTextureTools {
  45964. /**
  45965. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45966. * @param texture the texture to expand.
  45967. */
  45968. static ExpandRGBDTexture(texture: Texture): void;
  45969. }
  45970. }
  45971. declare module BABYLON {
  45972. /**
  45973. * Class used to host texture specific utilities
  45974. */
  45975. export class BRDFTextureTools {
  45976. /**
  45977. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45978. * @param scene defines the hosting scene
  45979. * @returns the environment BRDF texture
  45980. */
  45981. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45982. private static _environmentBRDFBase64Texture;
  45983. }
  45984. }
  45985. declare module BABYLON {
  45986. /**
  45987. * @hidden
  45988. */
  45989. export interface IMaterialClearCoatDefines {
  45990. CLEARCOAT: boolean;
  45991. CLEARCOAT_DEFAULTIOR: boolean;
  45992. CLEARCOAT_TEXTURE: boolean;
  45993. CLEARCOAT_TEXTUREDIRECTUV: number;
  45994. CLEARCOAT_BUMP: boolean;
  45995. CLEARCOAT_BUMPDIRECTUV: number;
  45996. CLEARCOAT_TINT: boolean;
  45997. CLEARCOAT_TINT_TEXTURE: boolean;
  45998. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45999. /** @hidden */
  46000. _areTexturesDirty: boolean;
  46001. }
  46002. /**
  46003. * Define the code related to the clear coat parameters of the pbr material.
  46004. */
  46005. export class PBRClearCoatConfiguration {
  46006. /**
  46007. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46008. * The default fits with a polyurethane material.
  46009. */
  46010. private static readonly _DefaultIndexOfRefraction;
  46011. private _isEnabled;
  46012. /**
  46013. * Defines if the clear coat is enabled in the material.
  46014. */
  46015. isEnabled: boolean;
  46016. /**
  46017. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46018. */
  46019. intensity: number;
  46020. /**
  46021. * Defines the clear coat layer roughness.
  46022. */
  46023. roughness: number;
  46024. private _indexOfRefraction;
  46025. /**
  46026. * Defines the index of refraction of the clear coat.
  46027. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46028. * The default fits with a polyurethane material.
  46029. * Changing the default value is more performance intensive.
  46030. */
  46031. indexOfRefraction: number;
  46032. private _texture;
  46033. /**
  46034. * Stores the clear coat values in a texture.
  46035. */
  46036. texture: Nullable<BaseTexture>;
  46037. private _bumpTexture;
  46038. /**
  46039. * Define the clear coat specific bump texture.
  46040. */
  46041. bumpTexture: Nullable<BaseTexture>;
  46042. private _isTintEnabled;
  46043. /**
  46044. * Defines if the clear coat tint is enabled in the material.
  46045. */
  46046. isTintEnabled: boolean;
  46047. /**
  46048. * Defines the clear coat tint of the material.
  46049. * This is only use if tint is enabled
  46050. */
  46051. tintColor: Color3;
  46052. /**
  46053. * Defines the distance at which the tint color should be found in the
  46054. * clear coat media.
  46055. * This is only use if tint is enabled
  46056. */
  46057. tintColorAtDistance: number;
  46058. /**
  46059. * Defines the clear coat layer thickness.
  46060. * This is only use if tint is enabled
  46061. */
  46062. tintThickness: number;
  46063. private _tintTexture;
  46064. /**
  46065. * Stores the clear tint values in a texture.
  46066. * rgb is tint
  46067. * a is a thickness factor
  46068. */
  46069. tintTexture: Nullable<BaseTexture>;
  46070. /** @hidden */
  46071. private _internalMarkAllSubMeshesAsTexturesDirty;
  46072. /** @hidden */
  46073. _markAllSubMeshesAsTexturesDirty(): void;
  46074. /**
  46075. * Instantiate a new istance of clear coat configuration.
  46076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46077. */
  46078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46079. /**
  46080. * Gets wehter the submesh is ready to be used or not.
  46081. * @param defines the list of "defines" to update.
  46082. * @param scene defines the scene the material belongs to.
  46083. * @param engine defines the engine the material belongs to.
  46084. * @param disableBumpMap defines wether the material disables bump or not.
  46085. * @returns - boolean indicating that the submesh is ready or not.
  46086. */
  46087. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46088. /**
  46089. * Checks to see if a texture is used in the material.
  46090. * @param defines the list of "defines" to update.
  46091. * @param scene defines the scene to the material belongs to.
  46092. */
  46093. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46094. /**
  46095. * Binds the material data.
  46096. * @param uniformBuffer defines the Uniform buffer to fill in.
  46097. * @param scene defines the scene the material belongs to.
  46098. * @param engine defines the engine the material belongs to.
  46099. * @param disableBumpMap defines wether the material disables bump or not.
  46100. * @param isFrozen defines wether the material is frozen or not.
  46101. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46102. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46103. */
  46104. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46105. /**
  46106. * Checks to see if a texture is used in the material.
  46107. * @param texture - Base texture to use.
  46108. * @returns - Boolean specifying if a texture is used in the material.
  46109. */
  46110. hasTexture(texture: BaseTexture): boolean;
  46111. /**
  46112. * Returns an array of the actively used textures.
  46113. * @param activeTextures Array of BaseTextures
  46114. */
  46115. getActiveTextures(activeTextures: BaseTexture[]): void;
  46116. /**
  46117. * Returns the animatable textures.
  46118. * @param animatables Array of animatable textures.
  46119. */
  46120. getAnimatables(animatables: IAnimatable[]): void;
  46121. /**
  46122. * Disposes the resources of the material.
  46123. * @param forceDisposeTextures - Forces the disposal of all textures.
  46124. */
  46125. dispose(forceDisposeTextures?: boolean): void;
  46126. /**
  46127. * Get the current class name of the texture useful for serialization or dynamic coding.
  46128. * @returns "PBRClearCoatConfiguration"
  46129. */
  46130. getClassName(): string;
  46131. /**
  46132. * Add fallbacks to the effect fallbacks list.
  46133. * @param defines defines the Base texture to use.
  46134. * @param fallbacks defines the current fallback list.
  46135. * @param currentRank defines the current fallback rank.
  46136. * @returns the new fallback rank.
  46137. */
  46138. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46139. /**
  46140. * Add the required uniforms to the current list.
  46141. * @param uniforms defines the current uniform list.
  46142. */
  46143. static AddUniforms(uniforms: string[]): void;
  46144. /**
  46145. * Add the required samplers to the current list.
  46146. * @param samplers defines the current sampler list.
  46147. */
  46148. static AddSamplers(samplers: string[]): void;
  46149. /**
  46150. * Add the required uniforms to the current buffer.
  46151. * @param uniformBuffer defines the current uniform buffer.
  46152. */
  46153. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46154. /**
  46155. * Makes a duplicate of the current configuration into another one.
  46156. * @param clearCoatConfiguration define the config where to copy the info
  46157. */
  46158. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46159. /**
  46160. * Serializes this clear coat configuration.
  46161. * @returns - An object with the serialized config.
  46162. */
  46163. serialize(): any;
  46164. /**
  46165. * Parses a anisotropy Configuration from a serialized object.
  46166. * @param source - Serialized object.
  46167. * @param scene Defines the scene we are parsing for
  46168. * @param rootUrl Defines the rootUrl to load from
  46169. */
  46170. parse(source: any, scene: Scene, rootUrl: string): void;
  46171. }
  46172. }
  46173. declare module BABYLON {
  46174. /**
  46175. * @hidden
  46176. */
  46177. export interface IMaterialAnisotropicDefines {
  46178. ANISOTROPIC: boolean;
  46179. ANISOTROPIC_TEXTURE: boolean;
  46180. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46181. MAINUV1: boolean;
  46182. _areTexturesDirty: boolean;
  46183. _needUVs: boolean;
  46184. }
  46185. /**
  46186. * Define the code related to the anisotropic parameters of the pbr material.
  46187. */
  46188. export class PBRAnisotropicConfiguration {
  46189. private _isEnabled;
  46190. /**
  46191. * Defines if the anisotropy is enabled in the material.
  46192. */
  46193. isEnabled: boolean;
  46194. /**
  46195. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46196. */
  46197. intensity: number;
  46198. /**
  46199. * Defines if the effect is along the tangents, bitangents or in between.
  46200. * By default, the effect is "strectching" the highlights along the tangents.
  46201. */
  46202. direction: Vector2;
  46203. private _texture;
  46204. /**
  46205. * Stores the anisotropy values in a texture.
  46206. * rg is direction (like normal from -1 to 1)
  46207. * b is a intensity
  46208. */
  46209. texture: Nullable<BaseTexture>;
  46210. /** @hidden */
  46211. private _internalMarkAllSubMeshesAsTexturesDirty;
  46212. /** @hidden */
  46213. _markAllSubMeshesAsTexturesDirty(): void;
  46214. /**
  46215. * Instantiate a new istance of anisotropy configuration.
  46216. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46217. */
  46218. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46219. /**
  46220. * Specifies that the submesh is ready to be used.
  46221. * @param defines the list of "defines" to update.
  46222. * @param scene defines the scene the material belongs to.
  46223. * @returns - boolean indicating that the submesh is ready or not.
  46224. */
  46225. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46226. /**
  46227. * Checks to see if a texture is used in the material.
  46228. * @param defines the list of "defines" to update.
  46229. * @param mesh the mesh we are preparing the defines for.
  46230. * @param scene defines the scene the material belongs to.
  46231. */
  46232. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46233. /**
  46234. * Binds the material data.
  46235. * @param uniformBuffer defines the Uniform buffer to fill in.
  46236. * @param scene defines the scene the material belongs to.
  46237. * @param isFrozen defines wether the material is frozen or not.
  46238. */
  46239. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46240. /**
  46241. * Checks to see if a texture is used in the material.
  46242. * @param texture - Base texture to use.
  46243. * @returns - Boolean specifying if a texture is used in the material.
  46244. */
  46245. hasTexture(texture: BaseTexture): boolean;
  46246. /**
  46247. * Returns an array of the actively used textures.
  46248. * @param activeTextures Array of BaseTextures
  46249. */
  46250. getActiveTextures(activeTextures: BaseTexture[]): void;
  46251. /**
  46252. * Returns the animatable textures.
  46253. * @param animatables Array of animatable textures.
  46254. */
  46255. getAnimatables(animatables: IAnimatable[]): void;
  46256. /**
  46257. * Disposes the resources of the material.
  46258. * @param forceDisposeTextures - Forces the disposal of all textures.
  46259. */
  46260. dispose(forceDisposeTextures?: boolean): void;
  46261. /**
  46262. * Get the current class name of the texture useful for serialization or dynamic coding.
  46263. * @returns "PBRAnisotropicConfiguration"
  46264. */
  46265. getClassName(): string;
  46266. /**
  46267. * Add fallbacks to the effect fallbacks list.
  46268. * @param defines defines the Base texture to use.
  46269. * @param fallbacks defines the current fallback list.
  46270. * @param currentRank defines the current fallback rank.
  46271. * @returns the new fallback rank.
  46272. */
  46273. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46274. /**
  46275. * Add the required uniforms to the current list.
  46276. * @param uniforms defines the current uniform list.
  46277. */
  46278. static AddUniforms(uniforms: string[]): void;
  46279. /**
  46280. * Add the required uniforms to the current buffer.
  46281. * @param uniformBuffer defines the current uniform buffer.
  46282. */
  46283. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46284. /**
  46285. * Add the required samplers to the current list.
  46286. * @param samplers defines the current sampler list.
  46287. */
  46288. static AddSamplers(samplers: string[]): void;
  46289. /**
  46290. * Makes a duplicate of the current configuration into another one.
  46291. * @param anisotropicConfiguration define the config where to copy the info
  46292. */
  46293. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46294. /**
  46295. * Serializes this anisotropy configuration.
  46296. * @returns - An object with the serialized config.
  46297. */
  46298. serialize(): any;
  46299. /**
  46300. * Parses a anisotropy Configuration from a serialized object.
  46301. * @param source - Serialized object.
  46302. * @param scene Defines the scene we are parsing for
  46303. * @param rootUrl Defines the rootUrl to load from
  46304. */
  46305. parse(source: any, scene: Scene, rootUrl: string): void;
  46306. }
  46307. }
  46308. declare module BABYLON {
  46309. /**
  46310. * @hidden
  46311. */
  46312. export interface IMaterialBRDFDefines {
  46313. BRDF_V_HEIGHT_CORRELATED: boolean;
  46314. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46315. SPHERICAL_HARMONICS: boolean;
  46316. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46317. /** @hidden */
  46318. _areMiscDirty: boolean;
  46319. }
  46320. /**
  46321. * Define the code related to the BRDF parameters of the pbr material.
  46322. */
  46323. export class PBRBRDFConfiguration {
  46324. /**
  46325. * Default value used for the energy conservation.
  46326. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46327. */
  46328. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46329. /**
  46330. * Default value used for the Smith Visibility Height Correlated mode.
  46331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46332. */
  46333. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46334. /**
  46335. * Default value used for the IBL diffuse part.
  46336. * This can help switching back to the polynomials mode globally which is a tiny bit
  46337. * less GPU intensive at the drawback of a lower quality.
  46338. */
  46339. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46340. /**
  46341. * Default value used for activating energy conservation for the specular workflow.
  46342. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46343. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46344. */
  46345. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46346. private _useEnergyConservation;
  46347. /**
  46348. * Defines if the material uses energy conservation.
  46349. */
  46350. useEnergyConservation: boolean;
  46351. private _useSmithVisibilityHeightCorrelated;
  46352. /**
  46353. * LEGACY Mode set to false
  46354. * Defines if the material uses height smith correlated visibility term.
  46355. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46356. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46357. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46358. * Not relying on height correlated will also disable energy conservation.
  46359. */
  46360. useSmithVisibilityHeightCorrelated: boolean;
  46361. private _useSphericalHarmonics;
  46362. /**
  46363. * LEGACY Mode set to false
  46364. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46365. * diffuse part of the IBL.
  46366. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46367. * to the ground truth.
  46368. */
  46369. useSphericalHarmonics: boolean;
  46370. private _useSpecularGlossinessInputEnergyConservation;
  46371. /**
  46372. * Defines if the material uses energy conservation, when the specular workflow is active.
  46373. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46374. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46375. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46376. */
  46377. useSpecularGlossinessInputEnergyConservation: boolean;
  46378. /** @hidden */
  46379. private _internalMarkAllSubMeshesAsMiscDirty;
  46380. /** @hidden */
  46381. _markAllSubMeshesAsMiscDirty(): void;
  46382. /**
  46383. * Instantiate a new istance of clear coat configuration.
  46384. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46385. */
  46386. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46387. /**
  46388. * Checks to see if a texture is used in the material.
  46389. * @param defines the list of "defines" to update.
  46390. */
  46391. prepareDefines(defines: IMaterialBRDFDefines): void;
  46392. /**
  46393. * Get the current class name of the texture useful for serialization or dynamic coding.
  46394. * @returns "PBRClearCoatConfiguration"
  46395. */
  46396. getClassName(): string;
  46397. /**
  46398. * Makes a duplicate of the current configuration into another one.
  46399. * @param brdfConfiguration define the config where to copy the info
  46400. */
  46401. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46402. /**
  46403. * Serializes this BRDF configuration.
  46404. * @returns - An object with the serialized config.
  46405. */
  46406. serialize(): any;
  46407. /**
  46408. * Parses a anisotropy Configuration from a serialized object.
  46409. * @param source - Serialized object.
  46410. * @param scene Defines the scene we are parsing for
  46411. * @param rootUrl Defines the rootUrl to load from
  46412. */
  46413. parse(source: any, scene: Scene, rootUrl: string): void;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /**
  46418. * @hidden
  46419. */
  46420. export interface IMaterialSheenDefines {
  46421. SHEEN: boolean;
  46422. SHEEN_TEXTURE: boolean;
  46423. SHEEN_TEXTUREDIRECTUV: number;
  46424. SHEEN_LINKWITHALBEDO: boolean;
  46425. /** @hidden */
  46426. _areTexturesDirty: boolean;
  46427. }
  46428. /**
  46429. * Define the code related to the Sheen parameters of the pbr material.
  46430. */
  46431. export class PBRSheenConfiguration {
  46432. private _isEnabled;
  46433. /**
  46434. * Defines if the material uses sheen.
  46435. */
  46436. isEnabled: boolean;
  46437. private _linkSheenWithAlbedo;
  46438. /**
  46439. * Defines if the sheen is linked to the sheen color.
  46440. */
  46441. linkSheenWithAlbedo: boolean;
  46442. /**
  46443. * Defines the sheen intensity.
  46444. */
  46445. intensity: number;
  46446. /**
  46447. * Defines the sheen color.
  46448. */
  46449. color: Color3;
  46450. private _texture;
  46451. /**
  46452. * Stores the sheen tint values in a texture.
  46453. * rgb is tint
  46454. * a is a intensity
  46455. */
  46456. texture: Nullable<BaseTexture>;
  46457. /** @hidden */
  46458. private _internalMarkAllSubMeshesAsTexturesDirty;
  46459. /** @hidden */
  46460. _markAllSubMeshesAsTexturesDirty(): void;
  46461. /**
  46462. * Instantiate a new istance of clear coat configuration.
  46463. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46464. */
  46465. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46466. /**
  46467. * Specifies that the submesh is ready to be used.
  46468. * @param defines the list of "defines" to update.
  46469. * @param scene defines the scene the material belongs to.
  46470. * @returns - boolean indicating that the submesh is ready or not.
  46471. */
  46472. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46473. /**
  46474. * Checks to see if a texture is used in the material.
  46475. * @param defines the list of "defines" to update.
  46476. * @param scene defines the scene the material belongs to.
  46477. */
  46478. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46479. /**
  46480. * Binds the material data.
  46481. * @param uniformBuffer defines the Uniform buffer to fill in.
  46482. * @param scene defines the scene the material belongs to.
  46483. * @param isFrozen defines wether the material is frozen or not.
  46484. */
  46485. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46486. /**
  46487. * Checks to see if a texture is used in the material.
  46488. * @param texture - Base texture to use.
  46489. * @returns - Boolean specifying if a texture is used in the material.
  46490. */
  46491. hasTexture(texture: BaseTexture): boolean;
  46492. /**
  46493. * Returns an array of the actively used textures.
  46494. * @param activeTextures Array of BaseTextures
  46495. */
  46496. getActiveTextures(activeTextures: BaseTexture[]): void;
  46497. /**
  46498. * Returns the animatable textures.
  46499. * @param animatables Array of animatable textures.
  46500. */
  46501. getAnimatables(animatables: IAnimatable[]): void;
  46502. /**
  46503. * Disposes the resources of the material.
  46504. * @param forceDisposeTextures - Forces the disposal of all textures.
  46505. */
  46506. dispose(forceDisposeTextures?: boolean): void;
  46507. /**
  46508. * Get the current class name of the texture useful for serialization or dynamic coding.
  46509. * @returns "PBRSheenConfiguration"
  46510. */
  46511. getClassName(): string;
  46512. /**
  46513. * Add fallbacks to the effect fallbacks list.
  46514. * @param defines defines the Base texture to use.
  46515. * @param fallbacks defines the current fallback list.
  46516. * @param currentRank defines the current fallback rank.
  46517. * @returns the new fallback rank.
  46518. */
  46519. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46520. /**
  46521. * Add the required uniforms to the current list.
  46522. * @param uniforms defines the current uniform list.
  46523. */
  46524. static AddUniforms(uniforms: string[]): void;
  46525. /**
  46526. * Add the required uniforms to the current buffer.
  46527. * @param uniformBuffer defines the current uniform buffer.
  46528. */
  46529. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46530. /**
  46531. * Add the required samplers to the current list.
  46532. * @param samplers defines the current sampler list.
  46533. */
  46534. static AddSamplers(samplers: string[]): void;
  46535. /**
  46536. * Makes a duplicate of the current configuration into another one.
  46537. * @param sheenConfiguration define the config where to copy the info
  46538. */
  46539. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46540. /**
  46541. * Serializes this BRDF configuration.
  46542. * @returns - An object with the serialized config.
  46543. */
  46544. serialize(): any;
  46545. /**
  46546. * Parses a anisotropy Configuration from a serialized object.
  46547. * @param source - Serialized object.
  46548. * @param scene Defines the scene we are parsing for
  46549. * @param rootUrl Defines the rootUrl to load from
  46550. */
  46551. parse(source: any, scene: Scene, rootUrl: string): void;
  46552. }
  46553. }
  46554. declare module BABYLON {
  46555. /**
  46556. * @hidden
  46557. */
  46558. export interface IMaterialSubSurfaceDefines {
  46559. SUBSURFACE: boolean;
  46560. SS_REFRACTION: boolean;
  46561. SS_TRANSLUCENCY: boolean;
  46562. SS_SCATERRING: boolean;
  46563. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46564. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46565. SS_REFRACTIONMAP_3D: boolean;
  46566. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46567. SS_LODINREFRACTIONALPHA: boolean;
  46568. SS_GAMMAREFRACTION: boolean;
  46569. SS_RGBDREFRACTION: boolean;
  46570. SS_LINEARSPECULARREFRACTION: boolean;
  46571. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46572. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46573. /** @hidden */
  46574. _areTexturesDirty: boolean;
  46575. }
  46576. /**
  46577. * Define the code related to the sub surface parameters of the pbr material.
  46578. */
  46579. export class PBRSubSurfaceConfiguration {
  46580. private _isRefractionEnabled;
  46581. /**
  46582. * Defines if the refraction is enabled in the material.
  46583. */
  46584. isRefractionEnabled: boolean;
  46585. private _isTranslucencyEnabled;
  46586. /**
  46587. * Defines if the translucency is enabled in the material.
  46588. */
  46589. isTranslucencyEnabled: boolean;
  46590. private _isScatteringEnabled;
  46591. /**
  46592. * Defines the refraction intensity of the material.
  46593. * The refraction when enabled replaces the Diffuse part of the material.
  46594. * The intensity helps transitionning between diffuse and refraction.
  46595. */
  46596. refractionIntensity: number;
  46597. /**
  46598. * Defines the translucency intensity of the material.
  46599. * When translucency has been enabled, this defines how much of the "translucency"
  46600. * is addded to the diffuse part of the material.
  46601. */
  46602. translucencyIntensity: number;
  46603. /**
  46604. * Defines the scattering intensity of the material.
  46605. * When scattering has been enabled, this defines how much of the "scattered light"
  46606. * is addded to the diffuse part of the material.
  46607. */
  46608. scatteringIntensity: number;
  46609. private _thicknessTexture;
  46610. /**
  46611. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46612. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46613. * 0 would mean minimumThickness
  46614. * 1 would mean maximumThickness
  46615. * The other channels might be use as a mask to vary the different effects intensity.
  46616. */
  46617. thicknessTexture: Nullable<BaseTexture>;
  46618. private _refractionTexture;
  46619. /**
  46620. * Defines the texture to use for refraction.
  46621. */
  46622. refractionTexture: Nullable<BaseTexture>;
  46623. private _indexOfRefraction;
  46624. /**
  46625. * Defines the index of refraction used in the material.
  46626. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46627. */
  46628. indexOfRefraction: number;
  46629. private _invertRefractionY;
  46630. /**
  46631. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46632. */
  46633. invertRefractionY: boolean;
  46634. private _linkRefractionWithTransparency;
  46635. /**
  46636. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46637. * Materials half opaque for instance using refraction could benefit from this control.
  46638. */
  46639. linkRefractionWithTransparency: boolean;
  46640. /**
  46641. * Defines the minimum thickness stored in the thickness map.
  46642. * If no thickness map is defined, this value will be used to simulate thickness.
  46643. */
  46644. minimumThickness: number;
  46645. /**
  46646. * Defines the maximum thickness stored in the thickness map.
  46647. */
  46648. maximumThickness: number;
  46649. /**
  46650. * Defines the volume tint of the material.
  46651. * This is used for both translucency and scattering.
  46652. */
  46653. tintColor: Color3;
  46654. /**
  46655. * Defines the distance at which the tint color should be found in the media.
  46656. * This is used for refraction only.
  46657. */
  46658. tintColorAtDistance: number;
  46659. /**
  46660. * Defines how far each channel transmit through the media.
  46661. * It is defined as a color to simplify it selection.
  46662. */
  46663. diffusionDistance: Color3;
  46664. private _useMaskFromThicknessTexture;
  46665. /**
  46666. * Stores the intensity of the different subsurface effects in the thickness texture.
  46667. * * the green channel is the translucency intensity.
  46668. * * the blue channel is the scattering intensity.
  46669. * * the alpha channel is the refraction intensity.
  46670. */
  46671. useMaskFromThicknessTexture: boolean;
  46672. /** @hidden */
  46673. private _internalMarkAllSubMeshesAsTexturesDirty;
  46674. /** @hidden */
  46675. _markAllSubMeshesAsTexturesDirty(): void;
  46676. /**
  46677. * Instantiate a new istance of sub surface configuration.
  46678. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46679. */
  46680. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46681. /**
  46682. * Gets wehter the submesh is ready to be used or not.
  46683. * @param defines the list of "defines" to update.
  46684. * @param scene defines the scene the material belongs to.
  46685. * @returns - boolean indicating that the submesh is ready or not.
  46686. */
  46687. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46688. /**
  46689. * Checks to see if a texture is used in the material.
  46690. * @param defines the list of "defines" to update.
  46691. * @param scene defines the scene to the material belongs to.
  46692. */
  46693. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46694. /**
  46695. * Binds the material data.
  46696. * @param uniformBuffer defines the Uniform buffer to fill in.
  46697. * @param scene defines the scene the material belongs to.
  46698. * @param engine defines the engine the material belongs to.
  46699. * @param isFrozen defines wether the material is frozen or not.
  46700. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46701. */
  46702. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46703. /**
  46704. * Unbinds the material from the mesh.
  46705. * @param activeEffect defines the effect that should be unbound from.
  46706. * @returns true if unbound, otherwise false
  46707. */
  46708. unbind(activeEffect: Effect): boolean;
  46709. /**
  46710. * Returns the texture used for refraction or null if none is used.
  46711. * @param scene defines the scene the material belongs to.
  46712. * @returns - Refraction texture if present. If no refraction texture and refraction
  46713. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46714. */
  46715. private _getRefractionTexture;
  46716. /**
  46717. * Returns true if alpha blending should be disabled.
  46718. */
  46719. readonly disableAlphaBlending: boolean;
  46720. /**
  46721. * Fills the list of render target textures.
  46722. * @param renderTargets the list of render targets to update
  46723. */
  46724. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46725. /**
  46726. * Checks to see if a texture is used in the material.
  46727. * @param texture - Base texture to use.
  46728. * @returns - Boolean specifying if a texture is used in the material.
  46729. */
  46730. hasTexture(texture: BaseTexture): boolean;
  46731. /**
  46732. * Gets a boolean indicating that current material needs to register RTT
  46733. * @returns true if this uses a render target otherwise false.
  46734. */
  46735. hasRenderTargetTextures(): boolean;
  46736. /**
  46737. * Returns an array of the actively used textures.
  46738. * @param activeTextures Array of BaseTextures
  46739. */
  46740. getActiveTextures(activeTextures: BaseTexture[]): void;
  46741. /**
  46742. * Returns the animatable textures.
  46743. * @param animatables Array of animatable textures.
  46744. */
  46745. getAnimatables(animatables: IAnimatable[]): void;
  46746. /**
  46747. * Disposes the resources of the material.
  46748. * @param forceDisposeTextures - Forces the disposal of all textures.
  46749. */
  46750. dispose(forceDisposeTextures?: boolean): void;
  46751. /**
  46752. * Get the current class name of the texture useful for serialization or dynamic coding.
  46753. * @returns "PBRSubSurfaceConfiguration"
  46754. */
  46755. getClassName(): string;
  46756. /**
  46757. * Add fallbacks to the effect fallbacks list.
  46758. * @param defines defines the Base texture to use.
  46759. * @param fallbacks defines the current fallback list.
  46760. * @param currentRank defines the current fallback rank.
  46761. * @returns the new fallback rank.
  46762. */
  46763. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46764. /**
  46765. * Add the required uniforms to the current list.
  46766. * @param uniforms defines the current uniform list.
  46767. */
  46768. static AddUniforms(uniforms: string[]): void;
  46769. /**
  46770. * Add the required samplers to the current list.
  46771. * @param samplers defines the current sampler list.
  46772. */
  46773. static AddSamplers(samplers: string[]): void;
  46774. /**
  46775. * Add the required uniforms to the current buffer.
  46776. * @param uniformBuffer defines the current uniform buffer.
  46777. */
  46778. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46779. /**
  46780. * Makes a duplicate of the current configuration into another one.
  46781. * @param configuration define the config where to copy the info
  46782. */
  46783. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46784. /**
  46785. * Serializes this Sub Surface configuration.
  46786. * @returns - An object with the serialized config.
  46787. */
  46788. serialize(): any;
  46789. /**
  46790. * Parses a anisotropy Configuration from a serialized object.
  46791. * @param source - Serialized object.
  46792. * @param scene Defines the scene we are parsing for
  46793. * @param rootUrl Defines the rootUrl to load from
  46794. */
  46795. parse(source: any, scene: Scene, rootUrl: string): void;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /** @hidden */
  46800. export var pbrFragmentDeclaration: {
  46801. name: string;
  46802. shader: string;
  46803. };
  46804. }
  46805. declare module BABYLON {
  46806. /** @hidden */
  46807. export var pbrUboDeclaration: {
  46808. name: string;
  46809. shader: string;
  46810. };
  46811. }
  46812. declare module BABYLON {
  46813. /** @hidden */
  46814. export var pbrFragmentExtraDeclaration: {
  46815. name: string;
  46816. shader: string;
  46817. };
  46818. }
  46819. declare module BABYLON {
  46820. /** @hidden */
  46821. export var pbrFragmentSamplersDeclaration: {
  46822. name: string;
  46823. shader: string;
  46824. };
  46825. }
  46826. declare module BABYLON {
  46827. /** @hidden */
  46828. export var pbrHelperFunctions: {
  46829. name: string;
  46830. shader: string;
  46831. };
  46832. }
  46833. declare module BABYLON {
  46834. /** @hidden */
  46835. export var harmonicsFunctions: {
  46836. name: string;
  46837. shader: string;
  46838. };
  46839. }
  46840. declare module BABYLON {
  46841. /** @hidden */
  46842. export var pbrDirectLightingSetupFunctions: {
  46843. name: string;
  46844. shader: string;
  46845. };
  46846. }
  46847. declare module BABYLON {
  46848. /** @hidden */
  46849. export var pbrDirectLightingFalloffFunctions: {
  46850. name: string;
  46851. shader: string;
  46852. };
  46853. }
  46854. declare module BABYLON {
  46855. /** @hidden */
  46856. export var pbrBRDFFunctions: {
  46857. name: string;
  46858. shader: string;
  46859. };
  46860. }
  46861. declare module BABYLON {
  46862. /** @hidden */
  46863. export var pbrDirectLightingFunctions: {
  46864. name: string;
  46865. shader: string;
  46866. };
  46867. }
  46868. declare module BABYLON {
  46869. /** @hidden */
  46870. export var pbrIBLFunctions: {
  46871. name: string;
  46872. shader: string;
  46873. };
  46874. }
  46875. declare module BABYLON {
  46876. /** @hidden */
  46877. export var pbrDebug: {
  46878. name: string;
  46879. shader: string;
  46880. };
  46881. }
  46882. declare module BABYLON {
  46883. /** @hidden */
  46884. export var pbrPixelShader: {
  46885. name: string;
  46886. shader: string;
  46887. };
  46888. }
  46889. declare module BABYLON {
  46890. /** @hidden */
  46891. export var pbrVertexDeclaration: {
  46892. name: string;
  46893. shader: string;
  46894. };
  46895. }
  46896. declare module BABYLON {
  46897. /** @hidden */
  46898. export var pbrVertexShader: {
  46899. name: string;
  46900. shader: string;
  46901. };
  46902. }
  46903. declare module BABYLON {
  46904. /**
  46905. * Manages the defines for the PBR Material.
  46906. * @hidden
  46907. */
  46908. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46909. PBR: boolean;
  46910. MAINUV1: boolean;
  46911. MAINUV2: boolean;
  46912. UV1: boolean;
  46913. UV2: boolean;
  46914. ALBEDO: boolean;
  46915. ALBEDODIRECTUV: number;
  46916. VERTEXCOLOR: boolean;
  46917. AMBIENT: boolean;
  46918. AMBIENTDIRECTUV: number;
  46919. AMBIENTINGRAYSCALE: boolean;
  46920. OPACITY: boolean;
  46921. VERTEXALPHA: boolean;
  46922. OPACITYDIRECTUV: number;
  46923. OPACITYRGB: boolean;
  46924. ALPHATEST: boolean;
  46925. DEPTHPREPASS: boolean;
  46926. ALPHABLEND: boolean;
  46927. ALPHAFROMALBEDO: boolean;
  46928. ALPHATESTVALUE: string;
  46929. SPECULAROVERALPHA: boolean;
  46930. RADIANCEOVERALPHA: boolean;
  46931. ALPHAFRESNEL: boolean;
  46932. LINEARALPHAFRESNEL: boolean;
  46933. PREMULTIPLYALPHA: boolean;
  46934. EMISSIVE: boolean;
  46935. EMISSIVEDIRECTUV: number;
  46936. REFLECTIVITY: boolean;
  46937. REFLECTIVITYDIRECTUV: number;
  46938. SPECULARTERM: boolean;
  46939. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46940. MICROSURFACEAUTOMATIC: boolean;
  46941. LODBASEDMICROSFURACE: boolean;
  46942. MICROSURFACEMAP: boolean;
  46943. MICROSURFACEMAPDIRECTUV: number;
  46944. METALLICWORKFLOW: boolean;
  46945. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46946. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46947. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46948. AOSTOREINMETALMAPRED: boolean;
  46949. ENVIRONMENTBRDF: boolean;
  46950. ENVIRONMENTBRDF_RGBD: boolean;
  46951. NORMAL: boolean;
  46952. TANGENT: boolean;
  46953. BUMP: boolean;
  46954. BUMPDIRECTUV: number;
  46955. OBJECTSPACE_NORMALMAP: boolean;
  46956. PARALLAX: boolean;
  46957. PARALLAXOCCLUSION: boolean;
  46958. NORMALXYSCALE: boolean;
  46959. LIGHTMAP: boolean;
  46960. LIGHTMAPDIRECTUV: number;
  46961. USELIGHTMAPASSHADOWMAP: boolean;
  46962. GAMMALIGHTMAP: boolean;
  46963. RGBDLIGHTMAP: boolean;
  46964. REFLECTION: boolean;
  46965. REFLECTIONMAP_3D: boolean;
  46966. REFLECTIONMAP_SPHERICAL: boolean;
  46967. REFLECTIONMAP_PLANAR: boolean;
  46968. REFLECTIONMAP_CUBIC: boolean;
  46969. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46970. REFLECTIONMAP_PROJECTION: boolean;
  46971. REFLECTIONMAP_SKYBOX: boolean;
  46972. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46973. REFLECTIONMAP_EXPLICIT: boolean;
  46974. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46975. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46976. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46977. INVERTCUBICMAP: boolean;
  46978. USESPHERICALFROMREFLECTIONMAP: boolean;
  46979. USEIRRADIANCEMAP: boolean;
  46980. SPHERICAL_HARMONICS: boolean;
  46981. USESPHERICALINVERTEX: boolean;
  46982. REFLECTIONMAP_OPPOSITEZ: boolean;
  46983. LODINREFLECTIONALPHA: boolean;
  46984. GAMMAREFLECTION: boolean;
  46985. RGBDREFLECTION: boolean;
  46986. LINEARSPECULARREFLECTION: boolean;
  46987. RADIANCEOCCLUSION: boolean;
  46988. HORIZONOCCLUSION: boolean;
  46989. INSTANCES: boolean;
  46990. NUM_BONE_INFLUENCERS: number;
  46991. BonesPerMesh: number;
  46992. BONETEXTURE: boolean;
  46993. NONUNIFORMSCALING: boolean;
  46994. MORPHTARGETS: boolean;
  46995. MORPHTARGETS_NORMAL: boolean;
  46996. MORPHTARGETS_TANGENT: boolean;
  46997. MORPHTARGETS_UV: boolean;
  46998. NUM_MORPH_INFLUENCERS: number;
  46999. IMAGEPROCESSING: boolean;
  47000. VIGNETTE: boolean;
  47001. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47002. VIGNETTEBLENDMODEOPAQUE: boolean;
  47003. TONEMAPPING: boolean;
  47004. TONEMAPPING_ACES: boolean;
  47005. CONTRAST: boolean;
  47006. COLORCURVES: boolean;
  47007. COLORGRADING: boolean;
  47008. COLORGRADING3D: boolean;
  47009. SAMPLER3DGREENDEPTH: boolean;
  47010. SAMPLER3DBGRMAP: boolean;
  47011. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47012. EXPOSURE: boolean;
  47013. MULTIVIEW: boolean;
  47014. USEPHYSICALLIGHTFALLOFF: boolean;
  47015. USEGLTFLIGHTFALLOFF: boolean;
  47016. TWOSIDEDLIGHTING: boolean;
  47017. SHADOWFLOAT: boolean;
  47018. CLIPPLANE: boolean;
  47019. CLIPPLANE2: boolean;
  47020. CLIPPLANE3: boolean;
  47021. CLIPPLANE4: boolean;
  47022. POINTSIZE: boolean;
  47023. FOG: boolean;
  47024. LOGARITHMICDEPTH: boolean;
  47025. FORCENORMALFORWARD: boolean;
  47026. SPECULARAA: boolean;
  47027. CLEARCOAT: boolean;
  47028. CLEARCOAT_DEFAULTIOR: boolean;
  47029. CLEARCOAT_TEXTURE: boolean;
  47030. CLEARCOAT_TEXTUREDIRECTUV: number;
  47031. CLEARCOAT_BUMP: boolean;
  47032. CLEARCOAT_BUMPDIRECTUV: number;
  47033. CLEARCOAT_TINT: boolean;
  47034. CLEARCOAT_TINT_TEXTURE: boolean;
  47035. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47036. ANISOTROPIC: boolean;
  47037. ANISOTROPIC_TEXTURE: boolean;
  47038. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47039. BRDF_V_HEIGHT_CORRELATED: boolean;
  47040. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47041. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47042. SHEEN: boolean;
  47043. SHEEN_TEXTURE: boolean;
  47044. SHEEN_TEXTUREDIRECTUV: number;
  47045. SHEEN_LINKWITHALBEDO: boolean;
  47046. SUBSURFACE: boolean;
  47047. SS_REFRACTION: boolean;
  47048. SS_TRANSLUCENCY: boolean;
  47049. SS_SCATERRING: boolean;
  47050. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47051. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47052. SS_REFRACTIONMAP_3D: boolean;
  47053. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47054. SS_LODINREFRACTIONALPHA: boolean;
  47055. SS_GAMMAREFRACTION: boolean;
  47056. SS_RGBDREFRACTION: boolean;
  47057. SS_LINEARSPECULARREFRACTION: boolean;
  47058. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47059. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47060. UNLIT: boolean;
  47061. DEBUGMODE: number;
  47062. /**
  47063. * Initializes the PBR Material defines.
  47064. */
  47065. constructor();
  47066. /**
  47067. * Resets the PBR Material defines.
  47068. */
  47069. reset(): void;
  47070. }
  47071. /**
  47072. * The Physically based material base class of BJS.
  47073. *
  47074. * This offers the main features of a standard PBR material.
  47075. * For more information, please refer to the documentation :
  47076. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47077. */
  47078. export abstract class PBRBaseMaterial extends PushMaterial {
  47079. /**
  47080. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47081. */
  47082. static readonly PBRMATERIAL_OPAQUE: number;
  47083. /**
  47084. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47085. */
  47086. static readonly PBRMATERIAL_ALPHATEST: number;
  47087. /**
  47088. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47089. */
  47090. static readonly PBRMATERIAL_ALPHABLEND: number;
  47091. /**
  47092. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47093. * They are also discarded below the alpha cutoff threshold to improve performances.
  47094. */
  47095. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47096. /**
  47097. * Defines the default value of how much AO map is occluding the analytical lights
  47098. * (point spot...).
  47099. */
  47100. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47101. /**
  47102. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47103. */
  47104. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47105. /**
  47106. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47107. * to enhance interoperability with other engines.
  47108. */
  47109. static readonly LIGHTFALLOFF_GLTF: number;
  47110. /**
  47111. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47112. * to enhance interoperability with other materials.
  47113. */
  47114. static readonly LIGHTFALLOFF_STANDARD: number;
  47115. /**
  47116. * Intensity of the direct lights e.g. the four lights available in your scene.
  47117. * This impacts both the direct diffuse and specular highlights.
  47118. */
  47119. protected _directIntensity: number;
  47120. /**
  47121. * Intensity of the emissive part of the material.
  47122. * This helps controlling the emissive effect without modifying the emissive color.
  47123. */
  47124. protected _emissiveIntensity: number;
  47125. /**
  47126. * Intensity of the environment e.g. how much the environment will light the object
  47127. * either through harmonics for rough material or through the refelction for shiny ones.
  47128. */
  47129. protected _environmentIntensity: number;
  47130. /**
  47131. * This is a special control allowing the reduction of the specular highlights coming from the
  47132. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47133. */
  47134. protected _specularIntensity: number;
  47135. /**
  47136. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47137. */
  47138. private _lightingInfos;
  47139. /**
  47140. * Debug Control allowing disabling the bump map on this material.
  47141. */
  47142. protected _disableBumpMap: boolean;
  47143. /**
  47144. * AKA Diffuse Texture in standard nomenclature.
  47145. */
  47146. protected _albedoTexture: Nullable<BaseTexture>;
  47147. /**
  47148. * AKA Occlusion Texture in other nomenclature.
  47149. */
  47150. protected _ambientTexture: Nullable<BaseTexture>;
  47151. /**
  47152. * AKA Occlusion Texture Intensity in other nomenclature.
  47153. */
  47154. protected _ambientTextureStrength: number;
  47155. /**
  47156. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47157. * 1 means it completely occludes it
  47158. * 0 mean it has no impact
  47159. */
  47160. protected _ambientTextureImpactOnAnalyticalLights: number;
  47161. /**
  47162. * Stores the alpha values in a texture.
  47163. */
  47164. protected _opacityTexture: Nullable<BaseTexture>;
  47165. /**
  47166. * Stores the reflection values in a texture.
  47167. */
  47168. protected _reflectionTexture: Nullable<BaseTexture>;
  47169. /**
  47170. * Stores the emissive values in a texture.
  47171. */
  47172. protected _emissiveTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * AKA Specular texture in other nomenclature.
  47175. */
  47176. protected _reflectivityTexture: Nullable<BaseTexture>;
  47177. /**
  47178. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47179. */
  47180. protected _metallicTexture: Nullable<BaseTexture>;
  47181. /**
  47182. * Specifies the metallic scalar of the metallic/roughness workflow.
  47183. * Can also be used to scale the metalness values of the metallic texture.
  47184. */
  47185. protected _metallic: Nullable<number>;
  47186. /**
  47187. * Specifies the roughness scalar of the metallic/roughness workflow.
  47188. * Can also be used to scale the roughness values of the metallic texture.
  47189. */
  47190. protected _roughness: Nullable<number>;
  47191. /**
  47192. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47193. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47194. */
  47195. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47196. /**
  47197. * Stores surface normal data used to displace a mesh in a texture.
  47198. */
  47199. protected _bumpTexture: Nullable<BaseTexture>;
  47200. /**
  47201. * Stores the pre-calculated light information of a mesh in a texture.
  47202. */
  47203. protected _lightmapTexture: Nullable<BaseTexture>;
  47204. /**
  47205. * The color of a material in ambient lighting.
  47206. */
  47207. protected _ambientColor: Color3;
  47208. /**
  47209. * AKA Diffuse Color in other nomenclature.
  47210. */
  47211. protected _albedoColor: Color3;
  47212. /**
  47213. * AKA Specular Color in other nomenclature.
  47214. */
  47215. protected _reflectivityColor: Color3;
  47216. /**
  47217. * The color applied when light is reflected from a material.
  47218. */
  47219. protected _reflectionColor: Color3;
  47220. /**
  47221. * The color applied when light is emitted from a material.
  47222. */
  47223. protected _emissiveColor: Color3;
  47224. /**
  47225. * AKA Glossiness in other nomenclature.
  47226. */
  47227. protected _microSurface: number;
  47228. /**
  47229. * Specifies that the material will use the light map as a show map.
  47230. */
  47231. protected _useLightmapAsShadowmap: boolean;
  47232. /**
  47233. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47234. * makes the reflect vector face the model (under horizon).
  47235. */
  47236. protected _useHorizonOcclusion: boolean;
  47237. /**
  47238. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47239. * too much the area relying on ambient texture to define their ambient occlusion.
  47240. */
  47241. protected _useRadianceOcclusion: boolean;
  47242. /**
  47243. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47244. */
  47245. protected _useAlphaFromAlbedoTexture: boolean;
  47246. /**
  47247. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47248. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47249. */
  47250. protected _useSpecularOverAlpha: boolean;
  47251. /**
  47252. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47253. */
  47254. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47255. /**
  47256. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47257. */
  47258. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47259. /**
  47260. * Specifies if the metallic texture contains the roughness information in its green channel.
  47261. */
  47262. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47263. /**
  47264. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47265. */
  47266. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47267. /**
  47268. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47269. */
  47270. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47271. /**
  47272. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47273. */
  47274. protected _useAmbientInGrayScale: boolean;
  47275. /**
  47276. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47277. * The material will try to infer what glossiness each pixel should be.
  47278. */
  47279. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47280. /**
  47281. * Defines the falloff type used in this material.
  47282. * It by default is Physical.
  47283. */
  47284. protected _lightFalloff: number;
  47285. /**
  47286. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47287. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47288. */
  47289. protected _useRadianceOverAlpha: boolean;
  47290. /**
  47291. * Allows using an object space normal map (instead of tangent space).
  47292. */
  47293. protected _useObjectSpaceNormalMap: boolean;
  47294. /**
  47295. * Allows using the bump map in parallax mode.
  47296. */
  47297. protected _useParallax: boolean;
  47298. /**
  47299. * Allows using the bump map in parallax occlusion mode.
  47300. */
  47301. protected _useParallaxOcclusion: boolean;
  47302. /**
  47303. * Controls the scale bias of the parallax mode.
  47304. */
  47305. protected _parallaxScaleBias: number;
  47306. /**
  47307. * If sets to true, disables all the lights affecting the material.
  47308. */
  47309. protected _disableLighting: boolean;
  47310. /**
  47311. * Number of Simultaneous lights allowed on the material.
  47312. */
  47313. protected _maxSimultaneousLights: number;
  47314. /**
  47315. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47316. */
  47317. protected _invertNormalMapX: boolean;
  47318. /**
  47319. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47320. */
  47321. protected _invertNormalMapY: boolean;
  47322. /**
  47323. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47324. */
  47325. protected _twoSidedLighting: boolean;
  47326. /**
  47327. * Defines the alpha limits in alpha test mode.
  47328. */
  47329. protected _alphaCutOff: number;
  47330. /**
  47331. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47332. */
  47333. protected _forceAlphaTest: boolean;
  47334. /**
  47335. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47336. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47337. */
  47338. protected _useAlphaFresnel: boolean;
  47339. /**
  47340. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47341. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47342. */
  47343. protected _useLinearAlphaFresnel: boolean;
  47344. /**
  47345. * The transparency mode of the material.
  47346. */
  47347. protected _transparencyMode: Nullable<number>;
  47348. /**
  47349. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47350. * from cos thetav and roughness:
  47351. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47352. */
  47353. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47354. /**
  47355. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47356. */
  47357. protected _forceIrradianceInFragment: boolean;
  47358. /**
  47359. * Force normal to face away from face.
  47360. */
  47361. protected _forceNormalForward: boolean;
  47362. /**
  47363. * Enables specular anti aliasing in the PBR shader.
  47364. * It will both interacts on the Geometry for analytical and IBL lighting.
  47365. * It also prefilter the roughness map based on the bump values.
  47366. */
  47367. protected _enableSpecularAntiAliasing: boolean;
  47368. /**
  47369. * Default configuration related to image processing available in the PBR Material.
  47370. */
  47371. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47372. /**
  47373. * Keep track of the image processing observer to allow dispose and replace.
  47374. */
  47375. private _imageProcessingObserver;
  47376. /**
  47377. * Attaches a new image processing configuration to the PBR Material.
  47378. * @param configuration
  47379. */
  47380. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47381. /**
  47382. * Stores the available render targets.
  47383. */
  47384. private _renderTargets;
  47385. /**
  47386. * Sets the global ambient color for the material used in lighting calculations.
  47387. */
  47388. private _globalAmbientColor;
  47389. /**
  47390. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47391. */
  47392. private _useLogarithmicDepth;
  47393. /**
  47394. * If set to true, no lighting calculations will be applied.
  47395. */
  47396. private _unlit;
  47397. private _debugMode;
  47398. /**
  47399. * @hidden
  47400. * This is reserved for the inspector.
  47401. * Defines the material debug mode.
  47402. * It helps seeing only some components of the material while troubleshooting.
  47403. */
  47404. debugMode: number;
  47405. /**
  47406. * @hidden
  47407. * This is reserved for the inspector.
  47408. * Specify from where on screen the debug mode should start.
  47409. * The value goes from -1 (full screen) to 1 (not visible)
  47410. * It helps with side by side comparison against the final render
  47411. * This defaults to -1
  47412. */
  47413. private debugLimit;
  47414. /**
  47415. * @hidden
  47416. * This is reserved for the inspector.
  47417. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47418. * You can use the factor to better multiply the final value.
  47419. */
  47420. private debugFactor;
  47421. /**
  47422. * Defines the clear coat layer parameters for the material.
  47423. */
  47424. readonly clearCoat: PBRClearCoatConfiguration;
  47425. /**
  47426. * Defines the anisotropic parameters for the material.
  47427. */
  47428. readonly anisotropy: PBRAnisotropicConfiguration;
  47429. /**
  47430. * Defines the BRDF parameters for the material.
  47431. */
  47432. readonly brdf: PBRBRDFConfiguration;
  47433. /**
  47434. * Defines the Sheen parameters for the material.
  47435. */
  47436. readonly sheen: PBRSheenConfiguration;
  47437. /**
  47438. * Defines the SubSurface parameters for the material.
  47439. */
  47440. readonly subSurface: PBRSubSurfaceConfiguration;
  47441. /**
  47442. * Custom callback helping to override the default shader used in the material.
  47443. */
  47444. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47445. protected _rebuildInParallel: boolean;
  47446. /**
  47447. * Instantiates a new PBRMaterial instance.
  47448. *
  47449. * @param name The material name
  47450. * @param scene The scene the material will be use in.
  47451. */
  47452. constructor(name: string, scene: Scene);
  47453. /**
  47454. * Gets a boolean indicating that current material needs to register RTT
  47455. */
  47456. readonly hasRenderTargetTextures: boolean;
  47457. /**
  47458. * Gets the name of the material class.
  47459. */
  47460. getClassName(): string;
  47461. /**
  47462. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47463. */
  47464. /**
  47465. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47466. */
  47467. useLogarithmicDepth: boolean;
  47468. /**
  47469. * Gets the current transparency mode.
  47470. */
  47471. /**
  47472. * Sets the transparency mode of the material.
  47473. *
  47474. * | Value | Type | Description |
  47475. * | ----- | ----------------------------------- | ----------- |
  47476. * | 0 | OPAQUE | |
  47477. * | 1 | ALPHATEST | |
  47478. * | 2 | ALPHABLEND | |
  47479. * | 3 | ALPHATESTANDBLEND | |
  47480. *
  47481. */
  47482. transparencyMode: Nullable<number>;
  47483. /**
  47484. * Returns true if alpha blending should be disabled.
  47485. */
  47486. private readonly _disableAlphaBlending;
  47487. /**
  47488. * Specifies whether or not this material should be rendered in alpha blend mode.
  47489. */
  47490. needAlphaBlending(): boolean;
  47491. /**
  47492. * Specifies if the mesh will require alpha blending.
  47493. * @param mesh - BJS mesh.
  47494. */
  47495. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47496. /**
  47497. * Specifies whether or not this material should be rendered in alpha test mode.
  47498. */
  47499. needAlphaTesting(): boolean;
  47500. /**
  47501. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47502. */
  47503. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47504. /**
  47505. * Gets the texture used for the alpha test.
  47506. */
  47507. getAlphaTestTexture(): Nullable<BaseTexture>;
  47508. /**
  47509. * Specifies that the submesh is ready to be used.
  47510. * @param mesh - BJS mesh.
  47511. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47512. * @param useInstances - Specifies that instances should be used.
  47513. * @returns - boolean indicating that the submesh is ready or not.
  47514. */
  47515. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47516. /**
  47517. * Specifies if the material uses metallic roughness workflow.
  47518. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47519. */
  47520. isMetallicWorkflow(): boolean;
  47521. private _prepareEffect;
  47522. private _prepareDefines;
  47523. /**
  47524. * Force shader compilation
  47525. */
  47526. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47527. clipPlane: boolean;
  47528. }>): void;
  47529. /**
  47530. * Initializes the uniform buffer layout for the shader.
  47531. */
  47532. buildUniformLayout(): void;
  47533. /**
  47534. * Unbinds the material from the mesh
  47535. */
  47536. unbind(): void;
  47537. /**
  47538. * Binds the submesh data.
  47539. * @param world - The world matrix.
  47540. * @param mesh - The BJS mesh.
  47541. * @param subMesh - A submesh of the BJS mesh.
  47542. */
  47543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47544. /**
  47545. * Returns the animatable textures.
  47546. * @returns - Array of animatable textures.
  47547. */
  47548. getAnimatables(): IAnimatable[];
  47549. /**
  47550. * Returns the texture used for reflections.
  47551. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47552. */
  47553. private _getReflectionTexture;
  47554. /**
  47555. * Returns an array of the actively used textures.
  47556. * @returns - Array of BaseTextures
  47557. */
  47558. getActiveTextures(): BaseTexture[];
  47559. /**
  47560. * Checks to see if a texture is used in the material.
  47561. * @param texture - Base texture to use.
  47562. * @returns - Boolean specifying if a texture is used in the material.
  47563. */
  47564. hasTexture(texture: BaseTexture): boolean;
  47565. /**
  47566. * Disposes the resources of the material.
  47567. * @param forceDisposeEffect - Forces the disposal of effects.
  47568. * @param forceDisposeTextures - Forces the disposal of all textures.
  47569. */
  47570. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47571. }
  47572. }
  47573. declare module BABYLON {
  47574. /**
  47575. * The Physically based material of BJS.
  47576. *
  47577. * This offers the main features of a standard PBR material.
  47578. * For more information, please refer to the documentation :
  47579. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47580. */
  47581. export class PBRMaterial extends PBRBaseMaterial {
  47582. /**
  47583. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47584. */
  47585. static readonly PBRMATERIAL_OPAQUE: number;
  47586. /**
  47587. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47588. */
  47589. static readonly PBRMATERIAL_ALPHATEST: number;
  47590. /**
  47591. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47592. */
  47593. static readonly PBRMATERIAL_ALPHABLEND: number;
  47594. /**
  47595. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47596. * They are also discarded below the alpha cutoff threshold to improve performances.
  47597. */
  47598. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47599. /**
  47600. * Defines the default value of how much AO map is occluding the analytical lights
  47601. * (point spot...).
  47602. */
  47603. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47604. /**
  47605. * Intensity of the direct lights e.g. the four lights available in your scene.
  47606. * This impacts both the direct diffuse and specular highlights.
  47607. */
  47608. directIntensity: number;
  47609. /**
  47610. * Intensity of the emissive part of the material.
  47611. * This helps controlling the emissive effect without modifying the emissive color.
  47612. */
  47613. emissiveIntensity: number;
  47614. /**
  47615. * Intensity of the environment e.g. how much the environment will light the object
  47616. * either through harmonics for rough material or through the refelction for shiny ones.
  47617. */
  47618. environmentIntensity: number;
  47619. /**
  47620. * This is a special control allowing the reduction of the specular highlights coming from the
  47621. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47622. */
  47623. specularIntensity: number;
  47624. /**
  47625. * Debug Control allowing disabling the bump map on this material.
  47626. */
  47627. disableBumpMap: boolean;
  47628. /**
  47629. * AKA Diffuse Texture in standard nomenclature.
  47630. */
  47631. albedoTexture: BaseTexture;
  47632. /**
  47633. * AKA Occlusion Texture in other nomenclature.
  47634. */
  47635. ambientTexture: BaseTexture;
  47636. /**
  47637. * AKA Occlusion Texture Intensity in other nomenclature.
  47638. */
  47639. ambientTextureStrength: number;
  47640. /**
  47641. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47642. * 1 means it completely occludes it
  47643. * 0 mean it has no impact
  47644. */
  47645. ambientTextureImpactOnAnalyticalLights: number;
  47646. /**
  47647. * Stores the alpha values in a texture.
  47648. */
  47649. opacityTexture: BaseTexture;
  47650. /**
  47651. * Stores the reflection values in a texture.
  47652. */
  47653. reflectionTexture: Nullable<BaseTexture>;
  47654. /**
  47655. * Stores the emissive values in a texture.
  47656. */
  47657. emissiveTexture: BaseTexture;
  47658. /**
  47659. * AKA Specular texture in other nomenclature.
  47660. */
  47661. reflectivityTexture: BaseTexture;
  47662. /**
  47663. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47664. */
  47665. metallicTexture: BaseTexture;
  47666. /**
  47667. * Specifies the metallic scalar of the metallic/roughness workflow.
  47668. * Can also be used to scale the metalness values of the metallic texture.
  47669. */
  47670. metallic: Nullable<number>;
  47671. /**
  47672. * Specifies the roughness scalar of the metallic/roughness workflow.
  47673. * Can also be used to scale the roughness values of the metallic texture.
  47674. */
  47675. roughness: Nullable<number>;
  47676. /**
  47677. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47678. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47679. */
  47680. microSurfaceTexture: BaseTexture;
  47681. /**
  47682. * Stores surface normal data used to displace a mesh in a texture.
  47683. */
  47684. bumpTexture: BaseTexture;
  47685. /**
  47686. * Stores the pre-calculated light information of a mesh in a texture.
  47687. */
  47688. lightmapTexture: BaseTexture;
  47689. /**
  47690. * Stores the refracted light information in a texture.
  47691. */
  47692. refractionTexture: Nullable<BaseTexture>;
  47693. /**
  47694. * The color of a material in ambient lighting.
  47695. */
  47696. ambientColor: Color3;
  47697. /**
  47698. * AKA Diffuse Color in other nomenclature.
  47699. */
  47700. albedoColor: Color3;
  47701. /**
  47702. * AKA Specular Color in other nomenclature.
  47703. */
  47704. reflectivityColor: Color3;
  47705. /**
  47706. * The color reflected from the material.
  47707. */
  47708. reflectionColor: Color3;
  47709. /**
  47710. * The color emitted from the material.
  47711. */
  47712. emissiveColor: Color3;
  47713. /**
  47714. * AKA Glossiness in other nomenclature.
  47715. */
  47716. microSurface: number;
  47717. /**
  47718. * source material index of refraction (IOR)' / 'destination material IOR.
  47719. */
  47720. indexOfRefraction: number;
  47721. /**
  47722. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47723. */
  47724. invertRefractionY: boolean;
  47725. /**
  47726. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47727. * Materials half opaque for instance using refraction could benefit from this control.
  47728. */
  47729. linkRefractionWithTransparency: boolean;
  47730. /**
  47731. * If true, the light map contains occlusion information instead of lighting info.
  47732. */
  47733. useLightmapAsShadowmap: boolean;
  47734. /**
  47735. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47736. */
  47737. useAlphaFromAlbedoTexture: boolean;
  47738. /**
  47739. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47740. */
  47741. forceAlphaTest: boolean;
  47742. /**
  47743. * Defines the alpha limits in alpha test mode.
  47744. */
  47745. alphaCutOff: number;
  47746. /**
  47747. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47748. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47749. */
  47750. useSpecularOverAlpha: boolean;
  47751. /**
  47752. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47753. */
  47754. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47755. /**
  47756. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47757. */
  47758. useRoughnessFromMetallicTextureAlpha: boolean;
  47759. /**
  47760. * Specifies if the metallic texture contains the roughness information in its green channel.
  47761. */
  47762. useRoughnessFromMetallicTextureGreen: boolean;
  47763. /**
  47764. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47765. */
  47766. useMetallnessFromMetallicTextureBlue: boolean;
  47767. /**
  47768. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47769. */
  47770. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47771. /**
  47772. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47773. */
  47774. useAmbientInGrayScale: boolean;
  47775. /**
  47776. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47777. * The material will try to infer what glossiness each pixel should be.
  47778. */
  47779. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47780. /**
  47781. * BJS is using an harcoded light falloff based on a manually sets up range.
  47782. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47783. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47784. */
  47785. /**
  47786. * BJS is using an harcoded light falloff based on a manually sets up range.
  47787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47789. */
  47790. usePhysicalLightFalloff: boolean;
  47791. /**
  47792. * In order to support the falloff compatibility with gltf, a special mode has been added
  47793. * to reproduce the gltf light falloff.
  47794. */
  47795. /**
  47796. * In order to support the falloff compatibility with gltf, a special mode has been added
  47797. * to reproduce the gltf light falloff.
  47798. */
  47799. useGLTFLightFalloff: boolean;
  47800. /**
  47801. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47802. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47803. */
  47804. useRadianceOverAlpha: boolean;
  47805. /**
  47806. * Allows using an object space normal map (instead of tangent space).
  47807. */
  47808. useObjectSpaceNormalMap: boolean;
  47809. /**
  47810. * Allows using the bump map in parallax mode.
  47811. */
  47812. useParallax: boolean;
  47813. /**
  47814. * Allows using the bump map in parallax occlusion mode.
  47815. */
  47816. useParallaxOcclusion: boolean;
  47817. /**
  47818. * Controls the scale bias of the parallax mode.
  47819. */
  47820. parallaxScaleBias: number;
  47821. /**
  47822. * If sets to true, disables all the lights affecting the material.
  47823. */
  47824. disableLighting: boolean;
  47825. /**
  47826. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47827. */
  47828. forceIrradianceInFragment: boolean;
  47829. /**
  47830. * Number of Simultaneous lights allowed on the material.
  47831. */
  47832. maxSimultaneousLights: number;
  47833. /**
  47834. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47835. */
  47836. invertNormalMapX: boolean;
  47837. /**
  47838. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47839. */
  47840. invertNormalMapY: boolean;
  47841. /**
  47842. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47843. */
  47844. twoSidedLighting: boolean;
  47845. /**
  47846. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47847. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47848. */
  47849. useAlphaFresnel: boolean;
  47850. /**
  47851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47852. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47853. */
  47854. useLinearAlphaFresnel: boolean;
  47855. /**
  47856. * Let user defines the brdf lookup texture used for IBL.
  47857. * A default 8bit version is embedded but you could point at :
  47858. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47859. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47860. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47861. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47862. */
  47863. environmentBRDFTexture: Nullable<BaseTexture>;
  47864. /**
  47865. * Force normal to face away from face.
  47866. */
  47867. forceNormalForward: boolean;
  47868. /**
  47869. * Enables specular anti aliasing in the PBR shader.
  47870. * It will both interacts on the Geometry for analytical and IBL lighting.
  47871. * It also prefilter the roughness map based on the bump values.
  47872. */
  47873. enableSpecularAntiAliasing: boolean;
  47874. /**
  47875. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47876. * makes the reflect vector face the model (under horizon).
  47877. */
  47878. useHorizonOcclusion: boolean;
  47879. /**
  47880. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47881. * too much the area relying on ambient texture to define their ambient occlusion.
  47882. */
  47883. useRadianceOcclusion: boolean;
  47884. /**
  47885. * If set to true, no lighting calculations will be applied.
  47886. */
  47887. unlit: boolean;
  47888. /**
  47889. * Gets the image processing configuration used either in this material.
  47890. */
  47891. /**
  47892. * Sets the Default image processing configuration used either in the this material.
  47893. *
  47894. * If sets to null, the scene one is in use.
  47895. */
  47896. imageProcessingConfiguration: ImageProcessingConfiguration;
  47897. /**
  47898. * Gets wether the color curves effect is enabled.
  47899. */
  47900. /**
  47901. * Sets wether the color curves effect is enabled.
  47902. */
  47903. cameraColorCurvesEnabled: boolean;
  47904. /**
  47905. * Gets wether the color grading effect is enabled.
  47906. */
  47907. /**
  47908. * Gets wether the color grading effect is enabled.
  47909. */
  47910. cameraColorGradingEnabled: boolean;
  47911. /**
  47912. * Gets wether tonemapping is enabled or not.
  47913. */
  47914. /**
  47915. * Sets wether tonemapping is enabled or not
  47916. */
  47917. cameraToneMappingEnabled: boolean;
  47918. /**
  47919. * The camera exposure used on this material.
  47920. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47921. * This corresponds to a photographic exposure.
  47922. */
  47923. /**
  47924. * The camera exposure used on this material.
  47925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47926. * This corresponds to a photographic exposure.
  47927. */
  47928. cameraExposure: number;
  47929. /**
  47930. * Gets The camera contrast used on this material.
  47931. */
  47932. /**
  47933. * Sets The camera contrast used on this material.
  47934. */
  47935. cameraContrast: number;
  47936. /**
  47937. * Gets the Color Grading 2D Lookup Texture.
  47938. */
  47939. /**
  47940. * Sets the Color Grading 2D Lookup Texture.
  47941. */
  47942. cameraColorGradingTexture: Nullable<BaseTexture>;
  47943. /**
  47944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47946. * 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;
  47947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47948. */
  47949. /**
  47950. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47951. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47952. * 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;
  47953. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47954. */
  47955. cameraColorCurves: Nullable<ColorCurves>;
  47956. /**
  47957. * Instantiates a new PBRMaterial instance.
  47958. *
  47959. * @param name The material name
  47960. * @param scene The scene the material will be use in.
  47961. */
  47962. constructor(name: string, scene: Scene);
  47963. /**
  47964. * Returns the name of this material class.
  47965. */
  47966. getClassName(): string;
  47967. /**
  47968. * Makes a duplicate of the current material.
  47969. * @param name - name to use for the new material.
  47970. */
  47971. clone(name: string): PBRMaterial;
  47972. /**
  47973. * Serializes this PBR Material.
  47974. * @returns - An object with the serialized material.
  47975. */
  47976. serialize(): any;
  47977. /**
  47978. * Parses a PBR Material from a serialized object.
  47979. * @param source - Serialized object.
  47980. * @param scene - BJS scene instance.
  47981. * @param rootUrl - url for the scene object
  47982. * @returns - PBRMaterial
  47983. */
  47984. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47985. }
  47986. }
  47987. declare module BABYLON {
  47988. /**
  47989. * Direct draw surface info
  47990. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47991. */
  47992. export interface DDSInfo {
  47993. /**
  47994. * Width of the texture
  47995. */
  47996. width: number;
  47997. /**
  47998. * Width of the texture
  47999. */
  48000. height: number;
  48001. /**
  48002. * Number of Mipmaps for the texture
  48003. * @see https://en.wikipedia.org/wiki/Mipmap
  48004. */
  48005. mipmapCount: number;
  48006. /**
  48007. * If the textures format is a known fourCC format
  48008. * @see https://www.fourcc.org/
  48009. */
  48010. isFourCC: boolean;
  48011. /**
  48012. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48013. */
  48014. isRGB: boolean;
  48015. /**
  48016. * If the texture is a lumincance format
  48017. */
  48018. isLuminance: boolean;
  48019. /**
  48020. * If this is a cube texture
  48021. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48022. */
  48023. isCube: boolean;
  48024. /**
  48025. * If the texture is a compressed format eg. FOURCC_DXT1
  48026. */
  48027. isCompressed: boolean;
  48028. /**
  48029. * The dxgiFormat of the texture
  48030. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48031. */
  48032. dxgiFormat: number;
  48033. /**
  48034. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48035. */
  48036. textureType: number;
  48037. /**
  48038. * Sphericle polynomial created for the dds texture
  48039. */
  48040. sphericalPolynomial?: SphericalPolynomial;
  48041. }
  48042. /**
  48043. * Class used to provide DDS decompression tools
  48044. */
  48045. export class DDSTools {
  48046. /**
  48047. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48048. */
  48049. static StoreLODInAlphaChannel: boolean;
  48050. /**
  48051. * Gets DDS information from an array buffer
  48052. * @param arrayBuffer defines the array buffer to read data from
  48053. * @returns the DDS information
  48054. */
  48055. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48056. private static _FloatView;
  48057. private static _Int32View;
  48058. private static _ToHalfFloat;
  48059. private static _FromHalfFloat;
  48060. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48061. private static _GetHalfFloatRGBAArrayBuffer;
  48062. private static _GetFloatRGBAArrayBuffer;
  48063. private static _GetFloatAsUIntRGBAArrayBuffer;
  48064. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48065. private static _GetRGBAArrayBuffer;
  48066. private static _ExtractLongWordOrder;
  48067. private static _GetRGBArrayBuffer;
  48068. private static _GetLuminanceArrayBuffer;
  48069. /**
  48070. * Uploads DDS Levels to a Babylon Texture
  48071. * @hidden
  48072. */
  48073. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48074. }
  48075. interface Engine {
  48076. /**
  48077. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48078. * @param rootUrl defines the url where the file to load is located
  48079. * @param scene defines the current scene
  48080. * @param lodScale defines scale to apply to the mip map selection
  48081. * @param lodOffset defines offset to apply to the mip map selection
  48082. * @param onLoad defines an optional callback raised when the texture is loaded
  48083. * @param onError defines an optional callback raised if there is an issue to load the texture
  48084. * @param format defines the format of the data
  48085. * @param forcedExtension defines the extension to use to pick the right loader
  48086. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48087. * @returns the cube texture as an InternalTexture
  48088. */
  48089. 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;
  48090. }
  48091. }
  48092. declare module BABYLON {
  48093. /**
  48094. * Implementation of the DDS Texture Loader.
  48095. * @hidden
  48096. */
  48097. export class _DDSTextureLoader implements IInternalTextureLoader {
  48098. /**
  48099. * Defines wether the loader supports cascade loading the different faces.
  48100. */
  48101. readonly supportCascades: boolean;
  48102. /**
  48103. * This returns if the loader support the current file information.
  48104. * @param extension defines the file extension of the file being loaded
  48105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48106. * @param fallback defines the fallback internal texture if any
  48107. * @param isBase64 defines whether the texture is encoded as a base64
  48108. * @param isBuffer defines whether the texture data are stored as a buffer
  48109. * @returns true if the loader can load the specified file
  48110. */
  48111. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48112. /**
  48113. * Transform the url before loading if required.
  48114. * @param rootUrl the url of the texture
  48115. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48116. * @returns the transformed texture
  48117. */
  48118. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48119. /**
  48120. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48121. * @param rootUrl the url of the texture
  48122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48123. * @returns the fallback texture
  48124. */
  48125. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48126. /**
  48127. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48128. * @param data contains the texture data
  48129. * @param texture defines the BabylonJS internal texture
  48130. * @param createPolynomials will be true if polynomials have been requested
  48131. * @param onLoad defines the callback to trigger once the texture is ready
  48132. * @param onError defines the callback to trigger in case of error
  48133. */
  48134. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48135. /**
  48136. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48137. * @param data contains the texture data
  48138. * @param texture defines the BabylonJS internal texture
  48139. * @param callback defines the method to call once ready to upload
  48140. */
  48141. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48142. }
  48143. }
  48144. declare module BABYLON {
  48145. /**
  48146. * Implementation of the ENV Texture Loader.
  48147. * @hidden
  48148. */
  48149. export class _ENVTextureLoader implements IInternalTextureLoader {
  48150. /**
  48151. * Defines wether the loader supports cascade loading the different faces.
  48152. */
  48153. readonly supportCascades: boolean;
  48154. /**
  48155. * This returns if the loader support the current file information.
  48156. * @param extension defines the file extension of the file being loaded
  48157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48158. * @param fallback defines the fallback internal texture if any
  48159. * @param isBase64 defines whether the texture is encoded as a base64
  48160. * @param isBuffer defines whether the texture data are stored as a buffer
  48161. * @returns true if the loader can load the specified file
  48162. */
  48163. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48164. /**
  48165. * Transform the url before loading if required.
  48166. * @param rootUrl the url of the texture
  48167. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48168. * @returns the transformed texture
  48169. */
  48170. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48171. /**
  48172. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48173. * @param rootUrl the url of the texture
  48174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48175. * @returns the fallback texture
  48176. */
  48177. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48178. /**
  48179. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48180. * @param data contains the texture data
  48181. * @param texture defines the BabylonJS internal texture
  48182. * @param createPolynomials will be true if polynomials have been requested
  48183. * @param onLoad defines the callback to trigger once the texture is ready
  48184. * @param onError defines the callback to trigger in case of error
  48185. */
  48186. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48187. /**
  48188. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48189. * @param data contains the texture data
  48190. * @param texture defines the BabylonJS internal texture
  48191. * @param callback defines the method to call once ready to upload
  48192. */
  48193. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48194. }
  48195. }
  48196. declare module BABYLON {
  48197. /**
  48198. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48199. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48200. */
  48201. export class KhronosTextureContainer {
  48202. /** contents of the KTX container file */
  48203. arrayBuffer: any;
  48204. private static HEADER_LEN;
  48205. private static COMPRESSED_2D;
  48206. private static COMPRESSED_3D;
  48207. private static TEX_2D;
  48208. private static TEX_3D;
  48209. /**
  48210. * Gets the openGL type
  48211. */
  48212. glType: number;
  48213. /**
  48214. * Gets the openGL type size
  48215. */
  48216. glTypeSize: number;
  48217. /**
  48218. * Gets the openGL format
  48219. */
  48220. glFormat: number;
  48221. /**
  48222. * Gets the openGL internal format
  48223. */
  48224. glInternalFormat: number;
  48225. /**
  48226. * Gets the base internal format
  48227. */
  48228. glBaseInternalFormat: number;
  48229. /**
  48230. * Gets image width in pixel
  48231. */
  48232. pixelWidth: number;
  48233. /**
  48234. * Gets image height in pixel
  48235. */
  48236. pixelHeight: number;
  48237. /**
  48238. * Gets image depth in pixels
  48239. */
  48240. pixelDepth: number;
  48241. /**
  48242. * Gets the number of array elements
  48243. */
  48244. numberOfArrayElements: number;
  48245. /**
  48246. * Gets the number of faces
  48247. */
  48248. numberOfFaces: number;
  48249. /**
  48250. * Gets the number of mipmap levels
  48251. */
  48252. numberOfMipmapLevels: number;
  48253. /**
  48254. * Gets the bytes of key value data
  48255. */
  48256. bytesOfKeyValueData: number;
  48257. /**
  48258. * Gets the load type
  48259. */
  48260. loadType: number;
  48261. /**
  48262. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48263. */
  48264. isInvalid: boolean;
  48265. /**
  48266. * Creates a new KhronosTextureContainer
  48267. * @param arrayBuffer contents of the KTX container file
  48268. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48269. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48270. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48271. */
  48272. constructor(
  48273. /** contents of the KTX container file */
  48274. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48275. /**
  48276. * Uploads KTX content to a Babylon Texture.
  48277. * It is assumed that the texture has already been created & is currently bound
  48278. * @hidden
  48279. */
  48280. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48281. private _upload2DCompressedLevels;
  48282. }
  48283. }
  48284. declare module BABYLON {
  48285. /**
  48286. * Implementation of the KTX Texture Loader.
  48287. * @hidden
  48288. */
  48289. export class _KTXTextureLoader implements IInternalTextureLoader {
  48290. /**
  48291. * Defines wether the loader supports cascade loading the different faces.
  48292. */
  48293. readonly supportCascades: boolean;
  48294. /**
  48295. * This returns if the loader support the current file information.
  48296. * @param extension defines the file extension of the file being loaded
  48297. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48298. * @param fallback defines the fallback internal texture if any
  48299. * @param isBase64 defines whether the texture is encoded as a base64
  48300. * @param isBuffer defines whether the texture data are stored as a buffer
  48301. * @returns true if the loader can load the specified file
  48302. */
  48303. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48304. /**
  48305. * Transform the url before loading if required.
  48306. * @param rootUrl the url of the texture
  48307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48308. * @returns the transformed texture
  48309. */
  48310. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48311. /**
  48312. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48313. * @param rootUrl the url of the texture
  48314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48315. * @returns the fallback texture
  48316. */
  48317. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48318. /**
  48319. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48320. * @param data contains the texture data
  48321. * @param texture defines the BabylonJS internal texture
  48322. * @param createPolynomials will be true if polynomials have been requested
  48323. * @param onLoad defines the callback to trigger once the texture is ready
  48324. * @param onError defines the callback to trigger in case of error
  48325. */
  48326. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48327. /**
  48328. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48329. * @param data contains the texture data
  48330. * @param texture defines the BabylonJS internal texture
  48331. * @param callback defines the method to call once ready to upload
  48332. */
  48333. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48334. }
  48335. }
  48336. declare module BABYLON {
  48337. /**
  48338. * Options for the default xr helper
  48339. */
  48340. export class WebXRDefaultExperienceOptions {
  48341. /**
  48342. * Floor meshes that should be used for teleporting
  48343. */
  48344. floorMeshes: Array<AbstractMesh>;
  48345. }
  48346. /**
  48347. * Default experience which provides a similar setup to the previous webVRExperience
  48348. */
  48349. export class WebXRDefaultExperience {
  48350. /**
  48351. * Base experience
  48352. */
  48353. baseExperience: WebXRExperienceHelper;
  48354. /**
  48355. * Input experience extension
  48356. */
  48357. input: WebXRInput;
  48358. /**
  48359. * Loads the controller models
  48360. */
  48361. controllerModelLoader: WebXRControllerModelLoader;
  48362. /**
  48363. * Enables laser pointer and selection
  48364. */
  48365. pointerSelection: WebXRControllerPointerSelection;
  48366. /**
  48367. * Enables teleportation
  48368. */
  48369. teleportation: WebXRControllerTeleportation;
  48370. /**
  48371. * Enables ui for enetering/exiting xr
  48372. */
  48373. enterExitUI: WebXREnterExitUI;
  48374. /**
  48375. * Default output canvas xr should render to
  48376. */
  48377. outputCanvas: WebXRManagedOutputCanvas;
  48378. /**
  48379. * Creates the default xr experience
  48380. * @param scene scene
  48381. * @param options options for basic configuration
  48382. * @returns resulting WebXRDefaultExperience
  48383. */
  48384. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48385. private constructor();
  48386. /**
  48387. * DIsposes of the experience helper
  48388. */
  48389. dispose(): void;
  48390. }
  48391. }
  48392. declare module BABYLON {
  48393. /** @hidden */
  48394. export var _forceSceneHelpersToBundle: boolean;
  48395. interface Scene {
  48396. /**
  48397. * Creates a default light for the scene.
  48398. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48399. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48400. */
  48401. createDefaultLight(replace?: boolean): void;
  48402. /**
  48403. * Creates a default camera for the scene.
  48404. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48405. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48406. * @param replace has default false, when true replaces the active camera in the scene
  48407. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48408. */
  48409. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48410. /**
  48411. * Creates a default camera and a default light.
  48412. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48413. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48414. * @param replace has the default false, when true replaces the active camera/light in the scene
  48415. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48416. */
  48417. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48418. /**
  48419. * Creates a new sky box
  48420. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48421. * @param environmentTexture defines the texture to use as environment texture
  48422. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48423. * @param scale defines the overall scale of the skybox
  48424. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48425. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48426. * @returns a new mesh holding the sky box
  48427. */
  48428. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48429. /**
  48430. * Creates a new environment
  48431. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48432. * @param options defines the options you can use to configure the environment
  48433. * @returns the new EnvironmentHelper
  48434. */
  48435. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48436. /**
  48437. * Creates a new VREXperienceHelper
  48438. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48439. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48440. * @returns a new VREXperienceHelper
  48441. */
  48442. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48443. /**
  48444. * Creates a new WebXRDefaultExperience
  48445. * @see http://doc.babylonjs.com/how_to/webxr
  48446. * @param options experience options
  48447. * @returns a promise for a new WebXRDefaultExperience
  48448. */
  48449. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48450. }
  48451. }
  48452. declare module BABYLON {
  48453. /**
  48454. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48455. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48456. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48457. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48458. */
  48459. export class VideoDome extends TransformNode {
  48460. /**
  48461. * Define the video source as a Monoscopic panoramic 360 video.
  48462. */
  48463. static readonly MODE_MONOSCOPIC: number;
  48464. /**
  48465. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48466. */
  48467. static readonly MODE_TOPBOTTOM: number;
  48468. /**
  48469. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48470. */
  48471. static readonly MODE_SIDEBYSIDE: number;
  48472. private _halfDome;
  48473. private _useDirectMapping;
  48474. /**
  48475. * The video texture being displayed on the sphere
  48476. */
  48477. protected _videoTexture: VideoTexture;
  48478. /**
  48479. * Gets the video texture being displayed on the sphere
  48480. */
  48481. readonly videoTexture: VideoTexture;
  48482. /**
  48483. * The skybox material
  48484. */
  48485. protected _material: BackgroundMaterial;
  48486. /**
  48487. * The surface used for the skybox
  48488. */
  48489. protected _mesh: Mesh;
  48490. /**
  48491. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48492. */
  48493. private _halfDomeMask;
  48494. /**
  48495. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48496. * Also see the options.resolution property.
  48497. */
  48498. fovMultiplier: number;
  48499. private _videoMode;
  48500. /**
  48501. * Gets or set the current video mode for the video. It can be:
  48502. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48503. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48504. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48505. */
  48506. videoMode: number;
  48507. /**
  48508. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48509. *
  48510. */
  48511. /**
  48512. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48513. */
  48514. halfDome: boolean;
  48515. /**
  48516. * Oberserver used in Stereoscopic VR Mode.
  48517. */
  48518. private _onBeforeCameraRenderObserver;
  48519. /**
  48520. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48521. * @param name Element's name, child elements will append suffixes for their own names.
  48522. * @param urlsOrVideo defines the url(s) or the video element to use
  48523. * @param options An object containing optional or exposed sub element properties
  48524. */
  48525. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48526. resolution?: number;
  48527. clickToPlay?: boolean;
  48528. autoPlay?: boolean;
  48529. loop?: boolean;
  48530. size?: number;
  48531. poster?: string;
  48532. faceForward?: boolean;
  48533. useDirectMapping?: boolean;
  48534. halfDomeMode?: boolean;
  48535. }, scene: Scene);
  48536. private _changeVideoMode;
  48537. /**
  48538. * Releases resources associated with this node.
  48539. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48540. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48541. */
  48542. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48543. }
  48544. }
  48545. declare module BABYLON {
  48546. /**
  48547. * This class can be used to get instrumentation data from a Babylon engine
  48548. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48549. */
  48550. export class EngineInstrumentation implements IDisposable {
  48551. /**
  48552. * Define the instrumented engine.
  48553. */
  48554. engine: Engine;
  48555. private _captureGPUFrameTime;
  48556. private _gpuFrameTimeToken;
  48557. private _gpuFrameTime;
  48558. private _captureShaderCompilationTime;
  48559. private _shaderCompilationTime;
  48560. private _onBeginFrameObserver;
  48561. private _onEndFrameObserver;
  48562. private _onBeforeShaderCompilationObserver;
  48563. private _onAfterShaderCompilationObserver;
  48564. /**
  48565. * Gets the perf counter used for GPU frame time
  48566. */
  48567. readonly gpuFrameTimeCounter: PerfCounter;
  48568. /**
  48569. * Gets the GPU frame time capture status
  48570. */
  48571. /**
  48572. * Enable or disable the GPU frame time capture
  48573. */
  48574. captureGPUFrameTime: boolean;
  48575. /**
  48576. * Gets the perf counter used for shader compilation time
  48577. */
  48578. readonly shaderCompilationTimeCounter: PerfCounter;
  48579. /**
  48580. * Gets the shader compilation time capture status
  48581. */
  48582. /**
  48583. * Enable or disable the shader compilation time capture
  48584. */
  48585. captureShaderCompilationTime: boolean;
  48586. /**
  48587. * Instantiates a new engine instrumentation.
  48588. * This class can be used to get instrumentation data from a Babylon engine
  48589. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48590. * @param engine Defines the engine to instrument
  48591. */
  48592. constructor(
  48593. /**
  48594. * Define the instrumented engine.
  48595. */
  48596. engine: Engine);
  48597. /**
  48598. * Dispose and release associated resources.
  48599. */
  48600. dispose(): void;
  48601. }
  48602. }
  48603. declare module BABYLON {
  48604. /**
  48605. * This class can be used to get instrumentation data from a Babylon engine
  48606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48607. */
  48608. export class SceneInstrumentation implements IDisposable {
  48609. /**
  48610. * Defines the scene to instrument
  48611. */
  48612. scene: Scene;
  48613. private _captureActiveMeshesEvaluationTime;
  48614. private _activeMeshesEvaluationTime;
  48615. private _captureRenderTargetsRenderTime;
  48616. private _renderTargetsRenderTime;
  48617. private _captureFrameTime;
  48618. private _frameTime;
  48619. private _captureRenderTime;
  48620. private _renderTime;
  48621. private _captureInterFrameTime;
  48622. private _interFrameTime;
  48623. private _captureParticlesRenderTime;
  48624. private _particlesRenderTime;
  48625. private _captureSpritesRenderTime;
  48626. private _spritesRenderTime;
  48627. private _capturePhysicsTime;
  48628. private _physicsTime;
  48629. private _captureAnimationsTime;
  48630. private _animationsTime;
  48631. private _captureCameraRenderTime;
  48632. private _cameraRenderTime;
  48633. private _onBeforeActiveMeshesEvaluationObserver;
  48634. private _onAfterActiveMeshesEvaluationObserver;
  48635. private _onBeforeRenderTargetsRenderObserver;
  48636. private _onAfterRenderTargetsRenderObserver;
  48637. private _onAfterRenderObserver;
  48638. private _onBeforeDrawPhaseObserver;
  48639. private _onAfterDrawPhaseObserver;
  48640. private _onBeforeAnimationsObserver;
  48641. private _onBeforeParticlesRenderingObserver;
  48642. private _onAfterParticlesRenderingObserver;
  48643. private _onBeforeSpritesRenderingObserver;
  48644. private _onAfterSpritesRenderingObserver;
  48645. private _onBeforePhysicsObserver;
  48646. private _onAfterPhysicsObserver;
  48647. private _onAfterAnimationsObserver;
  48648. private _onBeforeCameraRenderObserver;
  48649. private _onAfterCameraRenderObserver;
  48650. /**
  48651. * Gets the perf counter used for active meshes evaluation time
  48652. */
  48653. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48654. /**
  48655. * Gets the active meshes evaluation time capture status
  48656. */
  48657. /**
  48658. * Enable or disable the active meshes evaluation time capture
  48659. */
  48660. captureActiveMeshesEvaluationTime: boolean;
  48661. /**
  48662. * Gets the perf counter used for render targets render time
  48663. */
  48664. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48665. /**
  48666. * Gets the render targets render time capture status
  48667. */
  48668. /**
  48669. * Enable or disable the render targets render time capture
  48670. */
  48671. captureRenderTargetsRenderTime: boolean;
  48672. /**
  48673. * Gets the perf counter used for particles render time
  48674. */
  48675. readonly particlesRenderTimeCounter: PerfCounter;
  48676. /**
  48677. * Gets the particles render time capture status
  48678. */
  48679. /**
  48680. * Enable or disable the particles render time capture
  48681. */
  48682. captureParticlesRenderTime: boolean;
  48683. /**
  48684. * Gets the perf counter used for sprites render time
  48685. */
  48686. readonly spritesRenderTimeCounter: PerfCounter;
  48687. /**
  48688. * Gets the sprites render time capture status
  48689. */
  48690. /**
  48691. * Enable or disable the sprites render time capture
  48692. */
  48693. captureSpritesRenderTime: boolean;
  48694. /**
  48695. * Gets the perf counter used for physics time
  48696. */
  48697. readonly physicsTimeCounter: PerfCounter;
  48698. /**
  48699. * Gets the physics time capture status
  48700. */
  48701. /**
  48702. * Enable or disable the physics time capture
  48703. */
  48704. capturePhysicsTime: boolean;
  48705. /**
  48706. * Gets the perf counter used for animations time
  48707. */
  48708. readonly animationsTimeCounter: PerfCounter;
  48709. /**
  48710. * Gets the animations time capture status
  48711. */
  48712. /**
  48713. * Enable or disable the animations time capture
  48714. */
  48715. captureAnimationsTime: boolean;
  48716. /**
  48717. * Gets the perf counter used for frame time capture
  48718. */
  48719. readonly frameTimeCounter: PerfCounter;
  48720. /**
  48721. * Gets the frame time capture status
  48722. */
  48723. /**
  48724. * Enable or disable the frame time capture
  48725. */
  48726. captureFrameTime: boolean;
  48727. /**
  48728. * Gets the perf counter used for inter-frames time capture
  48729. */
  48730. readonly interFrameTimeCounter: PerfCounter;
  48731. /**
  48732. * Gets the inter-frames time capture status
  48733. */
  48734. /**
  48735. * Enable or disable the inter-frames time capture
  48736. */
  48737. captureInterFrameTime: boolean;
  48738. /**
  48739. * Gets the perf counter used for render time capture
  48740. */
  48741. readonly renderTimeCounter: PerfCounter;
  48742. /**
  48743. * Gets the render time capture status
  48744. */
  48745. /**
  48746. * Enable or disable the render time capture
  48747. */
  48748. captureRenderTime: boolean;
  48749. /**
  48750. * Gets the perf counter used for camera render time capture
  48751. */
  48752. readonly cameraRenderTimeCounter: PerfCounter;
  48753. /**
  48754. * Gets the camera render time capture status
  48755. */
  48756. /**
  48757. * Enable or disable the camera render time capture
  48758. */
  48759. captureCameraRenderTime: boolean;
  48760. /**
  48761. * Gets the perf counter used for draw calls
  48762. */
  48763. readonly drawCallsCounter: PerfCounter;
  48764. /**
  48765. * Instantiates a new scene instrumentation.
  48766. * This class can be used to get instrumentation data from a Babylon engine
  48767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48768. * @param scene Defines the scene to instrument
  48769. */
  48770. constructor(
  48771. /**
  48772. * Defines the scene to instrument
  48773. */
  48774. scene: Scene);
  48775. /**
  48776. * Dispose and release associated resources.
  48777. */
  48778. dispose(): void;
  48779. }
  48780. }
  48781. declare module BABYLON {
  48782. /** @hidden */
  48783. export var glowMapGenerationPixelShader: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module BABYLON {
  48789. /** @hidden */
  48790. export var glowMapGenerationVertexShader: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module BABYLON {
  48796. /**
  48797. * Effect layer options. This helps customizing the behaviour
  48798. * of the effect layer.
  48799. */
  48800. export interface IEffectLayerOptions {
  48801. /**
  48802. * Multiplication factor apply to the canvas size to compute the render target size
  48803. * used to generated the objects (the smaller the faster).
  48804. */
  48805. mainTextureRatio: number;
  48806. /**
  48807. * Enforces a fixed size texture to ensure effect stability across devices.
  48808. */
  48809. mainTextureFixedSize?: number;
  48810. /**
  48811. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48812. */
  48813. alphaBlendingMode: number;
  48814. /**
  48815. * The camera attached to the layer.
  48816. */
  48817. camera: Nullable<Camera>;
  48818. /**
  48819. * The rendering group to draw the layer in.
  48820. */
  48821. renderingGroupId: number;
  48822. }
  48823. /**
  48824. * The effect layer Helps adding post process effect blended with the main pass.
  48825. *
  48826. * This can be for instance use to generate glow or higlight effects on the scene.
  48827. *
  48828. * The effect layer class can not be used directly and is intented to inherited from to be
  48829. * customized per effects.
  48830. */
  48831. export abstract class EffectLayer {
  48832. private _vertexBuffers;
  48833. private _indexBuffer;
  48834. private _cachedDefines;
  48835. private _effectLayerMapGenerationEffect;
  48836. private _effectLayerOptions;
  48837. private _mergeEffect;
  48838. protected _scene: Scene;
  48839. protected _engine: Engine;
  48840. protected _maxSize: number;
  48841. protected _mainTextureDesiredSize: ISize;
  48842. protected _mainTexture: RenderTargetTexture;
  48843. protected _shouldRender: boolean;
  48844. protected _postProcesses: PostProcess[];
  48845. protected _textures: BaseTexture[];
  48846. protected _emissiveTextureAndColor: {
  48847. texture: Nullable<BaseTexture>;
  48848. color: Color4;
  48849. };
  48850. /**
  48851. * The name of the layer
  48852. */
  48853. name: string;
  48854. /**
  48855. * The clear color of the texture used to generate the glow map.
  48856. */
  48857. neutralColor: Color4;
  48858. /**
  48859. * Specifies wether the highlight layer is enabled or not.
  48860. */
  48861. isEnabled: boolean;
  48862. /**
  48863. * Gets the camera attached to the layer.
  48864. */
  48865. readonly camera: Nullable<Camera>;
  48866. /**
  48867. * Gets the rendering group id the layer should render in.
  48868. */
  48869. renderingGroupId: number;
  48870. /**
  48871. * An event triggered when the effect layer has been disposed.
  48872. */
  48873. onDisposeObservable: Observable<EffectLayer>;
  48874. /**
  48875. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48876. */
  48877. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48878. /**
  48879. * An event triggered when the generated texture is being merged in the scene.
  48880. */
  48881. onBeforeComposeObservable: Observable<EffectLayer>;
  48882. /**
  48883. * An event triggered when the generated texture has been merged in the scene.
  48884. */
  48885. onAfterComposeObservable: Observable<EffectLayer>;
  48886. /**
  48887. * An event triggered when the efffect layer changes its size.
  48888. */
  48889. onSizeChangedObservable: Observable<EffectLayer>;
  48890. /** @hidden */
  48891. static _SceneComponentInitialization: (scene: Scene) => void;
  48892. /**
  48893. * Instantiates a new effect Layer and references it in the scene.
  48894. * @param name The name of the layer
  48895. * @param scene The scene to use the layer in
  48896. */
  48897. constructor(
  48898. /** The Friendly of the effect in the scene */
  48899. name: string, scene: Scene);
  48900. /**
  48901. * Get the effect name of the layer.
  48902. * @return The effect name
  48903. */
  48904. abstract getEffectName(): string;
  48905. /**
  48906. * Checks for the readiness of the element composing the layer.
  48907. * @param subMesh the mesh to check for
  48908. * @param useInstances specify wether or not to use instances to render the mesh
  48909. * @return true if ready otherwise, false
  48910. */
  48911. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48912. /**
  48913. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48914. * @returns true if the effect requires stencil during the main canvas render pass.
  48915. */
  48916. abstract needStencil(): boolean;
  48917. /**
  48918. * Create the merge effect. This is the shader use to blit the information back
  48919. * to the main canvas at the end of the scene rendering.
  48920. * @returns The effect containing the shader used to merge the effect on the main canvas
  48921. */
  48922. protected abstract _createMergeEffect(): Effect;
  48923. /**
  48924. * Creates the render target textures and post processes used in the effect layer.
  48925. */
  48926. protected abstract _createTextureAndPostProcesses(): void;
  48927. /**
  48928. * Implementation specific of rendering the generating effect on the main canvas.
  48929. * @param effect The effect used to render through
  48930. */
  48931. protected abstract _internalRender(effect: Effect): void;
  48932. /**
  48933. * Sets the required values for both the emissive texture and and the main color.
  48934. */
  48935. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48936. /**
  48937. * Free any resources and references associated to a mesh.
  48938. * Internal use
  48939. * @param mesh The mesh to free.
  48940. */
  48941. abstract _disposeMesh(mesh: Mesh): void;
  48942. /**
  48943. * Serializes this layer (Glow or Highlight for example)
  48944. * @returns a serialized layer object
  48945. */
  48946. abstract serialize?(): any;
  48947. /**
  48948. * Initializes the effect layer with the required options.
  48949. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48950. */
  48951. protected _init(options: Partial<IEffectLayerOptions>): void;
  48952. /**
  48953. * Generates the index buffer of the full screen quad blending to the main canvas.
  48954. */
  48955. private _generateIndexBuffer;
  48956. /**
  48957. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48958. */
  48959. private _generateVertexBuffer;
  48960. /**
  48961. * Sets the main texture desired size which is the closest power of two
  48962. * of the engine canvas size.
  48963. */
  48964. private _setMainTextureSize;
  48965. /**
  48966. * Creates the main texture for the effect layer.
  48967. */
  48968. protected _createMainTexture(): void;
  48969. /**
  48970. * Adds specific effects defines.
  48971. * @param defines The defines to add specifics to.
  48972. */
  48973. protected _addCustomEffectDefines(defines: string[]): void;
  48974. /**
  48975. * Checks for the readiness of the element composing the layer.
  48976. * @param subMesh the mesh to check for
  48977. * @param useInstances specify wether or not to use instances to render the mesh
  48978. * @param emissiveTexture the associated emissive texture used to generate the glow
  48979. * @return true if ready otherwise, false
  48980. */
  48981. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48982. /**
  48983. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48984. */
  48985. render(): void;
  48986. /**
  48987. * Determine if a given mesh will be used in the current effect.
  48988. * @param mesh mesh to test
  48989. * @returns true if the mesh will be used
  48990. */
  48991. hasMesh(mesh: AbstractMesh): boolean;
  48992. /**
  48993. * Returns true if the layer contains information to display, otherwise false.
  48994. * @returns true if the glow layer should be rendered
  48995. */
  48996. shouldRender(): boolean;
  48997. /**
  48998. * Returns true if the mesh should render, otherwise false.
  48999. * @param mesh The mesh to render
  49000. * @returns true if it should render otherwise false
  49001. */
  49002. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49003. /**
  49004. * Returns true if the mesh can be rendered, otherwise false.
  49005. * @param mesh The mesh to render
  49006. * @param material The material used on the mesh
  49007. * @returns true if it can be rendered otherwise false
  49008. */
  49009. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49010. /**
  49011. * Returns true if the mesh should render, otherwise false.
  49012. * @param mesh The mesh to render
  49013. * @returns true if it should render otherwise false
  49014. */
  49015. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49016. /**
  49017. * Renders the submesh passed in parameter to the generation map.
  49018. */
  49019. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49020. /**
  49021. * Rebuild the required buffers.
  49022. * @hidden Internal use only.
  49023. */
  49024. _rebuild(): void;
  49025. /**
  49026. * Dispose only the render target textures and post process.
  49027. */
  49028. private _disposeTextureAndPostProcesses;
  49029. /**
  49030. * Dispose the highlight layer and free resources.
  49031. */
  49032. dispose(): void;
  49033. /**
  49034. * Gets the class name of the effect layer
  49035. * @returns the string with the class name of the effect layer
  49036. */
  49037. getClassName(): string;
  49038. /**
  49039. * Creates an effect layer from parsed effect layer data
  49040. * @param parsedEffectLayer defines effect layer data
  49041. * @param scene defines the current scene
  49042. * @param rootUrl defines the root URL containing the effect layer information
  49043. * @returns a parsed effect Layer
  49044. */
  49045. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. interface AbstractScene {
  49050. /**
  49051. * The list of effect layers (highlights/glow) added to the scene
  49052. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49053. * @see http://doc.babylonjs.com/how_to/glow_layer
  49054. */
  49055. effectLayers: Array<EffectLayer>;
  49056. /**
  49057. * Removes the given effect layer from this scene.
  49058. * @param toRemove defines the effect layer to remove
  49059. * @returns the index of the removed effect layer
  49060. */
  49061. removeEffectLayer(toRemove: EffectLayer): number;
  49062. /**
  49063. * Adds the given effect layer to this scene
  49064. * @param newEffectLayer defines the effect layer to add
  49065. */
  49066. addEffectLayer(newEffectLayer: EffectLayer): void;
  49067. }
  49068. /**
  49069. * Defines the layer scene component responsible to manage any effect layers
  49070. * in a given scene.
  49071. */
  49072. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49073. /**
  49074. * The component name helpfull to identify the component in the list of scene components.
  49075. */
  49076. readonly name: string;
  49077. /**
  49078. * The scene the component belongs to.
  49079. */
  49080. scene: Scene;
  49081. private _engine;
  49082. private _renderEffects;
  49083. private _needStencil;
  49084. private _previousStencilState;
  49085. /**
  49086. * Creates a new instance of the component for the given scene
  49087. * @param scene Defines the scene to register the component in
  49088. */
  49089. constructor(scene: Scene);
  49090. /**
  49091. * Registers the component in a given scene
  49092. */
  49093. register(): void;
  49094. /**
  49095. * Rebuilds the elements related to this component in case of
  49096. * context lost for instance.
  49097. */
  49098. rebuild(): void;
  49099. /**
  49100. * Serializes the component data to the specified json object
  49101. * @param serializationObject The object to serialize to
  49102. */
  49103. serialize(serializationObject: any): void;
  49104. /**
  49105. * Adds all the elements from the container to the scene
  49106. * @param container the container holding the elements
  49107. */
  49108. addFromContainer(container: AbstractScene): void;
  49109. /**
  49110. * Removes all the elements in the container from the scene
  49111. * @param container contains the elements to remove
  49112. * @param dispose if the removed element should be disposed (default: false)
  49113. */
  49114. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49115. /**
  49116. * Disposes the component and the associated ressources.
  49117. */
  49118. dispose(): void;
  49119. private _isReadyForMesh;
  49120. private _renderMainTexture;
  49121. private _setStencil;
  49122. private _setStencilBack;
  49123. private _draw;
  49124. private _drawCamera;
  49125. private _drawRenderingGroup;
  49126. }
  49127. }
  49128. declare module BABYLON {
  49129. /** @hidden */
  49130. export var glowMapMergePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module BABYLON {
  49136. /** @hidden */
  49137. export var glowMapMergeVertexShader: {
  49138. name: string;
  49139. shader: string;
  49140. };
  49141. }
  49142. declare module BABYLON {
  49143. interface AbstractScene {
  49144. /**
  49145. * Return a the first highlight layer of the scene with a given name.
  49146. * @param name The name of the highlight layer to look for.
  49147. * @return The highlight layer if found otherwise null.
  49148. */
  49149. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49150. }
  49151. /**
  49152. * Glow layer options. This helps customizing the behaviour
  49153. * of the glow layer.
  49154. */
  49155. export interface IGlowLayerOptions {
  49156. /**
  49157. * Multiplication factor apply to the canvas size to compute the render target size
  49158. * used to generated the glowing objects (the smaller the faster).
  49159. */
  49160. mainTextureRatio: number;
  49161. /**
  49162. * Enforces a fixed size texture to ensure resize independant blur.
  49163. */
  49164. mainTextureFixedSize?: number;
  49165. /**
  49166. * How big is the kernel of the blur texture.
  49167. */
  49168. blurKernelSize: number;
  49169. /**
  49170. * The camera attached to the layer.
  49171. */
  49172. camera: Nullable<Camera>;
  49173. /**
  49174. * Enable MSAA by chosing the number of samples.
  49175. */
  49176. mainTextureSamples?: number;
  49177. /**
  49178. * The rendering group to draw the layer in.
  49179. */
  49180. renderingGroupId: number;
  49181. }
  49182. /**
  49183. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49184. *
  49185. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49186. * glowy meshes to your scene.
  49187. *
  49188. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49189. */
  49190. export class GlowLayer extends EffectLayer {
  49191. /**
  49192. * Effect Name of the layer.
  49193. */
  49194. static readonly EffectName: string;
  49195. /**
  49196. * The default blur kernel size used for the glow.
  49197. */
  49198. static DefaultBlurKernelSize: number;
  49199. /**
  49200. * The default texture size ratio used for the glow.
  49201. */
  49202. static DefaultTextureRatio: number;
  49203. /**
  49204. * Sets the kernel size of the blur.
  49205. */
  49206. /**
  49207. * Gets the kernel size of the blur.
  49208. */
  49209. blurKernelSize: number;
  49210. /**
  49211. * Sets the glow intensity.
  49212. */
  49213. /**
  49214. * Gets the glow intensity.
  49215. */
  49216. intensity: number;
  49217. private _options;
  49218. private _intensity;
  49219. private _horizontalBlurPostprocess1;
  49220. private _verticalBlurPostprocess1;
  49221. private _horizontalBlurPostprocess2;
  49222. private _verticalBlurPostprocess2;
  49223. private _blurTexture1;
  49224. private _blurTexture2;
  49225. private _postProcesses1;
  49226. private _postProcesses2;
  49227. private _includedOnlyMeshes;
  49228. private _excludedMeshes;
  49229. /**
  49230. * Callback used to let the user override the color selection on a per mesh basis
  49231. */
  49232. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49233. /**
  49234. * Callback used to let the user override the texture selection on a per mesh basis
  49235. */
  49236. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49237. /**
  49238. * Instantiates a new glow Layer and references it to the scene.
  49239. * @param name The name of the layer
  49240. * @param scene The scene to use the layer in
  49241. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49242. */
  49243. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49244. /**
  49245. * Get the effect name of the layer.
  49246. * @return The effect name
  49247. */
  49248. getEffectName(): string;
  49249. /**
  49250. * Create the merge effect. This is the shader use to blit the information back
  49251. * to the main canvas at the end of the scene rendering.
  49252. */
  49253. protected _createMergeEffect(): Effect;
  49254. /**
  49255. * Creates the render target textures and post processes used in the glow layer.
  49256. */
  49257. protected _createTextureAndPostProcesses(): void;
  49258. /**
  49259. * Checks for the readiness of the element composing the layer.
  49260. * @param subMesh the mesh to check for
  49261. * @param useInstances specify wether or not to use instances to render the mesh
  49262. * @param emissiveTexture the associated emissive texture used to generate the glow
  49263. * @return true if ready otherwise, false
  49264. */
  49265. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49266. /**
  49267. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49268. */
  49269. needStencil(): boolean;
  49270. /**
  49271. * Returns true if the mesh can be rendered, otherwise false.
  49272. * @param mesh The mesh to render
  49273. * @param material The material used on the mesh
  49274. * @returns true if it can be rendered otherwise false
  49275. */
  49276. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49277. /**
  49278. * Implementation specific of rendering the generating effect on the main canvas.
  49279. * @param effect The effect used to render through
  49280. */
  49281. protected _internalRender(effect: Effect): void;
  49282. /**
  49283. * Sets the required values for both the emissive texture and and the main color.
  49284. */
  49285. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49286. /**
  49287. * Returns true if the mesh should render, otherwise false.
  49288. * @param mesh The mesh to render
  49289. * @returns true if it should render otherwise false
  49290. */
  49291. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49292. /**
  49293. * Adds specific effects defines.
  49294. * @param defines The defines to add specifics to.
  49295. */
  49296. protected _addCustomEffectDefines(defines: string[]): void;
  49297. /**
  49298. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49299. * @param mesh The mesh to exclude from the glow layer
  49300. */
  49301. addExcludedMesh(mesh: Mesh): void;
  49302. /**
  49303. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49304. * @param mesh The mesh to remove
  49305. */
  49306. removeExcludedMesh(mesh: Mesh): void;
  49307. /**
  49308. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49309. * @param mesh The mesh to include in the glow layer
  49310. */
  49311. addIncludedOnlyMesh(mesh: Mesh): void;
  49312. /**
  49313. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49314. * @param mesh The mesh to remove
  49315. */
  49316. removeIncludedOnlyMesh(mesh: Mesh): void;
  49317. /**
  49318. * Determine if a given mesh will be used in the glow layer
  49319. * @param mesh The mesh to test
  49320. * @returns true if the mesh will be highlighted by the current glow layer
  49321. */
  49322. hasMesh(mesh: AbstractMesh): boolean;
  49323. /**
  49324. * Free any resources and references associated to a mesh.
  49325. * Internal use
  49326. * @param mesh The mesh to free.
  49327. * @hidden
  49328. */
  49329. _disposeMesh(mesh: Mesh): void;
  49330. /**
  49331. * Gets the class name of the effect layer
  49332. * @returns the string with the class name of the effect layer
  49333. */
  49334. getClassName(): string;
  49335. /**
  49336. * Serializes this glow layer
  49337. * @returns a serialized glow layer object
  49338. */
  49339. serialize(): any;
  49340. /**
  49341. * Creates a Glow Layer from parsed glow layer data
  49342. * @param parsedGlowLayer defines glow layer data
  49343. * @param scene defines the current scene
  49344. * @param rootUrl defines the root URL containing the glow layer information
  49345. * @returns a parsed Glow Layer
  49346. */
  49347. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /** @hidden */
  49352. export var glowBlurPostProcessPixelShader: {
  49353. name: string;
  49354. shader: string;
  49355. };
  49356. }
  49357. declare module BABYLON {
  49358. interface AbstractScene {
  49359. /**
  49360. * Return a the first highlight layer of the scene with a given name.
  49361. * @param name The name of the highlight layer to look for.
  49362. * @return The highlight layer if found otherwise null.
  49363. */
  49364. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49365. }
  49366. /**
  49367. * Highlight layer options. This helps customizing the behaviour
  49368. * of the highlight layer.
  49369. */
  49370. export interface IHighlightLayerOptions {
  49371. /**
  49372. * Multiplication factor apply to the canvas size to compute the render target size
  49373. * used to generated the glowing objects (the smaller the faster).
  49374. */
  49375. mainTextureRatio: number;
  49376. /**
  49377. * Enforces a fixed size texture to ensure resize independant blur.
  49378. */
  49379. mainTextureFixedSize?: number;
  49380. /**
  49381. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49382. * of the picture to blur (the smaller the faster).
  49383. */
  49384. blurTextureSizeRatio: number;
  49385. /**
  49386. * How big in texel of the blur texture is the vertical blur.
  49387. */
  49388. blurVerticalSize: number;
  49389. /**
  49390. * How big in texel of the blur texture is the horizontal blur.
  49391. */
  49392. blurHorizontalSize: number;
  49393. /**
  49394. * Alpha blending mode used to apply the blur. Default is combine.
  49395. */
  49396. alphaBlendingMode: number;
  49397. /**
  49398. * The camera attached to the layer.
  49399. */
  49400. camera: Nullable<Camera>;
  49401. /**
  49402. * Should we display highlight as a solid stroke?
  49403. */
  49404. isStroke?: boolean;
  49405. /**
  49406. * The rendering group to draw the layer in.
  49407. */
  49408. renderingGroupId: number;
  49409. }
  49410. /**
  49411. * The highlight layer Helps adding a glow effect around a mesh.
  49412. *
  49413. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49414. * glowy meshes to your scene.
  49415. *
  49416. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49417. */
  49418. export class HighlightLayer extends EffectLayer {
  49419. name: string;
  49420. /**
  49421. * Effect Name of the highlight layer.
  49422. */
  49423. static readonly EffectName: string;
  49424. /**
  49425. * The neutral color used during the preparation of the glow effect.
  49426. * This is black by default as the blend operation is a blend operation.
  49427. */
  49428. static NeutralColor: Color4;
  49429. /**
  49430. * Stencil value used for glowing meshes.
  49431. */
  49432. static GlowingMeshStencilReference: number;
  49433. /**
  49434. * Stencil value used for the other meshes in the scene.
  49435. */
  49436. static NormalMeshStencilReference: number;
  49437. /**
  49438. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49439. */
  49440. innerGlow: boolean;
  49441. /**
  49442. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49443. */
  49444. outerGlow: boolean;
  49445. /**
  49446. * Specifies the horizontal size of the blur.
  49447. */
  49448. /**
  49449. * Gets the horizontal size of the blur.
  49450. */
  49451. blurHorizontalSize: number;
  49452. /**
  49453. * Specifies the vertical size of the blur.
  49454. */
  49455. /**
  49456. * Gets the vertical size of the blur.
  49457. */
  49458. blurVerticalSize: number;
  49459. /**
  49460. * An event triggered when the highlight layer is being blurred.
  49461. */
  49462. onBeforeBlurObservable: Observable<HighlightLayer>;
  49463. /**
  49464. * An event triggered when the highlight layer has been blurred.
  49465. */
  49466. onAfterBlurObservable: Observable<HighlightLayer>;
  49467. private _instanceGlowingMeshStencilReference;
  49468. private _options;
  49469. private _downSamplePostprocess;
  49470. private _horizontalBlurPostprocess;
  49471. private _verticalBlurPostprocess;
  49472. private _blurTexture;
  49473. private _meshes;
  49474. private _excludedMeshes;
  49475. /**
  49476. * Instantiates a new highlight Layer and references it to the scene..
  49477. * @param name The name of the layer
  49478. * @param scene The scene to use the layer in
  49479. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49480. */
  49481. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49482. /**
  49483. * Get the effect name of the layer.
  49484. * @return The effect name
  49485. */
  49486. getEffectName(): string;
  49487. /**
  49488. * Create the merge effect. This is the shader use to blit the information back
  49489. * to the main canvas at the end of the scene rendering.
  49490. */
  49491. protected _createMergeEffect(): Effect;
  49492. /**
  49493. * Creates the render target textures and post processes used in the highlight layer.
  49494. */
  49495. protected _createTextureAndPostProcesses(): void;
  49496. /**
  49497. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49498. */
  49499. needStencil(): boolean;
  49500. /**
  49501. * Checks for the readiness of the element composing the layer.
  49502. * @param subMesh the mesh to check for
  49503. * @param useInstances specify wether or not to use instances to render the mesh
  49504. * @param emissiveTexture the associated emissive texture used to generate the glow
  49505. * @return true if ready otherwise, false
  49506. */
  49507. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49508. /**
  49509. * Implementation specific of rendering the generating effect on the main canvas.
  49510. * @param effect The effect used to render through
  49511. */
  49512. protected _internalRender(effect: Effect): void;
  49513. /**
  49514. * Returns true if the layer contains information to display, otherwise false.
  49515. */
  49516. shouldRender(): boolean;
  49517. /**
  49518. * Returns true if the mesh should render, otherwise false.
  49519. * @param mesh The mesh to render
  49520. * @returns true if it should render otherwise false
  49521. */
  49522. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49523. /**
  49524. * Sets the required values for both the emissive texture and and the main color.
  49525. */
  49526. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49527. /**
  49528. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49529. * @param mesh The mesh to exclude from the highlight layer
  49530. */
  49531. addExcludedMesh(mesh: Mesh): void;
  49532. /**
  49533. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49534. * @param mesh The mesh to highlight
  49535. */
  49536. removeExcludedMesh(mesh: Mesh): void;
  49537. /**
  49538. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49539. * @param mesh mesh to test
  49540. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49541. */
  49542. hasMesh(mesh: AbstractMesh): boolean;
  49543. /**
  49544. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49545. * @param mesh The mesh to highlight
  49546. * @param color The color of the highlight
  49547. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49548. */
  49549. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49550. /**
  49551. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49552. * @param mesh The mesh to highlight
  49553. */
  49554. removeMesh(mesh: Mesh): void;
  49555. /**
  49556. * Force the stencil to the normal expected value for none glowing parts
  49557. */
  49558. private _defaultStencilReference;
  49559. /**
  49560. * Free any resources and references associated to a mesh.
  49561. * Internal use
  49562. * @param mesh The mesh to free.
  49563. * @hidden
  49564. */
  49565. _disposeMesh(mesh: Mesh): void;
  49566. /**
  49567. * Dispose the highlight layer and free resources.
  49568. */
  49569. dispose(): void;
  49570. /**
  49571. * Gets the class name of the effect layer
  49572. * @returns the string with the class name of the effect layer
  49573. */
  49574. getClassName(): string;
  49575. /**
  49576. * Serializes this Highlight layer
  49577. * @returns a serialized Highlight layer object
  49578. */
  49579. serialize(): any;
  49580. /**
  49581. * Creates a Highlight layer from parsed Highlight layer data
  49582. * @param parsedHightlightLayer defines the Highlight layer data
  49583. * @param scene defines the current scene
  49584. * @param rootUrl defines the root URL containing the Highlight layer information
  49585. * @returns a parsed Highlight layer
  49586. */
  49587. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49588. }
  49589. }
  49590. declare module BABYLON {
  49591. interface AbstractScene {
  49592. /**
  49593. * The list of layers (background and foreground) of the scene
  49594. */
  49595. layers: Array<Layer>;
  49596. }
  49597. /**
  49598. * Defines the layer scene component responsible to manage any layers
  49599. * in a given scene.
  49600. */
  49601. export class LayerSceneComponent implements ISceneComponent {
  49602. /**
  49603. * The component name helpfull to identify the component in the list of scene components.
  49604. */
  49605. readonly name: string;
  49606. /**
  49607. * The scene the component belongs to.
  49608. */
  49609. scene: Scene;
  49610. private _engine;
  49611. /**
  49612. * Creates a new instance of the component for the given scene
  49613. * @param scene Defines the scene to register the component in
  49614. */
  49615. constructor(scene: Scene);
  49616. /**
  49617. * Registers the component in a given scene
  49618. */
  49619. register(): void;
  49620. /**
  49621. * Rebuilds the elements related to this component in case of
  49622. * context lost for instance.
  49623. */
  49624. rebuild(): void;
  49625. /**
  49626. * Disposes the component and the associated ressources.
  49627. */
  49628. dispose(): void;
  49629. private _draw;
  49630. private _drawCameraPredicate;
  49631. private _drawCameraBackground;
  49632. private _drawCameraForeground;
  49633. private _drawRenderTargetPredicate;
  49634. private _drawRenderTargetBackground;
  49635. private _drawRenderTargetForeground;
  49636. /**
  49637. * Adds all the elements from the container to the scene
  49638. * @param container the container holding the elements
  49639. */
  49640. addFromContainer(container: AbstractScene): void;
  49641. /**
  49642. * Removes all the elements in the container from the scene
  49643. * @param container contains the elements to remove
  49644. * @param dispose if the removed element should be disposed (default: false)
  49645. */
  49646. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49647. }
  49648. }
  49649. declare module BABYLON {
  49650. /** @hidden */
  49651. export var layerPixelShader: {
  49652. name: string;
  49653. shader: string;
  49654. };
  49655. }
  49656. declare module BABYLON {
  49657. /** @hidden */
  49658. export var layerVertexShader: {
  49659. name: string;
  49660. shader: string;
  49661. };
  49662. }
  49663. declare module BABYLON {
  49664. /**
  49665. * This represents a full screen 2d layer.
  49666. * This can be useful to display a picture in the background of your scene for instance.
  49667. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49668. */
  49669. export class Layer {
  49670. /**
  49671. * Define the name of the layer.
  49672. */
  49673. name: string;
  49674. /**
  49675. * Define the texture the layer should display.
  49676. */
  49677. texture: Nullable<Texture>;
  49678. /**
  49679. * Is the layer in background or foreground.
  49680. */
  49681. isBackground: boolean;
  49682. /**
  49683. * Define the color of the layer (instead of texture).
  49684. */
  49685. color: Color4;
  49686. /**
  49687. * Define the scale of the layer in order to zoom in out of the texture.
  49688. */
  49689. scale: Vector2;
  49690. /**
  49691. * Define an offset for the layer in order to shift the texture.
  49692. */
  49693. offset: Vector2;
  49694. /**
  49695. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49696. */
  49697. alphaBlendingMode: number;
  49698. /**
  49699. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49700. * Alpha test will not mix with the background color in case of transparency.
  49701. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49702. */
  49703. alphaTest: boolean;
  49704. /**
  49705. * Define a mask to restrict the layer to only some of the scene cameras.
  49706. */
  49707. layerMask: number;
  49708. /**
  49709. * Define the list of render target the layer is visible into.
  49710. */
  49711. renderTargetTextures: RenderTargetTexture[];
  49712. /**
  49713. * Define if the layer is only used in renderTarget or if it also
  49714. * renders in the main frame buffer of the canvas.
  49715. */
  49716. renderOnlyInRenderTargetTextures: boolean;
  49717. private _scene;
  49718. private _vertexBuffers;
  49719. private _indexBuffer;
  49720. private _effect;
  49721. private _alphaTestEffect;
  49722. /**
  49723. * An event triggered when the layer is disposed.
  49724. */
  49725. onDisposeObservable: Observable<Layer>;
  49726. private _onDisposeObserver;
  49727. /**
  49728. * Back compatibility with callback before the onDisposeObservable existed.
  49729. * The set callback will be triggered when the layer has been disposed.
  49730. */
  49731. onDispose: () => void;
  49732. /**
  49733. * An event triggered before rendering the scene
  49734. */
  49735. onBeforeRenderObservable: Observable<Layer>;
  49736. private _onBeforeRenderObserver;
  49737. /**
  49738. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49739. * The set callback will be triggered just before rendering the layer.
  49740. */
  49741. onBeforeRender: () => void;
  49742. /**
  49743. * An event triggered after rendering the scene
  49744. */
  49745. onAfterRenderObservable: Observable<Layer>;
  49746. private _onAfterRenderObserver;
  49747. /**
  49748. * Back compatibility with callback before the onAfterRenderObservable existed.
  49749. * The set callback will be triggered just after rendering the layer.
  49750. */
  49751. onAfterRender: () => void;
  49752. /**
  49753. * Instantiates a new layer.
  49754. * This represents a full screen 2d layer.
  49755. * This can be useful to display a picture in the background of your scene for instance.
  49756. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49757. * @param name Define the name of the layer in the scene
  49758. * @param imgUrl Define the url of the texture to display in the layer
  49759. * @param scene Define the scene the layer belongs to
  49760. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49761. * @param color Defines a color for the layer
  49762. */
  49763. constructor(
  49764. /**
  49765. * Define the name of the layer.
  49766. */
  49767. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49768. private _createIndexBuffer;
  49769. /** @hidden */
  49770. _rebuild(): void;
  49771. /**
  49772. * Renders the layer in the scene.
  49773. */
  49774. render(): void;
  49775. /**
  49776. * Disposes and releases the associated ressources.
  49777. */
  49778. dispose(): void;
  49779. }
  49780. }
  49781. declare module BABYLON {
  49782. /** @hidden */
  49783. export var lensFlarePixelShader: {
  49784. name: string;
  49785. shader: string;
  49786. };
  49787. }
  49788. declare module BABYLON {
  49789. /** @hidden */
  49790. export var lensFlareVertexShader: {
  49791. name: string;
  49792. shader: string;
  49793. };
  49794. }
  49795. declare module BABYLON {
  49796. /**
  49797. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49798. * It is usually composed of several `lensFlare`.
  49799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49800. */
  49801. export class LensFlareSystem {
  49802. /**
  49803. * Define the name of the lens flare system
  49804. */
  49805. name: string;
  49806. /**
  49807. * List of lens flares used in this system.
  49808. */
  49809. lensFlares: LensFlare[];
  49810. /**
  49811. * Define a limit from the border the lens flare can be visible.
  49812. */
  49813. borderLimit: number;
  49814. /**
  49815. * Define a viewport border we do not want to see the lens flare in.
  49816. */
  49817. viewportBorder: number;
  49818. /**
  49819. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49820. */
  49821. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49822. /**
  49823. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49824. */
  49825. layerMask: number;
  49826. /**
  49827. * Define the id of the lens flare system in the scene.
  49828. * (equal to name by default)
  49829. */
  49830. id: string;
  49831. private _scene;
  49832. private _emitter;
  49833. private _vertexBuffers;
  49834. private _indexBuffer;
  49835. private _effect;
  49836. private _positionX;
  49837. private _positionY;
  49838. private _isEnabled;
  49839. /** @hidden */
  49840. static _SceneComponentInitialization: (scene: Scene) => void;
  49841. /**
  49842. * Instantiates a lens flare system.
  49843. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49844. * It is usually composed of several `lensFlare`.
  49845. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49846. * @param name Define the name of the lens flare system in the scene
  49847. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49848. * @param scene Define the scene the lens flare system belongs to
  49849. */
  49850. constructor(
  49851. /**
  49852. * Define the name of the lens flare system
  49853. */
  49854. name: string, emitter: any, scene: Scene);
  49855. /**
  49856. * Define if the lens flare system is enabled.
  49857. */
  49858. isEnabled: boolean;
  49859. /**
  49860. * Get the scene the effects belongs to.
  49861. * @returns the scene holding the lens flare system
  49862. */
  49863. getScene(): Scene;
  49864. /**
  49865. * Get the emitter of the lens flare system.
  49866. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49867. * @returns the emitter of the lens flare system
  49868. */
  49869. getEmitter(): any;
  49870. /**
  49871. * Set the emitter of the lens flare system.
  49872. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49873. * @param newEmitter Define the new emitter of the system
  49874. */
  49875. setEmitter(newEmitter: any): void;
  49876. /**
  49877. * Get the lens flare system emitter position.
  49878. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49879. * @returns the position
  49880. */
  49881. getEmitterPosition(): Vector3;
  49882. /**
  49883. * @hidden
  49884. */
  49885. computeEffectivePosition(globalViewport: Viewport): boolean;
  49886. /** @hidden */
  49887. _isVisible(): boolean;
  49888. /**
  49889. * @hidden
  49890. */
  49891. render(): boolean;
  49892. /**
  49893. * Dispose and release the lens flare with its associated resources.
  49894. */
  49895. dispose(): void;
  49896. /**
  49897. * Parse a lens flare system from a JSON repressentation
  49898. * @param parsedLensFlareSystem Define the JSON to parse
  49899. * @param scene Define the scene the parsed system should be instantiated in
  49900. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49901. * @returns the parsed system
  49902. */
  49903. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49904. /**
  49905. * Serialize the current Lens Flare System into a JSON representation.
  49906. * @returns the serialized JSON
  49907. */
  49908. serialize(): any;
  49909. }
  49910. }
  49911. declare module BABYLON {
  49912. /**
  49913. * This represents one of the lens effect in a `lensFlareSystem`.
  49914. * It controls one of the indiviual texture used in the effect.
  49915. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49916. */
  49917. export class LensFlare {
  49918. /**
  49919. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49920. */
  49921. size: number;
  49922. /**
  49923. * 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.
  49924. */
  49925. position: number;
  49926. /**
  49927. * Define the lens color.
  49928. */
  49929. color: Color3;
  49930. /**
  49931. * Define the lens texture.
  49932. */
  49933. texture: Nullable<Texture>;
  49934. /**
  49935. * Define the alpha mode to render this particular lens.
  49936. */
  49937. alphaMode: number;
  49938. private _system;
  49939. /**
  49940. * Creates a new Lens Flare.
  49941. * This represents one of the lens effect in a `lensFlareSystem`.
  49942. * It controls one of the indiviual texture used in the effect.
  49943. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49944. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49945. * @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.
  49946. * @param color Define the lens color
  49947. * @param imgUrl Define the lens texture url
  49948. * @param system Define the `lensFlareSystem` this flare is part of
  49949. * @returns The newly created Lens Flare
  49950. */
  49951. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49952. /**
  49953. * Instantiates a new Lens Flare.
  49954. * This represents one of the lens effect in a `lensFlareSystem`.
  49955. * It controls one of the indiviual texture used in the effect.
  49956. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49957. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49958. * @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.
  49959. * @param color Define the lens color
  49960. * @param imgUrl Define the lens texture url
  49961. * @param system Define the `lensFlareSystem` this flare is part of
  49962. */
  49963. constructor(
  49964. /**
  49965. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49966. */
  49967. size: number,
  49968. /**
  49969. * 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.
  49970. */
  49971. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49972. /**
  49973. * Dispose and release the lens flare with its associated resources.
  49974. */
  49975. dispose(): void;
  49976. }
  49977. }
  49978. declare module BABYLON {
  49979. interface AbstractScene {
  49980. /**
  49981. * The list of lens flare system added to the scene
  49982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49983. */
  49984. lensFlareSystems: Array<LensFlareSystem>;
  49985. /**
  49986. * Removes the given lens flare system from this scene.
  49987. * @param toRemove The lens flare system to remove
  49988. * @returns The index of the removed lens flare system
  49989. */
  49990. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49991. /**
  49992. * Adds the given lens flare system to this scene
  49993. * @param newLensFlareSystem The lens flare system to add
  49994. */
  49995. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49996. /**
  49997. * Gets a lens flare system using its name
  49998. * @param name defines the name to look for
  49999. * @returns the lens flare system or null if not found
  50000. */
  50001. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50002. /**
  50003. * Gets a lens flare system using its id
  50004. * @param id defines the id to look for
  50005. * @returns the lens flare system or null if not found
  50006. */
  50007. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50008. }
  50009. /**
  50010. * Defines the lens flare scene component responsible to manage any lens flares
  50011. * in a given scene.
  50012. */
  50013. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50014. /**
  50015. * The component name helpfull to identify the component in the list of scene components.
  50016. */
  50017. readonly name: string;
  50018. /**
  50019. * The scene the component belongs to.
  50020. */
  50021. scene: Scene;
  50022. /**
  50023. * Creates a new instance of the component for the given scene
  50024. * @param scene Defines the scene to register the component in
  50025. */
  50026. constructor(scene: Scene);
  50027. /**
  50028. * Registers the component in a given scene
  50029. */
  50030. register(): void;
  50031. /**
  50032. * Rebuilds the elements related to this component in case of
  50033. * context lost for instance.
  50034. */
  50035. rebuild(): void;
  50036. /**
  50037. * Adds all the elements from the container to the scene
  50038. * @param container the container holding the elements
  50039. */
  50040. addFromContainer(container: AbstractScene): void;
  50041. /**
  50042. * Removes all the elements in the container from the scene
  50043. * @param container contains the elements to remove
  50044. * @param dispose if the removed element should be disposed (default: false)
  50045. */
  50046. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50047. /**
  50048. * Serializes the component data to the specified json object
  50049. * @param serializationObject The object to serialize to
  50050. */
  50051. serialize(serializationObject: any): void;
  50052. /**
  50053. * Disposes the component and the associated ressources.
  50054. */
  50055. dispose(): void;
  50056. private _draw;
  50057. }
  50058. }
  50059. declare module BABYLON {
  50060. /**
  50061. * Defines the shadow generator component responsible to manage any shadow generators
  50062. * in a given scene.
  50063. */
  50064. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50065. /**
  50066. * The component name helpfull to identify the component in the list of scene components.
  50067. */
  50068. readonly name: string;
  50069. /**
  50070. * The scene the component belongs to.
  50071. */
  50072. scene: Scene;
  50073. /**
  50074. * Creates a new instance of the component for the given scene
  50075. * @param scene Defines the scene to register the component in
  50076. */
  50077. constructor(scene: Scene);
  50078. /**
  50079. * Registers the component in a given scene
  50080. */
  50081. register(): void;
  50082. /**
  50083. * Rebuilds the elements related to this component in case of
  50084. * context lost for instance.
  50085. */
  50086. rebuild(): void;
  50087. /**
  50088. * Serializes the component data to the specified json object
  50089. * @param serializationObject The object to serialize to
  50090. */
  50091. serialize(serializationObject: any): void;
  50092. /**
  50093. * Adds all the elements from the container to the scene
  50094. * @param container the container holding the elements
  50095. */
  50096. addFromContainer(container: AbstractScene): void;
  50097. /**
  50098. * Removes all the elements in the container from the scene
  50099. * @param container contains the elements to remove
  50100. * @param dispose if the removed element should be disposed (default: false)
  50101. */
  50102. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50103. /**
  50104. * Rebuilds the elements related to this component in case of
  50105. * context lost for instance.
  50106. */
  50107. dispose(): void;
  50108. private _gatherRenderTargets;
  50109. }
  50110. }
  50111. declare module BABYLON {
  50112. /**
  50113. * A point light is a light defined by an unique point in world space.
  50114. * The light is emitted in every direction from this point.
  50115. * A good example of a point light is a standard light bulb.
  50116. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50117. */
  50118. export class PointLight extends ShadowLight {
  50119. private _shadowAngle;
  50120. /**
  50121. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50122. * This specifies what angle the shadow will use to be created.
  50123. *
  50124. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50125. */
  50126. /**
  50127. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50128. * This specifies what angle the shadow will use to be created.
  50129. *
  50130. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50131. */
  50132. shadowAngle: number;
  50133. /**
  50134. * Gets the direction if it has been set.
  50135. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50136. */
  50137. /**
  50138. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50139. */
  50140. direction: Vector3;
  50141. /**
  50142. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50143. * A PointLight emits the light in every direction.
  50144. * It can cast shadows.
  50145. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50146. * ```javascript
  50147. * var pointLight = new PointLight("pl", camera.position, scene);
  50148. * ```
  50149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50150. * @param name The light friendly name
  50151. * @param position The position of the point light in the scene
  50152. * @param scene The scene the lights belongs to
  50153. */
  50154. constructor(name: string, position: Vector3, scene: Scene);
  50155. /**
  50156. * Returns the string "PointLight"
  50157. * @returns the class name
  50158. */
  50159. getClassName(): string;
  50160. /**
  50161. * Returns the integer 0.
  50162. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50163. */
  50164. getTypeID(): number;
  50165. /**
  50166. * Specifies wether or not the shadowmap should be a cube texture.
  50167. * @returns true if the shadowmap needs to be a cube texture.
  50168. */
  50169. needCube(): boolean;
  50170. /**
  50171. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50172. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50173. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50174. */
  50175. getShadowDirection(faceIndex?: number): Vector3;
  50176. /**
  50177. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50178. * - fov = PI / 2
  50179. * - aspect ratio : 1.0
  50180. * - z-near and far equal to the active camera minZ and maxZ.
  50181. * Returns the PointLight.
  50182. */
  50183. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50184. protected _buildUniformLayout(): void;
  50185. /**
  50186. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50187. * @param effect The effect to update
  50188. * @param lightIndex The index of the light in the effect to update
  50189. * @returns The point light
  50190. */
  50191. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50192. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50193. /**
  50194. * Prepares the list of defines specific to the light type.
  50195. * @param defines the list of defines
  50196. * @param lightIndex defines the index of the light for the effect
  50197. */
  50198. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. /**
  50203. * Header information of HDR texture files.
  50204. */
  50205. export interface HDRInfo {
  50206. /**
  50207. * The height of the texture in pixels.
  50208. */
  50209. height: number;
  50210. /**
  50211. * The width of the texture in pixels.
  50212. */
  50213. width: number;
  50214. /**
  50215. * The index of the beginning of the data in the binary file.
  50216. */
  50217. dataPosition: number;
  50218. }
  50219. /**
  50220. * This groups tools to convert HDR texture to native colors array.
  50221. */
  50222. export class HDRTools {
  50223. private static Ldexp;
  50224. private static Rgbe2float;
  50225. private static readStringLine;
  50226. /**
  50227. * Reads header information from an RGBE texture stored in a native array.
  50228. * More information on this format are available here:
  50229. * https://en.wikipedia.org/wiki/RGBE_image_format
  50230. *
  50231. * @param uint8array The binary file stored in native array.
  50232. * @return The header information.
  50233. */
  50234. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50235. /**
  50236. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50237. * This RGBE texture needs to store the information as a panorama.
  50238. *
  50239. * More information on this format are available here:
  50240. * https://en.wikipedia.org/wiki/RGBE_image_format
  50241. *
  50242. * @param buffer The binary file stored in an array buffer.
  50243. * @param size The expected size of the extracted cubemap.
  50244. * @return The Cube Map information.
  50245. */
  50246. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50247. /**
  50248. * Returns the pixels data extracted from an RGBE texture.
  50249. * This pixels will be stored left to right up to down in the R G B order in one array.
  50250. *
  50251. * More information on this format are available here:
  50252. * https://en.wikipedia.org/wiki/RGBE_image_format
  50253. *
  50254. * @param uint8array The binary file stored in an array buffer.
  50255. * @param hdrInfo The header information of the file.
  50256. * @return The pixels data in RGB right to left up to down order.
  50257. */
  50258. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50259. private static RGBE_ReadPixels_RLE;
  50260. }
  50261. }
  50262. declare module BABYLON {
  50263. /**
  50264. * This represents a texture coming from an HDR input.
  50265. *
  50266. * The only supported format is currently panorama picture stored in RGBE format.
  50267. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50268. */
  50269. export class HDRCubeTexture extends BaseTexture {
  50270. private static _facesMapping;
  50271. private _generateHarmonics;
  50272. private _noMipmap;
  50273. private _textureMatrix;
  50274. private _size;
  50275. private _onLoad;
  50276. private _onError;
  50277. /**
  50278. * The texture URL.
  50279. */
  50280. url: string;
  50281. /**
  50282. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50283. */
  50284. coordinatesMode: number;
  50285. protected _isBlocking: boolean;
  50286. /**
  50287. * Sets wether or not the texture is blocking during loading.
  50288. */
  50289. /**
  50290. * Gets wether or not the texture is blocking during loading.
  50291. */
  50292. isBlocking: boolean;
  50293. protected _rotationY: number;
  50294. /**
  50295. * Sets texture matrix rotation angle around Y axis in radians.
  50296. */
  50297. /**
  50298. * Gets texture matrix rotation angle around Y axis radians.
  50299. */
  50300. rotationY: number;
  50301. /**
  50302. * Gets or sets the center of the bounding box associated with the cube texture
  50303. * It must define where the camera used to render the texture was set
  50304. */
  50305. boundingBoxPosition: Vector3;
  50306. private _boundingBoxSize;
  50307. /**
  50308. * Gets or sets the size of the bounding box associated with the cube texture
  50309. * When defined, the cubemap will switch to local mode
  50310. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50311. * @example https://www.babylonjs-playground.com/#RNASML
  50312. */
  50313. boundingBoxSize: Vector3;
  50314. /**
  50315. * Instantiates an HDRTexture from the following parameters.
  50316. *
  50317. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50318. * @param scene The scene the texture will be used in
  50319. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50320. * @param noMipmap Forces to not generate the mipmap if true
  50321. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50322. * @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)
  50323. * @param reserved Reserved flag for internal use.
  50324. */
  50325. 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>);
  50326. /**
  50327. * Get the current class name of the texture useful for serialization or dynamic coding.
  50328. * @returns "HDRCubeTexture"
  50329. */
  50330. getClassName(): string;
  50331. /**
  50332. * Occurs when the file is raw .hdr file.
  50333. */
  50334. private loadTexture;
  50335. clone(): HDRCubeTexture;
  50336. delayLoad(): void;
  50337. /**
  50338. * Get the texture reflection matrix used to rotate/transform the reflection.
  50339. * @returns the reflection matrix
  50340. */
  50341. getReflectionTextureMatrix(): Matrix;
  50342. /**
  50343. * Set the texture reflection matrix used to rotate/transform the reflection.
  50344. * @param value Define the reflection matrix to set
  50345. */
  50346. setReflectionTextureMatrix(value: Matrix): void;
  50347. /**
  50348. * Parses a JSON representation of an HDR Texture in order to create the texture
  50349. * @param parsedTexture Define the JSON representation
  50350. * @param scene Define the scene the texture should be created in
  50351. * @param rootUrl Define the root url in case we need to load relative dependencies
  50352. * @returns the newly created texture after parsing
  50353. */
  50354. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50355. serialize(): any;
  50356. }
  50357. }
  50358. declare module BABYLON {
  50359. /**
  50360. * Class used to control physics engine
  50361. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50362. */
  50363. export class PhysicsEngine implements IPhysicsEngine {
  50364. private _physicsPlugin;
  50365. /**
  50366. * Global value used to control the smallest number supported by the simulation
  50367. */
  50368. static Epsilon: number;
  50369. private _impostors;
  50370. private _joints;
  50371. /**
  50372. * Gets the gravity vector used by the simulation
  50373. */
  50374. gravity: Vector3;
  50375. /**
  50376. * Factory used to create the default physics plugin.
  50377. * @returns The default physics plugin
  50378. */
  50379. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50380. /**
  50381. * Creates a new Physics Engine
  50382. * @param gravity defines the gravity vector used by the simulation
  50383. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50384. */
  50385. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50386. /**
  50387. * Sets the gravity vector used by the simulation
  50388. * @param gravity defines the gravity vector to use
  50389. */
  50390. setGravity(gravity: Vector3): void;
  50391. /**
  50392. * Set the time step of the physics engine.
  50393. * Default is 1/60.
  50394. * To slow it down, enter 1/600 for example.
  50395. * To speed it up, 1/30
  50396. * @param newTimeStep defines the new timestep to apply to this world.
  50397. */
  50398. setTimeStep(newTimeStep?: number): void;
  50399. /**
  50400. * Get the time step of the physics engine.
  50401. * @returns the current time step
  50402. */
  50403. getTimeStep(): number;
  50404. /**
  50405. * Release all resources
  50406. */
  50407. dispose(): void;
  50408. /**
  50409. * Gets the name of the current physics plugin
  50410. * @returns the name of the plugin
  50411. */
  50412. getPhysicsPluginName(): string;
  50413. /**
  50414. * Adding a new impostor for the impostor tracking.
  50415. * This will be done by the impostor itself.
  50416. * @param impostor the impostor to add
  50417. */
  50418. addImpostor(impostor: PhysicsImpostor): void;
  50419. /**
  50420. * Remove an impostor from the engine.
  50421. * This impostor and its mesh will not longer be updated by the physics engine.
  50422. * @param impostor the impostor to remove
  50423. */
  50424. removeImpostor(impostor: PhysicsImpostor): void;
  50425. /**
  50426. * Add a joint to the physics engine
  50427. * @param mainImpostor defines the main impostor to which the joint is added.
  50428. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50429. * @param joint defines the joint that will connect both impostors.
  50430. */
  50431. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50432. /**
  50433. * Removes a joint from the simulation
  50434. * @param mainImpostor defines the impostor used with the joint
  50435. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50436. * @param joint defines the joint to remove
  50437. */
  50438. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50439. /**
  50440. * Called by the scene. No need to call it.
  50441. * @param delta defines the timespam between frames
  50442. */
  50443. _step(delta: number): void;
  50444. /**
  50445. * Gets the current plugin used to run the simulation
  50446. * @returns current plugin
  50447. */
  50448. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50449. /**
  50450. * Gets the list of physic impostors
  50451. * @returns an array of PhysicsImpostor
  50452. */
  50453. getImpostors(): Array<PhysicsImpostor>;
  50454. /**
  50455. * Gets the impostor for a physics enabled object
  50456. * @param object defines the object impersonated by the impostor
  50457. * @returns the PhysicsImpostor or null if not found
  50458. */
  50459. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50460. /**
  50461. * Gets the impostor for a physics body object
  50462. * @param body defines physics body used by the impostor
  50463. * @returns the PhysicsImpostor or null if not found
  50464. */
  50465. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50466. /**
  50467. * Does a raycast in the physics world
  50468. * @param from when should the ray start?
  50469. * @param to when should the ray end?
  50470. * @returns PhysicsRaycastResult
  50471. */
  50472. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50473. }
  50474. }
  50475. declare module BABYLON {
  50476. /** @hidden */
  50477. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50478. private _useDeltaForWorldStep;
  50479. world: any;
  50480. name: string;
  50481. private _physicsMaterials;
  50482. private _fixedTimeStep;
  50483. private _cannonRaycastResult;
  50484. private _raycastResult;
  50485. private _physicsBodysToRemoveAfterStep;
  50486. BJSCANNON: any;
  50487. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50488. setGravity(gravity: Vector3): void;
  50489. setTimeStep(timeStep: number): void;
  50490. getTimeStep(): number;
  50491. executeStep(delta: number): void;
  50492. private _removeMarkedPhysicsBodiesFromWorld;
  50493. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50494. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50495. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50496. private _processChildMeshes;
  50497. removePhysicsBody(impostor: PhysicsImpostor): void;
  50498. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50499. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50500. private _addMaterial;
  50501. private _checkWithEpsilon;
  50502. private _createShape;
  50503. private _createHeightmap;
  50504. private _minus90X;
  50505. private _plus90X;
  50506. private _tmpPosition;
  50507. private _tmpDeltaPosition;
  50508. private _tmpUnityRotation;
  50509. private _updatePhysicsBodyTransformation;
  50510. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50511. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50512. isSupported(): boolean;
  50513. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50515. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50516. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50517. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50518. getBodyMass(impostor: PhysicsImpostor): number;
  50519. getBodyFriction(impostor: PhysicsImpostor): number;
  50520. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50521. getBodyRestitution(impostor: PhysicsImpostor): number;
  50522. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50523. sleepBody(impostor: PhysicsImpostor): void;
  50524. wakeUpBody(impostor: PhysicsImpostor): void;
  50525. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50526. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50527. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50528. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50529. getRadius(impostor: PhysicsImpostor): number;
  50530. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50531. dispose(): void;
  50532. private _extendNamespace;
  50533. /**
  50534. * Does a raycast in the physics world
  50535. * @param from when should the ray start?
  50536. * @param to when should the ray end?
  50537. * @returns PhysicsRaycastResult
  50538. */
  50539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50540. }
  50541. }
  50542. declare module BABYLON {
  50543. /** @hidden */
  50544. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50545. world: any;
  50546. name: string;
  50547. BJSOIMO: any;
  50548. private _raycastResult;
  50549. constructor(iterations?: number, oimoInjection?: any);
  50550. setGravity(gravity: Vector3): void;
  50551. setTimeStep(timeStep: number): void;
  50552. getTimeStep(): number;
  50553. private _tmpImpostorsArray;
  50554. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50555. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50556. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50557. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50558. private _tmpPositionVector;
  50559. removePhysicsBody(impostor: PhysicsImpostor): void;
  50560. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50561. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50562. isSupported(): boolean;
  50563. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50564. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50566. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50567. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50568. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50569. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50570. getBodyMass(impostor: PhysicsImpostor): number;
  50571. getBodyFriction(impostor: PhysicsImpostor): number;
  50572. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50573. getBodyRestitution(impostor: PhysicsImpostor): number;
  50574. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50575. sleepBody(impostor: PhysicsImpostor): void;
  50576. wakeUpBody(impostor: PhysicsImpostor): void;
  50577. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50578. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50579. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50580. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50581. getRadius(impostor: PhysicsImpostor): number;
  50582. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50583. dispose(): void;
  50584. /**
  50585. * Does a raycast in the physics world
  50586. * @param from when should the ray start?
  50587. * @param to when should the ray end?
  50588. * @returns PhysicsRaycastResult
  50589. */
  50590. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50591. }
  50592. }
  50593. declare module BABYLON {
  50594. /**
  50595. * Class containing static functions to help procedurally build meshes
  50596. */
  50597. export class RibbonBuilder {
  50598. /**
  50599. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50600. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50601. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50602. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50603. * * 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
  50604. * * 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
  50605. * * 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
  50606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50607. * * 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
  50608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50609. * * 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
  50610. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50611. * * 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
  50612. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50614. * @param name defines the name of the mesh
  50615. * @param options defines the options used to create the mesh
  50616. * @param scene defines the hosting scene
  50617. * @returns the ribbon mesh
  50618. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50619. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50620. */
  50621. static CreateRibbon(name: string, options: {
  50622. pathArray: Vector3[][];
  50623. closeArray?: boolean;
  50624. closePath?: boolean;
  50625. offset?: number;
  50626. updatable?: boolean;
  50627. sideOrientation?: number;
  50628. frontUVs?: Vector4;
  50629. backUVs?: Vector4;
  50630. instance?: Mesh;
  50631. invertUV?: boolean;
  50632. uvs?: Vector2[];
  50633. colors?: Color4[];
  50634. }, scene?: Nullable<Scene>): Mesh;
  50635. }
  50636. }
  50637. declare module BABYLON {
  50638. /**
  50639. * Class containing static functions to help procedurally build meshes
  50640. */
  50641. export class ShapeBuilder {
  50642. /**
  50643. * 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.
  50644. * * 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.
  50645. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50646. * * 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.
  50647. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50648. * * 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
  50649. * * 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
  50650. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50652. * * 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
  50653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50655. * @param name defines the name of the mesh
  50656. * @param options defines the options used to create the mesh
  50657. * @param scene defines the hosting scene
  50658. * @returns the extruded shape mesh
  50659. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50661. */
  50662. static ExtrudeShape(name: string, options: {
  50663. shape: Vector3[];
  50664. path: Vector3[];
  50665. scale?: number;
  50666. rotation?: number;
  50667. cap?: number;
  50668. updatable?: boolean;
  50669. sideOrientation?: number;
  50670. frontUVs?: Vector4;
  50671. backUVs?: Vector4;
  50672. instance?: Mesh;
  50673. invertUV?: boolean;
  50674. }, scene?: Nullable<Scene>): Mesh;
  50675. /**
  50676. * Creates an custom extruded shape mesh.
  50677. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50678. * * 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.
  50679. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50680. * * 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
  50681. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50682. * * 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
  50683. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50684. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50685. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50686. * * 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
  50687. * * 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
  50688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50690. * * 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
  50691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50693. * @param name defines the name of the mesh
  50694. * @param options defines the options used to create the mesh
  50695. * @param scene defines the hosting scene
  50696. * @returns the custom extruded shape mesh
  50697. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50698. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50700. */
  50701. static ExtrudeShapeCustom(name: string, options: {
  50702. shape: Vector3[];
  50703. path: Vector3[];
  50704. scaleFunction?: any;
  50705. rotationFunction?: any;
  50706. ribbonCloseArray?: boolean;
  50707. ribbonClosePath?: boolean;
  50708. cap?: number;
  50709. updatable?: boolean;
  50710. sideOrientation?: number;
  50711. frontUVs?: Vector4;
  50712. backUVs?: Vector4;
  50713. instance?: Mesh;
  50714. invertUV?: boolean;
  50715. }, scene?: Nullable<Scene>): Mesh;
  50716. private static _ExtrudeShapeGeneric;
  50717. }
  50718. }
  50719. declare module BABYLON {
  50720. /**
  50721. * AmmoJS Physics plugin
  50722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50723. * @see https://github.com/kripken/ammo.js/
  50724. */
  50725. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50726. private _useDeltaForWorldStep;
  50727. /**
  50728. * Reference to the Ammo library
  50729. */
  50730. bjsAMMO: any;
  50731. /**
  50732. * Created ammoJS world which physics bodies are added to
  50733. */
  50734. world: any;
  50735. /**
  50736. * Name of the plugin
  50737. */
  50738. name: string;
  50739. private _timeStep;
  50740. private _fixedTimeStep;
  50741. private _maxSteps;
  50742. private _tmpQuaternion;
  50743. private _tmpAmmoTransform;
  50744. private _tmpAmmoQuaternion;
  50745. private _tmpAmmoConcreteContactResultCallback;
  50746. private _collisionConfiguration;
  50747. private _dispatcher;
  50748. private _overlappingPairCache;
  50749. private _solver;
  50750. private _softBodySolver;
  50751. private _tmpAmmoVectorA;
  50752. private _tmpAmmoVectorB;
  50753. private _tmpAmmoVectorC;
  50754. private _tmpAmmoVectorD;
  50755. private _tmpContactCallbackResult;
  50756. private _tmpAmmoVectorRCA;
  50757. private _tmpAmmoVectorRCB;
  50758. private _raycastResult;
  50759. private static readonly DISABLE_COLLISION_FLAG;
  50760. private static readonly KINEMATIC_FLAG;
  50761. private static readonly DISABLE_DEACTIVATION_FLAG;
  50762. /**
  50763. * Initializes the ammoJS plugin
  50764. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50765. * @param ammoInjection can be used to inject your own ammo reference
  50766. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50767. */
  50768. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50769. /**
  50770. * Sets the gravity of the physics world (m/(s^2))
  50771. * @param gravity Gravity to set
  50772. */
  50773. setGravity(gravity: Vector3): void;
  50774. /**
  50775. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50776. * @param timeStep timestep to use in seconds
  50777. */
  50778. setTimeStep(timeStep: number): void;
  50779. /**
  50780. * 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)
  50781. * @param fixedTimeStep fixedTimeStep to use in seconds
  50782. */
  50783. setFixedTimeStep(fixedTimeStep: number): void;
  50784. /**
  50785. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50786. * @param maxSteps the maximum number of steps by the physics engine per frame
  50787. */
  50788. setMaxSteps(maxSteps: number): void;
  50789. /**
  50790. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50791. * @returns the current timestep in seconds
  50792. */
  50793. getTimeStep(): number;
  50794. private _isImpostorInContact;
  50795. private _isImpostorPairInContact;
  50796. private _stepSimulation;
  50797. /**
  50798. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50799. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50800. * After the step the babylon meshes are set to the position of the physics imposters
  50801. * @param delta amount of time to step forward
  50802. * @param impostors array of imposters to update before/after the step
  50803. */
  50804. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50805. /**
  50806. * Update babylon mesh to match physics world object
  50807. * @param impostor imposter to match
  50808. */
  50809. private _afterSoftStep;
  50810. /**
  50811. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50812. * @param impostor imposter to match
  50813. */
  50814. private _ropeStep;
  50815. /**
  50816. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50817. * @param impostor imposter to match
  50818. */
  50819. private _softbodyOrClothStep;
  50820. private _tmpVector;
  50821. private _tmpMatrix;
  50822. /**
  50823. * Applies an impulse on the imposter
  50824. * @param impostor imposter to apply impulse to
  50825. * @param force amount of force to be applied to the imposter
  50826. * @param contactPoint the location to apply the impulse on the imposter
  50827. */
  50828. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50829. /**
  50830. * Applies a force on the imposter
  50831. * @param impostor imposter to apply force
  50832. * @param force amount of force to be applied to the imposter
  50833. * @param contactPoint the location to apply the force on the imposter
  50834. */
  50835. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50836. /**
  50837. * Creates a physics body using the plugin
  50838. * @param impostor the imposter to create the physics body on
  50839. */
  50840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50841. /**
  50842. * Removes the physics body from the imposter and disposes of the body's memory
  50843. * @param impostor imposter to remove the physics body from
  50844. */
  50845. removePhysicsBody(impostor: PhysicsImpostor): void;
  50846. /**
  50847. * Generates a joint
  50848. * @param impostorJoint the imposter joint to create the joint with
  50849. */
  50850. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50851. /**
  50852. * Removes a joint
  50853. * @param impostorJoint the imposter joint to remove the joint from
  50854. */
  50855. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50856. private _addMeshVerts;
  50857. /**
  50858. * Initialise the soft body vertices to match its object's (mesh) vertices
  50859. * Softbody vertices (nodes) are in world space and to match this
  50860. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50861. * @param impostor to create the softbody for
  50862. */
  50863. private _softVertexData;
  50864. /**
  50865. * Create an impostor's soft body
  50866. * @param impostor to create the softbody for
  50867. */
  50868. private _createSoftbody;
  50869. /**
  50870. * Create cloth for an impostor
  50871. * @param impostor to create the softbody for
  50872. */
  50873. private _createCloth;
  50874. /**
  50875. * Create rope for an impostor
  50876. * @param impostor to create the softbody for
  50877. */
  50878. private _createRope;
  50879. private _addHullVerts;
  50880. private _createShape;
  50881. /**
  50882. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50883. * @param impostor imposter containing the physics body and babylon object
  50884. */
  50885. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50886. /**
  50887. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50888. * @param impostor imposter containing the physics body and babylon object
  50889. * @param newPosition new position
  50890. * @param newRotation new rotation
  50891. */
  50892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50893. /**
  50894. * If this plugin is supported
  50895. * @returns true if its supported
  50896. */
  50897. isSupported(): boolean;
  50898. /**
  50899. * Sets the linear velocity of the physics body
  50900. * @param impostor imposter to set the velocity on
  50901. * @param velocity velocity to set
  50902. */
  50903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50904. /**
  50905. * Sets the angular velocity of the physics body
  50906. * @param impostor imposter to set the velocity on
  50907. * @param velocity velocity to set
  50908. */
  50909. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50910. /**
  50911. * gets the linear velocity
  50912. * @param impostor imposter to get linear velocity from
  50913. * @returns linear velocity
  50914. */
  50915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50916. /**
  50917. * gets the angular velocity
  50918. * @param impostor imposter to get angular velocity from
  50919. * @returns angular velocity
  50920. */
  50921. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50922. /**
  50923. * Sets the mass of physics body
  50924. * @param impostor imposter to set the mass on
  50925. * @param mass mass to set
  50926. */
  50927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50928. /**
  50929. * Gets the mass of the physics body
  50930. * @param impostor imposter to get the mass from
  50931. * @returns mass
  50932. */
  50933. getBodyMass(impostor: PhysicsImpostor): number;
  50934. /**
  50935. * Gets friction of the impostor
  50936. * @param impostor impostor to get friction from
  50937. * @returns friction value
  50938. */
  50939. getBodyFriction(impostor: PhysicsImpostor): number;
  50940. /**
  50941. * Sets friction of the impostor
  50942. * @param impostor impostor to set friction on
  50943. * @param friction friction value
  50944. */
  50945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50946. /**
  50947. * Gets restitution of the impostor
  50948. * @param impostor impostor to get restitution from
  50949. * @returns restitution value
  50950. */
  50951. getBodyRestitution(impostor: PhysicsImpostor): number;
  50952. /**
  50953. * Sets resitution of the impostor
  50954. * @param impostor impostor to set resitution on
  50955. * @param restitution resitution value
  50956. */
  50957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50958. /**
  50959. * Gets pressure inside the impostor
  50960. * @param impostor impostor to get pressure from
  50961. * @returns pressure value
  50962. */
  50963. getBodyPressure(impostor: PhysicsImpostor): number;
  50964. /**
  50965. * Sets pressure inside a soft body impostor
  50966. * Cloth and rope must remain 0 pressure
  50967. * @param impostor impostor to set pressure on
  50968. * @param pressure pressure value
  50969. */
  50970. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50971. /**
  50972. * Gets stiffness of the impostor
  50973. * @param impostor impostor to get stiffness from
  50974. * @returns pressure value
  50975. */
  50976. getBodyStiffness(impostor: PhysicsImpostor): number;
  50977. /**
  50978. * Sets stiffness of the impostor
  50979. * @param impostor impostor to set stiffness on
  50980. * @param stiffness stiffness value from 0 to 1
  50981. */
  50982. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50983. /**
  50984. * Gets velocityIterations of the impostor
  50985. * @param impostor impostor to get velocity iterations from
  50986. * @returns velocityIterations value
  50987. */
  50988. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50989. /**
  50990. * Sets velocityIterations of the impostor
  50991. * @param impostor impostor to set velocity iterations on
  50992. * @param velocityIterations velocityIterations value
  50993. */
  50994. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50995. /**
  50996. * Gets positionIterations of the impostor
  50997. * @param impostor impostor to get position iterations from
  50998. * @returns positionIterations value
  50999. */
  51000. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51001. /**
  51002. * Sets positionIterations of the impostor
  51003. * @param impostor impostor to set position on
  51004. * @param positionIterations positionIterations value
  51005. */
  51006. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51007. /**
  51008. * Append an anchor to a cloth object
  51009. * @param impostor is the cloth impostor to add anchor to
  51010. * @param otherImpostor is the rigid impostor to anchor to
  51011. * @param width ratio across width from 0 to 1
  51012. * @param height ratio up height from 0 to 1
  51013. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51014. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51015. */
  51016. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51017. /**
  51018. * Append an hook to a rope object
  51019. * @param impostor is the rope impostor to add hook to
  51020. * @param otherImpostor is the rigid impostor to hook to
  51021. * @param length ratio along the rope from 0 to 1
  51022. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51023. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51024. */
  51025. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51026. /**
  51027. * Sleeps the physics body and stops it from being active
  51028. * @param impostor impostor to sleep
  51029. */
  51030. sleepBody(impostor: PhysicsImpostor): void;
  51031. /**
  51032. * Activates the physics body
  51033. * @param impostor impostor to activate
  51034. */
  51035. wakeUpBody(impostor: PhysicsImpostor): void;
  51036. /**
  51037. * Updates the distance parameters of the joint
  51038. * @param joint joint to update
  51039. * @param maxDistance maximum distance of the joint
  51040. * @param minDistance minimum distance of the joint
  51041. */
  51042. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51043. /**
  51044. * Sets a motor on the joint
  51045. * @param joint joint to set motor on
  51046. * @param speed speed of the motor
  51047. * @param maxForce maximum force of the motor
  51048. * @param motorIndex index of the motor
  51049. */
  51050. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51051. /**
  51052. * Sets the motors limit
  51053. * @param joint joint to set limit on
  51054. * @param upperLimit upper limit
  51055. * @param lowerLimit lower limit
  51056. */
  51057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51058. /**
  51059. * Syncs the position and rotation of a mesh with the impostor
  51060. * @param mesh mesh to sync
  51061. * @param impostor impostor to update the mesh with
  51062. */
  51063. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51064. /**
  51065. * Gets the radius of the impostor
  51066. * @param impostor impostor to get radius from
  51067. * @returns the radius
  51068. */
  51069. getRadius(impostor: PhysicsImpostor): number;
  51070. /**
  51071. * Gets the box size of the impostor
  51072. * @param impostor impostor to get box size from
  51073. * @param result the resulting box size
  51074. */
  51075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51076. /**
  51077. * Disposes of the impostor
  51078. */
  51079. dispose(): void;
  51080. /**
  51081. * Does a raycast in the physics world
  51082. * @param from when should the ray start?
  51083. * @param to when should the ray end?
  51084. * @returns PhysicsRaycastResult
  51085. */
  51086. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51087. }
  51088. }
  51089. declare module BABYLON {
  51090. interface AbstractScene {
  51091. /**
  51092. * The list of reflection probes added to the scene
  51093. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51094. */
  51095. reflectionProbes: Array<ReflectionProbe>;
  51096. /**
  51097. * Removes the given reflection probe from this scene.
  51098. * @param toRemove The reflection probe to remove
  51099. * @returns The index of the removed reflection probe
  51100. */
  51101. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51102. /**
  51103. * Adds the given reflection probe to this scene.
  51104. * @param newReflectionProbe The reflection probe to add
  51105. */
  51106. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51107. }
  51108. /**
  51109. * Class used to generate realtime reflection / refraction cube textures
  51110. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51111. */
  51112. export class ReflectionProbe {
  51113. /** defines the name of the probe */
  51114. name: string;
  51115. private _scene;
  51116. private _renderTargetTexture;
  51117. private _projectionMatrix;
  51118. private _viewMatrix;
  51119. private _target;
  51120. private _add;
  51121. private _attachedMesh;
  51122. private _invertYAxis;
  51123. /** Gets or sets probe position (center of the cube map) */
  51124. position: Vector3;
  51125. /**
  51126. * Creates a new reflection probe
  51127. * @param name defines the name of the probe
  51128. * @param size defines the texture resolution (for each face)
  51129. * @param scene defines the hosting scene
  51130. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51131. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51132. */
  51133. constructor(
  51134. /** defines the name of the probe */
  51135. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51136. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51137. samples: number;
  51138. /** Gets or sets the refresh rate to use (on every frame by default) */
  51139. refreshRate: number;
  51140. /**
  51141. * Gets the hosting scene
  51142. * @returns a Scene
  51143. */
  51144. getScene(): Scene;
  51145. /** Gets the internal CubeTexture used to render to */
  51146. readonly cubeTexture: RenderTargetTexture;
  51147. /** Gets the list of meshes to render */
  51148. readonly renderList: Nullable<AbstractMesh[]>;
  51149. /**
  51150. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51151. * @param mesh defines the mesh to attach to
  51152. */
  51153. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51154. /**
  51155. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51156. * @param renderingGroupId The rendering group id corresponding to its index
  51157. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51158. */
  51159. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51160. /**
  51161. * Clean all associated resources
  51162. */
  51163. dispose(): void;
  51164. /**
  51165. * Converts the reflection probe information to a readable string for debug purpose.
  51166. * @param fullDetails Supports for multiple levels of logging within scene loading
  51167. * @returns the human readable reflection probe info
  51168. */
  51169. toString(fullDetails?: boolean): string;
  51170. /**
  51171. * Get the class name of the relfection probe.
  51172. * @returns "ReflectionProbe"
  51173. */
  51174. getClassName(): string;
  51175. /**
  51176. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51177. * @returns The JSON representation of the texture
  51178. */
  51179. serialize(): any;
  51180. /**
  51181. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51182. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51183. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51184. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51185. * @returns The parsed reflection probe if successful
  51186. */
  51187. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51188. }
  51189. }
  51190. declare module BABYLON {
  51191. /** @hidden */
  51192. export var _BabylonLoaderRegistered: boolean;
  51193. }
  51194. declare module BABYLON {
  51195. /**
  51196. * The Physically based simple base material of BJS.
  51197. *
  51198. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51199. * It is used as the base class for both the specGloss and metalRough conventions.
  51200. */
  51201. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51202. /**
  51203. * Number of Simultaneous lights allowed on the material.
  51204. */
  51205. maxSimultaneousLights: number;
  51206. /**
  51207. * If sets to true, disables all the lights affecting the material.
  51208. */
  51209. disableLighting: boolean;
  51210. /**
  51211. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51212. */
  51213. environmentTexture: BaseTexture;
  51214. /**
  51215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51216. */
  51217. invertNormalMapX: boolean;
  51218. /**
  51219. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51220. */
  51221. invertNormalMapY: boolean;
  51222. /**
  51223. * Normal map used in the model.
  51224. */
  51225. normalTexture: BaseTexture;
  51226. /**
  51227. * Emissivie color used to self-illuminate the model.
  51228. */
  51229. emissiveColor: Color3;
  51230. /**
  51231. * Emissivie texture used to self-illuminate the model.
  51232. */
  51233. emissiveTexture: BaseTexture;
  51234. /**
  51235. * Occlusion Channel Strenght.
  51236. */
  51237. occlusionStrength: number;
  51238. /**
  51239. * Occlusion Texture of the material (adding extra occlusion effects).
  51240. */
  51241. occlusionTexture: BaseTexture;
  51242. /**
  51243. * Defines the alpha limits in alpha test mode.
  51244. */
  51245. alphaCutOff: number;
  51246. /**
  51247. * Gets the current double sided mode.
  51248. */
  51249. /**
  51250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51251. */
  51252. doubleSided: boolean;
  51253. /**
  51254. * Stores the pre-calculated light information of a mesh in a texture.
  51255. */
  51256. lightmapTexture: BaseTexture;
  51257. /**
  51258. * If true, the light map contains occlusion information instead of lighting info.
  51259. */
  51260. useLightmapAsShadowmap: boolean;
  51261. /**
  51262. * Instantiates a new PBRMaterial instance.
  51263. *
  51264. * @param name The material name
  51265. * @param scene The scene the material will be use in.
  51266. */
  51267. constructor(name: string, scene: Scene);
  51268. getClassName(): string;
  51269. }
  51270. }
  51271. declare module BABYLON {
  51272. /**
  51273. * The PBR material of BJS following the metal roughness convention.
  51274. *
  51275. * This fits to the PBR convention in the GLTF definition:
  51276. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51277. */
  51278. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51279. /**
  51280. * The base color has two different interpretations depending on the value of metalness.
  51281. * When the material is a metal, the base color is the specific measured reflectance value
  51282. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51283. * of the material.
  51284. */
  51285. baseColor: Color3;
  51286. /**
  51287. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51288. * well as opacity information in the alpha channel.
  51289. */
  51290. baseTexture: BaseTexture;
  51291. /**
  51292. * Specifies the metallic scalar value of the material.
  51293. * Can also be used to scale the metalness values of the metallic texture.
  51294. */
  51295. metallic: number;
  51296. /**
  51297. * Specifies the roughness scalar value of the material.
  51298. * Can also be used to scale the roughness values of the metallic texture.
  51299. */
  51300. roughness: number;
  51301. /**
  51302. * Texture containing both the metallic value in the B channel and the
  51303. * roughness value in the G channel to keep better precision.
  51304. */
  51305. metallicRoughnessTexture: BaseTexture;
  51306. /**
  51307. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51308. *
  51309. * @param name The material name
  51310. * @param scene The scene the material will be use in.
  51311. */
  51312. constructor(name: string, scene: Scene);
  51313. /**
  51314. * Return the currrent class name of the material.
  51315. */
  51316. getClassName(): string;
  51317. /**
  51318. * Makes a duplicate of the current material.
  51319. * @param name - name to use for the new material.
  51320. */
  51321. clone(name: string): PBRMetallicRoughnessMaterial;
  51322. /**
  51323. * Serialize the material to a parsable JSON object.
  51324. */
  51325. serialize(): any;
  51326. /**
  51327. * Parses a JSON object correponding to the serialize function.
  51328. */
  51329. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51330. }
  51331. }
  51332. declare module BABYLON {
  51333. /**
  51334. * The PBR material of BJS following the specular glossiness convention.
  51335. *
  51336. * This fits to the PBR convention in the GLTF definition:
  51337. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51338. */
  51339. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51340. /**
  51341. * Specifies the diffuse color of the material.
  51342. */
  51343. diffuseColor: Color3;
  51344. /**
  51345. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51346. * channel.
  51347. */
  51348. diffuseTexture: BaseTexture;
  51349. /**
  51350. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51351. */
  51352. specularColor: Color3;
  51353. /**
  51354. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51355. */
  51356. glossiness: number;
  51357. /**
  51358. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51359. */
  51360. specularGlossinessTexture: BaseTexture;
  51361. /**
  51362. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51363. *
  51364. * @param name The material name
  51365. * @param scene The scene the material will be use in.
  51366. */
  51367. constructor(name: string, scene: Scene);
  51368. /**
  51369. * Return the currrent class name of the material.
  51370. */
  51371. getClassName(): string;
  51372. /**
  51373. * Makes a duplicate of the current material.
  51374. * @param name - name to use for the new material.
  51375. */
  51376. clone(name: string): PBRSpecularGlossinessMaterial;
  51377. /**
  51378. * Serialize the material to a parsable JSON object.
  51379. */
  51380. serialize(): any;
  51381. /**
  51382. * Parses a JSON object correponding to the serialize function.
  51383. */
  51384. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51385. }
  51386. }
  51387. declare module BABYLON {
  51388. /**
  51389. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51390. * It can help converting any input color in a desired output one. This can then be used to create effects
  51391. * from sepia, black and white to sixties or futuristic rendering...
  51392. *
  51393. * The only supported format is currently 3dl.
  51394. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51395. */
  51396. export class ColorGradingTexture extends BaseTexture {
  51397. /**
  51398. * The current texture matrix. (will always be identity in color grading texture)
  51399. */
  51400. private _textureMatrix;
  51401. /**
  51402. * The texture URL.
  51403. */
  51404. url: string;
  51405. /**
  51406. * Empty line regex stored for GC.
  51407. */
  51408. private static _noneEmptyLineRegex;
  51409. private _engine;
  51410. /**
  51411. * Instantiates a ColorGradingTexture from the following parameters.
  51412. *
  51413. * @param url The location of the color gradind data (currently only supporting 3dl)
  51414. * @param scene The scene the texture will be used in
  51415. */
  51416. constructor(url: string, scene: Scene);
  51417. /**
  51418. * Returns the texture matrix used in most of the material.
  51419. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51420. */
  51421. getTextureMatrix(): Matrix;
  51422. /**
  51423. * Occurs when the file being loaded is a .3dl LUT file.
  51424. */
  51425. private load3dlTexture;
  51426. /**
  51427. * Starts the loading process of the texture.
  51428. */
  51429. private loadTexture;
  51430. /**
  51431. * Clones the color gradind texture.
  51432. */
  51433. clone(): ColorGradingTexture;
  51434. /**
  51435. * Called during delayed load for textures.
  51436. */
  51437. delayLoad(): void;
  51438. /**
  51439. * Parses a color grading texture serialized by Babylon.
  51440. * @param parsedTexture The texture information being parsedTexture
  51441. * @param scene The scene to load the texture in
  51442. * @param rootUrl The root url of the data assets to load
  51443. * @return A color gradind texture
  51444. */
  51445. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51446. /**
  51447. * Serializes the LUT texture to json format.
  51448. */
  51449. serialize(): any;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51455. */
  51456. export class EquiRectangularCubeTexture extends BaseTexture {
  51457. /** The six faces of the cube. */
  51458. private static _FacesMapping;
  51459. private _noMipmap;
  51460. private _onLoad;
  51461. private _onError;
  51462. /** The size of the cubemap. */
  51463. private _size;
  51464. /** The buffer of the image. */
  51465. private _buffer;
  51466. /** The width of the input image. */
  51467. private _width;
  51468. /** The height of the input image. */
  51469. private _height;
  51470. /** The URL to the image. */
  51471. url: string;
  51472. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51473. coordinatesMode: number;
  51474. /**
  51475. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51476. * @param url The location of the image
  51477. * @param scene The scene the texture will be used in
  51478. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51479. * @param noMipmap Forces to not generate the mipmap if true
  51480. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51481. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51482. * @param onLoad — defines a callback called when texture is loaded
  51483. * @param onError — defines a callback called if there is an error
  51484. */
  51485. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51486. /**
  51487. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51488. */
  51489. private loadImage;
  51490. /**
  51491. * Convert the image buffer into a cubemap and create a CubeTexture.
  51492. */
  51493. private loadTexture;
  51494. /**
  51495. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51496. * @param buffer The ArrayBuffer that should be converted.
  51497. * @returns The buffer as Float32Array.
  51498. */
  51499. private getFloat32ArrayFromArrayBuffer;
  51500. /**
  51501. * Get the current class name of the texture useful for serialization or dynamic coding.
  51502. * @returns "EquiRectangularCubeTexture"
  51503. */
  51504. getClassName(): string;
  51505. /**
  51506. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51507. * @returns A clone of the current EquiRectangularCubeTexture.
  51508. */
  51509. clone(): EquiRectangularCubeTexture;
  51510. }
  51511. }
  51512. declare module BABYLON {
  51513. /**
  51514. * Based on jsTGALoader - Javascript loader for TGA file
  51515. * By Vincent Thibault
  51516. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51517. */
  51518. export class TGATools {
  51519. private static _TYPE_INDEXED;
  51520. private static _TYPE_RGB;
  51521. private static _TYPE_GREY;
  51522. private static _TYPE_RLE_INDEXED;
  51523. private static _TYPE_RLE_RGB;
  51524. private static _TYPE_RLE_GREY;
  51525. private static _ORIGIN_MASK;
  51526. private static _ORIGIN_SHIFT;
  51527. private static _ORIGIN_BL;
  51528. private static _ORIGIN_BR;
  51529. private static _ORIGIN_UL;
  51530. private static _ORIGIN_UR;
  51531. /**
  51532. * Gets the header of a TGA file
  51533. * @param data defines the TGA data
  51534. * @returns the header
  51535. */
  51536. static GetTGAHeader(data: Uint8Array): any;
  51537. /**
  51538. * Uploads TGA content to a Babylon Texture
  51539. * @hidden
  51540. */
  51541. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51542. /** @hidden */
  51543. 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;
  51544. /** @hidden */
  51545. 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;
  51546. /** @hidden */
  51547. 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;
  51548. /** @hidden */
  51549. 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;
  51550. /** @hidden */
  51551. 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;
  51552. /** @hidden */
  51553. 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;
  51554. }
  51555. }
  51556. declare module BABYLON {
  51557. /**
  51558. * Implementation of the TGA Texture Loader.
  51559. * @hidden
  51560. */
  51561. export class _TGATextureLoader implements IInternalTextureLoader {
  51562. /**
  51563. * Defines wether the loader supports cascade loading the different faces.
  51564. */
  51565. readonly supportCascades: boolean;
  51566. /**
  51567. * This returns if the loader support the current file information.
  51568. * @param extension defines the file extension of the file being loaded
  51569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51570. * @param fallback defines the fallback internal texture if any
  51571. * @param isBase64 defines whether the texture is encoded as a base64
  51572. * @param isBuffer defines whether the texture data are stored as a buffer
  51573. * @returns true if the loader can load the specified file
  51574. */
  51575. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51576. /**
  51577. * Transform the url before loading if required.
  51578. * @param rootUrl the url of the texture
  51579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51580. * @returns the transformed texture
  51581. */
  51582. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51583. /**
  51584. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51585. * @param rootUrl the url of the texture
  51586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51587. * @returns the fallback texture
  51588. */
  51589. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51590. /**
  51591. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51592. * @param data contains the texture data
  51593. * @param texture defines the BabylonJS internal texture
  51594. * @param createPolynomials will be true if polynomials have been requested
  51595. * @param onLoad defines the callback to trigger once the texture is ready
  51596. * @param onError defines the callback to trigger in case of error
  51597. */
  51598. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51599. /**
  51600. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51601. * @param data contains the texture data
  51602. * @param texture defines the BabylonJS internal texture
  51603. * @param callback defines the method to call once ready to upload
  51604. */
  51605. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51606. }
  51607. }
  51608. declare module BABYLON {
  51609. /**
  51610. * Info about the .basis files
  51611. */
  51612. class BasisFileInfo {
  51613. /**
  51614. * If the file has alpha
  51615. */
  51616. hasAlpha: boolean;
  51617. /**
  51618. * Info about each image of the basis file
  51619. */
  51620. images: Array<{
  51621. levels: Array<{
  51622. width: number;
  51623. height: number;
  51624. transcodedPixels: ArrayBufferView;
  51625. }>;
  51626. }>;
  51627. }
  51628. /**
  51629. * Result of transcoding a basis file
  51630. */
  51631. class TranscodeResult {
  51632. /**
  51633. * Info about the .basis file
  51634. */
  51635. fileInfo: BasisFileInfo;
  51636. /**
  51637. * Format to use when loading the file
  51638. */
  51639. format: number;
  51640. }
  51641. /**
  51642. * Configuration options for the Basis transcoder
  51643. */
  51644. export class BasisTranscodeConfiguration {
  51645. /**
  51646. * Supported compression formats used to determine the supported output format of the transcoder
  51647. */
  51648. supportedCompressionFormats?: {
  51649. /**
  51650. * etc1 compression format
  51651. */
  51652. etc1?: boolean;
  51653. /**
  51654. * s3tc compression format
  51655. */
  51656. s3tc?: boolean;
  51657. /**
  51658. * pvrtc compression format
  51659. */
  51660. pvrtc?: boolean;
  51661. /**
  51662. * etc2 compression format
  51663. */
  51664. etc2?: boolean;
  51665. };
  51666. /**
  51667. * If mipmap levels should be loaded for transcoded images (Default: true)
  51668. */
  51669. loadMipmapLevels?: boolean;
  51670. /**
  51671. * Index of a single image to load (Default: all images)
  51672. */
  51673. loadSingleImage?: number;
  51674. }
  51675. /**
  51676. * Used to load .Basis files
  51677. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51678. */
  51679. export class BasisTools {
  51680. private static _IgnoreSupportedFormats;
  51681. /**
  51682. * URL to use when loading the basis transcoder
  51683. */
  51684. static JSModuleURL: string;
  51685. /**
  51686. * URL to use when loading the wasm module for the transcoder
  51687. */
  51688. static WasmModuleURL: string;
  51689. /**
  51690. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51691. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51692. * @returns internal format corresponding to the Basis format
  51693. */
  51694. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51695. private static _WorkerPromise;
  51696. private static _Worker;
  51697. private static _actionId;
  51698. private static _CreateWorkerAsync;
  51699. /**
  51700. * Transcodes a loaded image file to compressed pixel data
  51701. * @param imageData image data to transcode
  51702. * @param config configuration options for the transcoding
  51703. * @returns a promise resulting in the transcoded image
  51704. */
  51705. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51706. /**
  51707. * Loads a texture from the transcode result
  51708. * @param texture texture load to
  51709. * @param transcodeResult the result of transcoding the basis file to load from
  51710. */
  51711. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51712. }
  51713. }
  51714. declare module BABYLON {
  51715. /**
  51716. * Loader for .basis file format
  51717. */
  51718. export class _BasisTextureLoader implements IInternalTextureLoader {
  51719. /**
  51720. * Defines whether the loader supports cascade loading the different faces.
  51721. */
  51722. readonly supportCascades: boolean;
  51723. /**
  51724. * This returns if the loader support the current file information.
  51725. * @param extension defines the file extension of the file being loaded
  51726. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51727. * @param fallback defines the fallback internal texture if any
  51728. * @param isBase64 defines whether the texture is encoded as a base64
  51729. * @param isBuffer defines whether the texture data are stored as a buffer
  51730. * @returns true if the loader can load the specified file
  51731. */
  51732. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51733. /**
  51734. * Transform the url before loading if required.
  51735. * @param rootUrl the url of the texture
  51736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51737. * @returns the transformed texture
  51738. */
  51739. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51740. /**
  51741. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51742. * @param rootUrl the url of the texture
  51743. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51744. * @returns the fallback texture
  51745. */
  51746. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51747. /**
  51748. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51749. * @param data contains the texture data
  51750. * @param texture defines the BabylonJS internal texture
  51751. * @param createPolynomials will be true if polynomials have been requested
  51752. * @param onLoad defines the callback to trigger once the texture is ready
  51753. * @param onError defines the callback to trigger in case of error
  51754. */
  51755. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51756. /**
  51757. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51758. * @param data contains the texture data
  51759. * @param texture defines the BabylonJS internal texture
  51760. * @param callback defines the method to call once ready to upload
  51761. */
  51762. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51763. }
  51764. }
  51765. declare module BABYLON {
  51766. /**
  51767. * 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.
  51768. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51769. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51770. */
  51771. export class CustomProceduralTexture extends ProceduralTexture {
  51772. private _animate;
  51773. private _time;
  51774. private _config;
  51775. private _texturePath;
  51776. /**
  51777. * Instantiates a new Custom Procedural Texture.
  51778. * 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.
  51779. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51780. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51781. * @param name Define the name of the texture
  51782. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51783. * @param size Define the size of the texture to create
  51784. * @param scene Define the scene the texture belongs to
  51785. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51786. * @param generateMipMaps Define if the texture should creates mip maps or not
  51787. */
  51788. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51789. private _loadJson;
  51790. /**
  51791. * Is the texture ready to be used ? (rendered at least once)
  51792. * @returns true if ready, otherwise, false.
  51793. */
  51794. isReady(): boolean;
  51795. /**
  51796. * Render the texture to its associated render target.
  51797. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51798. */
  51799. render(useCameraPostProcess?: boolean): void;
  51800. /**
  51801. * Update the list of dependant textures samplers in the shader.
  51802. */
  51803. updateTextures(): void;
  51804. /**
  51805. * Update the uniform values of the procedural texture in the shader.
  51806. */
  51807. updateShaderUniforms(): void;
  51808. /**
  51809. * Define if the texture animates or not.
  51810. */
  51811. animate: boolean;
  51812. }
  51813. }
  51814. declare module BABYLON {
  51815. /** @hidden */
  51816. export var noisePixelShader: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module BABYLON {
  51822. /**
  51823. * Class used to generate noise procedural textures
  51824. */
  51825. export class NoiseProceduralTexture extends ProceduralTexture {
  51826. private _time;
  51827. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51828. brightness: number;
  51829. /** Defines the number of octaves to process */
  51830. octaves: number;
  51831. /** Defines the level of persistence (0.8 by default) */
  51832. persistence: number;
  51833. /** Gets or sets animation speed factor (default is 1) */
  51834. animationSpeedFactor: number;
  51835. /**
  51836. * Creates a new NoiseProceduralTexture
  51837. * @param name defines the name fo the texture
  51838. * @param size defines the size of the texture (default is 256)
  51839. * @param scene defines the hosting scene
  51840. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51841. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51842. */
  51843. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51844. private _updateShaderUniforms;
  51845. protected _getDefines(): string;
  51846. /** Generate the current state of the procedural texture */
  51847. render(useCameraPostProcess?: boolean): void;
  51848. /**
  51849. * Serializes this noise procedural texture
  51850. * @returns a serialized noise procedural texture object
  51851. */
  51852. serialize(): any;
  51853. /**
  51854. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51855. * @param parsedTexture defines parsed texture data
  51856. * @param scene defines the current scene
  51857. * @param rootUrl defines the root URL containing noise procedural texture information
  51858. * @returns a parsed NoiseProceduralTexture
  51859. */
  51860. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * Raw cube texture where the raw buffers are passed in
  51866. */
  51867. export class RawCubeTexture extends CubeTexture {
  51868. /**
  51869. * Creates a cube texture where the raw buffers are passed in.
  51870. * @param scene defines the scene the texture is attached to
  51871. * @param data defines the array of data to use to create each face
  51872. * @param size defines the size of the textures
  51873. * @param format defines the format of the data
  51874. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51875. * @param generateMipMaps defines if the engine should generate the mip levels
  51876. * @param invertY defines if data must be stored with Y axis inverted
  51877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51878. * @param compression defines the compression used (null by default)
  51879. */
  51880. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51881. /**
  51882. * Updates the raw cube texture.
  51883. * @param data defines the data to store
  51884. * @param format defines the data format
  51885. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51886. * @param invertY defines if data must be stored with Y axis inverted
  51887. * @param compression defines the compression used (null by default)
  51888. * @param level defines which level of the texture to update
  51889. */
  51890. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51891. /**
  51892. * Updates a raw cube texture with RGBD encoded data.
  51893. * @param data defines the array of data [mipmap][face] to use to create each face
  51894. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51895. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51896. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51897. * @returns a promsie that resolves when the operation is complete
  51898. */
  51899. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51900. /**
  51901. * Clones the raw cube texture.
  51902. * @return a new cube texture
  51903. */
  51904. clone(): CubeTexture;
  51905. /** @hidden */
  51906. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51907. }
  51908. }
  51909. declare module BABYLON {
  51910. /**
  51911. * Class used to store 3D textures containing user data
  51912. */
  51913. export class RawTexture3D extends Texture {
  51914. /** Gets or sets the texture format to use */
  51915. format: number;
  51916. private _engine;
  51917. /**
  51918. * Create a new RawTexture3D
  51919. * @param data defines the data of the texture
  51920. * @param width defines the width of the texture
  51921. * @param height defines the height of the texture
  51922. * @param depth defines the depth of the texture
  51923. * @param format defines the texture format to use
  51924. * @param scene defines the hosting scene
  51925. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51926. * @param invertY defines if texture must be stored with Y axis inverted
  51927. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51928. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51929. */
  51930. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51931. /** Gets or sets the texture format to use */
  51932. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51933. /**
  51934. * Update the texture with new data
  51935. * @param data defines the data to store in the texture
  51936. */
  51937. update(data: ArrayBufferView): void;
  51938. }
  51939. }
  51940. declare module BABYLON {
  51941. /**
  51942. * Creates a refraction texture used by refraction channel of the standard material.
  51943. * It is like a mirror but to see through a material.
  51944. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51945. */
  51946. export class RefractionTexture extends RenderTargetTexture {
  51947. /**
  51948. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51949. * 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.
  51950. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51951. */
  51952. refractionPlane: Plane;
  51953. /**
  51954. * Define how deep under the surface we should see.
  51955. */
  51956. depth: number;
  51957. /**
  51958. * Creates a refraction texture used by refraction channel of the standard material.
  51959. * It is like a mirror but to see through a material.
  51960. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51961. * @param name Define the texture name
  51962. * @param size Define the size of the underlying texture
  51963. * @param scene Define the scene the refraction belongs to
  51964. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51965. */
  51966. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51967. /**
  51968. * Clone the refraction texture.
  51969. * @returns the cloned texture
  51970. */
  51971. clone(): RefractionTexture;
  51972. /**
  51973. * Serialize the texture to a JSON representation you could use in Parse later on
  51974. * @returns the serialized JSON representation
  51975. */
  51976. serialize(): any;
  51977. }
  51978. }
  51979. declare module BABYLON {
  51980. /**
  51981. * Defines the options related to the creation of an HtmlElementTexture
  51982. */
  51983. export interface IHtmlElementTextureOptions {
  51984. /**
  51985. * Defines wether mip maps should be created or not.
  51986. */
  51987. generateMipMaps?: boolean;
  51988. /**
  51989. * Defines the sampling mode of the texture.
  51990. */
  51991. samplingMode?: number;
  51992. /**
  51993. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51994. */
  51995. engine: Nullable<Engine>;
  51996. /**
  51997. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51998. */
  51999. scene: Nullable<Scene>;
  52000. }
  52001. /**
  52002. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52003. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52004. * is automatically managed.
  52005. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52006. * in your application.
  52007. *
  52008. * As the update is not automatic, you need to call them manually.
  52009. */
  52010. export class HtmlElementTexture extends BaseTexture {
  52011. /**
  52012. * The texture URL.
  52013. */
  52014. element: HTMLVideoElement | HTMLCanvasElement;
  52015. private static readonly DefaultOptions;
  52016. private _textureMatrix;
  52017. private _engine;
  52018. private _isVideo;
  52019. private _generateMipMaps;
  52020. private _samplingMode;
  52021. /**
  52022. * Instantiates a HtmlElementTexture from the following parameters.
  52023. *
  52024. * @param name Defines the name of the texture
  52025. * @param element Defines the video or canvas the texture is filled with
  52026. * @param options Defines the other none mandatory texture creation options
  52027. */
  52028. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52029. private _createInternalTexture;
  52030. /**
  52031. * Returns the texture matrix used in most of the material.
  52032. */
  52033. getTextureMatrix(): Matrix;
  52034. /**
  52035. * Updates the content of the texture.
  52036. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52037. */
  52038. update(invertY?: Nullable<boolean>): void;
  52039. }
  52040. }
  52041. declare module BABYLON {
  52042. /**
  52043. * Enum used to define the target of a block
  52044. */
  52045. export enum NodeMaterialBlockTargets {
  52046. /** Vertex shader */
  52047. Vertex = 1,
  52048. /** Fragment shader */
  52049. Fragment = 2,
  52050. /** Neutral */
  52051. Neutral = 4,
  52052. /** Vertex and Fragment */
  52053. VertexAndFragment = 3
  52054. }
  52055. }
  52056. declare module BABYLON {
  52057. /**
  52058. * Defines the kind of connection point for node based material
  52059. */
  52060. export enum NodeMaterialBlockConnectionPointTypes {
  52061. /** Float */
  52062. Float = 1,
  52063. /** Int */
  52064. Int = 2,
  52065. /** Vector2 */
  52066. Vector2 = 4,
  52067. /** Vector3 */
  52068. Vector3 = 8,
  52069. /** Vector4 */
  52070. Vector4 = 16,
  52071. /** Color3 */
  52072. Color3 = 32,
  52073. /** Color4 */
  52074. Color4 = 64,
  52075. /** Matrix */
  52076. Matrix = 128,
  52077. /** Detect type based on connection */
  52078. AutoDetect = 1024,
  52079. /** Output type that will be defined by input type */
  52080. BasedOnInput = 2048
  52081. }
  52082. }
  52083. declare module BABYLON {
  52084. /**
  52085. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52086. */
  52087. export enum NodeMaterialBlockConnectionPointMode {
  52088. /** Value is an uniform */
  52089. Uniform = 0,
  52090. /** Value is a mesh attribute */
  52091. Attribute = 1,
  52092. /** Value is a varying between vertex and fragment shaders */
  52093. Varying = 2,
  52094. /** Mode is undefined */
  52095. Undefined = 3
  52096. }
  52097. }
  52098. declare module BABYLON {
  52099. /**
  52100. * Enum used to define system values e.g. values automatically provided by the system
  52101. */
  52102. export enum NodeMaterialSystemValues {
  52103. /** World */
  52104. World = 1,
  52105. /** View */
  52106. View = 2,
  52107. /** Projection */
  52108. Projection = 3,
  52109. /** ViewProjection */
  52110. ViewProjection = 4,
  52111. /** WorldView */
  52112. WorldView = 5,
  52113. /** WorldViewProjection */
  52114. WorldViewProjection = 6,
  52115. /** CameraPosition */
  52116. CameraPosition = 7,
  52117. /** Fog Color */
  52118. FogColor = 8
  52119. }
  52120. }
  52121. declare module BABYLON {
  52122. /**
  52123. * Root class for all node material optimizers
  52124. */
  52125. export class NodeMaterialOptimizer {
  52126. /**
  52127. * Function used to optimize a NodeMaterial graph
  52128. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52129. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52130. */
  52131. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52132. }
  52133. }
  52134. declare module BABYLON {
  52135. /**
  52136. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52137. */
  52138. export class TransformBlock extends NodeMaterialBlock {
  52139. /**
  52140. * Defines the value to use to complement W value to transform it to a Vector4
  52141. */
  52142. complementW: number;
  52143. /**
  52144. * Defines the value to use to complement z value to transform it to a Vector4
  52145. */
  52146. complementZ: number;
  52147. /**
  52148. * Creates a new TransformBlock
  52149. * @param name defines the block name
  52150. */
  52151. constructor(name: string);
  52152. /**
  52153. * Gets the current class name
  52154. * @returns the class name
  52155. */
  52156. getClassName(): string;
  52157. /**
  52158. * Gets the vector input
  52159. */
  52160. readonly vector: NodeMaterialConnectionPoint;
  52161. /**
  52162. * Gets the output component
  52163. */
  52164. readonly output: NodeMaterialConnectionPoint;
  52165. /**
  52166. * Gets the matrix transform input
  52167. */
  52168. readonly transform: NodeMaterialConnectionPoint;
  52169. protected _buildBlock(state: NodeMaterialBuildState): this;
  52170. serialize(): any;
  52171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52172. protected _dumpPropertiesCode(): string;
  52173. }
  52174. }
  52175. declare module BABYLON {
  52176. /**
  52177. * Block used to output the vertex position
  52178. */
  52179. export class VertexOutputBlock extends NodeMaterialBlock {
  52180. /**
  52181. * Creates a new VertexOutputBlock
  52182. * @param name defines the block name
  52183. */
  52184. constructor(name: string);
  52185. /**
  52186. * Gets the current class name
  52187. * @returns the class name
  52188. */
  52189. getClassName(): string;
  52190. /**
  52191. * Gets the vector input component
  52192. */
  52193. readonly vector: NodeMaterialConnectionPoint;
  52194. protected _buildBlock(state: NodeMaterialBuildState): this;
  52195. }
  52196. }
  52197. declare module BABYLON {
  52198. /**
  52199. * Block used to output the final color
  52200. */
  52201. export class FragmentOutputBlock extends NodeMaterialBlock {
  52202. /**
  52203. * Create a new FragmentOutputBlock
  52204. * @param name defines the block name
  52205. */
  52206. constructor(name: string);
  52207. /**
  52208. * Gets the current class name
  52209. * @returns the class name
  52210. */
  52211. getClassName(): string;
  52212. /**
  52213. * Gets the rgba input component
  52214. */
  52215. readonly rgba: NodeMaterialConnectionPoint;
  52216. /**
  52217. * Gets the rgb input component
  52218. */
  52219. readonly rgb: NodeMaterialConnectionPoint;
  52220. /**
  52221. * Gets the a input component
  52222. */
  52223. readonly a: NodeMaterialConnectionPoint;
  52224. protected _buildBlock(state: NodeMaterialBuildState): this;
  52225. }
  52226. }
  52227. declare module BABYLON {
  52228. /**
  52229. * Block used to read a reflection texture from a sampler
  52230. */
  52231. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52232. private _define3DName;
  52233. private _defineCubicName;
  52234. private _defineExplicitName;
  52235. private _defineProjectionName;
  52236. private _defineLocalCubicName;
  52237. private _defineSphericalName;
  52238. private _definePlanarName;
  52239. private _defineEquirectangularName;
  52240. private _defineMirroredEquirectangularFixedName;
  52241. private _defineEquirectangularFixedName;
  52242. private _defineSkyboxName;
  52243. private _cubeSamplerName;
  52244. private _2DSamplerName;
  52245. private _positionUVWName;
  52246. private _directionWName;
  52247. private _reflectionCoordsName;
  52248. private _reflection2DCoordsName;
  52249. private _reflectionColorName;
  52250. private _reflectionMatrixName;
  52251. /**
  52252. * Gets or sets the texture associated with the node
  52253. */
  52254. texture: Nullable<BaseTexture>;
  52255. /**
  52256. * Create a new TextureBlock
  52257. * @param name defines the block name
  52258. */
  52259. constructor(name: string);
  52260. /**
  52261. * Gets the current class name
  52262. * @returns the class name
  52263. */
  52264. getClassName(): string;
  52265. /**
  52266. * Gets the world position input component
  52267. */
  52268. readonly position: NodeMaterialConnectionPoint;
  52269. /**
  52270. * Gets the world position input component
  52271. */
  52272. readonly worldPosition: NodeMaterialConnectionPoint;
  52273. /**
  52274. * Gets the world normal input component
  52275. */
  52276. readonly worldNormal: NodeMaterialConnectionPoint;
  52277. /**
  52278. * Gets the world input component
  52279. */
  52280. readonly world: NodeMaterialConnectionPoint;
  52281. /**
  52282. * Gets the camera (or eye) position component
  52283. */
  52284. readonly cameraPosition: NodeMaterialConnectionPoint;
  52285. /**
  52286. * Gets the view input component
  52287. */
  52288. readonly view: NodeMaterialConnectionPoint;
  52289. /**
  52290. * Gets the rgb output component
  52291. */
  52292. readonly rgb: NodeMaterialConnectionPoint;
  52293. /**
  52294. * Gets the r output component
  52295. */
  52296. readonly r: NodeMaterialConnectionPoint;
  52297. /**
  52298. * Gets the g output component
  52299. */
  52300. readonly g: NodeMaterialConnectionPoint;
  52301. /**
  52302. * Gets the b output component
  52303. */
  52304. readonly b: NodeMaterialConnectionPoint;
  52305. autoConfigure(material: NodeMaterial): void;
  52306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52307. isReady(): boolean;
  52308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52309. private _injectVertexCode;
  52310. private _writeOutput;
  52311. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52312. serialize(): any;
  52313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /**
  52318. * Interface used to configure the node material editor
  52319. */
  52320. export interface INodeMaterialEditorOptions {
  52321. /** Define the URl to load node editor script */
  52322. editorURL?: string;
  52323. }
  52324. /** @hidden */
  52325. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52326. /** BONES */
  52327. NUM_BONE_INFLUENCERS: number;
  52328. BonesPerMesh: number;
  52329. BONETEXTURE: boolean;
  52330. /** MORPH TARGETS */
  52331. MORPHTARGETS: boolean;
  52332. MORPHTARGETS_NORMAL: boolean;
  52333. MORPHTARGETS_TANGENT: boolean;
  52334. MORPHTARGETS_UV: boolean;
  52335. NUM_MORPH_INFLUENCERS: number;
  52336. /** IMAGE PROCESSING */
  52337. IMAGEPROCESSING: boolean;
  52338. VIGNETTE: boolean;
  52339. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52340. VIGNETTEBLENDMODEOPAQUE: boolean;
  52341. TONEMAPPING: boolean;
  52342. TONEMAPPING_ACES: boolean;
  52343. CONTRAST: boolean;
  52344. EXPOSURE: boolean;
  52345. COLORCURVES: boolean;
  52346. COLORGRADING: boolean;
  52347. COLORGRADING3D: boolean;
  52348. SAMPLER3DGREENDEPTH: boolean;
  52349. SAMPLER3DBGRMAP: boolean;
  52350. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52351. /** MISC. */
  52352. BUMPDIRECTUV: number;
  52353. constructor();
  52354. setValue(name: string, value: boolean): void;
  52355. }
  52356. /**
  52357. * Class used to configure NodeMaterial
  52358. */
  52359. export interface INodeMaterialOptions {
  52360. /**
  52361. * Defines if blocks should emit comments
  52362. */
  52363. emitComments: boolean;
  52364. }
  52365. /**
  52366. * Class used to create a node based material built by assembling shader blocks
  52367. */
  52368. export class NodeMaterial extends PushMaterial {
  52369. private static _BuildIdGenerator;
  52370. private _options;
  52371. private _vertexCompilationState;
  52372. private _fragmentCompilationState;
  52373. private _sharedData;
  52374. private _buildId;
  52375. private _buildWasSuccessful;
  52376. private _cachedWorldViewMatrix;
  52377. private _cachedWorldViewProjectionMatrix;
  52378. private _optimizers;
  52379. private _animationFrame;
  52380. /** Define the URl to load node editor script */
  52381. static EditorURL: string;
  52382. private BJSNODEMATERIALEDITOR;
  52383. /** Get the inspector from bundle or global */
  52384. private _getGlobalNodeMaterialEditor;
  52385. /**
  52386. * 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)
  52387. */
  52388. ignoreAlpha: boolean;
  52389. /**
  52390. * Defines the maximum number of lights that can be used in the material
  52391. */
  52392. maxSimultaneousLights: number;
  52393. /**
  52394. * Observable raised when the material is built
  52395. */
  52396. onBuildObservable: Observable<NodeMaterial>;
  52397. /**
  52398. * Gets or sets the root nodes of the material vertex shader
  52399. */
  52400. _vertexOutputNodes: NodeMaterialBlock[];
  52401. /**
  52402. * Gets or sets the root nodes of the material fragment (pixel) shader
  52403. */
  52404. _fragmentOutputNodes: NodeMaterialBlock[];
  52405. /** Gets or sets options to control the node material overall behavior */
  52406. options: INodeMaterialOptions;
  52407. /**
  52408. * Default configuration related to image processing available in the standard Material.
  52409. */
  52410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52411. /**
  52412. * Gets the image processing configuration used either in this material.
  52413. */
  52414. /**
  52415. * Sets the Default image processing configuration used either in the this material.
  52416. *
  52417. * If sets to null, the scene one is in use.
  52418. */
  52419. imageProcessingConfiguration: ImageProcessingConfiguration;
  52420. /**
  52421. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52422. */
  52423. attachedBlocks: NodeMaterialBlock[];
  52424. /**
  52425. * Create a new node based material
  52426. * @param name defines the material name
  52427. * @param scene defines the hosting scene
  52428. * @param options defines creation option
  52429. */
  52430. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52431. /**
  52432. * Gets the current class name of the material e.g. "NodeMaterial"
  52433. * @returns the class name
  52434. */
  52435. getClassName(): string;
  52436. /**
  52437. * Keep track of the image processing observer to allow dispose and replace.
  52438. */
  52439. private _imageProcessingObserver;
  52440. /**
  52441. * Attaches a new image processing configuration to the Standard Material.
  52442. * @param configuration
  52443. */
  52444. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52445. /**
  52446. * Get a block by its name
  52447. * @param name defines the name of the block to retrieve
  52448. * @returns the required block or null if not found
  52449. */
  52450. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52451. /**
  52452. * Get a block by its name
  52453. * @param predicate defines the predicate used to find the good candidate
  52454. * @returns the required block or null if not found
  52455. */
  52456. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52457. /**
  52458. * Get an input block by its name
  52459. * @param predicate defines the predicate used to find the good candidate
  52460. * @returns the required input block or null if not found
  52461. */
  52462. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52463. /**
  52464. * Gets the list of input blocks attached to this material
  52465. * @returns an array of InputBlocks
  52466. */
  52467. getInputBlocks(): InputBlock[];
  52468. /**
  52469. * Adds a new optimizer to the list of optimizers
  52470. * @param optimizer defines the optimizers to add
  52471. * @returns the current material
  52472. */
  52473. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52474. /**
  52475. * Remove an optimizer from the list of optimizers
  52476. * @param optimizer defines the optimizers to remove
  52477. * @returns the current material
  52478. */
  52479. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52480. /**
  52481. * Add a new block to the list of output nodes
  52482. * @param node defines the node to add
  52483. * @returns the current material
  52484. */
  52485. addOutputNode(node: NodeMaterialBlock): this;
  52486. /**
  52487. * Remove a block from the list of root nodes
  52488. * @param node defines the node to remove
  52489. * @returns the current material
  52490. */
  52491. removeOutputNode(node: NodeMaterialBlock): this;
  52492. private _addVertexOutputNode;
  52493. private _removeVertexOutputNode;
  52494. private _addFragmentOutputNode;
  52495. private _removeFragmentOutputNode;
  52496. /**
  52497. * Specifies if the material will require alpha blending
  52498. * @returns a boolean specifying if alpha blending is needed
  52499. */
  52500. needAlphaBlending(): boolean;
  52501. /**
  52502. * Specifies if this material should be rendered in alpha test mode
  52503. * @returns a boolean specifying if an alpha test is needed.
  52504. */
  52505. needAlphaTesting(): boolean;
  52506. private _initializeBlock;
  52507. private _resetDualBlocks;
  52508. /**
  52509. * Build the material and generates the inner effect
  52510. * @param verbose defines if the build should log activity
  52511. */
  52512. build(verbose?: boolean): void;
  52513. /**
  52514. * Runs an otpimization phase to try to improve the shader code
  52515. */
  52516. optimize(): void;
  52517. private _prepareDefinesForAttributes;
  52518. /**
  52519. * Get if the submesh is ready to be used and all its information available.
  52520. * Child classes can use it to update shaders
  52521. * @param mesh defines the mesh to check
  52522. * @param subMesh defines which submesh to check
  52523. * @param useInstances specifies that instances should be used
  52524. * @returns a boolean indicating that the submesh is ready or not
  52525. */
  52526. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52527. /**
  52528. * Get a string representing the shaders built by the current node graph
  52529. */
  52530. readonly compiledShaders: string;
  52531. /**
  52532. * Binds the world matrix to the material
  52533. * @param world defines the world transformation matrix
  52534. */
  52535. bindOnlyWorldMatrix(world: Matrix): void;
  52536. /**
  52537. * Binds the submesh to this material by preparing the effect and shader to draw
  52538. * @param world defines the world transformation matrix
  52539. * @param mesh defines the mesh containing the submesh
  52540. * @param subMesh defines the submesh to bind the material to
  52541. */
  52542. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52543. /**
  52544. * Gets the active textures from the material
  52545. * @returns an array of textures
  52546. */
  52547. getActiveTextures(): BaseTexture[];
  52548. /**
  52549. * Gets the list of texture blocks
  52550. * @returns an array of texture blocks
  52551. */
  52552. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52553. /**
  52554. * Specifies if the material uses a texture
  52555. * @param texture defines the texture to check against the material
  52556. * @returns a boolean specifying if the material uses the texture
  52557. */
  52558. hasTexture(texture: BaseTexture): boolean;
  52559. /**
  52560. * Disposes the material
  52561. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52562. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52563. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52564. */
  52565. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52566. /** Creates the node editor window. */
  52567. private _createNodeEditor;
  52568. /**
  52569. * Launch the node material editor
  52570. * @param config Define the configuration of the editor
  52571. * @return a promise fulfilled when the node editor is visible
  52572. */
  52573. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52574. /**
  52575. * Clear the current material
  52576. */
  52577. clear(): void;
  52578. /**
  52579. * Clear the current material and set it to a default state
  52580. */
  52581. setToDefault(): void;
  52582. /**
  52583. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52584. * @param url defines the url to load from
  52585. * @returns a promise that will fullfil when the material is fully loaded
  52586. */
  52587. loadAsync(url: string): Promise<unknown>;
  52588. private _gatherBlocks;
  52589. /**
  52590. * Generate a string containing the code declaration required to create an equivalent of this material
  52591. * @returns a string
  52592. */
  52593. generateCode(): string;
  52594. /**
  52595. * Serializes this material in a JSON representation
  52596. * @returns the serialized material object
  52597. */
  52598. serialize(): any;
  52599. private _restoreConnections;
  52600. /**
  52601. * Clear the current graph and load a new one from a serialization object
  52602. * @param source defines the JSON representation of the material
  52603. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52604. */
  52605. loadFromSerialization(source: any, rootUrl?: string): void;
  52606. /**
  52607. * Creates a node material from parsed material data
  52608. * @param source defines the JSON representation of the material
  52609. * @param scene defines the hosting scene
  52610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52611. * @returns a new node material
  52612. */
  52613. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52614. /**
  52615. * Creates a new node material set to default basic configuration
  52616. * @param name defines the name of the material
  52617. * @param scene defines the hosting scene
  52618. * @returns a new NodeMaterial
  52619. */
  52620. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52621. }
  52622. }
  52623. declare module BABYLON {
  52624. /**
  52625. * Block used to read a texture from a sampler
  52626. */
  52627. export class TextureBlock extends NodeMaterialBlock {
  52628. private _defineName;
  52629. private _samplerName;
  52630. private _transformedUVName;
  52631. private _textureTransformName;
  52632. private _textureInfoName;
  52633. private _mainUVName;
  52634. private _mainUVDefineName;
  52635. /**
  52636. * Gets or sets the texture associated with the node
  52637. */
  52638. texture: Nullable<Texture>;
  52639. /**
  52640. * Create a new TextureBlock
  52641. * @param name defines the block name
  52642. */
  52643. constructor(name: string);
  52644. /**
  52645. * Gets the current class name
  52646. * @returns the class name
  52647. */
  52648. getClassName(): string;
  52649. /**
  52650. * Gets the uv input component
  52651. */
  52652. readonly uv: NodeMaterialConnectionPoint;
  52653. /**
  52654. * Gets the rgba output component
  52655. */
  52656. readonly rgba: NodeMaterialConnectionPoint;
  52657. /**
  52658. * Gets the rgb output component
  52659. */
  52660. readonly rgb: NodeMaterialConnectionPoint;
  52661. /**
  52662. * Gets the r output component
  52663. */
  52664. readonly r: NodeMaterialConnectionPoint;
  52665. /**
  52666. * Gets the g output component
  52667. */
  52668. readonly g: NodeMaterialConnectionPoint;
  52669. /**
  52670. * Gets the b output component
  52671. */
  52672. readonly b: NodeMaterialConnectionPoint;
  52673. /**
  52674. * Gets the a output component
  52675. */
  52676. readonly a: NodeMaterialConnectionPoint;
  52677. readonly target: NodeMaterialBlockTargets;
  52678. autoConfigure(material: NodeMaterial): void;
  52679. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52681. isReady(): boolean;
  52682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52683. private readonly _isMixed;
  52684. private _injectVertexCode;
  52685. private _writeOutput;
  52686. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52687. protected _dumpPropertiesCode(): string;
  52688. serialize(): any;
  52689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52690. }
  52691. }
  52692. declare module BABYLON {
  52693. /**
  52694. * Class used to store shared data between 2 NodeMaterialBuildState
  52695. */
  52696. export class NodeMaterialBuildStateSharedData {
  52697. /**
  52698. * Gets the list of emitted varyings
  52699. */
  52700. temps: string[];
  52701. /**
  52702. * Gets the list of emitted varyings
  52703. */
  52704. varyings: string[];
  52705. /**
  52706. * Gets the varying declaration string
  52707. */
  52708. varyingDeclaration: string;
  52709. /**
  52710. * Input blocks
  52711. */
  52712. inputBlocks: InputBlock[];
  52713. /**
  52714. * Input blocks
  52715. */
  52716. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52717. /**
  52718. * Bindable blocks (Blocks that need to set data to the effect)
  52719. */
  52720. bindableBlocks: NodeMaterialBlock[];
  52721. /**
  52722. * List of blocks that can provide a compilation fallback
  52723. */
  52724. blocksWithFallbacks: NodeMaterialBlock[];
  52725. /**
  52726. * List of blocks that can provide a define update
  52727. */
  52728. blocksWithDefines: NodeMaterialBlock[];
  52729. /**
  52730. * List of blocks that can provide a repeatable content
  52731. */
  52732. repeatableContentBlocks: NodeMaterialBlock[];
  52733. /**
  52734. * List of blocks that can provide a dynamic list of uniforms
  52735. */
  52736. dynamicUniformBlocks: NodeMaterialBlock[];
  52737. /**
  52738. * List of blocks that can block the isReady function for the material
  52739. */
  52740. blockingBlocks: NodeMaterialBlock[];
  52741. /**
  52742. * Gets the list of animated inputs
  52743. */
  52744. animatedInputs: InputBlock[];
  52745. /**
  52746. * Build Id used to avoid multiple recompilations
  52747. */
  52748. buildId: number;
  52749. /** List of emitted variables */
  52750. variableNames: {
  52751. [key: string]: number;
  52752. };
  52753. /** List of emitted defines */
  52754. defineNames: {
  52755. [key: string]: number;
  52756. };
  52757. /** Should emit comments? */
  52758. emitComments: boolean;
  52759. /** Emit build activity */
  52760. verbose: boolean;
  52761. /** Gets or sets the hosting scene */
  52762. scene: Scene;
  52763. /**
  52764. * Gets the compilation hints emitted at compilation time
  52765. */
  52766. hints: {
  52767. needWorldViewMatrix: boolean;
  52768. needWorldViewProjectionMatrix: boolean;
  52769. needAlphaBlending: boolean;
  52770. needAlphaTesting: boolean;
  52771. };
  52772. /**
  52773. * List of compilation checks
  52774. */
  52775. checks: {
  52776. emitVertex: boolean;
  52777. emitFragment: boolean;
  52778. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52779. };
  52780. /** Creates a new shared data */
  52781. constructor();
  52782. /**
  52783. * Emits console errors and exceptions if there is a failing check
  52784. */
  52785. emitErrors(): void;
  52786. }
  52787. }
  52788. declare module BABYLON {
  52789. /**
  52790. * Class used to store node based material build state
  52791. */
  52792. export class NodeMaterialBuildState {
  52793. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52794. supportUniformBuffers: boolean;
  52795. /**
  52796. * Gets the list of emitted attributes
  52797. */
  52798. attributes: string[];
  52799. /**
  52800. * Gets the list of emitted uniforms
  52801. */
  52802. uniforms: string[];
  52803. /**
  52804. * Gets the list of emitted constants
  52805. */
  52806. constants: string[];
  52807. /**
  52808. * Gets the list of emitted uniform buffers
  52809. */
  52810. uniformBuffers: string[];
  52811. /**
  52812. * Gets the list of emitted samplers
  52813. */
  52814. samplers: string[];
  52815. /**
  52816. * Gets the list of emitted functions
  52817. */
  52818. functions: {
  52819. [key: string]: string;
  52820. };
  52821. /**
  52822. * Gets the list of emitted extensions
  52823. */
  52824. extensions: {
  52825. [key: string]: string;
  52826. };
  52827. /**
  52828. * Gets the target of the compilation state
  52829. */
  52830. target: NodeMaterialBlockTargets;
  52831. /**
  52832. * Gets the list of emitted counters
  52833. */
  52834. counters: {
  52835. [key: string]: number;
  52836. };
  52837. /**
  52838. * Shared data between multiple NodeMaterialBuildState instances
  52839. */
  52840. sharedData: NodeMaterialBuildStateSharedData;
  52841. /** @hidden */
  52842. _vertexState: NodeMaterialBuildState;
  52843. /** @hidden */
  52844. _attributeDeclaration: string;
  52845. /** @hidden */
  52846. _uniformDeclaration: string;
  52847. /** @hidden */
  52848. _constantDeclaration: string;
  52849. /** @hidden */
  52850. _samplerDeclaration: string;
  52851. /** @hidden */
  52852. _varyingTransfer: string;
  52853. private _repeatableContentAnchorIndex;
  52854. /** @hidden */
  52855. _builtCompilationString: string;
  52856. /**
  52857. * Gets the emitted compilation strings
  52858. */
  52859. compilationString: string;
  52860. /**
  52861. * Finalize the compilation strings
  52862. * @param state defines the current compilation state
  52863. */
  52864. finalize(state: NodeMaterialBuildState): void;
  52865. /** @hidden */
  52866. readonly _repeatableContentAnchor: string;
  52867. /** @hidden */
  52868. _getFreeVariableName(prefix: string): string;
  52869. /** @hidden */
  52870. _getFreeDefineName(prefix: string): string;
  52871. /** @hidden */
  52872. _excludeVariableName(name: string): void;
  52873. /** @hidden */
  52874. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52875. /** @hidden */
  52876. _emitExtension(name: string, extension: string): void;
  52877. /** @hidden */
  52878. _emitFunction(name: string, code: string, comments: string): void;
  52879. /** @hidden */
  52880. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52881. replaceStrings?: {
  52882. search: RegExp;
  52883. replace: string;
  52884. }[];
  52885. repeatKey?: string;
  52886. }): string;
  52887. /** @hidden */
  52888. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52889. repeatKey?: string;
  52890. removeAttributes?: boolean;
  52891. removeUniforms?: boolean;
  52892. removeVaryings?: boolean;
  52893. removeIfDef?: boolean;
  52894. replaceStrings?: {
  52895. search: RegExp;
  52896. replace: string;
  52897. }[];
  52898. }, storeKey?: string): void;
  52899. /** @hidden */
  52900. _registerTempVariable(name: string): boolean;
  52901. /** @hidden */
  52902. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52903. /** @hidden */
  52904. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52905. }
  52906. }
  52907. declare module BABYLON {
  52908. /**
  52909. * Defines a block that can be used inside a node based material
  52910. */
  52911. export class NodeMaterialBlock {
  52912. private _buildId;
  52913. private _buildTarget;
  52914. private _target;
  52915. private _isFinalMerger;
  52916. private _isInput;
  52917. /** @hidden */
  52918. _codeVariableName: string;
  52919. /** @hidden */
  52920. _inputs: NodeMaterialConnectionPoint[];
  52921. /** @hidden */
  52922. _outputs: NodeMaterialConnectionPoint[];
  52923. /** @hidden */
  52924. _preparationId: number;
  52925. /**
  52926. * Gets or sets the name of the block
  52927. */
  52928. name: string;
  52929. /**
  52930. * Gets or sets the unique id of the node
  52931. */
  52932. uniqueId: number;
  52933. /**
  52934. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52935. */
  52936. readonly isFinalMerger: boolean;
  52937. /**
  52938. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52939. */
  52940. readonly isInput: boolean;
  52941. /**
  52942. * Gets or sets the build Id
  52943. */
  52944. buildId: number;
  52945. /**
  52946. * Gets or sets the target of the block
  52947. */
  52948. target: NodeMaterialBlockTargets;
  52949. /**
  52950. * Gets the list of input points
  52951. */
  52952. readonly inputs: NodeMaterialConnectionPoint[];
  52953. /** Gets the list of output points */
  52954. readonly outputs: NodeMaterialConnectionPoint[];
  52955. /**
  52956. * Find an input by its name
  52957. * @param name defines the name of the input to look for
  52958. * @returns the input or null if not found
  52959. */
  52960. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52961. /**
  52962. * Find an output by its name
  52963. * @param name defines the name of the outputto look for
  52964. * @returns the output or null if not found
  52965. */
  52966. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52967. /**
  52968. * Creates a new NodeMaterialBlock
  52969. * @param name defines the block name
  52970. * @param target defines the target of that block (Vertex by default)
  52971. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52972. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52973. */
  52974. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52975. /**
  52976. * Initialize the block and prepare the context for build
  52977. * @param state defines the state that will be used for the build
  52978. */
  52979. initialize(state: NodeMaterialBuildState): void;
  52980. /**
  52981. * Bind data to effect. Will only be called for blocks with isBindable === true
  52982. * @param effect defines the effect to bind data to
  52983. * @param nodeMaterial defines the hosting NodeMaterial
  52984. * @param mesh defines the mesh that will be rendered
  52985. */
  52986. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52987. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52988. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52989. protected _writeFloat(value: number): string;
  52990. /**
  52991. * Gets the current class name e.g. "NodeMaterialBlock"
  52992. * @returns the class name
  52993. */
  52994. getClassName(): string;
  52995. /**
  52996. * Register a new input. Must be called inside a block constructor
  52997. * @param name defines the connection point name
  52998. * @param type defines the connection point type
  52999. * @param isOptional defines a boolean indicating that this input can be omitted
  53000. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53001. * @returns the current block
  53002. */
  53003. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53004. /**
  53005. * Register a new output. Must be called inside a block constructor
  53006. * @param name defines the connection point name
  53007. * @param type defines the connection point type
  53008. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53009. * @returns the current block
  53010. */
  53011. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53012. /**
  53013. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53014. * @param forOutput defines an optional connection point to check compatibility with
  53015. * @returns the first available input or null
  53016. */
  53017. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53018. /**
  53019. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53020. * @param forBlock defines an optional block to check compatibility with
  53021. * @returns the first available input or null
  53022. */
  53023. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53024. /**
  53025. * Gets the sibling of the given output
  53026. * @param current defines the current output
  53027. * @returns the next output in the list or null
  53028. */
  53029. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53030. /**
  53031. * Connect current block with another block
  53032. * @param other defines the block to connect with
  53033. * @param options define the various options to help pick the right connections
  53034. * @returns the current block
  53035. */
  53036. connectTo(other: NodeMaterialBlock, options?: {
  53037. input?: string;
  53038. output?: string;
  53039. outputSwizzle?: string;
  53040. }): this | undefined;
  53041. protected _buildBlock(state: NodeMaterialBuildState): void;
  53042. /**
  53043. * Add uniforms, samplers and uniform buffers at compilation time
  53044. * @param state defines the state to update
  53045. * @param nodeMaterial defines the node material requesting the update
  53046. * @param defines defines the material defines to update
  53047. */
  53048. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53049. /**
  53050. * Add potential fallbacks if shader compilation fails
  53051. * @param mesh defines the mesh to be rendered
  53052. * @param fallbacks defines the current prioritized list of fallbacks
  53053. */
  53054. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53055. /**
  53056. * Initialize defines for shader compilation
  53057. * @param mesh defines the mesh to be rendered
  53058. * @param nodeMaterial defines the node material requesting the update
  53059. * @param defines defines the material defines to update
  53060. * @param useInstances specifies that instances should be used
  53061. */
  53062. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53063. /**
  53064. * Update defines for shader compilation
  53065. * @param mesh defines the mesh to be rendered
  53066. * @param nodeMaterial defines the node material requesting the update
  53067. * @param defines defines the material defines to update
  53068. * @param useInstances specifies that instances should be used
  53069. */
  53070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53071. /**
  53072. * Lets the block try to connect some inputs automatically
  53073. * @param material defines the hosting NodeMaterial
  53074. */
  53075. autoConfigure(material: NodeMaterial): void;
  53076. /**
  53077. * Function called when a block is declared as repeatable content generator
  53078. * @param vertexShaderState defines the current compilation state for the vertex shader
  53079. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53080. * @param mesh defines the mesh to be rendered
  53081. * @param defines defines the material defines to update
  53082. */
  53083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53084. /**
  53085. * Checks if the block is ready
  53086. * @param mesh defines the mesh to be rendered
  53087. * @param nodeMaterial defines the node material requesting the update
  53088. * @param defines defines the material defines to update
  53089. * @param useInstances specifies that instances should be used
  53090. * @returns true if the block is ready
  53091. */
  53092. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53093. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53094. private _processBuild;
  53095. /**
  53096. * Compile the current node and generate the shader code
  53097. * @param state defines the current compilation state (uniforms, samplers, current string)
  53098. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53099. * @returns true if already built
  53100. */
  53101. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53102. protected _inputRename(name: string): string;
  53103. protected _outputRename(name: string): string;
  53104. protected _dumpPropertiesCode(): string;
  53105. /** @hidden */
  53106. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53107. /**
  53108. * Clone the current block to a new identical block
  53109. * @param scene defines the hosting scene
  53110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53111. * @returns a copy of the current block
  53112. */
  53113. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53114. /**
  53115. * Serializes this block in a JSON representation
  53116. * @returns the serialized block object
  53117. */
  53118. serialize(): any;
  53119. /** @hidden */
  53120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53121. }
  53122. }
  53123. declare module BABYLON {
  53124. /**
  53125. * Enum defining the type of animations supported by InputBlock
  53126. */
  53127. export enum AnimatedInputBlockTypes {
  53128. /** No animation */
  53129. None = 0,
  53130. /** Time based animation. Will only work for floats */
  53131. Time = 1
  53132. }
  53133. }
  53134. declare module BABYLON {
  53135. /**
  53136. * Block used to expose an input value
  53137. */
  53138. export class InputBlock extends NodeMaterialBlock {
  53139. private _mode;
  53140. private _associatedVariableName;
  53141. private _storedValue;
  53142. private _valueCallback;
  53143. private _type;
  53144. private _animationType;
  53145. /** Gets or set a value used to limit the range of float values */
  53146. min: number;
  53147. /** Gets or set a value used to limit the range of float values */
  53148. max: number;
  53149. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53150. matrixMode: number;
  53151. /** @hidden */
  53152. _systemValue: Nullable<NodeMaterialSystemValues>;
  53153. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53154. visibleInInspector: boolean;
  53155. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53156. isConstant: boolean;
  53157. /**
  53158. * Gets or sets the connection point type (default is float)
  53159. */
  53160. readonly type: NodeMaterialBlockConnectionPointTypes;
  53161. /**
  53162. * Creates a new InputBlock
  53163. * @param name defines the block name
  53164. * @param target defines the target of that block (Vertex by default)
  53165. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53166. */
  53167. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53168. /**
  53169. * Gets the output component
  53170. */
  53171. readonly output: NodeMaterialConnectionPoint;
  53172. /**
  53173. * Set the source of this connection point to a vertex attribute
  53174. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53175. * @returns the current connection point
  53176. */
  53177. setAsAttribute(attributeName?: string): InputBlock;
  53178. /**
  53179. * Set the source of this connection point to a system value
  53180. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53181. * @returns the current connection point
  53182. */
  53183. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53184. /**
  53185. * Gets or sets the value of that point.
  53186. * Please note that this value will be ignored if valueCallback is defined
  53187. */
  53188. value: any;
  53189. /**
  53190. * Gets or sets a callback used to get the value of that point.
  53191. * Please note that setting this value will force the connection point to ignore the value property
  53192. */
  53193. valueCallback: () => any;
  53194. /**
  53195. * Gets or sets the associated variable name in the shader
  53196. */
  53197. associatedVariableName: string;
  53198. /** Gets or sets the type of animation applied to the input */
  53199. animationType: AnimatedInputBlockTypes;
  53200. /**
  53201. * Gets a boolean indicating that this connection point not defined yet
  53202. */
  53203. readonly isUndefined: boolean;
  53204. /**
  53205. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53206. * In this case the connection point name must be the name of the uniform to use.
  53207. * Can only be set on inputs
  53208. */
  53209. isUniform: boolean;
  53210. /**
  53211. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53212. * In this case the connection point name must be the name of the attribute to use
  53213. * Can only be set on inputs
  53214. */
  53215. isAttribute: boolean;
  53216. /**
  53217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53218. * Can only be set on exit points
  53219. */
  53220. isVarying: boolean;
  53221. /**
  53222. * Gets a boolean indicating that the current connection point is a system value
  53223. */
  53224. readonly isSystemValue: boolean;
  53225. /**
  53226. * Gets or sets the current well known value or null if not defined as a system value
  53227. */
  53228. systemValue: Nullable<NodeMaterialSystemValues>;
  53229. /**
  53230. * Gets the current class name
  53231. * @returns the class name
  53232. */
  53233. getClassName(): string;
  53234. /**
  53235. * Animate the input if animationType !== None
  53236. * @param scene defines the rendering scene
  53237. */
  53238. animate(scene: Scene): void;
  53239. private _emitDefine;
  53240. initialize(state: NodeMaterialBuildState): void;
  53241. /**
  53242. * Set the input block to its default value (based on its type)
  53243. */
  53244. setDefaultValue(): void;
  53245. private _emitConstant;
  53246. private _emit;
  53247. /** @hidden */
  53248. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53249. /** @hidden */
  53250. _transmit(effect: Effect, scene: Scene): void;
  53251. protected _buildBlock(state: NodeMaterialBuildState): void;
  53252. protected _dumpPropertiesCode(): string;
  53253. serialize(): any;
  53254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53255. }
  53256. }
  53257. declare module BABYLON {
  53258. /**
  53259. * Defines a connection point for a block
  53260. */
  53261. export class NodeMaterialConnectionPoint {
  53262. /** @hidden */
  53263. _ownerBlock: NodeMaterialBlock;
  53264. /** @hidden */
  53265. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53266. private _endpoints;
  53267. private _associatedVariableName;
  53268. /** @hidden */
  53269. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53270. /** @hidden */
  53271. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53272. private _type;
  53273. /** @hidden */
  53274. _enforceAssociatedVariableName: boolean;
  53275. /**
  53276. * Gets or sets the additional types supported by this connection point
  53277. */
  53278. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53279. /**
  53280. * Gets or sets the additional types excluded by this connection point
  53281. */
  53282. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53283. /**
  53284. * Gets or sets the associated variable name in the shader
  53285. */
  53286. associatedVariableName: string;
  53287. /**
  53288. * Gets or sets the connection point type (default is float)
  53289. */
  53290. type: NodeMaterialBlockConnectionPointTypes;
  53291. /**
  53292. * Gets or sets the connection point name
  53293. */
  53294. name: string;
  53295. /**
  53296. * Gets or sets a boolean indicating that this connection point can be omitted
  53297. */
  53298. isOptional: boolean;
  53299. /**
  53300. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53301. */
  53302. define: string;
  53303. /** Gets or sets the target of that connection point */
  53304. target: NodeMaterialBlockTargets;
  53305. /**
  53306. * Gets a boolean indicating that the current point is connected
  53307. */
  53308. readonly isConnected: boolean;
  53309. /**
  53310. * Gets a boolean indicating that the current point is connected to an input block
  53311. */
  53312. readonly isConnectedToInputBlock: boolean;
  53313. /**
  53314. * Gets a the connected input block (if any)
  53315. */
  53316. readonly connectInputBlock: Nullable<InputBlock>;
  53317. /** Get the other side of the connection (if any) */
  53318. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53319. /** Get the block that owns this connection point */
  53320. readonly ownerBlock: NodeMaterialBlock;
  53321. /** Get the block connected on the other side of this connection (if any) */
  53322. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53323. /** Get the block connected on the endpoints of this connection (if any) */
  53324. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53325. /** Gets the list of connected endpoints */
  53326. readonly endpoints: NodeMaterialConnectionPoint[];
  53327. /** Gets a boolean indicating if that output point is connected to at least one input */
  53328. readonly hasEndpoints: boolean;
  53329. /**
  53330. * Creates a new connection point
  53331. * @param name defines the connection point name
  53332. * @param ownerBlock defines the block hosting this connection point
  53333. */
  53334. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53335. /**
  53336. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53337. * @returns the class name
  53338. */
  53339. getClassName(): string;
  53340. /**
  53341. * Gets an boolean indicating if the current point can be connected to another point
  53342. * @param connectionPoint defines the other connection point
  53343. * @returns true if the connection is possible
  53344. */
  53345. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53346. /**
  53347. * Connect this point to another connection point
  53348. * @param connectionPoint defines the other connection point
  53349. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53350. * @returns the current connection point
  53351. */
  53352. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53353. /**
  53354. * Disconnect this point from one of his endpoint
  53355. * @param endpoint defines the other connection point
  53356. * @returns the current connection point
  53357. */
  53358. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53359. /**
  53360. * Serializes this point in a JSON representation
  53361. * @returns the serialized point object
  53362. */
  53363. serialize(): any;
  53364. }
  53365. }
  53366. declare module BABYLON {
  53367. /**
  53368. * Block used to add support for vertex skinning (bones)
  53369. */
  53370. export class BonesBlock extends NodeMaterialBlock {
  53371. /**
  53372. * Creates a new BonesBlock
  53373. * @param name defines the block name
  53374. */
  53375. constructor(name: string);
  53376. /**
  53377. * Initialize the block and prepare the context for build
  53378. * @param state defines the state that will be used for the build
  53379. */
  53380. initialize(state: NodeMaterialBuildState): void;
  53381. /**
  53382. * Gets the current class name
  53383. * @returns the class name
  53384. */
  53385. getClassName(): string;
  53386. /**
  53387. * Gets the matrix indices input component
  53388. */
  53389. readonly matricesIndices: NodeMaterialConnectionPoint;
  53390. /**
  53391. * Gets the matrix weights input component
  53392. */
  53393. readonly matricesWeights: NodeMaterialConnectionPoint;
  53394. /**
  53395. * Gets the extra matrix indices input component
  53396. */
  53397. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53398. /**
  53399. * Gets the extra matrix weights input component
  53400. */
  53401. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53402. /**
  53403. * Gets the world input component
  53404. */
  53405. readonly world: NodeMaterialConnectionPoint;
  53406. /**
  53407. * Gets the output component
  53408. */
  53409. readonly output: NodeMaterialConnectionPoint;
  53410. autoConfigure(material: NodeMaterial): void;
  53411. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53414. protected _buildBlock(state: NodeMaterialBuildState): this;
  53415. }
  53416. }
  53417. declare module BABYLON {
  53418. /**
  53419. * Block used to add support for instances
  53420. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53421. */
  53422. export class InstancesBlock extends NodeMaterialBlock {
  53423. /**
  53424. * Creates a new InstancesBlock
  53425. * @param name defines the block name
  53426. */
  53427. constructor(name: string);
  53428. /**
  53429. * Gets the current class name
  53430. * @returns the class name
  53431. */
  53432. getClassName(): string;
  53433. /**
  53434. * Gets the first world row input component
  53435. */
  53436. readonly world0: NodeMaterialConnectionPoint;
  53437. /**
  53438. * Gets the second world row input component
  53439. */
  53440. readonly world1: NodeMaterialConnectionPoint;
  53441. /**
  53442. * Gets the third world row input component
  53443. */
  53444. readonly world2: NodeMaterialConnectionPoint;
  53445. /**
  53446. * Gets the forth world row input component
  53447. */
  53448. readonly world3: NodeMaterialConnectionPoint;
  53449. /**
  53450. * Gets the world input component
  53451. */
  53452. readonly world: NodeMaterialConnectionPoint;
  53453. /**
  53454. * Gets the output component
  53455. */
  53456. readonly output: NodeMaterialConnectionPoint;
  53457. autoConfigure(material: NodeMaterial): void;
  53458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53459. protected _buildBlock(state: NodeMaterialBuildState): this;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. /**
  53464. * Block used to add morph targets support to vertex shader
  53465. */
  53466. export class MorphTargetsBlock extends NodeMaterialBlock {
  53467. private _repeatableContentAnchor;
  53468. private _repeatebleContentGenerated;
  53469. /**
  53470. * Create a new MorphTargetsBlock
  53471. * @param name defines the block name
  53472. */
  53473. constructor(name: string);
  53474. /**
  53475. * Gets the current class name
  53476. * @returns the class name
  53477. */
  53478. getClassName(): string;
  53479. /**
  53480. * Gets the position input component
  53481. */
  53482. readonly position: NodeMaterialConnectionPoint;
  53483. /**
  53484. * Gets the normal input component
  53485. */
  53486. readonly normal: NodeMaterialConnectionPoint;
  53487. /**
  53488. * Gets the tangent input component
  53489. */
  53490. readonly tangent: NodeMaterialConnectionPoint;
  53491. /**
  53492. * Gets the tangent input component
  53493. */
  53494. readonly uv: NodeMaterialConnectionPoint;
  53495. /**
  53496. * Gets the position output component
  53497. */
  53498. readonly positionOutput: NodeMaterialConnectionPoint;
  53499. /**
  53500. * Gets the normal output component
  53501. */
  53502. readonly normalOutput: NodeMaterialConnectionPoint;
  53503. /**
  53504. * Gets the tangent output component
  53505. */
  53506. readonly tangentOutput: NodeMaterialConnectionPoint;
  53507. /**
  53508. * Gets the tangent output component
  53509. */
  53510. readonly uvOutput: NodeMaterialConnectionPoint;
  53511. initialize(state: NodeMaterialBuildState): void;
  53512. autoConfigure(material: NodeMaterial): void;
  53513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53514. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53515. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53516. protected _buildBlock(state: NodeMaterialBuildState): this;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. /**
  53521. * Block used to get data information from a light
  53522. */
  53523. export class LightInformationBlock extends NodeMaterialBlock {
  53524. private _lightDataUniformName;
  53525. private _lightColorUniformName;
  53526. private _lightTypeDefineName;
  53527. /**
  53528. * Gets or sets the light associated with this block
  53529. */
  53530. light: Nullable<Light>;
  53531. /**
  53532. * Creates a new LightInformationBlock
  53533. * @param name defines the block name
  53534. */
  53535. constructor(name: string);
  53536. /**
  53537. * Gets the current class name
  53538. * @returns the class name
  53539. */
  53540. getClassName(): string;
  53541. /**
  53542. * Gets the world position input component
  53543. */
  53544. readonly worldPosition: NodeMaterialConnectionPoint;
  53545. /**
  53546. * Gets the direction output component
  53547. */
  53548. readonly direction: NodeMaterialConnectionPoint;
  53549. /**
  53550. * Gets the direction output component
  53551. */
  53552. readonly color: NodeMaterialConnectionPoint;
  53553. /**
  53554. * Gets the direction output component
  53555. */
  53556. readonly intensity: NodeMaterialConnectionPoint;
  53557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53559. protected _buildBlock(state: NodeMaterialBuildState): this;
  53560. serialize(): any;
  53561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53562. }
  53563. }
  53564. declare module BABYLON {
  53565. /**
  53566. * Block used to add image processing support to fragment shader
  53567. */
  53568. export class ImageProcessingBlock extends NodeMaterialBlock {
  53569. /**
  53570. * Create a new ImageProcessingBlock
  53571. * @param name defines the block name
  53572. */
  53573. constructor(name: string);
  53574. /**
  53575. * Gets the current class name
  53576. * @returns the class name
  53577. */
  53578. getClassName(): string;
  53579. /**
  53580. * Gets the color input component
  53581. */
  53582. readonly color: NodeMaterialConnectionPoint;
  53583. /**
  53584. * Gets the output component
  53585. */
  53586. readonly output: NodeMaterialConnectionPoint;
  53587. /**
  53588. * Initialize the block and prepare the context for build
  53589. * @param state defines the state that will be used for the build
  53590. */
  53591. initialize(state: NodeMaterialBuildState): void;
  53592. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53595. protected _buildBlock(state: NodeMaterialBuildState): this;
  53596. }
  53597. }
  53598. declare module BABYLON {
  53599. /**
  53600. * Block used to pertub normals based on a normal map
  53601. */
  53602. export class PerturbNormalBlock extends NodeMaterialBlock {
  53603. private _tangentSpaceParameterName;
  53604. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53605. invertX: boolean;
  53606. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53607. invertY: boolean;
  53608. /**
  53609. * Create a new PerturbNormalBlock
  53610. * @param name defines the block name
  53611. */
  53612. constructor(name: string);
  53613. /**
  53614. * Gets the current class name
  53615. * @returns the class name
  53616. */
  53617. getClassName(): string;
  53618. /**
  53619. * Gets the world position input component
  53620. */
  53621. readonly worldPosition: NodeMaterialConnectionPoint;
  53622. /**
  53623. * Gets the world normal input component
  53624. */
  53625. readonly worldNormal: NodeMaterialConnectionPoint;
  53626. /**
  53627. * Gets the uv input component
  53628. */
  53629. readonly uv: NodeMaterialConnectionPoint;
  53630. /**
  53631. * Gets the normal map color input component
  53632. */
  53633. readonly normalMapColor: NodeMaterialConnectionPoint;
  53634. /**
  53635. * Gets the strength input component
  53636. */
  53637. readonly strength: NodeMaterialConnectionPoint;
  53638. /**
  53639. * Gets the output component
  53640. */
  53641. readonly output: NodeMaterialConnectionPoint;
  53642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53644. autoConfigure(material: NodeMaterial): void;
  53645. protected _buildBlock(state: NodeMaterialBuildState): this;
  53646. protected _dumpPropertiesCode(): string;
  53647. serialize(): any;
  53648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /**
  53653. * Block used to discard a pixel if a value is smaller than a cutoff
  53654. */
  53655. export class DiscardBlock extends NodeMaterialBlock {
  53656. /**
  53657. * Create a new DiscardBlock
  53658. * @param name defines the block name
  53659. */
  53660. constructor(name: string);
  53661. /**
  53662. * Gets the current class name
  53663. * @returns the class name
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Gets the color input component
  53668. */
  53669. readonly value: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the cutoff input component
  53672. */
  53673. readonly cutoff: NodeMaterialConnectionPoint;
  53674. protected _buildBlock(state: NodeMaterialBuildState): this;
  53675. }
  53676. }
  53677. declare module BABYLON {
  53678. /**
  53679. * Block used to add support for scene fog
  53680. */
  53681. export class FogBlock extends NodeMaterialBlock {
  53682. private _fogDistanceName;
  53683. private _fogParameters;
  53684. /**
  53685. * Create a new FogBlock
  53686. * @param name defines the block name
  53687. */
  53688. constructor(name: string);
  53689. /**
  53690. * Gets the current class name
  53691. * @returns the class name
  53692. */
  53693. getClassName(): string;
  53694. /**
  53695. * Gets the world position input component
  53696. */
  53697. readonly worldPosition: NodeMaterialConnectionPoint;
  53698. /**
  53699. * Gets the view input component
  53700. */
  53701. readonly view: NodeMaterialConnectionPoint;
  53702. /**
  53703. * Gets the color input component
  53704. */
  53705. readonly input: NodeMaterialConnectionPoint;
  53706. /**
  53707. * Gets the fog color input component
  53708. */
  53709. readonly fogColor: NodeMaterialConnectionPoint;
  53710. /**
  53711. * Gets the output component
  53712. */
  53713. readonly output: NodeMaterialConnectionPoint;
  53714. autoConfigure(material: NodeMaterial): void;
  53715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53716. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53717. protected _buildBlock(state: NodeMaterialBuildState): this;
  53718. }
  53719. }
  53720. declare module BABYLON {
  53721. /**
  53722. * Block used to add light in the fragment shader
  53723. */
  53724. export class LightBlock extends NodeMaterialBlock {
  53725. private _lightId;
  53726. /**
  53727. * Gets or sets the light associated with this block
  53728. */
  53729. light: Nullable<Light>;
  53730. /**
  53731. * Create a new LightBlock
  53732. * @param name defines the block name
  53733. */
  53734. constructor(name: string);
  53735. /**
  53736. * Gets the current class name
  53737. * @returns the class name
  53738. */
  53739. getClassName(): string;
  53740. /**
  53741. * Gets the world position input component
  53742. */
  53743. readonly worldPosition: NodeMaterialConnectionPoint;
  53744. /**
  53745. * Gets the world normal input component
  53746. */
  53747. readonly worldNormal: NodeMaterialConnectionPoint;
  53748. /**
  53749. * Gets the camera (or eye) position component
  53750. */
  53751. readonly cameraPosition: NodeMaterialConnectionPoint;
  53752. /**
  53753. * Gets the diffuse output component
  53754. */
  53755. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53756. /**
  53757. * Gets the specular output component
  53758. */
  53759. readonly specularOutput: NodeMaterialConnectionPoint;
  53760. autoConfigure(material: NodeMaterial): void;
  53761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53762. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53764. private _injectVertexCode;
  53765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53766. serialize(): any;
  53767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53768. }
  53769. }
  53770. declare module BABYLON {
  53771. /**
  53772. * Block used to multiply 2 values
  53773. */
  53774. export class MultiplyBlock extends NodeMaterialBlock {
  53775. /**
  53776. * Creates a new MultiplyBlock
  53777. * @param name defines the block name
  53778. */
  53779. constructor(name: string);
  53780. /**
  53781. * Gets the current class name
  53782. * @returns the class name
  53783. */
  53784. getClassName(): string;
  53785. /**
  53786. * Gets the left operand input component
  53787. */
  53788. readonly left: NodeMaterialConnectionPoint;
  53789. /**
  53790. * Gets the right operand input component
  53791. */
  53792. readonly right: NodeMaterialConnectionPoint;
  53793. /**
  53794. * Gets the output component
  53795. */
  53796. readonly output: NodeMaterialConnectionPoint;
  53797. protected _buildBlock(state: NodeMaterialBuildState): this;
  53798. }
  53799. }
  53800. declare module BABYLON {
  53801. /**
  53802. * Block used to add 2 vectors
  53803. */
  53804. export class AddBlock extends NodeMaterialBlock {
  53805. /**
  53806. * Creates a new AddBlock
  53807. * @param name defines the block name
  53808. */
  53809. constructor(name: string);
  53810. /**
  53811. * Gets the current class name
  53812. * @returns the class name
  53813. */
  53814. getClassName(): string;
  53815. /**
  53816. * Gets the left operand input component
  53817. */
  53818. readonly left: NodeMaterialConnectionPoint;
  53819. /**
  53820. * Gets the right operand input component
  53821. */
  53822. readonly right: NodeMaterialConnectionPoint;
  53823. /**
  53824. * Gets the output component
  53825. */
  53826. readonly output: NodeMaterialConnectionPoint;
  53827. protected _buildBlock(state: NodeMaterialBuildState): this;
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. /**
  53832. * Block used to scale a vector by a float
  53833. */
  53834. export class ScaleBlock extends NodeMaterialBlock {
  53835. /**
  53836. * Creates a new ScaleBlock
  53837. * @param name defines the block name
  53838. */
  53839. constructor(name: string);
  53840. /**
  53841. * Gets the current class name
  53842. * @returns the class name
  53843. */
  53844. getClassName(): string;
  53845. /**
  53846. * Gets the input component
  53847. */
  53848. readonly input: NodeMaterialConnectionPoint;
  53849. /**
  53850. * Gets the factor input component
  53851. */
  53852. readonly factor: NodeMaterialConnectionPoint;
  53853. /**
  53854. * Gets the output component
  53855. */
  53856. readonly output: NodeMaterialConnectionPoint;
  53857. protected _buildBlock(state: NodeMaterialBuildState): this;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * Block used to clamp a float
  53863. */
  53864. export class ClampBlock extends NodeMaterialBlock {
  53865. /** Gets or sets the minimum range */
  53866. minimum: number;
  53867. /** Gets or sets the maximum range */
  53868. maximum: number;
  53869. /**
  53870. * Creates a new ClampBlock
  53871. * @param name defines the block name
  53872. */
  53873. constructor(name: string);
  53874. /**
  53875. * Gets the current class name
  53876. * @returns the class name
  53877. */
  53878. getClassName(): string;
  53879. /**
  53880. * Gets the value input component
  53881. */
  53882. readonly value: NodeMaterialConnectionPoint;
  53883. /**
  53884. * Gets the output component
  53885. */
  53886. readonly output: NodeMaterialConnectionPoint;
  53887. protected _buildBlock(state: NodeMaterialBuildState): this;
  53888. protected _dumpPropertiesCode(): string;
  53889. serialize(): any;
  53890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53891. }
  53892. }
  53893. declare module BABYLON {
  53894. /**
  53895. * Block used to apply a cross product between 2 vectors
  53896. */
  53897. export class CrossBlock extends NodeMaterialBlock {
  53898. /**
  53899. * Creates a new CrossBlock
  53900. * @param name defines the block name
  53901. */
  53902. constructor(name: string);
  53903. /**
  53904. * Gets the current class name
  53905. * @returns the class name
  53906. */
  53907. getClassName(): string;
  53908. /**
  53909. * Gets the left operand input component
  53910. */
  53911. readonly left: NodeMaterialConnectionPoint;
  53912. /**
  53913. * Gets the right operand input component
  53914. */
  53915. readonly right: NodeMaterialConnectionPoint;
  53916. /**
  53917. * Gets the output component
  53918. */
  53919. readonly output: NodeMaterialConnectionPoint;
  53920. protected _buildBlock(state: NodeMaterialBuildState): this;
  53921. }
  53922. }
  53923. declare module BABYLON {
  53924. /**
  53925. * Block used to apply a dot product between 2 vectors
  53926. */
  53927. export class DotBlock extends NodeMaterialBlock {
  53928. /**
  53929. * Creates a new DotBlock
  53930. * @param name defines the block name
  53931. */
  53932. constructor(name: string);
  53933. /**
  53934. * Gets the current class name
  53935. * @returns the class name
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Gets the left operand input component
  53940. */
  53941. readonly left: NodeMaterialConnectionPoint;
  53942. /**
  53943. * Gets the right operand input component
  53944. */
  53945. readonly right: NodeMaterialConnectionPoint;
  53946. /**
  53947. * Gets the output component
  53948. */
  53949. readonly output: NodeMaterialConnectionPoint;
  53950. protected _buildBlock(state: NodeMaterialBuildState): this;
  53951. }
  53952. }
  53953. declare module BABYLON {
  53954. /**
  53955. * Block used to remap a float from a range to a new one
  53956. */
  53957. export class RemapBlock extends NodeMaterialBlock {
  53958. /**
  53959. * Gets or sets the source range
  53960. */
  53961. sourceRange: Vector2;
  53962. /**
  53963. * Gets or sets the target range
  53964. */
  53965. targetRange: Vector2;
  53966. /**
  53967. * Creates a new RemapBlock
  53968. * @param name defines the block name
  53969. */
  53970. constructor(name: string);
  53971. /**
  53972. * Gets the current class name
  53973. * @returns the class name
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Gets the input component
  53978. */
  53979. readonly input: NodeMaterialConnectionPoint;
  53980. /**
  53981. * Gets the source min input component
  53982. */
  53983. readonly sourceMin: NodeMaterialConnectionPoint;
  53984. /**
  53985. * Gets the source max input component
  53986. */
  53987. readonly sourceMax: NodeMaterialConnectionPoint;
  53988. /**
  53989. * Gets the target min input component
  53990. */
  53991. readonly targetMin: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the target max input component
  53994. */
  53995. readonly targetMax: NodeMaterialConnectionPoint;
  53996. /**
  53997. * Gets the output component
  53998. */
  53999. readonly output: NodeMaterialConnectionPoint;
  54000. protected _buildBlock(state: NodeMaterialBuildState): this;
  54001. protected _dumpPropertiesCode(): string;
  54002. serialize(): any;
  54003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54004. }
  54005. }
  54006. declare module BABYLON {
  54007. /**
  54008. * Block used to normalize a vector
  54009. */
  54010. export class NormalizeBlock extends NodeMaterialBlock {
  54011. /**
  54012. * Creates a new NormalizeBlock
  54013. * @param name defines the block name
  54014. */
  54015. constructor(name: string);
  54016. /**
  54017. * Gets the current class name
  54018. * @returns the class name
  54019. */
  54020. getClassName(): string;
  54021. /**
  54022. * Gets the input component
  54023. */
  54024. readonly input: NodeMaterialConnectionPoint;
  54025. /**
  54026. * Gets the output component
  54027. */
  54028. readonly output: NodeMaterialConnectionPoint;
  54029. protected _buildBlock(state: NodeMaterialBuildState): this;
  54030. }
  54031. }
  54032. declare module BABYLON {
  54033. /**
  54034. * Operations supported by the Trigonometry block
  54035. */
  54036. export enum TrigonometryBlockOperations {
  54037. /** Cos */
  54038. Cos = 0,
  54039. /** Sin */
  54040. Sin = 1,
  54041. /** Abs */
  54042. Abs = 2,
  54043. /** Exp */
  54044. Exp = 3,
  54045. /** Exp2 */
  54046. Exp2 = 4,
  54047. /** Round */
  54048. Round = 5,
  54049. /** Floor */
  54050. Floor = 6,
  54051. /** Ceiling */
  54052. Ceiling = 7,
  54053. /** Square root */
  54054. Sqrt = 8
  54055. }
  54056. /**
  54057. * Block used to apply trigonometry operation to floats
  54058. */
  54059. export class TrigonometryBlock extends NodeMaterialBlock {
  54060. /**
  54061. * Gets or sets the operation applied by the block
  54062. */
  54063. operation: TrigonometryBlockOperations;
  54064. /**
  54065. * Creates a new TrigonometryBlock
  54066. * @param name defines the block name
  54067. */
  54068. constructor(name: string);
  54069. /**
  54070. * Gets the current class name
  54071. * @returns the class name
  54072. */
  54073. getClassName(): string;
  54074. /**
  54075. * Gets the input component
  54076. */
  54077. readonly input: NodeMaterialConnectionPoint;
  54078. /**
  54079. * Gets the output component
  54080. */
  54081. readonly output: NodeMaterialConnectionPoint;
  54082. protected _buildBlock(state: NodeMaterialBuildState): this;
  54083. serialize(): any;
  54084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54085. }
  54086. }
  54087. declare module BABYLON {
  54088. /**
  54089. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54090. */
  54091. export class ColorMergerBlock extends NodeMaterialBlock {
  54092. /**
  54093. * Create a new ColorMergerBlock
  54094. * @param name defines the block name
  54095. */
  54096. constructor(name: string);
  54097. /**
  54098. * Gets the current class name
  54099. * @returns the class name
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Gets the r component (input)
  54104. */
  54105. readonly r: NodeMaterialConnectionPoint;
  54106. /**
  54107. * Gets the g component (input)
  54108. */
  54109. readonly g: NodeMaterialConnectionPoint;
  54110. /**
  54111. * Gets the b component (input)
  54112. */
  54113. readonly b: NodeMaterialConnectionPoint;
  54114. /**
  54115. * Gets the a component (input)
  54116. */
  54117. readonly a: NodeMaterialConnectionPoint;
  54118. /**
  54119. * Gets the rgba component (output)
  54120. */
  54121. readonly rgba: NodeMaterialConnectionPoint;
  54122. /**
  54123. * Gets the rgb component (output)
  54124. */
  54125. readonly rgb: NodeMaterialConnectionPoint;
  54126. protected _buildBlock(state: NodeMaterialBuildState): this;
  54127. }
  54128. }
  54129. declare module BABYLON {
  54130. /**
  54131. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54132. */
  54133. export class VectorMergerBlock extends NodeMaterialBlock {
  54134. /**
  54135. * Create a new VectorMergerBlock
  54136. * @param name defines the block name
  54137. */
  54138. constructor(name: string);
  54139. /**
  54140. * Gets the current class name
  54141. * @returns the class name
  54142. */
  54143. getClassName(): string;
  54144. /**
  54145. * Gets the x component (input)
  54146. */
  54147. readonly x: NodeMaterialConnectionPoint;
  54148. /**
  54149. * Gets the y component (input)
  54150. */
  54151. readonly y: NodeMaterialConnectionPoint;
  54152. /**
  54153. * Gets the z component (input)
  54154. */
  54155. readonly z: NodeMaterialConnectionPoint;
  54156. /**
  54157. * Gets the w component (input)
  54158. */
  54159. readonly w: NodeMaterialConnectionPoint;
  54160. /**
  54161. * Gets the xyzw component (output)
  54162. */
  54163. readonly xyzw: NodeMaterialConnectionPoint;
  54164. /**
  54165. * Gets the xyz component (output)
  54166. */
  54167. readonly xyz: NodeMaterialConnectionPoint;
  54168. /**
  54169. * Gets the xy component (output)
  54170. */
  54171. readonly xy: NodeMaterialConnectionPoint;
  54172. protected _buildBlock(state: NodeMaterialBuildState): this;
  54173. }
  54174. }
  54175. declare module BABYLON {
  54176. /**
  54177. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54178. */
  54179. export class ColorSplitterBlock extends NodeMaterialBlock {
  54180. /**
  54181. * Create a new ColorSplitterBlock
  54182. * @param name defines the block name
  54183. */
  54184. constructor(name: string);
  54185. /**
  54186. * Gets the current class name
  54187. * @returns the class name
  54188. */
  54189. getClassName(): string;
  54190. /**
  54191. * Gets the rgba component (input)
  54192. */
  54193. readonly rgba: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the rgb component (input)
  54196. */
  54197. readonly rgbIn: NodeMaterialConnectionPoint;
  54198. /**
  54199. * Gets the rgb component (output)
  54200. */
  54201. readonly rgbOut: NodeMaterialConnectionPoint;
  54202. /**
  54203. * Gets the r component (output)
  54204. */
  54205. readonly r: NodeMaterialConnectionPoint;
  54206. /**
  54207. * Gets the g component (output)
  54208. */
  54209. readonly g: NodeMaterialConnectionPoint;
  54210. /**
  54211. * Gets the b component (output)
  54212. */
  54213. readonly b: NodeMaterialConnectionPoint;
  54214. /**
  54215. * Gets the a component (output)
  54216. */
  54217. readonly a: NodeMaterialConnectionPoint;
  54218. protected _inputRename(name: string): string;
  54219. protected _outputRename(name: string): string;
  54220. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54221. }
  54222. }
  54223. declare module BABYLON {
  54224. /**
  54225. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54226. */
  54227. export class VectorSplitterBlock extends NodeMaterialBlock {
  54228. /**
  54229. * Create a new VectorSplitterBlock
  54230. * @param name defines the block name
  54231. */
  54232. constructor(name: string);
  54233. /**
  54234. * Gets the current class name
  54235. * @returns the class name
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Gets the xyzw component (input)
  54240. */
  54241. readonly xyzw: NodeMaterialConnectionPoint;
  54242. /**
  54243. * Gets the xyz component (input)
  54244. */
  54245. readonly xyzIn: NodeMaterialConnectionPoint;
  54246. /**
  54247. * Gets the xy component (input)
  54248. */
  54249. readonly xyIn: NodeMaterialConnectionPoint;
  54250. /**
  54251. * Gets the xyz component (output)
  54252. */
  54253. readonly xyzOut: NodeMaterialConnectionPoint;
  54254. /**
  54255. * Gets the xy component (output)
  54256. */
  54257. readonly xyOut: NodeMaterialConnectionPoint;
  54258. /**
  54259. * Gets the x component (output)
  54260. */
  54261. readonly x: NodeMaterialConnectionPoint;
  54262. /**
  54263. * Gets the y component (output)
  54264. */
  54265. readonly y: NodeMaterialConnectionPoint;
  54266. /**
  54267. * Gets the z component (output)
  54268. */
  54269. readonly z: NodeMaterialConnectionPoint;
  54270. /**
  54271. * Gets the w component (output)
  54272. */
  54273. readonly w: NodeMaterialConnectionPoint;
  54274. protected _inputRename(name: string): string;
  54275. protected _outputRename(name: string): string;
  54276. protected _buildBlock(state: NodeMaterialBuildState): this;
  54277. }
  54278. }
  54279. declare module BABYLON {
  54280. /**
  54281. * Block used to lerp 2 values
  54282. */
  54283. export class LerpBlock extends NodeMaterialBlock {
  54284. /**
  54285. * Creates a new LerpBlock
  54286. * @param name defines the block name
  54287. */
  54288. constructor(name: string);
  54289. /**
  54290. * Gets the current class name
  54291. * @returns the class name
  54292. */
  54293. getClassName(): string;
  54294. /**
  54295. * Gets the left operand input component
  54296. */
  54297. readonly left: NodeMaterialConnectionPoint;
  54298. /**
  54299. * Gets the right operand input component
  54300. */
  54301. readonly right: NodeMaterialConnectionPoint;
  54302. /**
  54303. * Gets the gradient operand input component
  54304. */
  54305. readonly gradient: NodeMaterialConnectionPoint;
  54306. /**
  54307. * Gets the output component
  54308. */
  54309. readonly output: NodeMaterialConnectionPoint;
  54310. protected _buildBlock(state: NodeMaterialBuildState): this;
  54311. }
  54312. }
  54313. declare module BABYLON {
  54314. /**
  54315. * Block used to divide 2 vectors
  54316. */
  54317. export class DivideBlock extends NodeMaterialBlock {
  54318. /**
  54319. * Creates a new DivideBlock
  54320. * @param name defines the block name
  54321. */
  54322. constructor(name: string);
  54323. /**
  54324. * Gets the current class name
  54325. * @returns the class name
  54326. */
  54327. getClassName(): string;
  54328. /**
  54329. * Gets the left operand input component
  54330. */
  54331. readonly left: NodeMaterialConnectionPoint;
  54332. /**
  54333. * Gets the right operand input component
  54334. */
  54335. readonly right: NodeMaterialConnectionPoint;
  54336. /**
  54337. * Gets the output component
  54338. */
  54339. readonly output: NodeMaterialConnectionPoint;
  54340. protected _buildBlock(state: NodeMaterialBuildState): this;
  54341. }
  54342. }
  54343. declare module BABYLON {
  54344. /**
  54345. * Block used to subtract 2 vectors
  54346. */
  54347. export class SubtractBlock extends NodeMaterialBlock {
  54348. /**
  54349. * Creates a new SubtractBlock
  54350. * @param name defines the block name
  54351. */
  54352. constructor(name: string);
  54353. /**
  54354. * Gets the current class name
  54355. * @returns the class name
  54356. */
  54357. getClassName(): string;
  54358. /**
  54359. * Gets the left operand input component
  54360. */
  54361. readonly left: NodeMaterialConnectionPoint;
  54362. /**
  54363. * Gets the right operand input component
  54364. */
  54365. readonly right: NodeMaterialConnectionPoint;
  54366. /**
  54367. * Gets the output component
  54368. */
  54369. readonly output: NodeMaterialConnectionPoint;
  54370. protected _buildBlock(state: NodeMaterialBuildState): this;
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /**
  54375. * Block used to step a value
  54376. */
  54377. export class StepBlock extends NodeMaterialBlock {
  54378. /**
  54379. * Creates a new AddBlock
  54380. * @param name defines the block name
  54381. */
  54382. constructor(name: string);
  54383. /**
  54384. * Gets the current class name
  54385. * @returns the class name
  54386. */
  54387. getClassName(): string;
  54388. /**
  54389. * Gets the value operand input component
  54390. */
  54391. readonly value: NodeMaterialConnectionPoint;
  54392. /**
  54393. * Gets the edge operand input component
  54394. */
  54395. readonly edge: NodeMaterialConnectionPoint;
  54396. /**
  54397. * Gets the output component
  54398. */
  54399. readonly output: NodeMaterialConnectionPoint;
  54400. protected _buildBlock(state: NodeMaterialBuildState): this;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Block used to get the opposite (1 - x) of a value
  54406. */
  54407. export class OneMinusBlock extends NodeMaterialBlock {
  54408. /**
  54409. * Creates a new OneMinusBlock
  54410. * @param name defines the block name
  54411. */
  54412. constructor(name: string);
  54413. /**
  54414. * Gets the current class name
  54415. * @returns the class name
  54416. */
  54417. getClassName(): string;
  54418. /**
  54419. * Gets the input component
  54420. */
  54421. readonly input: NodeMaterialConnectionPoint;
  54422. /**
  54423. * Gets the output component
  54424. */
  54425. readonly output: NodeMaterialConnectionPoint;
  54426. protected _buildBlock(state: NodeMaterialBuildState): this;
  54427. }
  54428. }
  54429. declare module BABYLON {
  54430. /**
  54431. * Block used to get the view direction
  54432. */
  54433. export class ViewDirectionBlock extends NodeMaterialBlock {
  54434. /**
  54435. * Creates a new ViewDirectionBlock
  54436. * @param name defines the block name
  54437. */
  54438. constructor(name: string);
  54439. /**
  54440. * Gets the current class name
  54441. * @returns the class name
  54442. */
  54443. getClassName(): string;
  54444. /**
  54445. * Gets the world position component
  54446. */
  54447. readonly worldPosition: NodeMaterialConnectionPoint;
  54448. /**
  54449. * Gets the camera position component
  54450. */
  54451. readonly cameraPosition: NodeMaterialConnectionPoint;
  54452. /**
  54453. * Gets the output component
  54454. */
  54455. readonly output: NodeMaterialConnectionPoint;
  54456. autoConfigure(material: NodeMaterial): void;
  54457. protected _buildBlock(state: NodeMaterialBuildState): this;
  54458. }
  54459. }
  54460. declare module BABYLON {
  54461. /**
  54462. * Block used to compute fresnel value
  54463. */
  54464. export class FresnelBlock extends NodeMaterialBlock {
  54465. /**
  54466. * Create a new FresnelBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the world normal input component
  54477. */
  54478. readonly worldNormal: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the view direction input component
  54481. */
  54482. readonly viewDirection: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the bias input component
  54485. */
  54486. readonly bias: NodeMaterialConnectionPoint;
  54487. /**
  54488. * Gets the camera (or eye) position component
  54489. */
  54490. readonly power: NodeMaterialConnectionPoint;
  54491. /**
  54492. * Gets the fresnel output component
  54493. */
  54494. readonly fresnel: NodeMaterialConnectionPoint;
  54495. autoConfigure(material: NodeMaterial): void;
  54496. protected _buildBlock(state: NodeMaterialBuildState): this;
  54497. }
  54498. }
  54499. declare module BABYLON {
  54500. /**
  54501. * Block used to get the max of 2 values
  54502. */
  54503. export class MaxBlock extends NodeMaterialBlock {
  54504. /**
  54505. * Creates a new MaxBlock
  54506. * @param name defines the block name
  54507. */
  54508. constructor(name: string);
  54509. /**
  54510. * Gets the current class name
  54511. * @returns the class name
  54512. */
  54513. getClassName(): string;
  54514. /**
  54515. * Gets the left operand input component
  54516. */
  54517. readonly left: NodeMaterialConnectionPoint;
  54518. /**
  54519. * Gets the right operand input component
  54520. */
  54521. readonly right: NodeMaterialConnectionPoint;
  54522. /**
  54523. * Gets the output component
  54524. */
  54525. readonly output: NodeMaterialConnectionPoint;
  54526. protected _buildBlock(state: NodeMaterialBuildState): this;
  54527. }
  54528. }
  54529. declare module BABYLON {
  54530. /**
  54531. * Block used to get the min of 2 values
  54532. */
  54533. export class MinBlock extends NodeMaterialBlock {
  54534. /**
  54535. * Creates a new MinBlock
  54536. * @param name defines the block name
  54537. */
  54538. constructor(name: string);
  54539. /**
  54540. * Gets the current class name
  54541. * @returns the class name
  54542. */
  54543. getClassName(): string;
  54544. /**
  54545. * Gets the left operand input component
  54546. */
  54547. readonly left: NodeMaterialConnectionPoint;
  54548. /**
  54549. * Gets the right operand input component
  54550. */
  54551. readonly right: NodeMaterialConnectionPoint;
  54552. /**
  54553. * Gets the output component
  54554. */
  54555. readonly output: NodeMaterialConnectionPoint;
  54556. protected _buildBlock(state: NodeMaterialBuildState): this;
  54557. }
  54558. }
  54559. declare module BABYLON {
  54560. /**
  54561. * Block used to get the distance between 2 values
  54562. */
  54563. export class DistanceBlock extends NodeMaterialBlock {
  54564. /**
  54565. * Creates a new DistanceBlock
  54566. * @param name defines the block name
  54567. */
  54568. constructor(name: string);
  54569. /**
  54570. * Gets the current class name
  54571. * @returns the class name
  54572. */
  54573. getClassName(): string;
  54574. /**
  54575. * Gets the left operand input component
  54576. */
  54577. readonly left: NodeMaterialConnectionPoint;
  54578. /**
  54579. * Gets the right operand input component
  54580. */
  54581. readonly right: NodeMaterialConnectionPoint;
  54582. /**
  54583. * Gets the output component
  54584. */
  54585. readonly output: NodeMaterialConnectionPoint;
  54586. protected _buildBlock(state: NodeMaterialBuildState): this;
  54587. }
  54588. }
  54589. declare module BABYLON {
  54590. /**
  54591. * Block used to get the length of a vector
  54592. */
  54593. export class LengthBlock extends NodeMaterialBlock {
  54594. /**
  54595. * Creates a new LengthBlock
  54596. * @param name defines the block name
  54597. */
  54598. constructor(name: string);
  54599. /**
  54600. * Gets the current class name
  54601. * @returns the class name
  54602. */
  54603. getClassName(): string;
  54604. /**
  54605. * Gets the value input component
  54606. */
  54607. readonly value: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the output component
  54610. */
  54611. readonly output: NodeMaterialConnectionPoint;
  54612. protected _buildBlock(state: NodeMaterialBuildState): this;
  54613. }
  54614. }
  54615. declare module BABYLON {
  54616. /**
  54617. * Block used to get negative version of a value (i.e. x * -1)
  54618. */
  54619. export class NegateBlock extends NodeMaterialBlock {
  54620. /**
  54621. * Creates a new NegateBlock
  54622. * @param name defines the block name
  54623. */
  54624. constructor(name: string);
  54625. /**
  54626. * Gets the current class name
  54627. * @returns the class name
  54628. */
  54629. getClassName(): string;
  54630. /**
  54631. * Gets the value input component
  54632. */
  54633. readonly value: NodeMaterialConnectionPoint;
  54634. /**
  54635. * Gets the output component
  54636. */
  54637. readonly output: NodeMaterialConnectionPoint;
  54638. protected _buildBlock(state: NodeMaterialBuildState): this;
  54639. }
  54640. }
  54641. declare module BABYLON {
  54642. /**
  54643. * Block used to get the value of the first parameter raised to the power of the second
  54644. */
  54645. export class PowBlock extends NodeMaterialBlock {
  54646. /**
  54647. * Creates a new PowBlock
  54648. * @param name defines the block name
  54649. */
  54650. constructor(name: string);
  54651. /**
  54652. * Gets the current class name
  54653. * @returns the class name
  54654. */
  54655. getClassName(): string;
  54656. /**
  54657. * Gets the value operand input component
  54658. */
  54659. readonly value: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the power operand input component
  54662. */
  54663. readonly power: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the output component
  54666. */
  54667. readonly output: NodeMaterialConnectionPoint;
  54668. protected _buildBlock(state: NodeMaterialBuildState): this;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Block used to get a random number
  54674. */
  54675. export class RandomNumberBlock extends NodeMaterialBlock {
  54676. /**
  54677. * Creates a new RandomNumberBlock
  54678. * @param name defines the block name
  54679. */
  54680. constructor(name: string);
  54681. /**
  54682. * Gets the current class name
  54683. * @returns the class name
  54684. */
  54685. getClassName(): string;
  54686. /**
  54687. * Gets the seed input component
  54688. */
  54689. readonly seed: NodeMaterialConnectionPoint;
  54690. /**
  54691. * Gets the output component
  54692. */
  54693. readonly output: NodeMaterialConnectionPoint;
  54694. protected _buildBlock(state: NodeMaterialBuildState): this;
  54695. }
  54696. }
  54697. declare module BABYLON {
  54698. /**
  54699. * Effect Render Options
  54700. */
  54701. export interface IEffectRendererOptions {
  54702. /**
  54703. * Defines the vertices positions.
  54704. */
  54705. positions?: number[];
  54706. /**
  54707. * Defines the indices.
  54708. */
  54709. indices?: number[];
  54710. }
  54711. /**
  54712. * Helper class to render one or more effects
  54713. */
  54714. export class EffectRenderer {
  54715. private engine;
  54716. private static _DefaultOptions;
  54717. private _vertexBuffers;
  54718. private _indexBuffer;
  54719. private _ringBufferIndex;
  54720. private _ringScreenBuffer;
  54721. private _fullscreenViewport;
  54722. private _getNextFrameBuffer;
  54723. /**
  54724. * Creates an effect renderer
  54725. * @param engine the engine to use for rendering
  54726. * @param options defines the options of the effect renderer
  54727. */
  54728. constructor(engine: Engine, options?: IEffectRendererOptions);
  54729. /**
  54730. * Sets the current viewport in normalized coordinates 0-1
  54731. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54732. */
  54733. setViewport(viewport?: Viewport): void;
  54734. /**
  54735. * Binds the embedded attributes buffer to the effect.
  54736. * @param effect Defines the effect to bind the attributes for
  54737. */
  54738. bindBuffers(effect: Effect): void;
  54739. /**
  54740. * Sets the current effect wrapper to use during draw.
  54741. * The effect needs to be ready before calling this api.
  54742. * This also sets the default full screen position attribute.
  54743. * @param effectWrapper Defines the effect to draw with
  54744. */
  54745. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54746. /**
  54747. * Draws a full screen quad.
  54748. */
  54749. draw(): void;
  54750. /**
  54751. * renders one or more effects to a specified texture
  54752. * @param effectWrappers list of effects to renderer
  54753. * @param outputTexture texture to draw to, if null it will render to the screen
  54754. */
  54755. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54756. /**
  54757. * Disposes of the effect renderer
  54758. */
  54759. dispose(): void;
  54760. }
  54761. /**
  54762. * Options to create an EffectWrapper
  54763. */
  54764. interface EffectWrapperCreationOptions {
  54765. /**
  54766. * Engine to use to create the effect
  54767. */
  54768. engine: Engine;
  54769. /**
  54770. * Fragment shader for the effect
  54771. */
  54772. fragmentShader: string;
  54773. /**
  54774. * Vertex shader for the effect
  54775. */
  54776. vertexShader?: string;
  54777. /**
  54778. * Attributes to use in the shader
  54779. */
  54780. attributeNames?: Array<string>;
  54781. /**
  54782. * Uniforms to use in the shader
  54783. */
  54784. uniformNames?: Array<string>;
  54785. /**
  54786. * Texture sampler names to use in the shader
  54787. */
  54788. samplerNames?: Array<string>;
  54789. /**
  54790. * The friendly name of the effect displayed in Spector.
  54791. */
  54792. name?: string;
  54793. }
  54794. /**
  54795. * Wraps an effect to be used for rendering
  54796. */
  54797. export class EffectWrapper {
  54798. /**
  54799. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54800. */
  54801. onApplyObservable: Observable<{}>;
  54802. /**
  54803. * The underlying effect
  54804. */
  54805. effect: Effect;
  54806. /**
  54807. * Creates an effect to be renderer
  54808. * @param creationOptions options to create the effect
  54809. */
  54810. constructor(creationOptions: EffectWrapperCreationOptions);
  54811. /**
  54812. * Disposes of the effect wrapper
  54813. */
  54814. dispose(): void;
  54815. }
  54816. }
  54817. declare module BABYLON {
  54818. /**
  54819. * Helper class to push actions to a pool of workers.
  54820. */
  54821. export class WorkerPool implements IDisposable {
  54822. private _workerInfos;
  54823. private _pendingActions;
  54824. /**
  54825. * Constructor
  54826. * @param workers Array of workers to use for actions
  54827. */
  54828. constructor(workers: Array<Worker>);
  54829. /**
  54830. * Terminates all workers and clears any pending actions.
  54831. */
  54832. dispose(): void;
  54833. /**
  54834. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54835. * pended until a worker has completed its action.
  54836. * @param action The action to perform. Call onComplete when the action is complete.
  54837. */
  54838. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54839. private _execute;
  54840. }
  54841. }
  54842. declare module BABYLON {
  54843. /**
  54844. * Configuration for Draco compression
  54845. */
  54846. export interface IDracoCompressionConfiguration {
  54847. /**
  54848. * Configuration for the decoder.
  54849. */
  54850. decoder: {
  54851. /**
  54852. * The url to the WebAssembly module.
  54853. */
  54854. wasmUrl?: string;
  54855. /**
  54856. * The url to the WebAssembly binary.
  54857. */
  54858. wasmBinaryUrl?: string;
  54859. /**
  54860. * The url to the fallback JavaScript module.
  54861. */
  54862. fallbackUrl?: string;
  54863. };
  54864. }
  54865. /**
  54866. * Draco compression (https://google.github.io/draco/)
  54867. *
  54868. * This class wraps the Draco module.
  54869. *
  54870. * **Encoder**
  54871. *
  54872. * The encoder is not currently implemented.
  54873. *
  54874. * **Decoder**
  54875. *
  54876. * 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.
  54877. *
  54878. * To update the configuration, use the following code:
  54879. * ```javascript
  54880. * DracoCompression.Configuration = {
  54881. * decoder: {
  54882. * wasmUrl: "<url to the WebAssembly library>",
  54883. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54884. * fallbackUrl: "<url to the fallback JavaScript library>",
  54885. * }
  54886. * };
  54887. * ```
  54888. *
  54889. * 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.
  54890. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54891. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54892. *
  54893. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54894. * ```javascript
  54895. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54896. * ```
  54897. *
  54898. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54899. */
  54900. export class DracoCompression implements IDisposable {
  54901. private _workerPoolPromise?;
  54902. private _decoderModulePromise?;
  54903. /**
  54904. * The configuration. Defaults to the following urls:
  54905. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54906. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54907. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54908. */
  54909. static Configuration: IDracoCompressionConfiguration;
  54910. /**
  54911. * Returns true if the decoder configuration is available.
  54912. */
  54913. static readonly DecoderAvailable: boolean;
  54914. /**
  54915. * Default number of workers to create when creating the draco compression object.
  54916. */
  54917. static DefaultNumWorkers: number;
  54918. private static GetDefaultNumWorkers;
  54919. private static _Default;
  54920. /**
  54921. * Default instance for the draco compression object.
  54922. */
  54923. static readonly Default: DracoCompression;
  54924. /**
  54925. * Constructor
  54926. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54927. */
  54928. constructor(numWorkers?: number);
  54929. /**
  54930. * Stop all async operations and release resources.
  54931. */
  54932. dispose(): void;
  54933. /**
  54934. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54935. * @returns a promise that resolves when ready
  54936. */
  54937. whenReadyAsync(): Promise<void>;
  54938. /**
  54939. * Decode Draco compressed mesh data to vertex data.
  54940. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54941. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54942. * @returns A promise that resolves with the decoded vertex data
  54943. */
  54944. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54945. [kind: string]: number;
  54946. }): Promise<VertexData>;
  54947. }
  54948. }
  54949. declare module BABYLON {
  54950. /**
  54951. * Class for building Constructive Solid Geometry
  54952. */
  54953. export class CSG {
  54954. private polygons;
  54955. /**
  54956. * The world matrix
  54957. */
  54958. matrix: Matrix;
  54959. /**
  54960. * Stores the position
  54961. */
  54962. position: Vector3;
  54963. /**
  54964. * Stores the rotation
  54965. */
  54966. rotation: Vector3;
  54967. /**
  54968. * Stores the rotation quaternion
  54969. */
  54970. rotationQuaternion: Nullable<Quaternion>;
  54971. /**
  54972. * Stores the scaling vector
  54973. */
  54974. scaling: Vector3;
  54975. /**
  54976. * Convert the Mesh to CSG
  54977. * @param mesh The Mesh to convert to CSG
  54978. * @returns A new CSG from the Mesh
  54979. */
  54980. static FromMesh(mesh: Mesh): CSG;
  54981. /**
  54982. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54983. * @param polygons Polygons used to construct a CSG solid
  54984. */
  54985. private static FromPolygons;
  54986. /**
  54987. * Clones, or makes a deep copy, of the CSG
  54988. * @returns A new CSG
  54989. */
  54990. clone(): CSG;
  54991. /**
  54992. * Unions this CSG with another CSG
  54993. * @param csg The CSG to union against this CSG
  54994. * @returns The unioned CSG
  54995. */
  54996. union(csg: CSG): CSG;
  54997. /**
  54998. * Unions this CSG with another CSG in place
  54999. * @param csg The CSG to union against this CSG
  55000. */
  55001. unionInPlace(csg: CSG): void;
  55002. /**
  55003. * Subtracts this CSG with another CSG
  55004. * @param csg The CSG to subtract against this CSG
  55005. * @returns A new CSG
  55006. */
  55007. subtract(csg: CSG): CSG;
  55008. /**
  55009. * Subtracts this CSG with another CSG in place
  55010. * @param csg The CSG to subtact against this CSG
  55011. */
  55012. subtractInPlace(csg: CSG): void;
  55013. /**
  55014. * Intersect this CSG with another CSG
  55015. * @param csg The CSG to intersect against this CSG
  55016. * @returns A new CSG
  55017. */
  55018. intersect(csg: CSG): CSG;
  55019. /**
  55020. * Intersects this CSG with another CSG in place
  55021. * @param csg The CSG to intersect against this CSG
  55022. */
  55023. intersectInPlace(csg: CSG): void;
  55024. /**
  55025. * Return a new CSG solid with solid and empty space switched. This solid is
  55026. * not modified.
  55027. * @returns A new CSG solid with solid and empty space switched
  55028. */
  55029. inverse(): CSG;
  55030. /**
  55031. * Inverses the CSG in place
  55032. */
  55033. inverseInPlace(): void;
  55034. /**
  55035. * This is used to keep meshes transformations so they can be restored
  55036. * when we build back a Babylon Mesh
  55037. * NB : All CSG operations are performed in world coordinates
  55038. * @param csg The CSG to copy the transform attributes from
  55039. * @returns This CSG
  55040. */
  55041. copyTransformAttributes(csg: CSG): CSG;
  55042. /**
  55043. * Build Raw mesh from CSG
  55044. * Coordinates here are in world space
  55045. * @param name The name of the mesh geometry
  55046. * @param scene The Scene
  55047. * @param keepSubMeshes Specifies if the submeshes should be kept
  55048. * @returns A new Mesh
  55049. */
  55050. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55051. /**
  55052. * Build Mesh from CSG taking material and transforms into account
  55053. * @param name The name of the Mesh
  55054. * @param material The material of the Mesh
  55055. * @param scene The Scene
  55056. * @param keepSubMeshes Specifies if submeshes should be kept
  55057. * @returns The new Mesh
  55058. */
  55059. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55060. }
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Class used to create a trail following a mesh
  55065. */
  55066. export class TrailMesh extends Mesh {
  55067. private _generator;
  55068. private _autoStart;
  55069. private _running;
  55070. private _diameter;
  55071. private _length;
  55072. private _sectionPolygonPointsCount;
  55073. private _sectionVectors;
  55074. private _sectionNormalVectors;
  55075. private _beforeRenderObserver;
  55076. /**
  55077. * @constructor
  55078. * @param name The value used by scene.getMeshByName() to do a lookup.
  55079. * @param generator The mesh to generate a trail.
  55080. * @param scene The scene to add this mesh to.
  55081. * @param diameter Diameter of trailing mesh. Default is 1.
  55082. * @param length Length of trailing mesh. Default is 60.
  55083. * @param autoStart Automatically start trailing mesh. Default true.
  55084. */
  55085. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55086. /**
  55087. * "TrailMesh"
  55088. * @returns "TrailMesh"
  55089. */
  55090. getClassName(): string;
  55091. private _createMesh;
  55092. /**
  55093. * Start trailing mesh.
  55094. */
  55095. start(): void;
  55096. /**
  55097. * Stop trailing mesh.
  55098. */
  55099. stop(): void;
  55100. /**
  55101. * Update trailing mesh geometry.
  55102. */
  55103. update(): void;
  55104. /**
  55105. * Returns a new TrailMesh object.
  55106. * @param name is a string, the name given to the new mesh
  55107. * @param newGenerator use new generator object for cloned trail mesh
  55108. * @returns a new mesh
  55109. */
  55110. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55111. /**
  55112. * Serializes this trail mesh
  55113. * @param serializationObject object to write serialization to
  55114. */
  55115. serialize(serializationObject: any): void;
  55116. /**
  55117. * Parses a serialized trail mesh
  55118. * @param parsedMesh the serialized mesh
  55119. * @param scene the scene to create the trail mesh in
  55120. * @returns the created trail mesh
  55121. */
  55122. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55123. }
  55124. }
  55125. declare module BABYLON {
  55126. /**
  55127. * Class containing static functions to help procedurally build meshes
  55128. */
  55129. export class TiledBoxBuilder {
  55130. /**
  55131. * Creates a box mesh
  55132. * 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)
  55133. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55135. * * 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
  55136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55137. * @param name defines the name of the mesh
  55138. * @param options defines the options used to create the mesh
  55139. * @param scene defines the hosting scene
  55140. * @returns the box mesh
  55141. */
  55142. static CreateTiledBox(name: string, options: {
  55143. pattern?: number;
  55144. width?: number;
  55145. height?: number;
  55146. depth?: number;
  55147. tileSize?: number;
  55148. tileWidth?: number;
  55149. tileHeight?: number;
  55150. alignHorizontal?: number;
  55151. alignVertical?: number;
  55152. faceUV?: Vector4[];
  55153. faceColors?: Color4[];
  55154. sideOrientation?: number;
  55155. updatable?: boolean;
  55156. }, scene?: Nullable<Scene>): Mesh;
  55157. }
  55158. }
  55159. declare module BABYLON {
  55160. /**
  55161. * Class containing static functions to help procedurally build meshes
  55162. */
  55163. export class TorusKnotBuilder {
  55164. /**
  55165. * Creates a torus knot mesh
  55166. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55167. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55168. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55169. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55171. * * 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
  55172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55173. * @param name defines the name of the mesh
  55174. * @param options defines the options used to create the mesh
  55175. * @param scene defines the hosting scene
  55176. * @returns the torus knot mesh
  55177. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55178. */
  55179. static CreateTorusKnot(name: string, options: {
  55180. radius?: number;
  55181. tube?: number;
  55182. radialSegments?: number;
  55183. tubularSegments?: number;
  55184. p?: number;
  55185. q?: number;
  55186. updatable?: boolean;
  55187. sideOrientation?: number;
  55188. frontUVs?: Vector4;
  55189. backUVs?: Vector4;
  55190. }, scene: any): Mesh;
  55191. }
  55192. }
  55193. declare module BABYLON {
  55194. /**
  55195. * Polygon
  55196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55197. */
  55198. export class Polygon {
  55199. /**
  55200. * Creates a rectangle
  55201. * @param xmin bottom X coord
  55202. * @param ymin bottom Y coord
  55203. * @param xmax top X coord
  55204. * @param ymax top Y coord
  55205. * @returns points that make the resulting rectation
  55206. */
  55207. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55208. /**
  55209. * Creates a circle
  55210. * @param radius radius of circle
  55211. * @param cx scale in x
  55212. * @param cy scale in y
  55213. * @param numberOfSides number of sides that make up the circle
  55214. * @returns points that make the resulting circle
  55215. */
  55216. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55217. /**
  55218. * Creates a polygon from input string
  55219. * @param input Input polygon data
  55220. * @returns the parsed points
  55221. */
  55222. static Parse(input: string): Vector2[];
  55223. /**
  55224. * Starts building a polygon from x and y coordinates
  55225. * @param x x coordinate
  55226. * @param y y coordinate
  55227. * @returns the started path2
  55228. */
  55229. static StartingAt(x: number, y: number): Path2;
  55230. }
  55231. /**
  55232. * Builds a polygon
  55233. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55234. */
  55235. export class PolygonMeshBuilder {
  55236. private _points;
  55237. private _outlinepoints;
  55238. private _holes;
  55239. private _name;
  55240. private _scene;
  55241. private _epoints;
  55242. private _eholes;
  55243. private _addToepoint;
  55244. /**
  55245. * Babylon reference to the earcut plugin.
  55246. */
  55247. bjsEarcut: any;
  55248. /**
  55249. * Creates a PolygonMeshBuilder
  55250. * @param name name of the builder
  55251. * @param contours Path of the polygon
  55252. * @param scene scene to add to when creating the mesh
  55253. * @param earcutInjection can be used to inject your own earcut reference
  55254. */
  55255. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55256. /**
  55257. * Adds a whole within the polygon
  55258. * @param hole Array of points defining the hole
  55259. * @returns this
  55260. */
  55261. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55262. /**
  55263. * Creates the polygon
  55264. * @param updatable If the mesh should be updatable
  55265. * @param depth The depth of the mesh created
  55266. * @returns the created mesh
  55267. */
  55268. build(updatable?: boolean, depth?: number): Mesh;
  55269. /**
  55270. * Creates the polygon
  55271. * @param depth The depth of the mesh created
  55272. * @returns the created VertexData
  55273. */
  55274. buildVertexData(depth?: number): VertexData;
  55275. /**
  55276. * Adds a side to the polygon
  55277. * @param positions points that make the polygon
  55278. * @param normals normals of the polygon
  55279. * @param uvs uvs of the polygon
  55280. * @param indices indices of the polygon
  55281. * @param bounds bounds of the polygon
  55282. * @param points points of the polygon
  55283. * @param depth depth of the polygon
  55284. * @param flip flip of the polygon
  55285. */
  55286. private addSide;
  55287. }
  55288. }
  55289. declare module BABYLON {
  55290. /**
  55291. * Class containing static functions to help procedurally build meshes
  55292. */
  55293. export class PolygonBuilder {
  55294. /**
  55295. * Creates a polygon mesh
  55296. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55297. * * 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
  55298. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55300. * * 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)
  55301. * * Remember you can only change the shape positions, not their number when updating a polygon
  55302. * @param name defines the name of the mesh
  55303. * @param options defines the options used to create the mesh
  55304. * @param scene defines the hosting scene
  55305. * @param earcutInjection can be used to inject your own earcut reference
  55306. * @returns the polygon mesh
  55307. */
  55308. static CreatePolygon(name: string, options: {
  55309. shape: Vector3[];
  55310. holes?: Vector3[][];
  55311. depth?: number;
  55312. faceUV?: Vector4[];
  55313. faceColors?: Color4[];
  55314. updatable?: boolean;
  55315. sideOrientation?: number;
  55316. frontUVs?: Vector4;
  55317. backUVs?: Vector4;
  55318. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55319. /**
  55320. * Creates an extruded polygon mesh, with depth in the Y direction.
  55321. * * 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)
  55322. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55323. * @param name defines the name of the mesh
  55324. * @param options defines the options used to create the mesh
  55325. * @param scene defines the hosting scene
  55326. * @param earcutInjection can be used to inject your own earcut reference
  55327. * @returns the polygon mesh
  55328. */
  55329. static ExtrudePolygon(name: string, options: {
  55330. shape: Vector3[];
  55331. holes?: Vector3[][];
  55332. depth?: number;
  55333. faceUV?: Vector4[];
  55334. faceColors?: Color4[];
  55335. updatable?: boolean;
  55336. sideOrientation?: number;
  55337. frontUVs?: Vector4;
  55338. backUVs?: Vector4;
  55339. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55340. }
  55341. }
  55342. declare module BABYLON {
  55343. /**
  55344. * Class containing static functions to help procedurally build meshes
  55345. */
  55346. export class LatheBuilder {
  55347. /**
  55348. * Creates lathe mesh.
  55349. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55350. * * 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
  55351. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55352. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55353. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55354. * * 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
  55355. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55356. * * 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
  55357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55358. * * 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
  55359. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55361. * @param name defines the name of the mesh
  55362. * @param options defines the options used to create the mesh
  55363. * @param scene defines the hosting scene
  55364. * @returns the lathe mesh
  55365. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55366. */
  55367. static CreateLathe(name: string, options: {
  55368. shape: Vector3[];
  55369. radius?: number;
  55370. tessellation?: number;
  55371. clip?: number;
  55372. arc?: number;
  55373. closed?: boolean;
  55374. updatable?: boolean;
  55375. sideOrientation?: number;
  55376. frontUVs?: Vector4;
  55377. backUVs?: Vector4;
  55378. cap?: number;
  55379. invertUV?: boolean;
  55380. }, scene?: Nullable<Scene>): Mesh;
  55381. }
  55382. }
  55383. declare module BABYLON {
  55384. /**
  55385. * Class containing static functions to help procedurally build meshes
  55386. */
  55387. export class TiledPlaneBuilder {
  55388. /**
  55389. * Creates a tiled plane mesh
  55390. * * The parameter `pattern` will, depending on value, do nothing or
  55391. * * * flip (reflect about central vertical) alternate tiles across and up
  55392. * * * flip every tile on alternate rows
  55393. * * * rotate (180 degs) alternate tiles across and up
  55394. * * * rotate every tile on alternate rows
  55395. * * * flip and rotate alternate tiles across and up
  55396. * * * flip and rotate every tile on alternate rows
  55397. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55398. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55399. * * 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
  55400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55401. * * 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)
  55402. * * 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)
  55403. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55404. * @param name defines the name of the mesh
  55405. * @param options defines the options used to create the mesh
  55406. * @param scene defines the hosting scene
  55407. * @returns the box mesh
  55408. */
  55409. static CreateTiledPlane(name: string, options: {
  55410. pattern?: number;
  55411. tileSize?: number;
  55412. tileWidth?: number;
  55413. tileHeight?: number;
  55414. size?: number;
  55415. width?: number;
  55416. height?: number;
  55417. alignHorizontal?: number;
  55418. alignVertical?: number;
  55419. sideOrientation?: number;
  55420. frontUVs?: Vector4;
  55421. backUVs?: Vector4;
  55422. updatable?: boolean;
  55423. }, scene?: Nullable<Scene>): Mesh;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Class containing static functions to help procedurally build meshes
  55429. */
  55430. export class TubeBuilder {
  55431. /**
  55432. * Creates a tube mesh.
  55433. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55434. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55435. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55436. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55437. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55438. * * 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)
  55439. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55440. * * 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
  55441. * * 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
  55442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55443. * * 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
  55444. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55446. * @param name defines the name of the mesh
  55447. * @param options defines the options used to create the mesh
  55448. * @param scene defines the hosting scene
  55449. * @returns the tube mesh
  55450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55451. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55452. */
  55453. static CreateTube(name: string, options: {
  55454. path: Vector3[];
  55455. radius?: number;
  55456. tessellation?: number;
  55457. radiusFunction?: {
  55458. (i: number, distance: number): number;
  55459. };
  55460. cap?: number;
  55461. arc?: number;
  55462. updatable?: boolean;
  55463. sideOrientation?: number;
  55464. frontUVs?: Vector4;
  55465. backUVs?: Vector4;
  55466. instance?: Mesh;
  55467. invertUV?: boolean;
  55468. }, scene?: Nullable<Scene>): Mesh;
  55469. }
  55470. }
  55471. declare module BABYLON {
  55472. /**
  55473. * Class containing static functions to help procedurally build meshes
  55474. */
  55475. export class IcoSphereBuilder {
  55476. /**
  55477. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55478. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55479. * * 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`)
  55480. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55481. * * 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
  55482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55483. * * 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
  55484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55485. * @param name defines the name of the mesh
  55486. * @param options defines the options used to create the mesh
  55487. * @param scene defines the hosting scene
  55488. * @returns the icosahedron mesh
  55489. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55490. */
  55491. static CreateIcoSphere(name: string, options: {
  55492. radius?: number;
  55493. radiusX?: number;
  55494. radiusY?: number;
  55495. radiusZ?: number;
  55496. flat?: boolean;
  55497. subdivisions?: number;
  55498. sideOrientation?: number;
  55499. frontUVs?: Vector4;
  55500. backUVs?: Vector4;
  55501. updatable?: boolean;
  55502. }, scene?: Nullable<Scene>): Mesh;
  55503. }
  55504. }
  55505. declare module BABYLON {
  55506. /**
  55507. * Class containing static functions to help procedurally build meshes
  55508. */
  55509. export class DecalBuilder {
  55510. /**
  55511. * Creates a decal mesh.
  55512. * 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
  55513. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55514. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55515. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55516. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55517. * @param name defines the name of the mesh
  55518. * @param sourceMesh defines the mesh where the decal must be applied
  55519. * @param options defines the options used to create the mesh
  55520. * @param scene defines the hosting scene
  55521. * @returns the decal mesh
  55522. * @see https://doc.babylonjs.com/how_to/decals
  55523. */
  55524. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55525. position?: Vector3;
  55526. normal?: Vector3;
  55527. size?: Vector3;
  55528. angle?: number;
  55529. }): Mesh;
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Class containing static functions to help procedurally build meshes
  55535. */
  55536. export class MeshBuilder {
  55537. /**
  55538. * Creates a box mesh
  55539. * * The parameter `size` sets the size (float) of each box side (default 1)
  55540. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55541. * * 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)
  55542. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55544. * * 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
  55545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55546. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55547. * @param name defines the name of the mesh
  55548. * @param options defines the options used to create the mesh
  55549. * @param scene defines the hosting scene
  55550. * @returns the box mesh
  55551. */
  55552. static CreateBox(name: string, options: {
  55553. size?: number;
  55554. width?: number;
  55555. height?: number;
  55556. depth?: number;
  55557. faceUV?: Vector4[];
  55558. faceColors?: Color4[];
  55559. sideOrientation?: number;
  55560. frontUVs?: Vector4;
  55561. backUVs?: Vector4;
  55562. updatable?: boolean;
  55563. }, scene?: Nullable<Scene>): Mesh;
  55564. /**
  55565. * Creates a tiled box mesh
  55566. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55568. * @param name defines the name of the mesh
  55569. * @param options defines the options used to create the mesh
  55570. * @param scene defines the hosting scene
  55571. * @returns the tiled box mesh
  55572. */
  55573. static CreateTiledBox(name: string, options: {
  55574. pattern?: number;
  55575. size?: number;
  55576. width?: number;
  55577. height?: number;
  55578. depth: number;
  55579. tileSize?: number;
  55580. tileWidth?: number;
  55581. tileHeight?: number;
  55582. faceUV?: Vector4[];
  55583. faceColors?: Color4[];
  55584. alignHorizontal?: number;
  55585. alignVertical?: number;
  55586. sideOrientation?: number;
  55587. updatable?: boolean;
  55588. }, scene?: Nullable<Scene>): Mesh;
  55589. /**
  55590. * Creates a sphere mesh
  55591. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55592. * * 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`)
  55593. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55594. * * 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
  55595. * * 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)
  55596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55597. * * 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
  55598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55599. * @param name defines the name of the mesh
  55600. * @param options defines the options used to create the mesh
  55601. * @param scene defines the hosting scene
  55602. * @returns the sphere mesh
  55603. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55604. */
  55605. static CreateSphere(name: string, options: {
  55606. segments?: number;
  55607. diameter?: number;
  55608. diameterX?: number;
  55609. diameterY?: number;
  55610. diameterZ?: number;
  55611. arc?: number;
  55612. slice?: number;
  55613. sideOrientation?: number;
  55614. frontUVs?: Vector4;
  55615. backUVs?: Vector4;
  55616. updatable?: boolean;
  55617. }, scene?: Nullable<Scene>): Mesh;
  55618. /**
  55619. * Creates a plane polygonal mesh. By default, this is a disc
  55620. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55621. * * 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
  55622. * * 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
  55623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55624. * * 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
  55625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55626. * @param name defines the name of the mesh
  55627. * @param options defines the options used to create the mesh
  55628. * @param scene defines the hosting scene
  55629. * @returns the plane polygonal mesh
  55630. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55631. */
  55632. static CreateDisc(name: string, options: {
  55633. radius?: number;
  55634. tessellation?: number;
  55635. arc?: number;
  55636. updatable?: boolean;
  55637. sideOrientation?: number;
  55638. frontUVs?: Vector4;
  55639. backUVs?: Vector4;
  55640. }, scene?: Nullable<Scene>): Mesh;
  55641. /**
  55642. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55643. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55644. * * 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`)
  55645. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55646. * * 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
  55647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55648. * * 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
  55649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55650. * @param name defines the name of the mesh
  55651. * @param options defines the options used to create the mesh
  55652. * @param scene defines the hosting scene
  55653. * @returns the icosahedron mesh
  55654. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55655. */
  55656. static CreateIcoSphere(name: string, options: {
  55657. radius?: number;
  55658. radiusX?: number;
  55659. radiusY?: number;
  55660. radiusZ?: number;
  55661. flat?: boolean;
  55662. subdivisions?: number;
  55663. sideOrientation?: number;
  55664. frontUVs?: Vector4;
  55665. backUVs?: Vector4;
  55666. updatable?: boolean;
  55667. }, scene?: Nullable<Scene>): Mesh;
  55668. /**
  55669. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55670. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55671. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55672. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55673. * * 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
  55674. * * 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
  55675. * * 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
  55676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55677. * * 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
  55678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55679. * * 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
  55680. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55681. * * 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
  55682. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55684. * @param name defines the name of the mesh
  55685. * @param options defines the options used to create the mesh
  55686. * @param scene defines the hosting scene
  55687. * @returns the ribbon mesh
  55688. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55689. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55690. */
  55691. static CreateRibbon(name: string, options: {
  55692. pathArray: Vector3[][];
  55693. closeArray?: boolean;
  55694. closePath?: boolean;
  55695. offset?: number;
  55696. updatable?: boolean;
  55697. sideOrientation?: number;
  55698. frontUVs?: Vector4;
  55699. backUVs?: Vector4;
  55700. instance?: Mesh;
  55701. invertUV?: boolean;
  55702. uvs?: Vector2[];
  55703. colors?: Color4[];
  55704. }, scene?: Nullable<Scene>): Mesh;
  55705. /**
  55706. * Creates a cylinder or a cone mesh
  55707. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55708. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55709. * * 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.
  55710. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55711. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55712. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55713. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55714. * * 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).
  55715. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55716. * * 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).
  55717. * * 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
  55718. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55719. * * 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
  55720. * * 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.
  55721. * * If `enclose` is false, a ring surface is one element.
  55722. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55723. * * 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
  55724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55725. * * 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
  55726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55727. * @param name defines the name of the mesh
  55728. * @param options defines the options used to create the mesh
  55729. * @param scene defines the hosting scene
  55730. * @returns the cylinder mesh
  55731. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55732. */
  55733. static CreateCylinder(name: string, options: {
  55734. height?: number;
  55735. diameterTop?: number;
  55736. diameterBottom?: number;
  55737. diameter?: number;
  55738. tessellation?: number;
  55739. subdivisions?: number;
  55740. arc?: number;
  55741. faceColors?: Color4[];
  55742. faceUV?: Vector4[];
  55743. updatable?: boolean;
  55744. hasRings?: boolean;
  55745. enclose?: boolean;
  55746. cap?: number;
  55747. sideOrientation?: number;
  55748. frontUVs?: Vector4;
  55749. backUVs?: Vector4;
  55750. }, scene?: Nullable<Scene>): Mesh;
  55751. /**
  55752. * Creates a torus mesh
  55753. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55754. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55755. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55757. * * 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
  55758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55759. * @param name defines the name of the mesh
  55760. * @param options defines the options used to create the mesh
  55761. * @param scene defines the hosting scene
  55762. * @returns the torus mesh
  55763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55764. */
  55765. static CreateTorus(name: string, options: {
  55766. diameter?: number;
  55767. thickness?: number;
  55768. tessellation?: number;
  55769. updatable?: boolean;
  55770. sideOrientation?: number;
  55771. frontUVs?: Vector4;
  55772. backUVs?: Vector4;
  55773. }, scene?: Nullable<Scene>): Mesh;
  55774. /**
  55775. * Creates a torus knot mesh
  55776. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55777. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55778. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55779. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55781. * * 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
  55782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55783. * @param name defines the name of the mesh
  55784. * @param options defines the options used to create the mesh
  55785. * @param scene defines the hosting scene
  55786. * @returns the torus knot mesh
  55787. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55788. */
  55789. static CreateTorusKnot(name: string, options: {
  55790. radius?: number;
  55791. tube?: number;
  55792. radialSegments?: number;
  55793. tubularSegments?: number;
  55794. p?: number;
  55795. q?: number;
  55796. updatable?: boolean;
  55797. sideOrientation?: number;
  55798. frontUVs?: Vector4;
  55799. backUVs?: Vector4;
  55800. }, scene?: Nullable<Scene>): Mesh;
  55801. /**
  55802. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55803. * * 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
  55804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55805. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55806. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55807. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55808. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55809. * * 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
  55810. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55812. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55813. * @param name defines the name of the new line system
  55814. * @param options defines the options used to create the line system
  55815. * @param scene defines the hosting scene
  55816. * @returns a new line system mesh
  55817. */
  55818. static CreateLineSystem(name: string, options: {
  55819. lines: Vector3[][];
  55820. updatable?: boolean;
  55821. instance?: Nullable<LinesMesh>;
  55822. colors?: Nullable<Color4[][]>;
  55823. useVertexAlpha?: boolean;
  55824. }, scene: Nullable<Scene>): LinesMesh;
  55825. /**
  55826. * Creates a line mesh
  55827. * 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
  55828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55829. * * The parameter `points` is an array successive Vector3
  55830. * * 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
  55831. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55832. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55833. * * When updating an instance, remember that only point positions can change, not the number of points
  55834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55836. * @param name defines the name of the new line system
  55837. * @param options defines the options used to create the line system
  55838. * @param scene defines the hosting scene
  55839. * @returns a new line mesh
  55840. */
  55841. static CreateLines(name: string, options: {
  55842. points: Vector3[];
  55843. updatable?: boolean;
  55844. instance?: Nullable<LinesMesh>;
  55845. colors?: Color4[];
  55846. useVertexAlpha?: boolean;
  55847. }, scene?: Nullable<Scene>): LinesMesh;
  55848. /**
  55849. * Creates a dashed line mesh
  55850. * * 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
  55851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55852. * * The parameter `points` is an array successive Vector3
  55853. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55854. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55855. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55856. * * 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
  55857. * * When updating an instance, remember that only point positions can change, not the number of points
  55858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55859. * @param name defines the name of the mesh
  55860. * @param options defines the options used to create the mesh
  55861. * @param scene defines the hosting scene
  55862. * @returns the dashed line mesh
  55863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55864. */
  55865. static CreateDashedLines(name: string, options: {
  55866. points: Vector3[];
  55867. dashSize?: number;
  55868. gapSize?: number;
  55869. dashNb?: number;
  55870. updatable?: boolean;
  55871. instance?: LinesMesh;
  55872. }, scene?: Nullable<Scene>): LinesMesh;
  55873. /**
  55874. * 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.
  55875. * * 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.
  55876. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55877. * * 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.
  55878. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55879. * * 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
  55880. * * 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
  55881. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55883. * * 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
  55884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55886. * @param name defines the name of the mesh
  55887. * @param options defines the options used to create the mesh
  55888. * @param scene defines the hosting scene
  55889. * @returns the extruded shape mesh
  55890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55892. */
  55893. static ExtrudeShape(name: string, options: {
  55894. shape: Vector3[];
  55895. path: Vector3[];
  55896. scale?: number;
  55897. rotation?: number;
  55898. cap?: number;
  55899. updatable?: boolean;
  55900. sideOrientation?: number;
  55901. frontUVs?: Vector4;
  55902. backUVs?: Vector4;
  55903. instance?: Mesh;
  55904. invertUV?: boolean;
  55905. }, scene?: Nullable<Scene>): Mesh;
  55906. /**
  55907. * Creates an custom extruded shape mesh.
  55908. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55909. * * 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.
  55910. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55911. * * 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
  55912. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55913. * * 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
  55914. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55915. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55916. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55917. * * 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
  55918. * * 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
  55919. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55921. * * 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
  55922. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55924. * @param name defines the name of the mesh
  55925. * @param options defines the options used to create the mesh
  55926. * @param scene defines the hosting scene
  55927. * @returns the custom extruded shape mesh
  55928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55931. */
  55932. static ExtrudeShapeCustom(name: string, options: {
  55933. shape: Vector3[];
  55934. path: Vector3[];
  55935. scaleFunction?: any;
  55936. rotationFunction?: any;
  55937. ribbonCloseArray?: boolean;
  55938. ribbonClosePath?: boolean;
  55939. cap?: number;
  55940. updatable?: boolean;
  55941. sideOrientation?: number;
  55942. frontUVs?: Vector4;
  55943. backUVs?: Vector4;
  55944. instance?: Mesh;
  55945. invertUV?: boolean;
  55946. }, scene?: Nullable<Scene>): Mesh;
  55947. /**
  55948. * Creates lathe mesh.
  55949. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55950. * * 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
  55951. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55952. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55953. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55954. * * 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
  55955. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55956. * * 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
  55957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55958. * * 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
  55959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55961. * @param name defines the name of the mesh
  55962. * @param options defines the options used to create the mesh
  55963. * @param scene defines the hosting scene
  55964. * @returns the lathe mesh
  55965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55966. */
  55967. static CreateLathe(name: string, options: {
  55968. shape: Vector3[];
  55969. radius?: number;
  55970. tessellation?: number;
  55971. clip?: number;
  55972. arc?: number;
  55973. closed?: boolean;
  55974. updatable?: boolean;
  55975. sideOrientation?: number;
  55976. frontUVs?: Vector4;
  55977. backUVs?: Vector4;
  55978. cap?: number;
  55979. invertUV?: boolean;
  55980. }, scene?: Nullable<Scene>): Mesh;
  55981. /**
  55982. * Creates a tiled plane mesh
  55983. * * You can set a limited pattern arrangement with the tiles
  55984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55985. * * 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
  55986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55987. * @param name defines the name of the mesh
  55988. * @param options defines the options used to create the mesh
  55989. * @param scene defines the hosting scene
  55990. * @returns the plane mesh
  55991. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55992. */
  55993. static CreateTiledPlane(name: string, options: {
  55994. pattern?: number;
  55995. tileSize?: number;
  55996. tileWidth?: number;
  55997. tileHeight?: number;
  55998. size?: number;
  55999. width?: number;
  56000. height?: number;
  56001. alignHorizontal?: number;
  56002. alignVertical?: number;
  56003. sideOrientation?: number;
  56004. frontUVs?: Vector4;
  56005. backUVs?: Vector4;
  56006. updatable?: boolean;
  56007. }, scene?: Nullable<Scene>): Mesh;
  56008. /**
  56009. * Creates a plane mesh
  56010. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56011. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56012. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56014. * * 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
  56015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56016. * @param name defines the name of the mesh
  56017. * @param options defines the options used to create the mesh
  56018. * @param scene defines the hosting scene
  56019. * @returns the plane mesh
  56020. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56021. */
  56022. static CreatePlane(name: string, options: {
  56023. size?: number;
  56024. width?: number;
  56025. height?: number;
  56026. sideOrientation?: number;
  56027. frontUVs?: Vector4;
  56028. backUVs?: Vector4;
  56029. updatable?: boolean;
  56030. sourcePlane?: Plane;
  56031. }, scene?: Nullable<Scene>): Mesh;
  56032. /**
  56033. * Creates a ground mesh
  56034. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56035. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56037. * @param name defines the name of the mesh
  56038. * @param options defines the options used to create the mesh
  56039. * @param scene defines the hosting scene
  56040. * @returns the ground mesh
  56041. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56042. */
  56043. static CreateGround(name: string, options: {
  56044. width?: number;
  56045. height?: number;
  56046. subdivisions?: number;
  56047. subdivisionsX?: number;
  56048. subdivisionsY?: number;
  56049. updatable?: boolean;
  56050. }, scene?: Nullable<Scene>): Mesh;
  56051. /**
  56052. * Creates a tiled ground mesh
  56053. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56054. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56055. * * 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
  56056. * * 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
  56057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56058. * @param name defines the name of the mesh
  56059. * @param options defines the options used to create the mesh
  56060. * @param scene defines the hosting scene
  56061. * @returns the tiled ground mesh
  56062. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56063. */
  56064. static CreateTiledGround(name: string, options: {
  56065. xmin: number;
  56066. zmin: number;
  56067. xmax: number;
  56068. zmax: number;
  56069. subdivisions?: {
  56070. w: number;
  56071. h: number;
  56072. };
  56073. precision?: {
  56074. w: number;
  56075. h: number;
  56076. };
  56077. updatable?: boolean;
  56078. }, scene?: Nullable<Scene>): Mesh;
  56079. /**
  56080. * Creates a ground mesh from a height map
  56081. * * The parameter `url` sets the URL of the height map image resource.
  56082. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56083. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56084. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56085. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56086. * * 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.
  56087. * * 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).
  56088. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56090. * @param name defines the name of the mesh
  56091. * @param url defines the url to the height map
  56092. * @param options defines the options used to create the mesh
  56093. * @param scene defines the hosting scene
  56094. * @returns the ground mesh
  56095. * @see https://doc.babylonjs.com/babylon101/height_map
  56096. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56097. */
  56098. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56099. width?: number;
  56100. height?: number;
  56101. subdivisions?: number;
  56102. minHeight?: number;
  56103. maxHeight?: number;
  56104. colorFilter?: Color3;
  56105. alphaFilter?: number;
  56106. updatable?: boolean;
  56107. onReady?: (mesh: GroundMesh) => void;
  56108. }, scene?: Nullable<Scene>): GroundMesh;
  56109. /**
  56110. * Creates a polygon mesh
  56111. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56112. * * 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
  56113. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56115. * * 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)
  56116. * * Remember you can only change the shape positions, not their number when updating a polygon
  56117. * @param name defines the name of the mesh
  56118. * @param options defines the options used to create the mesh
  56119. * @param scene defines the hosting scene
  56120. * @param earcutInjection can be used to inject your own earcut reference
  56121. * @returns the polygon mesh
  56122. */
  56123. static CreatePolygon(name: string, options: {
  56124. shape: Vector3[];
  56125. holes?: Vector3[][];
  56126. depth?: number;
  56127. faceUV?: Vector4[];
  56128. faceColors?: Color4[];
  56129. updatable?: boolean;
  56130. sideOrientation?: number;
  56131. frontUVs?: Vector4;
  56132. backUVs?: Vector4;
  56133. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56134. /**
  56135. * Creates an extruded polygon mesh, with depth in the Y direction.
  56136. * * 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)
  56137. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56138. * @param name defines the name of the mesh
  56139. * @param options defines the options used to create the mesh
  56140. * @param scene defines the hosting scene
  56141. * @param earcutInjection can be used to inject your own earcut reference
  56142. * @returns the polygon mesh
  56143. */
  56144. static ExtrudePolygon(name: string, options: {
  56145. shape: Vector3[];
  56146. holes?: Vector3[][];
  56147. depth?: number;
  56148. faceUV?: Vector4[];
  56149. faceColors?: Color4[];
  56150. updatable?: boolean;
  56151. sideOrientation?: number;
  56152. frontUVs?: Vector4;
  56153. backUVs?: Vector4;
  56154. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56155. /**
  56156. * Creates a tube mesh.
  56157. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56158. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56159. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56160. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56161. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56162. * * 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)
  56163. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56164. * * 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
  56165. * * 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
  56166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56167. * * 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
  56168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56170. * @param name defines the name of the mesh
  56171. * @param options defines the options used to create the mesh
  56172. * @param scene defines the hosting scene
  56173. * @returns the tube mesh
  56174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56175. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56176. */
  56177. static CreateTube(name: string, options: {
  56178. path: Vector3[];
  56179. radius?: number;
  56180. tessellation?: number;
  56181. radiusFunction?: {
  56182. (i: number, distance: number): number;
  56183. };
  56184. cap?: number;
  56185. arc?: number;
  56186. updatable?: boolean;
  56187. sideOrientation?: number;
  56188. frontUVs?: Vector4;
  56189. backUVs?: Vector4;
  56190. instance?: Mesh;
  56191. invertUV?: boolean;
  56192. }, scene?: Nullable<Scene>): Mesh;
  56193. /**
  56194. * Creates a polyhedron mesh
  56195. * * 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
  56196. * * The parameter `size` (positive float, default 1) sets the polygon size
  56197. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56198. * * 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`
  56199. * * 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
  56200. * * 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)`)
  56201. * * 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
  56202. * * 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
  56203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56204. * * 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
  56205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56206. * @param name defines the name of the mesh
  56207. * @param options defines the options used to create the mesh
  56208. * @param scene defines the hosting scene
  56209. * @returns the polyhedron mesh
  56210. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56211. */
  56212. static CreatePolyhedron(name: string, options: {
  56213. type?: number;
  56214. size?: number;
  56215. sizeX?: number;
  56216. sizeY?: number;
  56217. sizeZ?: number;
  56218. custom?: any;
  56219. faceUV?: Vector4[];
  56220. faceColors?: Color4[];
  56221. flat?: boolean;
  56222. updatable?: boolean;
  56223. sideOrientation?: number;
  56224. frontUVs?: Vector4;
  56225. backUVs?: Vector4;
  56226. }, scene?: Nullable<Scene>): Mesh;
  56227. /**
  56228. * Creates a decal mesh.
  56229. * 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
  56230. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56231. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56232. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56233. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56234. * @param name defines the name of the mesh
  56235. * @param sourceMesh defines the mesh where the decal must be applied
  56236. * @param options defines the options used to create the mesh
  56237. * @param scene defines the hosting scene
  56238. * @returns the decal mesh
  56239. * @see https://doc.babylonjs.com/how_to/decals
  56240. */
  56241. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56242. position?: Vector3;
  56243. normal?: Vector3;
  56244. size?: Vector3;
  56245. angle?: number;
  56246. }): Mesh;
  56247. }
  56248. }
  56249. declare module BABYLON {
  56250. /**
  56251. * A simplifier interface for future simplification implementations
  56252. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56253. */
  56254. export interface ISimplifier {
  56255. /**
  56256. * Simplification of a given mesh according to the given settings.
  56257. * Since this requires computation, it is assumed that the function runs async.
  56258. * @param settings The settings of the simplification, including quality and distance
  56259. * @param successCallback A callback that will be called after the mesh was simplified.
  56260. * @param errorCallback in case of an error, this callback will be called. optional.
  56261. */
  56262. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56263. }
  56264. /**
  56265. * Expected simplification settings.
  56266. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56267. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56268. */
  56269. export interface ISimplificationSettings {
  56270. /**
  56271. * Gets or sets the expected quality
  56272. */
  56273. quality: number;
  56274. /**
  56275. * Gets or sets the distance when this optimized version should be used
  56276. */
  56277. distance: number;
  56278. /**
  56279. * Gets an already optimized mesh
  56280. */
  56281. optimizeMesh?: boolean;
  56282. }
  56283. /**
  56284. * Class used to specify simplification options
  56285. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56286. */
  56287. export class SimplificationSettings implements ISimplificationSettings {
  56288. /** expected quality */
  56289. quality: number;
  56290. /** distance when this optimized version should be used */
  56291. distance: number;
  56292. /** already optimized mesh */
  56293. optimizeMesh?: boolean | undefined;
  56294. /**
  56295. * Creates a SimplificationSettings
  56296. * @param quality expected quality
  56297. * @param distance distance when this optimized version should be used
  56298. * @param optimizeMesh already optimized mesh
  56299. */
  56300. constructor(
  56301. /** expected quality */
  56302. quality: number,
  56303. /** distance when this optimized version should be used */
  56304. distance: number,
  56305. /** already optimized mesh */
  56306. optimizeMesh?: boolean | undefined);
  56307. }
  56308. /**
  56309. * Interface used to define a simplification task
  56310. */
  56311. export interface ISimplificationTask {
  56312. /**
  56313. * Array of settings
  56314. */
  56315. settings: Array<ISimplificationSettings>;
  56316. /**
  56317. * Simplification type
  56318. */
  56319. simplificationType: SimplificationType;
  56320. /**
  56321. * Mesh to simplify
  56322. */
  56323. mesh: Mesh;
  56324. /**
  56325. * Callback called on success
  56326. */
  56327. successCallback?: () => void;
  56328. /**
  56329. * Defines if parallel processing can be used
  56330. */
  56331. parallelProcessing: boolean;
  56332. }
  56333. /**
  56334. * Queue used to order the simplification tasks
  56335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56336. */
  56337. export class SimplificationQueue {
  56338. private _simplificationArray;
  56339. /**
  56340. * Gets a boolean indicating that the process is still running
  56341. */
  56342. running: boolean;
  56343. /**
  56344. * Creates a new queue
  56345. */
  56346. constructor();
  56347. /**
  56348. * Adds a new simplification task
  56349. * @param task defines a task to add
  56350. */
  56351. addTask(task: ISimplificationTask): void;
  56352. /**
  56353. * Execute next task
  56354. */
  56355. executeNext(): void;
  56356. /**
  56357. * Execute a simplification task
  56358. * @param task defines the task to run
  56359. */
  56360. runSimplification(task: ISimplificationTask): void;
  56361. private getSimplifier;
  56362. }
  56363. /**
  56364. * The implemented types of simplification
  56365. * At the moment only Quadratic Error Decimation is implemented
  56366. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56367. */
  56368. export enum SimplificationType {
  56369. /** Quadratic error decimation */
  56370. QUADRATIC = 0
  56371. }
  56372. }
  56373. declare module BABYLON {
  56374. interface Scene {
  56375. /** @hidden (Backing field) */
  56376. _simplificationQueue: SimplificationQueue;
  56377. /**
  56378. * Gets or sets the simplification queue attached to the scene
  56379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56380. */
  56381. simplificationQueue: SimplificationQueue;
  56382. }
  56383. interface Mesh {
  56384. /**
  56385. * Simplify the mesh according to the given array of settings.
  56386. * Function will return immediately and will simplify async
  56387. * @param settings a collection of simplification settings
  56388. * @param parallelProcessing should all levels calculate parallel or one after the other
  56389. * @param simplificationType the type of simplification to run
  56390. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56391. * @returns the current mesh
  56392. */
  56393. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56394. }
  56395. /**
  56396. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56397. * created in a scene
  56398. */
  56399. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56400. /**
  56401. * The component name helpfull to identify the component in the list of scene components.
  56402. */
  56403. readonly name: string;
  56404. /**
  56405. * The scene the component belongs to.
  56406. */
  56407. scene: Scene;
  56408. /**
  56409. * Creates a new instance of the component for the given scene
  56410. * @param scene Defines the scene to register the component in
  56411. */
  56412. constructor(scene: Scene);
  56413. /**
  56414. * Registers the component in a given scene
  56415. */
  56416. register(): void;
  56417. /**
  56418. * Rebuilds the elements related to this component in case of
  56419. * context lost for instance.
  56420. */
  56421. rebuild(): void;
  56422. /**
  56423. * Disposes the component and the associated ressources
  56424. */
  56425. dispose(): void;
  56426. private _beforeCameraUpdate;
  56427. }
  56428. }
  56429. declare module BABYLON {
  56430. /**
  56431. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56432. */
  56433. export interface INavigationEnginePlugin {
  56434. /**
  56435. * plugin name
  56436. */
  56437. name: string;
  56438. /**
  56439. * Creates a navigation mesh
  56440. * @param meshes array of all the geometry used to compute the navigatio mesh
  56441. * @param parameters bunch of parameters used to filter geometry
  56442. */
  56443. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56444. /**
  56445. * Create a navigation mesh debug mesh
  56446. * @param scene is where the mesh will be added
  56447. * @returns debug display mesh
  56448. */
  56449. createDebugNavMesh(scene: Scene): Mesh;
  56450. /**
  56451. * Get a navigation mesh constrained position, closest to the parameter position
  56452. * @param position world position
  56453. * @returns the closest point to position constrained by the navigation mesh
  56454. */
  56455. getClosestPoint(position: Vector3): Vector3;
  56456. /**
  56457. * Get a navigation mesh constrained position, within a particular radius
  56458. * @param position world position
  56459. * @param maxRadius the maximum distance to the constrained world position
  56460. * @returns the closest point to position constrained by the navigation mesh
  56461. */
  56462. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56463. /**
  56464. * Compute the final position from a segment made of destination-position
  56465. * @param position world position
  56466. * @param destination world position
  56467. * @returns the resulting point along the navmesh
  56468. */
  56469. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56470. /**
  56471. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56472. * @param start world position
  56473. * @param end world position
  56474. * @returns array containing world position composing the path
  56475. */
  56476. computePath(start: Vector3, end: Vector3): Vector3[];
  56477. /**
  56478. * If this plugin is supported
  56479. * @returns true if plugin is supported
  56480. */
  56481. isSupported(): boolean;
  56482. /**
  56483. * Create a new Crowd so you can add agents
  56484. * @param maxAgents the maximum agent count in the crowd
  56485. * @param maxAgentRadius the maximum radius an agent can have
  56486. * @param scene to attach the crowd to
  56487. * @returns the crowd you can add agents to
  56488. */
  56489. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56490. /**
  56491. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56492. * The queries will try to find a solution within those bounds
  56493. * default is (1,1,1)
  56494. * @param extent x,y,z value that define the extent around the queries point of reference
  56495. */
  56496. setDefaultQueryExtent(extent: Vector3): void;
  56497. /**
  56498. * Get the Bounding box extent specified by setDefaultQueryExtent
  56499. * @returns the box extent values
  56500. */
  56501. getDefaultQueryExtent(): Vector3;
  56502. /**
  56503. * Release all resources
  56504. */
  56505. dispose(): void;
  56506. }
  56507. /**
  56508. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56509. */
  56510. export interface ICrowd {
  56511. /**
  56512. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56513. * You can attach anything to that node. The node position is updated in the scene update tick.
  56514. * @param pos world position that will be constrained by the navigation mesh
  56515. * @param parameters agent parameters
  56516. * @param transform hooked to the agent that will be update by the scene
  56517. * @returns agent index
  56518. */
  56519. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56520. /**
  56521. * Returns the agent position in world space
  56522. * @param index agent index returned by addAgent
  56523. * @returns world space position
  56524. */
  56525. getAgentPosition(index: number): Vector3;
  56526. /**
  56527. * Gets the agent velocity in world space
  56528. * @param index agent index returned by addAgent
  56529. * @returns world space velocity
  56530. */
  56531. getAgentVelocity(index: number): Vector3;
  56532. /**
  56533. * remove a particular agent previously created
  56534. * @param index agent index returned by addAgent
  56535. */
  56536. removeAgent(index: number): void;
  56537. /**
  56538. * get the list of all agents attached to this crowd
  56539. * @returns list of agent indices
  56540. */
  56541. getAgents(): number[];
  56542. /**
  56543. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56544. * @param deltaTime in seconds
  56545. */
  56546. update(deltaTime: number): void;
  56547. /**
  56548. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56549. * @param index agent index returned by addAgent
  56550. * @param destination targeted world position
  56551. */
  56552. agentGoto(index: number, destination: Vector3): void;
  56553. /**
  56554. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56555. * The queries will try to find a solution within those bounds
  56556. * default is (1,1,1)
  56557. * @param extent x,y,z value that define the extent around the queries point of reference
  56558. */
  56559. setDefaultQueryExtent(extent: Vector3): void;
  56560. /**
  56561. * Get the Bounding box extent specified by setDefaultQueryExtent
  56562. * @returns the box extent values
  56563. */
  56564. getDefaultQueryExtent(): Vector3;
  56565. /**
  56566. * Release all resources
  56567. */
  56568. dispose(): void;
  56569. }
  56570. /**
  56571. * Configures an agent
  56572. */
  56573. export interface IAgentParameters {
  56574. /**
  56575. * Agent radius. [Limit: >= 0]
  56576. */
  56577. radius: number;
  56578. /**
  56579. * Agent height. [Limit: > 0]
  56580. */
  56581. height: number;
  56582. /**
  56583. * Maximum allowed acceleration. [Limit: >= 0]
  56584. */
  56585. maxAcceleration: number;
  56586. /**
  56587. * Maximum allowed speed. [Limit: >= 0]
  56588. */
  56589. maxSpeed: number;
  56590. /**
  56591. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56592. */
  56593. collisionQueryRange: number;
  56594. /**
  56595. * The path visibility optimization range. [Limit: > 0]
  56596. */
  56597. pathOptimizationRange: number;
  56598. /**
  56599. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56600. */
  56601. separationWeight: number;
  56602. }
  56603. /**
  56604. * Configures the navigation mesh creation
  56605. */
  56606. export interface INavMeshParameters {
  56607. /**
  56608. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56609. */
  56610. cs: number;
  56611. /**
  56612. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56613. */
  56614. ch: number;
  56615. /**
  56616. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56617. */
  56618. walkableSlopeAngle: number;
  56619. /**
  56620. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56621. * be considered walkable. [Limit: >= 3] [Units: vx]
  56622. */
  56623. walkableHeight: number;
  56624. /**
  56625. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56626. */
  56627. walkableClimb: number;
  56628. /**
  56629. * The distance to erode/shrink the walkable area of the heightfield away from
  56630. * obstructions. [Limit: >=0] [Units: vx]
  56631. */
  56632. walkableRadius: number;
  56633. /**
  56634. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56635. */
  56636. maxEdgeLen: number;
  56637. /**
  56638. * The maximum distance a simplfied contour's border edges should deviate
  56639. * the original raw contour. [Limit: >=0] [Units: vx]
  56640. */
  56641. maxSimplificationError: number;
  56642. /**
  56643. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56644. */
  56645. minRegionArea: number;
  56646. /**
  56647. * Any regions with a span count smaller than this value will, if possible,
  56648. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56649. */
  56650. mergeRegionArea: number;
  56651. /**
  56652. * The maximum number of vertices allowed for polygons generated during the
  56653. * contour to polygon conversion process. [Limit: >= 3]
  56654. */
  56655. maxVertsPerPoly: number;
  56656. /**
  56657. * Sets the sampling distance to use when generating the detail mesh.
  56658. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56659. */
  56660. detailSampleDist: number;
  56661. /**
  56662. * The maximum distance the detail mesh surface should deviate from heightfield
  56663. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56664. */
  56665. detailSampleMaxError: number;
  56666. }
  56667. }
  56668. declare module BABYLON {
  56669. /**
  56670. * RecastJS navigation plugin
  56671. */
  56672. export class RecastJSPlugin implements INavigationEnginePlugin {
  56673. /**
  56674. * Reference to the Recast library
  56675. */
  56676. bjsRECAST: any;
  56677. /**
  56678. * plugin name
  56679. */
  56680. name: string;
  56681. /**
  56682. * the first navmesh created. We might extend this to support multiple navmeshes
  56683. */
  56684. navMesh: any;
  56685. /**
  56686. * Initializes the recastJS plugin
  56687. * @param recastInjection can be used to inject your own recast reference
  56688. */
  56689. constructor(recastInjection?: any);
  56690. /**
  56691. * Creates a navigation mesh
  56692. * @param meshes array of all the geometry used to compute the navigatio mesh
  56693. * @param parameters bunch of parameters used to filter geometry
  56694. */
  56695. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56696. /**
  56697. * Create a navigation mesh debug mesh
  56698. * @param scene is where the mesh will be added
  56699. * @returns debug display mesh
  56700. */
  56701. createDebugNavMesh(scene: Scene): Mesh;
  56702. /**
  56703. * Get a navigation mesh constrained position, closest to the parameter position
  56704. * @param position world position
  56705. * @returns the closest point to position constrained by the navigation mesh
  56706. */
  56707. getClosestPoint(position: Vector3): Vector3;
  56708. /**
  56709. * Get a navigation mesh constrained position, within a particular radius
  56710. * @param position world position
  56711. * @param maxRadius the maximum distance to the constrained world position
  56712. * @returns the closest point to position constrained by the navigation mesh
  56713. */
  56714. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56715. /**
  56716. * Compute the final position from a segment made of destination-position
  56717. * @param position world position
  56718. * @param destination world position
  56719. * @returns the resulting point along the navmesh
  56720. */
  56721. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56722. /**
  56723. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56724. * @param start world position
  56725. * @param end world position
  56726. * @returns array containing world position composing the path
  56727. */
  56728. computePath(start: Vector3, end: Vector3): Vector3[];
  56729. /**
  56730. * Create a new Crowd so you can add agents
  56731. * @param maxAgents the maximum agent count in the crowd
  56732. * @param maxAgentRadius the maximum radius an agent can have
  56733. * @param scene to attach the crowd to
  56734. * @returns the crowd you can add agents to
  56735. */
  56736. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56737. /**
  56738. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56739. * The queries will try to find a solution within those bounds
  56740. * default is (1,1,1)
  56741. * @param extent x,y,z value that define the extent around the queries point of reference
  56742. */
  56743. setDefaultQueryExtent(extent: Vector3): void;
  56744. /**
  56745. * Get the Bounding box extent specified by setDefaultQueryExtent
  56746. * @returns the box extent values
  56747. */
  56748. getDefaultQueryExtent(): Vector3;
  56749. /**
  56750. * Disposes
  56751. */
  56752. dispose(): void;
  56753. /**
  56754. * If this plugin is supported
  56755. * @returns true if plugin is supported
  56756. */
  56757. isSupported(): boolean;
  56758. }
  56759. /**
  56760. * Recast detour crowd implementation
  56761. */
  56762. export class RecastJSCrowd implements ICrowd {
  56763. /**
  56764. * Recast/detour plugin
  56765. */
  56766. bjsRECASTPlugin: RecastJSPlugin;
  56767. /**
  56768. * Link to the detour crowd
  56769. */
  56770. recastCrowd: any;
  56771. /**
  56772. * One transform per agent
  56773. */
  56774. transforms: TransformNode[];
  56775. /**
  56776. * All agents created
  56777. */
  56778. agents: number[];
  56779. /**
  56780. * Link to the scene is kept to unregister the crowd from the scene
  56781. */
  56782. private _scene;
  56783. /**
  56784. * Observer for crowd updates
  56785. */
  56786. private _onBeforeAnimationsObserver;
  56787. /**
  56788. * Constructor
  56789. * @param plugin recastJS plugin
  56790. * @param maxAgents the maximum agent count in the crowd
  56791. * @param maxAgentRadius the maximum radius an agent can have
  56792. * @param scene to attach the crowd to
  56793. * @returns the crowd you can add agents to
  56794. */
  56795. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56796. /**
  56797. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56798. * You can attach anything to that node. The node position is updated in the scene update tick.
  56799. * @param pos world position that will be constrained by the navigation mesh
  56800. * @param parameters agent parameters
  56801. * @param transform hooked to the agent that will be update by the scene
  56802. * @returns agent index
  56803. */
  56804. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56805. /**
  56806. * Returns the agent position in world space
  56807. * @param index agent index returned by addAgent
  56808. * @returns world space position
  56809. */
  56810. getAgentPosition(index: number): Vector3;
  56811. /**
  56812. * Returns the agent velocity in world space
  56813. * @param index agent index returned by addAgent
  56814. * @returns world space velocity
  56815. */
  56816. getAgentVelocity(index: number): Vector3;
  56817. /**
  56818. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56819. * @param index agent index returned by addAgent
  56820. * @param destination targeted world position
  56821. */
  56822. agentGoto(index: number, destination: Vector3): void;
  56823. /**
  56824. * remove a particular agent previously created
  56825. * @param index agent index returned by addAgent
  56826. */
  56827. removeAgent(index: number): void;
  56828. /**
  56829. * get the list of all agents attached to this crowd
  56830. * @returns list of agent indices
  56831. */
  56832. getAgents(): number[];
  56833. /**
  56834. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56835. * @param deltaTime in seconds
  56836. */
  56837. update(deltaTime: number): void;
  56838. /**
  56839. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56840. * The queries will try to find a solution within those bounds
  56841. * default is (1,1,1)
  56842. * @param extent x,y,z value that define the extent around the queries point of reference
  56843. */
  56844. setDefaultQueryExtent(extent: Vector3): void;
  56845. /**
  56846. * Get the Bounding box extent specified by setDefaultQueryExtent
  56847. * @returns the box extent values
  56848. */
  56849. getDefaultQueryExtent(): Vector3;
  56850. /**
  56851. * Release all resources
  56852. */
  56853. dispose(): void;
  56854. }
  56855. }
  56856. declare module BABYLON {
  56857. /**
  56858. * Class used to enable access to IndexedDB
  56859. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56860. */
  56861. export class Database implements IOfflineProvider {
  56862. private _callbackManifestChecked;
  56863. private _currentSceneUrl;
  56864. private _db;
  56865. private _enableSceneOffline;
  56866. private _enableTexturesOffline;
  56867. private _manifestVersionFound;
  56868. private _mustUpdateRessources;
  56869. private _hasReachedQuota;
  56870. private _isSupported;
  56871. private _idbFactory;
  56872. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56873. private static IsUASupportingBlobStorage;
  56874. /**
  56875. * Gets a boolean indicating if Database storate is enabled (off by default)
  56876. */
  56877. static IDBStorageEnabled: boolean;
  56878. /**
  56879. * Gets a boolean indicating if scene must be saved in the database
  56880. */
  56881. readonly enableSceneOffline: boolean;
  56882. /**
  56883. * Gets a boolean indicating if textures must be saved in the database
  56884. */
  56885. readonly enableTexturesOffline: boolean;
  56886. /**
  56887. * Creates a new Database
  56888. * @param urlToScene defines the url to load the scene
  56889. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56890. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56891. */
  56892. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56893. private static _ParseURL;
  56894. private static _ReturnFullUrlLocation;
  56895. private _checkManifestFile;
  56896. /**
  56897. * Open the database and make it available
  56898. * @param successCallback defines the callback to call on success
  56899. * @param errorCallback defines the callback to call on error
  56900. */
  56901. open(successCallback: () => void, errorCallback: () => void): void;
  56902. /**
  56903. * Loads an image from the database
  56904. * @param url defines the url to load from
  56905. * @param image defines the target DOM image
  56906. */
  56907. loadImage(url: string, image: HTMLImageElement): void;
  56908. private _loadImageFromDBAsync;
  56909. private _saveImageIntoDBAsync;
  56910. private _checkVersionFromDB;
  56911. private _loadVersionFromDBAsync;
  56912. private _saveVersionIntoDBAsync;
  56913. /**
  56914. * Loads a file from database
  56915. * @param url defines the URL to load from
  56916. * @param sceneLoaded defines a callback to call on success
  56917. * @param progressCallBack defines a callback to call when progress changed
  56918. * @param errorCallback defines a callback to call on error
  56919. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56920. */
  56921. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56922. private _loadFileAsync;
  56923. private _saveFileAsync;
  56924. /**
  56925. * Validates if xhr data is correct
  56926. * @param xhr defines the request to validate
  56927. * @param dataType defines the expected data type
  56928. * @returns true if data is correct
  56929. */
  56930. private static _ValidateXHRData;
  56931. }
  56932. }
  56933. declare module BABYLON {
  56934. /** @hidden */
  56935. export var gpuUpdateParticlesPixelShader: {
  56936. name: string;
  56937. shader: string;
  56938. };
  56939. }
  56940. declare module BABYLON {
  56941. /** @hidden */
  56942. export var gpuUpdateParticlesVertexShader: {
  56943. name: string;
  56944. shader: string;
  56945. };
  56946. }
  56947. declare module BABYLON {
  56948. /** @hidden */
  56949. export var clipPlaneFragmentDeclaration2: {
  56950. name: string;
  56951. shader: string;
  56952. };
  56953. }
  56954. declare module BABYLON {
  56955. /** @hidden */
  56956. export var gpuRenderParticlesPixelShader: {
  56957. name: string;
  56958. shader: string;
  56959. };
  56960. }
  56961. declare module BABYLON {
  56962. /** @hidden */
  56963. export var clipPlaneVertexDeclaration2: {
  56964. name: string;
  56965. shader: string;
  56966. };
  56967. }
  56968. declare module BABYLON {
  56969. /** @hidden */
  56970. export var gpuRenderParticlesVertexShader: {
  56971. name: string;
  56972. shader: string;
  56973. };
  56974. }
  56975. declare module BABYLON {
  56976. /**
  56977. * This represents a GPU particle system in Babylon
  56978. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56979. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56980. */
  56981. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56982. /**
  56983. * The layer mask we are rendering the particles through.
  56984. */
  56985. layerMask: number;
  56986. private _capacity;
  56987. private _activeCount;
  56988. private _currentActiveCount;
  56989. private _accumulatedCount;
  56990. private _renderEffect;
  56991. private _updateEffect;
  56992. private _buffer0;
  56993. private _buffer1;
  56994. private _spriteBuffer;
  56995. private _updateVAO;
  56996. private _renderVAO;
  56997. private _targetIndex;
  56998. private _sourceBuffer;
  56999. private _targetBuffer;
  57000. private _engine;
  57001. private _currentRenderId;
  57002. private _started;
  57003. private _stopped;
  57004. private _timeDelta;
  57005. private _randomTexture;
  57006. private _randomTexture2;
  57007. private _attributesStrideSize;
  57008. private _updateEffectOptions;
  57009. private _randomTextureSize;
  57010. private _actualFrame;
  57011. private readonly _rawTextureWidth;
  57012. /**
  57013. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57014. */
  57015. static readonly IsSupported: boolean;
  57016. /**
  57017. * An event triggered when the system is disposed.
  57018. */
  57019. onDisposeObservable: Observable<GPUParticleSystem>;
  57020. /**
  57021. * Gets the maximum number of particles active at the same time.
  57022. * @returns The max number of active particles.
  57023. */
  57024. getCapacity(): number;
  57025. /**
  57026. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57027. * to override the particles.
  57028. */
  57029. forceDepthWrite: boolean;
  57030. /**
  57031. * Gets or set the number of active particles
  57032. */
  57033. activeParticleCount: number;
  57034. private _preWarmDone;
  57035. /**
  57036. * Is this system ready to be used/rendered
  57037. * @return true if the system is ready
  57038. */
  57039. isReady(): boolean;
  57040. /**
  57041. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57042. * @returns True if it has been started, otherwise false.
  57043. */
  57044. isStarted(): boolean;
  57045. /**
  57046. * Starts the particle system and begins to emit
  57047. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57048. */
  57049. start(delay?: number): void;
  57050. /**
  57051. * Stops the particle system.
  57052. */
  57053. stop(): void;
  57054. /**
  57055. * Remove all active particles
  57056. */
  57057. reset(): void;
  57058. /**
  57059. * Returns the string "GPUParticleSystem"
  57060. * @returns a string containing the class name
  57061. */
  57062. getClassName(): string;
  57063. private _colorGradientsTexture;
  57064. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57065. /**
  57066. * Adds a new color gradient
  57067. * @param gradient defines the gradient to use (between 0 and 1)
  57068. * @param color1 defines the color to affect to the specified gradient
  57069. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57070. * @returns the current particle system
  57071. */
  57072. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57073. /**
  57074. * Remove a specific color gradient
  57075. * @param gradient defines the gradient to remove
  57076. * @returns the current particle system
  57077. */
  57078. removeColorGradient(gradient: number): GPUParticleSystem;
  57079. private _angularSpeedGradientsTexture;
  57080. private _sizeGradientsTexture;
  57081. private _velocityGradientsTexture;
  57082. private _limitVelocityGradientsTexture;
  57083. private _dragGradientsTexture;
  57084. private _addFactorGradient;
  57085. /**
  57086. * Adds a new size gradient
  57087. * @param gradient defines the gradient to use (between 0 and 1)
  57088. * @param factor defines the size factor to affect to the specified gradient
  57089. * @returns the current particle system
  57090. */
  57091. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57092. /**
  57093. * Remove a specific size gradient
  57094. * @param gradient defines the gradient to remove
  57095. * @returns the current particle system
  57096. */
  57097. removeSizeGradient(gradient: number): GPUParticleSystem;
  57098. /**
  57099. * Adds a new angular speed gradient
  57100. * @param gradient defines the gradient to use (between 0 and 1)
  57101. * @param factor defines the angular speed to affect to the specified gradient
  57102. * @returns the current particle system
  57103. */
  57104. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57105. /**
  57106. * Remove a specific angular speed gradient
  57107. * @param gradient defines the gradient to remove
  57108. * @returns the current particle system
  57109. */
  57110. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57111. /**
  57112. * Adds a new velocity gradient
  57113. * @param gradient defines the gradient to use (between 0 and 1)
  57114. * @param factor defines the velocity to affect to the specified gradient
  57115. * @returns the current particle system
  57116. */
  57117. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57118. /**
  57119. * Remove a specific velocity gradient
  57120. * @param gradient defines the gradient to remove
  57121. * @returns the current particle system
  57122. */
  57123. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57124. /**
  57125. * Adds a new limit velocity gradient
  57126. * @param gradient defines the gradient to use (between 0 and 1)
  57127. * @param factor defines the limit velocity value to affect to the specified gradient
  57128. * @returns the current particle system
  57129. */
  57130. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57131. /**
  57132. * Remove a specific limit velocity gradient
  57133. * @param gradient defines the gradient to remove
  57134. * @returns the current particle system
  57135. */
  57136. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57137. /**
  57138. * Adds a new drag gradient
  57139. * @param gradient defines the gradient to use (between 0 and 1)
  57140. * @param factor defines the drag value to affect to the specified gradient
  57141. * @returns the current particle system
  57142. */
  57143. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57144. /**
  57145. * Remove a specific drag gradient
  57146. * @param gradient defines the gradient to remove
  57147. * @returns the current particle system
  57148. */
  57149. removeDragGradient(gradient: number): GPUParticleSystem;
  57150. /**
  57151. * Not supported by GPUParticleSystem
  57152. * @param gradient defines the gradient to use (between 0 and 1)
  57153. * @param factor defines the emit rate value to affect to the specified gradient
  57154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57155. * @returns the current particle system
  57156. */
  57157. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57158. /**
  57159. * Not supported by GPUParticleSystem
  57160. * @param gradient defines the gradient to remove
  57161. * @returns the current particle system
  57162. */
  57163. removeEmitRateGradient(gradient: number): IParticleSystem;
  57164. /**
  57165. * Not supported by GPUParticleSystem
  57166. * @param gradient defines the gradient to use (between 0 and 1)
  57167. * @param factor defines the start size value to affect to the specified gradient
  57168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57169. * @returns the current particle system
  57170. */
  57171. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57172. /**
  57173. * Not supported by GPUParticleSystem
  57174. * @param gradient defines the gradient to remove
  57175. * @returns the current particle system
  57176. */
  57177. removeStartSizeGradient(gradient: number): IParticleSystem;
  57178. /**
  57179. * Not supported by GPUParticleSystem
  57180. * @param gradient defines the gradient to use (between 0 and 1)
  57181. * @param min defines the color remap minimal range
  57182. * @param max defines the color remap maximal range
  57183. * @returns the current particle system
  57184. */
  57185. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57186. /**
  57187. * Not supported by GPUParticleSystem
  57188. * @param gradient defines the gradient to remove
  57189. * @returns the current particle system
  57190. */
  57191. removeColorRemapGradient(): IParticleSystem;
  57192. /**
  57193. * Not supported by GPUParticleSystem
  57194. * @param gradient defines the gradient to use (between 0 and 1)
  57195. * @param min defines the alpha remap minimal range
  57196. * @param max defines the alpha remap maximal range
  57197. * @returns the current particle system
  57198. */
  57199. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57200. /**
  57201. * Not supported by GPUParticleSystem
  57202. * @param gradient defines the gradient to remove
  57203. * @returns the current particle system
  57204. */
  57205. removeAlphaRemapGradient(): IParticleSystem;
  57206. /**
  57207. * Not supported by GPUParticleSystem
  57208. * @param gradient defines the gradient to use (between 0 and 1)
  57209. * @param color defines the color to affect to the specified gradient
  57210. * @returns the current particle system
  57211. */
  57212. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57213. /**
  57214. * Not supported by GPUParticleSystem
  57215. * @param gradient defines the gradient to remove
  57216. * @returns the current particle system
  57217. */
  57218. removeRampGradient(): IParticleSystem;
  57219. /**
  57220. * Not supported by GPUParticleSystem
  57221. * @returns the list of ramp gradients
  57222. */
  57223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57224. /**
  57225. * Not supported by GPUParticleSystem
  57226. * Gets or sets a boolean indicating that ramp gradients must be used
  57227. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57228. */
  57229. useRampGradients: boolean;
  57230. /**
  57231. * Not supported by GPUParticleSystem
  57232. * @param gradient defines the gradient to use (between 0 and 1)
  57233. * @param factor defines the life time factor to affect to the specified gradient
  57234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57235. * @returns the current particle system
  57236. */
  57237. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57238. /**
  57239. * Not supported by GPUParticleSystem
  57240. * @param gradient defines the gradient to remove
  57241. * @returns the current particle system
  57242. */
  57243. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57244. /**
  57245. * Instantiates a GPU particle system.
  57246. * 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.
  57247. * @param name The name of the particle system
  57248. * @param options The options used to create the system
  57249. * @param scene The scene the particle system belongs to
  57250. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57251. */
  57252. constructor(name: string, options: Partial<{
  57253. capacity: number;
  57254. randomTextureSize: number;
  57255. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57256. protected _reset(): void;
  57257. private _createUpdateVAO;
  57258. private _createRenderVAO;
  57259. private _initialize;
  57260. /** @hidden */
  57261. _recreateUpdateEffect(): void;
  57262. /** @hidden */
  57263. _recreateRenderEffect(): void;
  57264. /**
  57265. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57266. * @param preWarm defines if we are in the pre-warmimg phase
  57267. */
  57268. animate(preWarm?: boolean): void;
  57269. private _createFactorGradientTexture;
  57270. private _createSizeGradientTexture;
  57271. private _createAngularSpeedGradientTexture;
  57272. private _createVelocityGradientTexture;
  57273. private _createLimitVelocityGradientTexture;
  57274. private _createDragGradientTexture;
  57275. private _createColorGradientTexture;
  57276. /**
  57277. * Renders the particle system in its current state
  57278. * @param preWarm defines if the system should only update the particles but not render them
  57279. * @returns the current number of particles
  57280. */
  57281. render(preWarm?: boolean): number;
  57282. /**
  57283. * Rebuilds the particle system
  57284. */
  57285. rebuild(): void;
  57286. private _releaseBuffers;
  57287. private _releaseVAOs;
  57288. /**
  57289. * Disposes the particle system and free the associated resources
  57290. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57291. */
  57292. dispose(disposeTexture?: boolean): void;
  57293. /**
  57294. * Clones the particle system.
  57295. * @param name The name of the cloned object
  57296. * @param newEmitter The new emitter to use
  57297. * @returns the cloned particle system
  57298. */
  57299. clone(name: string, newEmitter: any): GPUParticleSystem;
  57300. /**
  57301. * Serializes the particle system to a JSON object.
  57302. * @returns the JSON object
  57303. */
  57304. serialize(): any;
  57305. /**
  57306. * Parses a JSON object to create a GPU particle system.
  57307. * @param parsedParticleSystem The JSON object to parse
  57308. * @param scene The scene to create the particle system in
  57309. * @param rootUrl The root url to use to load external dependencies like texture
  57310. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57311. * @returns the parsed GPU particle system
  57312. */
  57313. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57314. }
  57315. }
  57316. declare module BABYLON {
  57317. /**
  57318. * Represents a set of particle systems working together to create a specific effect
  57319. */
  57320. export class ParticleSystemSet implements IDisposable {
  57321. private _emitterCreationOptions;
  57322. private _emitterNode;
  57323. /**
  57324. * Gets the particle system list
  57325. */
  57326. systems: IParticleSystem[];
  57327. /**
  57328. * Gets the emitter node used with this set
  57329. */
  57330. readonly emitterNode: Nullable<TransformNode>;
  57331. /**
  57332. * Creates a new emitter mesh as a sphere
  57333. * @param options defines the options used to create the sphere
  57334. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57335. * @param scene defines the hosting scene
  57336. */
  57337. setEmitterAsSphere(options: {
  57338. diameter: number;
  57339. segments: number;
  57340. color: Color3;
  57341. }, renderingGroupId: number, scene: Scene): void;
  57342. /**
  57343. * Starts all particle systems of the set
  57344. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57345. */
  57346. start(emitter?: AbstractMesh): void;
  57347. /**
  57348. * Release all associated resources
  57349. */
  57350. dispose(): void;
  57351. /**
  57352. * Serialize the set into a JSON compatible object
  57353. * @returns a JSON compatible representation of the set
  57354. */
  57355. serialize(): any;
  57356. /**
  57357. * Parse a new ParticleSystemSet from a serialized source
  57358. * @param data defines a JSON compatible representation of the set
  57359. * @param scene defines the hosting scene
  57360. * @param gpu defines if we want GPU particles or CPU particles
  57361. * @returns a new ParticleSystemSet
  57362. */
  57363. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57364. }
  57365. }
  57366. declare module BABYLON {
  57367. /**
  57368. * This class is made for on one-liner static method to help creating particle system set.
  57369. */
  57370. export class ParticleHelper {
  57371. /**
  57372. * Gets or sets base Assets URL
  57373. */
  57374. static BaseAssetsUrl: string;
  57375. /**
  57376. * Create a default particle system that you can tweak
  57377. * @param emitter defines the emitter to use
  57378. * @param capacity defines the system capacity (default is 500 particles)
  57379. * @param scene defines the hosting scene
  57380. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57381. * @returns the new Particle system
  57382. */
  57383. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57384. /**
  57385. * This is the main static method (one-liner) of this helper to create different particle systems
  57386. * @param type This string represents the type to the particle system to create
  57387. * @param scene The scene where the particle system should live
  57388. * @param gpu If the system will use gpu
  57389. * @returns the ParticleSystemSet created
  57390. */
  57391. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57392. /**
  57393. * Static function used to export a particle system to a ParticleSystemSet variable.
  57394. * Please note that the emitter shape is not exported
  57395. * @param systems defines the particle systems to export
  57396. * @returns the created particle system set
  57397. */
  57398. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57399. }
  57400. }
  57401. declare module BABYLON {
  57402. interface Engine {
  57403. /**
  57404. * Create an effect to use with particle systems.
  57405. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57406. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57407. * @param uniformsNames defines a list of attribute names
  57408. * @param samplers defines an array of string used to represent textures
  57409. * @param defines defines the string containing the defines to use to compile the shaders
  57410. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57411. * @param onCompiled defines a function to call when the effect creation is successful
  57412. * @param onError defines a function to call when the effect creation has failed
  57413. * @returns the new Effect
  57414. */
  57415. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57416. }
  57417. interface Mesh {
  57418. /**
  57419. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57420. * @returns an array of IParticleSystem
  57421. */
  57422. getEmittedParticleSystems(): IParticleSystem[];
  57423. /**
  57424. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57425. * @returns an array of IParticleSystem
  57426. */
  57427. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57428. }
  57429. /**
  57430. * @hidden
  57431. */
  57432. export var _IDoNeedToBeInTheBuild: number;
  57433. }
  57434. declare module BABYLON {
  57435. interface Scene {
  57436. /** @hidden (Backing field) */
  57437. _physicsEngine: Nullable<IPhysicsEngine>;
  57438. /**
  57439. * Gets the current physics engine
  57440. * @returns a IPhysicsEngine or null if none attached
  57441. */
  57442. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57443. /**
  57444. * Enables physics to the current scene
  57445. * @param gravity defines the scene's gravity for the physics engine
  57446. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57447. * @return a boolean indicating if the physics engine was initialized
  57448. */
  57449. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57450. /**
  57451. * Disables and disposes the physics engine associated with the scene
  57452. */
  57453. disablePhysicsEngine(): void;
  57454. /**
  57455. * Gets a boolean indicating if there is an active physics engine
  57456. * @returns a boolean indicating if there is an active physics engine
  57457. */
  57458. isPhysicsEnabled(): boolean;
  57459. /**
  57460. * Deletes a physics compound impostor
  57461. * @param compound defines the compound to delete
  57462. */
  57463. deleteCompoundImpostor(compound: any): void;
  57464. /**
  57465. * An event triggered when physic simulation is about to be run
  57466. */
  57467. onBeforePhysicsObservable: Observable<Scene>;
  57468. /**
  57469. * An event triggered when physic simulation has been done
  57470. */
  57471. onAfterPhysicsObservable: Observable<Scene>;
  57472. }
  57473. interface AbstractMesh {
  57474. /** @hidden */
  57475. _physicsImpostor: Nullable<PhysicsImpostor>;
  57476. /**
  57477. * Gets or sets impostor used for physic simulation
  57478. * @see http://doc.babylonjs.com/features/physics_engine
  57479. */
  57480. physicsImpostor: Nullable<PhysicsImpostor>;
  57481. /**
  57482. * Gets the current physics impostor
  57483. * @see http://doc.babylonjs.com/features/physics_engine
  57484. * @returns a physics impostor or null
  57485. */
  57486. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57487. /** Apply a physic impulse to the mesh
  57488. * @param force defines the force to apply
  57489. * @param contactPoint defines where to apply the force
  57490. * @returns the current mesh
  57491. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57492. */
  57493. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57494. /**
  57495. * Creates a physic joint between two meshes
  57496. * @param otherMesh defines the other mesh to use
  57497. * @param pivot1 defines the pivot to use on this mesh
  57498. * @param pivot2 defines the pivot to use on the other mesh
  57499. * @param options defines additional options (can be plugin dependent)
  57500. * @returns the current mesh
  57501. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57502. */
  57503. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57504. /** @hidden */
  57505. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57506. }
  57507. /**
  57508. * Defines the physics engine scene component responsible to manage a physics engine
  57509. */
  57510. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57511. /**
  57512. * The component name helpful to identify the component in the list of scene components.
  57513. */
  57514. readonly name: string;
  57515. /**
  57516. * The scene the component belongs to.
  57517. */
  57518. scene: Scene;
  57519. /**
  57520. * Creates a new instance of the component for the given scene
  57521. * @param scene Defines the scene to register the component in
  57522. */
  57523. constructor(scene: Scene);
  57524. /**
  57525. * Registers the component in a given scene
  57526. */
  57527. register(): void;
  57528. /**
  57529. * Rebuilds the elements related to this component in case of
  57530. * context lost for instance.
  57531. */
  57532. rebuild(): void;
  57533. /**
  57534. * Disposes the component and the associated ressources
  57535. */
  57536. dispose(): void;
  57537. }
  57538. }
  57539. declare module BABYLON {
  57540. /**
  57541. * A helper for physics simulations
  57542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57543. */
  57544. export class PhysicsHelper {
  57545. private _scene;
  57546. private _physicsEngine;
  57547. /**
  57548. * Initializes the Physics helper
  57549. * @param scene Babylon.js scene
  57550. */
  57551. constructor(scene: Scene);
  57552. /**
  57553. * Applies a radial explosion impulse
  57554. * @param origin the origin of the explosion
  57555. * @param radiusOrEventOptions the radius or the options of radial explosion
  57556. * @param strength the explosion strength
  57557. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57558. * @returns A physics radial explosion event, or null
  57559. */
  57560. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57561. /**
  57562. * Applies a radial explosion force
  57563. * @param origin the origin of the explosion
  57564. * @param radiusOrEventOptions the radius or the options of radial explosion
  57565. * @param strength the explosion strength
  57566. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57567. * @returns A physics radial explosion event, or null
  57568. */
  57569. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57570. /**
  57571. * Creates a gravitational field
  57572. * @param origin the origin of the explosion
  57573. * @param radiusOrEventOptions the radius or the options of radial explosion
  57574. * @param strength the explosion strength
  57575. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57576. * @returns A physics gravitational field event, or null
  57577. */
  57578. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57579. /**
  57580. * Creates a physics updraft event
  57581. * @param origin the origin of the updraft
  57582. * @param radiusOrEventOptions the radius or the options of the updraft
  57583. * @param strength the strength of the updraft
  57584. * @param height the height of the updraft
  57585. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57586. * @returns A physics updraft event, or null
  57587. */
  57588. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57589. /**
  57590. * Creates a physics vortex event
  57591. * @param origin the of the vortex
  57592. * @param radiusOrEventOptions the radius or the options of the vortex
  57593. * @param strength the strength of the vortex
  57594. * @param height the height of the vortex
  57595. * @returns a Physics vortex event, or null
  57596. * A physics vortex event or null
  57597. */
  57598. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57599. }
  57600. /**
  57601. * Represents a physics radial explosion event
  57602. */
  57603. class PhysicsRadialExplosionEvent {
  57604. private _scene;
  57605. private _options;
  57606. private _sphere;
  57607. private _dataFetched;
  57608. /**
  57609. * Initializes a radial explosioin event
  57610. * @param _scene BabylonJS scene
  57611. * @param _options The options for the vortex event
  57612. */
  57613. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57614. /**
  57615. * Returns the data related to the radial explosion event (sphere).
  57616. * @returns The radial explosion event data
  57617. */
  57618. getData(): PhysicsRadialExplosionEventData;
  57619. /**
  57620. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57621. * @param impostor A physics imposter
  57622. * @param origin the origin of the explosion
  57623. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57624. */
  57625. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57626. /**
  57627. * Triggers affecterd impostors callbacks
  57628. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57629. */
  57630. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57631. /**
  57632. * Disposes the sphere.
  57633. * @param force Specifies if the sphere should be disposed by force
  57634. */
  57635. dispose(force?: boolean): void;
  57636. /*** Helpers ***/
  57637. private _prepareSphere;
  57638. private _intersectsWithSphere;
  57639. }
  57640. /**
  57641. * Represents a gravitational field event
  57642. */
  57643. class PhysicsGravitationalFieldEvent {
  57644. private _physicsHelper;
  57645. private _scene;
  57646. private _origin;
  57647. private _options;
  57648. private _tickCallback;
  57649. private _sphere;
  57650. private _dataFetched;
  57651. /**
  57652. * Initializes the physics gravitational field event
  57653. * @param _physicsHelper A physics helper
  57654. * @param _scene BabylonJS scene
  57655. * @param _origin The origin position of the gravitational field event
  57656. * @param _options The options for the vortex event
  57657. */
  57658. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57659. /**
  57660. * Returns the data related to the gravitational field event (sphere).
  57661. * @returns A gravitational field event
  57662. */
  57663. getData(): PhysicsGravitationalFieldEventData;
  57664. /**
  57665. * Enables the gravitational field.
  57666. */
  57667. enable(): void;
  57668. /**
  57669. * Disables the gravitational field.
  57670. */
  57671. disable(): void;
  57672. /**
  57673. * Disposes the sphere.
  57674. * @param force The force to dispose from the gravitational field event
  57675. */
  57676. dispose(force?: boolean): void;
  57677. private _tick;
  57678. }
  57679. /**
  57680. * Represents a physics updraft event
  57681. */
  57682. class PhysicsUpdraftEvent {
  57683. private _scene;
  57684. private _origin;
  57685. private _options;
  57686. private _physicsEngine;
  57687. private _originTop;
  57688. private _originDirection;
  57689. private _tickCallback;
  57690. private _cylinder;
  57691. private _cylinderPosition;
  57692. private _dataFetched;
  57693. /**
  57694. * Initializes the physics updraft event
  57695. * @param _scene BabylonJS scene
  57696. * @param _origin The origin position of the updraft
  57697. * @param _options The options for the updraft event
  57698. */
  57699. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57700. /**
  57701. * Returns the data related to the updraft event (cylinder).
  57702. * @returns A physics updraft event
  57703. */
  57704. getData(): PhysicsUpdraftEventData;
  57705. /**
  57706. * Enables the updraft.
  57707. */
  57708. enable(): void;
  57709. /**
  57710. * Disables the updraft.
  57711. */
  57712. disable(): void;
  57713. /**
  57714. * Disposes the cylinder.
  57715. * @param force Specifies if the updraft should be disposed by force
  57716. */
  57717. dispose(force?: boolean): void;
  57718. private getImpostorHitData;
  57719. private _tick;
  57720. /*** Helpers ***/
  57721. private _prepareCylinder;
  57722. private _intersectsWithCylinder;
  57723. }
  57724. /**
  57725. * Represents a physics vortex event
  57726. */
  57727. class PhysicsVortexEvent {
  57728. private _scene;
  57729. private _origin;
  57730. private _options;
  57731. private _physicsEngine;
  57732. private _originTop;
  57733. private _tickCallback;
  57734. private _cylinder;
  57735. private _cylinderPosition;
  57736. private _dataFetched;
  57737. /**
  57738. * Initializes the physics vortex event
  57739. * @param _scene The BabylonJS scene
  57740. * @param _origin The origin position of the vortex
  57741. * @param _options The options for the vortex event
  57742. */
  57743. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57744. /**
  57745. * Returns the data related to the vortex event (cylinder).
  57746. * @returns The physics vortex event data
  57747. */
  57748. getData(): PhysicsVortexEventData;
  57749. /**
  57750. * Enables the vortex.
  57751. */
  57752. enable(): void;
  57753. /**
  57754. * Disables the cortex.
  57755. */
  57756. disable(): void;
  57757. /**
  57758. * Disposes the sphere.
  57759. * @param force
  57760. */
  57761. dispose(force?: boolean): void;
  57762. private getImpostorHitData;
  57763. private _tick;
  57764. /*** Helpers ***/
  57765. private _prepareCylinder;
  57766. private _intersectsWithCylinder;
  57767. }
  57768. /**
  57769. * Options fot the radial explosion event
  57770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57771. */
  57772. export class PhysicsRadialExplosionEventOptions {
  57773. /**
  57774. * The radius of the sphere for the radial explosion.
  57775. */
  57776. radius: number;
  57777. /**
  57778. * The strenth of the explosion.
  57779. */
  57780. strength: number;
  57781. /**
  57782. * The strenght of the force in correspondence to the distance of the affected object
  57783. */
  57784. falloff: PhysicsRadialImpulseFalloff;
  57785. /**
  57786. * Sphere options for the radial explosion.
  57787. */
  57788. sphere: {
  57789. segments: number;
  57790. diameter: number;
  57791. };
  57792. /**
  57793. * Sphere options for the radial explosion.
  57794. */
  57795. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57796. }
  57797. /**
  57798. * Options fot the updraft event
  57799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57800. */
  57801. export class PhysicsUpdraftEventOptions {
  57802. /**
  57803. * The radius of the cylinder for the vortex
  57804. */
  57805. radius: number;
  57806. /**
  57807. * The strenth of the updraft.
  57808. */
  57809. strength: number;
  57810. /**
  57811. * The height of the cylinder for the updraft.
  57812. */
  57813. height: number;
  57814. /**
  57815. * The mode for the the updraft.
  57816. */
  57817. updraftMode: PhysicsUpdraftMode;
  57818. }
  57819. /**
  57820. * Options fot the vortex event
  57821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57822. */
  57823. export class PhysicsVortexEventOptions {
  57824. /**
  57825. * The radius of the cylinder for the vortex
  57826. */
  57827. radius: number;
  57828. /**
  57829. * The strenth of the vortex.
  57830. */
  57831. strength: number;
  57832. /**
  57833. * The height of the cylinder for the vortex.
  57834. */
  57835. height: number;
  57836. /**
  57837. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57838. */
  57839. centripetalForceThreshold: number;
  57840. /**
  57841. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57842. */
  57843. centripetalForceMultiplier: number;
  57844. /**
  57845. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57846. */
  57847. centrifugalForceMultiplier: number;
  57848. /**
  57849. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57850. */
  57851. updraftForceMultiplier: number;
  57852. }
  57853. /**
  57854. * The strenght of the force in correspondence to the distance of the affected object
  57855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57856. */
  57857. export enum PhysicsRadialImpulseFalloff {
  57858. /** Defines that impulse is constant in strength across it's whole radius */
  57859. Constant = 0,
  57860. /** Defines that impulse gets weaker if it's further from the origin */
  57861. Linear = 1
  57862. }
  57863. /**
  57864. * The strength of the force in correspondence to the distance of the affected object
  57865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57866. */
  57867. export enum PhysicsUpdraftMode {
  57868. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57869. Center = 0,
  57870. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57871. Perpendicular = 1
  57872. }
  57873. /**
  57874. * Interface for a physics hit data
  57875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57876. */
  57877. export interface PhysicsHitData {
  57878. /**
  57879. * The force applied at the contact point
  57880. */
  57881. force: Vector3;
  57882. /**
  57883. * The contact point
  57884. */
  57885. contactPoint: Vector3;
  57886. /**
  57887. * The distance from the origin to the contact point
  57888. */
  57889. distanceFromOrigin: number;
  57890. }
  57891. /**
  57892. * Interface for radial explosion event data
  57893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57894. */
  57895. export interface PhysicsRadialExplosionEventData {
  57896. /**
  57897. * A sphere used for the radial explosion event
  57898. */
  57899. sphere: Mesh;
  57900. }
  57901. /**
  57902. * Interface for gravitational field event data
  57903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57904. */
  57905. export interface PhysicsGravitationalFieldEventData {
  57906. /**
  57907. * A sphere mesh used for the gravitational field event
  57908. */
  57909. sphere: Mesh;
  57910. }
  57911. /**
  57912. * Interface for updraft event data
  57913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57914. */
  57915. export interface PhysicsUpdraftEventData {
  57916. /**
  57917. * A cylinder used for the updraft event
  57918. */
  57919. cylinder: Mesh;
  57920. }
  57921. /**
  57922. * Interface for vortex event data
  57923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57924. */
  57925. export interface PhysicsVortexEventData {
  57926. /**
  57927. * A cylinder used for the vortex event
  57928. */
  57929. cylinder: Mesh;
  57930. }
  57931. /**
  57932. * Interface for an affected physics impostor
  57933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57934. */
  57935. export interface PhysicsAffectedImpostorWithData {
  57936. /**
  57937. * The impostor affected by the effect
  57938. */
  57939. impostor: PhysicsImpostor;
  57940. /**
  57941. * The data about the hit/horce from the explosion
  57942. */
  57943. hitData: PhysicsHitData;
  57944. }
  57945. }
  57946. declare module BABYLON {
  57947. /** @hidden */
  57948. export var blackAndWhitePixelShader: {
  57949. name: string;
  57950. shader: string;
  57951. };
  57952. }
  57953. declare module BABYLON {
  57954. /**
  57955. * Post process used to render in black and white
  57956. */
  57957. export class BlackAndWhitePostProcess extends PostProcess {
  57958. /**
  57959. * Linear about to convert he result to black and white (default: 1)
  57960. */
  57961. degree: number;
  57962. /**
  57963. * Creates a black and white post process
  57964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57965. * @param name The name of the effect.
  57966. * @param options The required width/height ratio to downsize to before computing the render pass.
  57967. * @param camera The camera to apply the render pass to.
  57968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57969. * @param engine The engine which the post process will be applied. (default: current engine)
  57970. * @param reusable If the post process can be reused on the same frame. (default: false)
  57971. */
  57972. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57973. }
  57974. }
  57975. declare module BABYLON {
  57976. /**
  57977. * This represents a set of one or more post processes in Babylon.
  57978. * A post process can be used to apply a shader to a texture after it is rendered.
  57979. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57980. */
  57981. export class PostProcessRenderEffect {
  57982. private _postProcesses;
  57983. private _getPostProcesses;
  57984. private _singleInstance;
  57985. private _cameras;
  57986. private _indicesForCamera;
  57987. /**
  57988. * Name of the effect
  57989. * @hidden
  57990. */
  57991. _name: string;
  57992. /**
  57993. * Instantiates a post process render effect.
  57994. * A post process can be used to apply a shader to a texture after it is rendered.
  57995. * @param engine The engine the effect is tied to
  57996. * @param name The name of the effect
  57997. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57998. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57999. */
  58000. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58001. /**
  58002. * Checks if all the post processes in the effect are supported.
  58003. */
  58004. readonly isSupported: boolean;
  58005. /**
  58006. * Updates the current state of the effect
  58007. * @hidden
  58008. */
  58009. _update(): void;
  58010. /**
  58011. * Attaches the effect on cameras
  58012. * @param cameras The camera to attach to.
  58013. * @hidden
  58014. */
  58015. _attachCameras(cameras: Camera): void;
  58016. /**
  58017. * Attaches the effect on cameras
  58018. * @param cameras The camera to attach to.
  58019. * @hidden
  58020. */
  58021. _attachCameras(cameras: Camera[]): void;
  58022. /**
  58023. * Detaches the effect on cameras
  58024. * @param cameras The camera to detatch from.
  58025. * @hidden
  58026. */
  58027. _detachCameras(cameras: Camera): void;
  58028. /**
  58029. * Detatches the effect on cameras
  58030. * @param cameras The camera to detatch from.
  58031. * @hidden
  58032. */
  58033. _detachCameras(cameras: Camera[]): void;
  58034. /**
  58035. * Enables the effect on given cameras
  58036. * @param cameras The camera to enable.
  58037. * @hidden
  58038. */
  58039. _enable(cameras: Camera): void;
  58040. /**
  58041. * Enables the effect on given cameras
  58042. * @param cameras The camera to enable.
  58043. * @hidden
  58044. */
  58045. _enable(cameras: Nullable<Camera[]>): void;
  58046. /**
  58047. * Disables the effect on the given cameras
  58048. * @param cameras The camera to disable.
  58049. * @hidden
  58050. */
  58051. _disable(cameras: Camera): void;
  58052. /**
  58053. * Disables the effect on the given cameras
  58054. * @param cameras The camera to disable.
  58055. * @hidden
  58056. */
  58057. _disable(cameras: Nullable<Camera[]>): void;
  58058. /**
  58059. * Gets a list of the post processes contained in the effect.
  58060. * @param camera The camera to get the post processes on.
  58061. * @returns The list of the post processes in the effect.
  58062. */
  58063. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58064. }
  58065. }
  58066. declare module BABYLON {
  58067. /** @hidden */
  58068. export var extractHighlightsPixelShader: {
  58069. name: string;
  58070. shader: string;
  58071. };
  58072. }
  58073. declare module BABYLON {
  58074. /**
  58075. * 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.
  58076. */
  58077. export class ExtractHighlightsPostProcess extends PostProcess {
  58078. /**
  58079. * The luminance threshold, pixels below this value will be set to black.
  58080. */
  58081. threshold: number;
  58082. /** @hidden */
  58083. _exposure: number;
  58084. /**
  58085. * Post process which has the input texture to be used when performing highlight extraction
  58086. * @hidden
  58087. */
  58088. _inputPostProcess: Nullable<PostProcess>;
  58089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58090. }
  58091. }
  58092. declare module BABYLON {
  58093. /** @hidden */
  58094. export var bloomMergePixelShader: {
  58095. name: string;
  58096. shader: string;
  58097. };
  58098. }
  58099. declare module BABYLON {
  58100. /**
  58101. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58102. */
  58103. export class BloomMergePostProcess extends PostProcess {
  58104. /** Weight of the bloom to be added to the original input. */
  58105. weight: number;
  58106. /**
  58107. * Creates a new instance of @see BloomMergePostProcess
  58108. * @param name The name of the effect.
  58109. * @param originalFromInput Post process which's input will be used for the merge.
  58110. * @param blurred Blurred highlights post process which's output will be used.
  58111. * @param weight Weight of the bloom to be added to the original input.
  58112. * @param options The required width/height ratio to downsize to before computing the render pass.
  58113. * @param camera The camera to apply the render pass to.
  58114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58115. * @param engine The engine which the post process will be applied. (default: current engine)
  58116. * @param reusable If the post process can be reused on the same frame. (default: false)
  58117. * @param textureType Type of textures used when performing the post process. (default: 0)
  58118. * @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)
  58119. */
  58120. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58121. /** Weight of the bloom to be added to the original input. */
  58122. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58123. }
  58124. }
  58125. declare module BABYLON {
  58126. /**
  58127. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58128. */
  58129. export class BloomEffect extends PostProcessRenderEffect {
  58130. private bloomScale;
  58131. /**
  58132. * @hidden Internal
  58133. */
  58134. _effects: Array<PostProcess>;
  58135. /**
  58136. * @hidden Internal
  58137. */
  58138. _downscale: ExtractHighlightsPostProcess;
  58139. private _blurX;
  58140. private _blurY;
  58141. private _merge;
  58142. /**
  58143. * The luminance threshold to find bright areas of the image to bloom.
  58144. */
  58145. threshold: number;
  58146. /**
  58147. * The strength of the bloom.
  58148. */
  58149. weight: number;
  58150. /**
  58151. * Specifies the size of the bloom blur kernel, relative to the final output size
  58152. */
  58153. kernel: number;
  58154. /**
  58155. * Creates a new instance of @see BloomEffect
  58156. * @param scene The scene the effect belongs to.
  58157. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58158. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58159. * @param bloomWeight The the strength of bloom.
  58160. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58161. * @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)
  58162. */
  58163. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58164. /**
  58165. * Disposes each of the internal effects for a given camera.
  58166. * @param camera The camera to dispose the effect on.
  58167. */
  58168. disposeEffects(camera: Camera): void;
  58169. /**
  58170. * @hidden Internal
  58171. */
  58172. _updateEffects(): void;
  58173. /**
  58174. * Internal
  58175. * @returns if all the contained post processes are ready.
  58176. * @hidden
  58177. */
  58178. _isReady(): boolean;
  58179. }
  58180. }
  58181. declare module BABYLON {
  58182. /** @hidden */
  58183. export var chromaticAberrationPixelShader: {
  58184. name: string;
  58185. shader: string;
  58186. };
  58187. }
  58188. declare module BABYLON {
  58189. /**
  58190. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58191. */
  58192. export class ChromaticAberrationPostProcess extends PostProcess {
  58193. /**
  58194. * The amount of seperation of rgb channels (default: 30)
  58195. */
  58196. aberrationAmount: number;
  58197. /**
  58198. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58199. */
  58200. radialIntensity: number;
  58201. /**
  58202. * 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))
  58203. */
  58204. direction: Vector2;
  58205. /**
  58206. * 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))
  58207. */
  58208. centerPosition: Vector2;
  58209. /**
  58210. * Creates a new instance ChromaticAberrationPostProcess
  58211. * @param name The name of the effect.
  58212. * @param screenWidth The width of the screen to apply the effect on.
  58213. * @param screenHeight The height of the screen to apply the effect on.
  58214. * @param options The required width/height ratio to downsize to before computing the render pass.
  58215. * @param camera The camera to apply the render pass to.
  58216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58217. * @param engine The engine which the post process will be applied. (default: current engine)
  58218. * @param reusable If the post process can be reused on the same frame. (default: false)
  58219. * @param textureType Type of textures used when performing the post process. (default: 0)
  58220. * @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)
  58221. */
  58222. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58223. }
  58224. }
  58225. declare module BABYLON {
  58226. /** @hidden */
  58227. export var circleOfConfusionPixelShader: {
  58228. name: string;
  58229. shader: string;
  58230. };
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58235. */
  58236. export class CircleOfConfusionPostProcess extends PostProcess {
  58237. /**
  58238. * 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.
  58239. */
  58240. lensSize: number;
  58241. /**
  58242. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58243. */
  58244. fStop: number;
  58245. /**
  58246. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58247. */
  58248. focusDistance: number;
  58249. /**
  58250. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58251. */
  58252. focalLength: number;
  58253. private _depthTexture;
  58254. /**
  58255. * Creates a new instance CircleOfConfusionPostProcess
  58256. * @param name The name of the effect.
  58257. * @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.
  58258. * @param options The required width/height ratio to downsize to before computing the render pass.
  58259. * @param camera The camera to apply the render pass to.
  58260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58261. * @param engine The engine which the post process will be applied. (default: current engine)
  58262. * @param reusable If the post process can be reused on the same frame. (default: false)
  58263. * @param textureType Type of textures used when performing the post process. (default: 0)
  58264. * @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)
  58265. */
  58266. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58267. /**
  58268. * 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.
  58269. */
  58270. depthTexture: RenderTargetTexture;
  58271. }
  58272. }
  58273. declare module BABYLON {
  58274. /** @hidden */
  58275. export var colorCorrectionPixelShader: {
  58276. name: string;
  58277. shader: string;
  58278. };
  58279. }
  58280. declare module BABYLON {
  58281. /**
  58282. *
  58283. * This post-process allows the modification of rendered colors by using
  58284. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58285. *
  58286. * The object needs to be provided an url to a texture containing the color
  58287. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58288. * Use an image editing software to tweak the LUT to match your needs.
  58289. *
  58290. * For an example of a color LUT, see here:
  58291. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58292. * For explanations on color grading, see here:
  58293. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58294. *
  58295. */
  58296. export class ColorCorrectionPostProcess extends PostProcess {
  58297. private _colorTableTexture;
  58298. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58299. }
  58300. }
  58301. declare module BABYLON {
  58302. /** @hidden */
  58303. export var convolutionPixelShader: {
  58304. name: string;
  58305. shader: string;
  58306. };
  58307. }
  58308. declare module BABYLON {
  58309. /**
  58310. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58311. * input texture to perform effects such as edge detection or sharpening
  58312. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58313. */
  58314. export class ConvolutionPostProcess extends PostProcess {
  58315. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58316. kernel: number[];
  58317. /**
  58318. * Creates a new instance ConvolutionPostProcess
  58319. * @param name The name of the effect.
  58320. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58321. * @param options The required width/height ratio to downsize to before computing the render pass.
  58322. * @param camera The camera to apply the render pass to.
  58323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58324. * @param engine The engine which the post process will be applied. (default: current engine)
  58325. * @param reusable If the post process can be reused on the same frame. (default: false)
  58326. * @param textureType Type of textures used when performing the post process. (default: 0)
  58327. */
  58328. constructor(name: string,
  58329. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58330. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58331. /**
  58332. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58333. */
  58334. static EdgeDetect0Kernel: number[];
  58335. /**
  58336. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58337. */
  58338. static EdgeDetect1Kernel: number[];
  58339. /**
  58340. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58341. */
  58342. static EdgeDetect2Kernel: number[];
  58343. /**
  58344. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58345. */
  58346. static SharpenKernel: number[];
  58347. /**
  58348. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58349. */
  58350. static EmbossKernel: number[];
  58351. /**
  58352. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58353. */
  58354. static GaussianKernel: number[];
  58355. }
  58356. }
  58357. declare module BABYLON {
  58358. /**
  58359. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58360. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58361. * based on samples that have a large difference in distance than the center pixel.
  58362. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58363. */
  58364. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58365. direction: Vector2;
  58366. /**
  58367. * Creates a new instance CircleOfConfusionPostProcess
  58368. * @param name The name of the effect.
  58369. * @param scene The scene the effect belongs to.
  58370. * @param direction The direction the blur should be applied.
  58371. * @param kernel The size of the kernel used to blur.
  58372. * @param options The required width/height ratio to downsize to before computing the render pass.
  58373. * @param camera The camera to apply the render pass to.
  58374. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58375. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58377. * @param engine The engine which the post process will be applied. (default: current engine)
  58378. * @param reusable If the post process can be reused on the same frame. (default: false)
  58379. * @param textureType Type of textures used when performing the post process. (default: 0)
  58380. * @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)
  58381. */
  58382. 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);
  58383. }
  58384. }
  58385. declare module BABYLON {
  58386. /** @hidden */
  58387. export var depthOfFieldMergePixelShader: {
  58388. name: string;
  58389. shader: string;
  58390. };
  58391. }
  58392. declare module BABYLON {
  58393. /**
  58394. * Options to be set when merging outputs from the default pipeline.
  58395. */
  58396. export class DepthOfFieldMergePostProcessOptions {
  58397. /**
  58398. * The original image to merge on top of
  58399. */
  58400. originalFromInput: PostProcess;
  58401. /**
  58402. * Parameters to perform the merge of the depth of field effect
  58403. */
  58404. depthOfField?: {
  58405. circleOfConfusion: PostProcess;
  58406. blurSteps: Array<PostProcess>;
  58407. };
  58408. /**
  58409. * Parameters to perform the merge of bloom effect
  58410. */
  58411. bloom?: {
  58412. blurred: PostProcess;
  58413. weight: number;
  58414. };
  58415. }
  58416. /**
  58417. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58418. */
  58419. export class DepthOfFieldMergePostProcess extends PostProcess {
  58420. private blurSteps;
  58421. /**
  58422. * Creates a new instance of DepthOfFieldMergePostProcess
  58423. * @param name The name of the effect.
  58424. * @param originalFromInput Post process which's input will be used for the merge.
  58425. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58426. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58427. * @param options The required width/height ratio to downsize to before computing the render pass.
  58428. * @param camera The camera to apply the render pass to.
  58429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58430. * @param engine The engine which the post process will be applied. (default: current engine)
  58431. * @param reusable If the post process can be reused on the same frame. (default: false)
  58432. * @param textureType Type of textures used when performing the post process. (default: 0)
  58433. * @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)
  58434. */
  58435. 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);
  58436. /**
  58437. * Updates the effect with the current post process compile time values and recompiles the shader.
  58438. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58439. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58440. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58441. * @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
  58442. * @param onCompiled Called when the shader has been compiled.
  58443. * @param onError Called if there is an error when compiling a shader.
  58444. */
  58445. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58446. }
  58447. }
  58448. declare module BABYLON {
  58449. /**
  58450. * Specifies the level of max blur that should be applied when using the depth of field effect
  58451. */
  58452. export enum DepthOfFieldEffectBlurLevel {
  58453. /**
  58454. * Subtle blur
  58455. */
  58456. Low = 0,
  58457. /**
  58458. * Medium blur
  58459. */
  58460. Medium = 1,
  58461. /**
  58462. * Large blur
  58463. */
  58464. High = 2
  58465. }
  58466. /**
  58467. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58468. */
  58469. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58470. private _circleOfConfusion;
  58471. /**
  58472. * @hidden Internal, blurs from high to low
  58473. */
  58474. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58475. private _depthOfFieldBlurY;
  58476. private _dofMerge;
  58477. /**
  58478. * @hidden Internal post processes in depth of field effect
  58479. */
  58480. _effects: Array<PostProcess>;
  58481. /**
  58482. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58483. */
  58484. focalLength: number;
  58485. /**
  58486. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58487. */
  58488. fStop: number;
  58489. /**
  58490. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58491. */
  58492. focusDistance: number;
  58493. /**
  58494. * 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.
  58495. */
  58496. lensSize: number;
  58497. /**
  58498. * Creates a new instance DepthOfFieldEffect
  58499. * @param scene The scene the effect belongs to.
  58500. * @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.
  58501. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58502. * @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)
  58503. */
  58504. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58505. /**
  58506. * Get the current class name of the current effet
  58507. * @returns "DepthOfFieldEffect"
  58508. */
  58509. getClassName(): string;
  58510. /**
  58511. * 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.
  58512. */
  58513. depthTexture: RenderTargetTexture;
  58514. /**
  58515. * Disposes each of the internal effects for a given camera.
  58516. * @param camera The camera to dispose the effect on.
  58517. */
  58518. disposeEffects(camera: Camera): void;
  58519. /**
  58520. * @hidden Internal
  58521. */
  58522. _updateEffects(): void;
  58523. /**
  58524. * Internal
  58525. * @returns if all the contained post processes are ready.
  58526. * @hidden
  58527. */
  58528. _isReady(): boolean;
  58529. }
  58530. }
  58531. declare module BABYLON {
  58532. /** @hidden */
  58533. export var displayPassPixelShader: {
  58534. name: string;
  58535. shader: string;
  58536. };
  58537. }
  58538. declare module BABYLON {
  58539. /**
  58540. * DisplayPassPostProcess which produces an output the same as it's input
  58541. */
  58542. export class DisplayPassPostProcess extends PostProcess {
  58543. /**
  58544. * Creates the DisplayPassPostProcess
  58545. * @param name The name of the effect.
  58546. * @param options The required width/height ratio to downsize to before computing the render pass.
  58547. * @param camera The camera to apply the render pass to.
  58548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58549. * @param engine The engine which the post process will be applied. (default: current engine)
  58550. * @param reusable If the post process can be reused on the same frame. (default: false)
  58551. */
  58552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58553. }
  58554. }
  58555. declare module BABYLON {
  58556. /** @hidden */
  58557. export var filterPixelShader: {
  58558. name: string;
  58559. shader: string;
  58560. };
  58561. }
  58562. declare module BABYLON {
  58563. /**
  58564. * Applies a kernel filter to the image
  58565. */
  58566. export class FilterPostProcess extends PostProcess {
  58567. /** The matrix to be applied to the image */
  58568. kernelMatrix: Matrix;
  58569. /**
  58570. *
  58571. * @param name The name of the effect.
  58572. * @param kernelMatrix The matrix to be applied to the image
  58573. * @param options The required width/height ratio to downsize to before computing the render pass.
  58574. * @param camera The camera to apply the render pass to.
  58575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58576. * @param engine The engine which the post process will be applied. (default: current engine)
  58577. * @param reusable If the post process can be reused on the same frame. (default: false)
  58578. */
  58579. constructor(name: string,
  58580. /** The matrix to be applied to the image */
  58581. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58582. }
  58583. }
  58584. declare module BABYLON {
  58585. /** @hidden */
  58586. export var fxaaPixelShader: {
  58587. name: string;
  58588. shader: string;
  58589. };
  58590. }
  58591. declare module BABYLON {
  58592. /** @hidden */
  58593. export var fxaaVertexShader: {
  58594. name: string;
  58595. shader: string;
  58596. };
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * Fxaa post process
  58601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58602. */
  58603. export class FxaaPostProcess extends PostProcess {
  58604. /** @hidden */
  58605. texelWidth: number;
  58606. /** @hidden */
  58607. texelHeight: number;
  58608. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58609. private _getDefines;
  58610. }
  58611. }
  58612. declare module BABYLON {
  58613. /** @hidden */
  58614. export var grainPixelShader: {
  58615. name: string;
  58616. shader: string;
  58617. };
  58618. }
  58619. declare module BABYLON {
  58620. /**
  58621. * The GrainPostProcess adds noise to the image at mid luminance levels
  58622. */
  58623. export class GrainPostProcess extends PostProcess {
  58624. /**
  58625. * The intensity of the grain added (default: 30)
  58626. */
  58627. intensity: number;
  58628. /**
  58629. * If the grain should be randomized on every frame
  58630. */
  58631. animated: boolean;
  58632. /**
  58633. * Creates a new instance of @see GrainPostProcess
  58634. * @param name The name of the effect.
  58635. * @param options The required width/height ratio to downsize to before computing the render pass.
  58636. * @param camera The camera to apply the render pass to.
  58637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58638. * @param engine The engine which the post process will be applied. (default: current engine)
  58639. * @param reusable If the post process can be reused on the same frame. (default: false)
  58640. * @param textureType Type of textures used when performing the post process. (default: 0)
  58641. * @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)
  58642. */
  58643. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58644. }
  58645. }
  58646. declare module BABYLON {
  58647. /** @hidden */
  58648. export var highlightsPixelShader: {
  58649. name: string;
  58650. shader: string;
  58651. };
  58652. }
  58653. declare module BABYLON {
  58654. /**
  58655. * Extracts highlights from the image
  58656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58657. */
  58658. export class HighlightsPostProcess extends PostProcess {
  58659. /**
  58660. * Extracts highlights from the image
  58661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58662. * @param name The name of the effect.
  58663. * @param options The required width/height ratio to downsize to before computing the render pass.
  58664. * @param camera The camera to apply the render pass to.
  58665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58666. * @param engine The engine which the post process will be applied. (default: current engine)
  58667. * @param reusable If the post process can be reused on the same frame. (default: false)
  58668. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58669. */
  58670. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58671. }
  58672. }
  58673. declare module BABYLON {
  58674. /** @hidden */
  58675. export var mrtFragmentDeclaration: {
  58676. name: string;
  58677. shader: string;
  58678. };
  58679. }
  58680. declare module BABYLON {
  58681. /** @hidden */
  58682. export var geometryPixelShader: {
  58683. name: string;
  58684. shader: string;
  58685. };
  58686. }
  58687. declare module BABYLON {
  58688. /** @hidden */
  58689. export var geometryVertexShader: {
  58690. name: string;
  58691. shader: string;
  58692. };
  58693. }
  58694. declare module BABYLON {
  58695. /** @hidden */
  58696. interface ISavedTransformationMatrix {
  58697. world: Matrix;
  58698. viewProjection: Matrix;
  58699. }
  58700. /**
  58701. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58702. */
  58703. export class GeometryBufferRenderer {
  58704. /**
  58705. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58706. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58707. */
  58708. static readonly POSITION_TEXTURE_TYPE: number;
  58709. /**
  58710. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58711. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58712. */
  58713. static readonly VELOCITY_TEXTURE_TYPE: number;
  58714. /**
  58715. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58716. * in order to compute objects velocities when enableVelocity is set to "true"
  58717. * @hidden
  58718. */
  58719. _previousTransformationMatrices: {
  58720. [index: number]: ISavedTransformationMatrix;
  58721. };
  58722. /**
  58723. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58724. * in order to compute objects velocities when enableVelocity is set to "true"
  58725. * @hidden
  58726. */
  58727. _previousBonesTransformationMatrices: {
  58728. [index: number]: Float32Array;
  58729. };
  58730. /**
  58731. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58732. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58733. */
  58734. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58735. private _scene;
  58736. private _multiRenderTarget;
  58737. private _ratio;
  58738. private _enablePosition;
  58739. private _enableVelocity;
  58740. private _positionIndex;
  58741. private _velocityIndex;
  58742. protected _effect: Effect;
  58743. protected _cachedDefines: string;
  58744. /**
  58745. * Set the render list (meshes to be rendered) used in the G buffer.
  58746. */
  58747. renderList: Mesh[];
  58748. /**
  58749. * Gets wether or not G buffer are supported by the running hardware.
  58750. * This requires draw buffer supports
  58751. */
  58752. readonly isSupported: boolean;
  58753. /**
  58754. * Returns the index of the given texture type in the G-Buffer textures array
  58755. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58756. * @returns the index of the given texture type in the G-Buffer textures array
  58757. */
  58758. getTextureIndex(textureType: number): number;
  58759. /**
  58760. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58761. */
  58762. /**
  58763. * Sets whether or not objects positions are enabled for the G buffer.
  58764. */
  58765. enablePosition: boolean;
  58766. /**
  58767. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58768. */
  58769. /**
  58770. * Sets wether or not objects velocities are enabled for the G buffer.
  58771. */
  58772. enableVelocity: boolean;
  58773. /**
  58774. * Gets the scene associated with the buffer.
  58775. */
  58776. readonly scene: Scene;
  58777. /**
  58778. * Gets the ratio used by the buffer during its creation.
  58779. * How big is the buffer related to the main canvas.
  58780. */
  58781. readonly ratio: number;
  58782. /** @hidden */
  58783. static _SceneComponentInitialization: (scene: Scene) => void;
  58784. /**
  58785. * Creates a new G Buffer for the scene
  58786. * @param scene The scene the buffer belongs to
  58787. * @param ratio How big is the buffer related to the main canvas.
  58788. */
  58789. constructor(scene: Scene, ratio?: number);
  58790. /**
  58791. * Checks wether everything is ready to render a submesh to the G buffer.
  58792. * @param subMesh the submesh to check readiness for
  58793. * @param useInstances is the mesh drawn using instance or not
  58794. * @returns true if ready otherwise false
  58795. */
  58796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58797. /**
  58798. * Gets the current underlying G Buffer.
  58799. * @returns the buffer
  58800. */
  58801. getGBuffer(): MultiRenderTarget;
  58802. /**
  58803. * Gets the number of samples used to render the buffer (anti aliasing).
  58804. */
  58805. /**
  58806. * Sets the number of samples used to render the buffer (anti aliasing).
  58807. */
  58808. samples: number;
  58809. /**
  58810. * Disposes the renderer and frees up associated resources.
  58811. */
  58812. dispose(): void;
  58813. protected _createRenderTargets(): void;
  58814. private _copyBonesTransformationMatrices;
  58815. }
  58816. }
  58817. declare module BABYLON {
  58818. interface Scene {
  58819. /** @hidden (Backing field) */
  58820. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58821. /**
  58822. * Gets or Sets the current geometry buffer associated to the scene.
  58823. */
  58824. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58825. /**
  58826. * Enables a GeometryBufferRender and associates it with the scene
  58827. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58828. * @returns the GeometryBufferRenderer
  58829. */
  58830. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58831. /**
  58832. * Disables the GeometryBufferRender associated with the scene
  58833. */
  58834. disableGeometryBufferRenderer(): void;
  58835. }
  58836. /**
  58837. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58838. * in several rendering techniques.
  58839. */
  58840. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58841. /**
  58842. * The component name helpful to identify the component in the list of scene components.
  58843. */
  58844. readonly name: string;
  58845. /**
  58846. * The scene the component belongs to.
  58847. */
  58848. scene: Scene;
  58849. /**
  58850. * Creates a new instance of the component for the given scene
  58851. * @param scene Defines the scene to register the component in
  58852. */
  58853. constructor(scene: Scene);
  58854. /**
  58855. * Registers the component in a given scene
  58856. */
  58857. register(): void;
  58858. /**
  58859. * Rebuilds the elements related to this component in case of
  58860. * context lost for instance.
  58861. */
  58862. rebuild(): void;
  58863. /**
  58864. * Disposes the component and the associated ressources
  58865. */
  58866. dispose(): void;
  58867. private _gatherRenderTargets;
  58868. }
  58869. }
  58870. declare module BABYLON {
  58871. /** @hidden */
  58872. export var motionBlurPixelShader: {
  58873. name: string;
  58874. shader: string;
  58875. };
  58876. }
  58877. declare module BABYLON {
  58878. /**
  58879. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58880. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58881. * As an example, all you have to do is to create the post-process:
  58882. * var mb = new BABYLON.MotionBlurPostProcess(
  58883. * 'mb', // The name of the effect.
  58884. * scene, // The scene containing the objects to blur according to their velocity.
  58885. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58886. * camera // The camera to apply the render pass to.
  58887. * );
  58888. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58889. */
  58890. export class MotionBlurPostProcess extends PostProcess {
  58891. /**
  58892. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58893. */
  58894. motionStrength: number;
  58895. /**
  58896. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58897. */
  58898. /**
  58899. * Sets the number of iterations to be used for motion blur quality
  58900. */
  58901. motionBlurSamples: number;
  58902. private _motionBlurSamples;
  58903. private _geometryBufferRenderer;
  58904. /**
  58905. * Creates a new instance MotionBlurPostProcess
  58906. * @param name The name of the effect.
  58907. * @param scene The scene containing the objects to blur according to their velocity.
  58908. * @param options The required width/height ratio to downsize to before computing the render pass.
  58909. * @param camera The camera to apply the render pass to.
  58910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58911. * @param engine The engine which the post process will be applied. (default: current engine)
  58912. * @param reusable If the post process can be reused on the same frame. (default: false)
  58913. * @param textureType Type of textures used when performing the post process. (default: 0)
  58914. * @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)
  58915. */
  58916. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58917. /**
  58918. * Excludes the given skinned mesh from computing bones velocities.
  58919. * 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.
  58920. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58921. */
  58922. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58923. /**
  58924. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58925. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58926. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58927. */
  58928. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58929. /**
  58930. * Disposes the post process.
  58931. * @param camera The camera to dispose the post process on.
  58932. */
  58933. dispose(camera?: Camera): void;
  58934. }
  58935. }
  58936. declare module BABYLON {
  58937. /** @hidden */
  58938. export var refractionPixelShader: {
  58939. name: string;
  58940. shader: string;
  58941. };
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Post process which applies a refractin texture
  58946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58947. */
  58948. export class RefractionPostProcess extends PostProcess {
  58949. /** the base color of the refraction (used to taint the rendering) */
  58950. color: Color3;
  58951. /** simulated refraction depth */
  58952. depth: number;
  58953. /** the coefficient of the base color (0 to remove base color tainting) */
  58954. colorLevel: number;
  58955. private _refTexture;
  58956. private _ownRefractionTexture;
  58957. /**
  58958. * Gets or sets the refraction texture
  58959. * Please note that you are responsible for disposing the texture if you set it manually
  58960. */
  58961. refractionTexture: Texture;
  58962. /**
  58963. * Initializes the RefractionPostProcess
  58964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58965. * @param name The name of the effect.
  58966. * @param refractionTextureUrl Url of the refraction texture to use
  58967. * @param color the base color of the refraction (used to taint the rendering)
  58968. * @param depth simulated refraction depth
  58969. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58970. * @param camera The camera to apply the render pass to.
  58971. * @param options The required width/height ratio to downsize to before computing the render pass.
  58972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58973. * @param engine The engine which the post process will be applied. (default: current engine)
  58974. * @param reusable If the post process can be reused on the same frame. (default: false)
  58975. */
  58976. constructor(name: string, refractionTextureUrl: string,
  58977. /** the base color of the refraction (used to taint the rendering) */
  58978. color: Color3,
  58979. /** simulated refraction depth */
  58980. depth: number,
  58981. /** the coefficient of the base color (0 to remove base color tainting) */
  58982. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58983. /**
  58984. * Disposes of the post process
  58985. * @param camera Camera to dispose post process on
  58986. */
  58987. dispose(camera: Camera): void;
  58988. }
  58989. }
  58990. declare module BABYLON {
  58991. /** @hidden */
  58992. export var sharpenPixelShader: {
  58993. name: string;
  58994. shader: string;
  58995. };
  58996. }
  58997. declare module BABYLON {
  58998. /**
  58999. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59000. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59001. */
  59002. export class SharpenPostProcess extends PostProcess {
  59003. /**
  59004. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59005. */
  59006. colorAmount: number;
  59007. /**
  59008. * How much sharpness should be applied (default: 0.3)
  59009. */
  59010. edgeAmount: number;
  59011. /**
  59012. * Creates a new instance ConvolutionPostProcess
  59013. * @param name The name of the effect.
  59014. * @param options The required width/height ratio to downsize to before computing the render pass.
  59015. * @param camera The camera to apply the render pass to.
  59016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59017. * @param engine The engine which the post process will be applied. (default: current engine)
  59018. * @param reusable If the post process can be reused on the same frame. (default: false)
  59019. * @param textureType Type of textures used when performing the post process. (default: 0)
  59020. * @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)
  59021. */
  59022. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59023. }
  59024. }
  59025. declare module BABYLON {
  59026. /**
  59027. * PostProcessRenderPipeline
  59028. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59029. */
  59030. export class PostProcessRenderPipeline {
  59031. private engine;
  59032. private _renderEffects;
  59033. private _renderEffectsForIsolatedPass;
  59034. /**
  59035. * List of inspectable custom properties (used by the Inspector)
  59036. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59037. */
  59038. inspectableCustomProperties: IInspectable[];
  59039. /**
  59040. * @hidden
  59041. */
  59042. protected _cameras: Camera[];
  59043. /** @hidden */
  59044. _name: string;
  59045. /**
  59046. * Gets pipeline name
  59047. */
  59048. readonly name: string;
  59049. /**
  59050. * Initializes a PostProcessRenderPipeline
  59051. * @param engine engine to add the pipeline to
  59052. * @param name name of the pipeline
  59053. */
  59054. constructor(engine: Engine, name: string);
  59055. /**
  59056. * Gets the class name
  59057. * @returns "PostProcessRenderPipeline"
  59058. */
  59059. getClassName(): string;
  59060. /**
  59061. * If all the render effects in the pipeline are supported
  59062. */
  59063. readonly isSupported: boolean;
  59064. /**
  59065. * Adds an effect to the pipeline
  59066. * @param renderEffect the effect to add
  59067. */
  59068. addEffect(renderEffect: PostProcessRenderEffect): void;
  59069. /** @hidden */
  59070. _rebuild(): void;
  59071. /** @hidden */
  59072. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59073. /** @hidden */
  59074. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59075. /** @hidden */
  59076. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59077. /** @hidden */
  59078. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59079. /** @hidden */
  59080. _attachCameras(cameras: Camera, unique: boolean): void;
  59081. /** @hidden */
  59082. _attachCameras(cameras: Camera[], unique: boolean): void;
  59083. /** @hidden */
  59084. _detachCameras(cameras: Camera): void;
  59085. /** @hidden */
  59086. _detachCameras(cameras: Nullable<Camera[]>): void;
  59087. /** @hidden */
  59088. _update(): void;
  59089. /** @hidden */
  59090. _reset(): void;
  59091. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59092. /**
  59093. * Disposes of the pipeline
  59094. */
  59095. dispose(): void;
  59096. }
  59097. }
  59098. declare module BABYLON {
  59099. /**
  59100. * PostProcessRenderPipelineManager class
  59101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59102. */
  59103. export class PostProcessRenderPipelineManager {
  59104. private _renderPipelines;
  59105. /**
  59106. * Initializes a PostProcessRenderPipelineManager
  59107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59108. */
  59109. constructor();
  59110. /**
  59111. * Gets the list of supported render pipelines
  59112. */
  59113. readonly supportedPipelines: PostProcessRenderPipeline[];
  59114. /**
  59115. * Adds a pipeline to the manager
  59116. * @param renderPipeline The pipeline to add
  59117. */
  59118. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59119. /**
  59120. * Attaches a camera to the pipeline
  59121. * @param renderPipelineName The name of the pipeline to attach to
  59122. * @param cameras the camera to attach
  59123. * @param unique if the camera can be attached multiple times to the pipeline
  59124. */
  59125. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59126. /**
  59127. * Detaches a camera from the pipeline
  59128. * @param renderPipelineName The name of the pipeline to detach from
  59129. * @param cameras the camera to detach
  59130. */
  59131. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59132. /**
  59133. * Enables an effect by name on a pipeline
  59134. * @param renderPipelineName the name of the pipeline to enable the effect in
  59135. * @param renderEffectName the name of the effect to enable
  59136. * @param cameras the cameras that the effect should be enabled on
  59137. */
  59138. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59139. /**
  59140. * Disables an effect by name on a pipeline
  59141. * @param renderPipelineName the name of the pipeline to disable the effect in
  59142. * @param renderEffectName the name of the effect to disable
  59143. * @param cameras the cameras that the effect should be disabled on
  59144. */
  59145. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59146. /**
  59147. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59148. */
  59149. update(): void;
  59150. /** @hidden */
  59151. _rebuild(): void;
  59152. /**
  59153. * Disposes of the manager and pipelines
  59154. */
  59155. dispose(): void;
  59156. }
  59157. }
  59158. declare module BABYLON {
  59159. interface Scene {
  59160. /** @hidden (Backing field) */
  59161. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59162. /**
  59163. * Gets the postprocess render pipeline manager
  59164. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59165. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59166. */
  59167. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59168. }
  59169. /**
  59170. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59171. */
  59172. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59173. /**
  59174. * The component name helpfull to identify the component in the list of scene components.
  59175. */
  59176. readonly name: string;
  59177. /**
  59178. * The scene the component belongs to.
  59179. */
  59180. scene: Scene;
  59181. /**
  59182. * Creates a new instance of the component for the given scene
  59183. * @param scene Defines the scene to register the component in
  59184. */
  59185. constructor(scene: Scene);
  59186. /**
  59187. * Registers the component in a given scene
  59188. */
  59189. register(): void;
  59190. /**
  59191. * Rebuilds the elements related to this component in case of
  59192. * context lost for instance.
  59193. */
  59194. rebuild(): void;
  59195. /**
  59196. * Disposes the component and the associated ressources
  59197. */
  59198. dispose(): void;
  59199. private _gatherRenderTargets;
  59200. }
  59201. }
  59202. declare module BABYLON {
  59203. /**
  59204. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59205. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59206. */
  59207. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59208. private _scene;
  59209. private _camerasToBeAttached;
  59210. /**
  59211. * ID of the sharpen post process,
  59212. */
  59213. private readonly SharpenPostProcessId;
  59214. /**
  59215. * @ignore
  59216. * ID of the image processing post process;
  59217. */
  59218. readonly ImageProcessingPostProcessId: string;
  59219. /**
  59220. * @ignore
  59221. * ID of the Fast Approximate Anti-Aliasing post process;
  59222. */
  59223. readonly FxaaPostProcessId: string;
  59224. /**
  59225. * ID of the chromatic aberration post process,
  59226. */
  59227. private readonly ChromaticAberrationPostProcessId;
  59228. /**
  59229. * ID of the grain post process
  59230. */
  59231. private readonly GrainPostProcessId;
  59232. /**
  59233. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59234. */
  59235. sharpen: SharpenPostProcess;
  59236. private _sharpenEffect;
  59237. private bloom;
  59238. /**
  59239. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59240. */
  59241. depthOfField: DepthOfFieldEffect;
  59242. /**
  59243. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59244. */
  59245. fxaa: FxaaPostProcess;
  59246. /**
  59247. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59248. */
  59249. imageProcessing: ImageProcessingPostProcess;
  59250. /**
  59251. * Chromatic aberration post process which will shift rgb colors in the image
  59252. */
  59253. chromaticAberration: ChromaticAberrationPostProcess;
  59254. private _chromaticAberrationEffect;
  59255. /**
  59256. * Grain post process which add noise to the image
  59257. */
  59258. grain: GrainPostProcess;
  59259. private _grainEffect;
  59260. /**
  59261. * Glow post process which adds a glow to emissive areas of the image
  59262. */
  59263. private _glowLayer;
  59264. /**
  59265. * Animations which can be used to tweak settings over a period of time
  59266. */
  59267. animations: Animation[];
  59268. private _imageProcessingConfigurationObserver;
  59269. private _sharpenEnabled;
  59270. private _bloomEnabled;
  59271. private _depthOfFieldEnabled;
  59272. private _depthOfFieldBlurLevel;
  59273. private _fxaaEnabled;
  59274. private _imageProcessingEnabled;
  59275. private _defaultPipelineTextureType;
  59276. private _bloomScale;
  59277. private _chromaticAberrationEnabled;
  59278. private _grainEnabled;
  59279. private _buildAllowed;
  59280. /**
  59281. * Gets active scene
  59282. */
  59283. readonly scene: Scene;
  59284. /**
  59285. * Enable or disable the sharpen process from the pipeline
  59286. */
  59287. sharpenEnabled: boolean;
  59288. private _resizeObserver;
  59289. private _hardwareScaleLevel;
  59290. private _bloomKernel;
  59291. /**
  59292. * Specifies the size of the bloom blur kernel, relative to the final output size
  59293. */
  59294. bloomKernel: number;
  59295. /**
  59296. * Specifies the weight of the bloom in the final rendering
  59297. */
  59298. private _bloomWeight;
  59299. /**
  59300. * Specifies the luma threshold for the area that will be blurred by the bloom
  59301. */
  59302. private _bloomThreshold;
  59303. private _hdr;
  59304. /**
  59305. * The strength of the bloom.
  59306. */
  59307. bloomWeight: number;
  59308. /**
  59309. * The strength of the bloom.
  59310. */
  59311. bloomThreshold: number;
  59312. /**
  59313. * The scale of the bloom, lower value will provide better performance.
  59314. */
  59315. bloomScale: number;
  59316. /**
  59317. * Enable or disable the bloom from the pipeline
  59318. */
  59319. bloomEnabled: boolean;
  59320. private _rebuildBloom;
  59321. /**
  59322. * If the depth of field is enabled.
  59323. */
  59324. depthOfFieldEnabled: boolean;
  59325. /**
  59326. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59327. */
  59328. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59329. /**
  59330. * If the anti aliasing is enabled.
  59331. */
  59332. fxaaEnabled: boolean;
  59333. private _samples;
  59334. /**
  59335. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59336. */
  59337. samples: number;
  59338. /**
  59339. * If image processing is enabled.
  59340. */
  59341. imageProcessingEnabled: boolean;
  59342. /**
  59343. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59344. */
  59345. glowLayerEnabled: boolean;
  59346. /**
  59347. * Gets the glow layer (or null if not defined)
  59348. */
  59349. readonly glowLayer: Nullable<GlowLayer>;
  59350. /**
  59351. * Enable or disable the chromaticAberration process from the pipeline
  59352. */
  59353. chromaticAberrationEnabled: boolean;
  59354. /**
  59355. * Enable or disable the grain process from the pipeline
  59356. */
  59357. grainEnabled: boolean;
  59358. /**
  59359. * @constructor
  59360. * @param name - The rendering pipeline name (default: "")
  59361. * @param hdr - If high dynamic range textures should be used (default: true)
  59362. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59363. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59364. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59365. */
  59366. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59367. /**
  59368. * Get the class name
  59369. * @returns "DefaultRenderingPipeline"
  59370. */
  59371. getClassName(): string;
  59372. /**
  59373. * Force the compilation of the entire pipeline.
  59374. */
  59375. prepare(): void;
  59376. private _hasCleared;
  59377. private _prevPostProcess;
  59378. private _prevPrevPostProcess;
  59379. private _setAutoClearAndTextureSharing;
  59380. private _depthOfFieldSceneObserver;
  59381. private _buildPipeline;
  59382. private _disposePostProcesses;
  59383. /**
  59384. * Adds a camera to the pipeline
  59385. * @param camera the camera to be added
  59386. */
  59387. addCamera(camera: Camera): void;
  59388. /**
  59389. * Removes a camera from the pipeline
  59390. * @param camera the camera to remove
  59391. */
  59392. removeCamera(camera: Camera): void;
  59393. /**
  59394. * Dispose of the pipeline and stop all post processes
  59395. */
  59396. dispose(): void;
  59397. /**
  59398. * Serialize the rendering pipeline (Used when exporting)
  59399. * @returns the serialized object
  59400. */
  59401. serialize(): any;
  59402. /**
  59403. * Parse the serialized pipeline
  59404. * @param source Source pipeline.
  59405. * @param scene The scene to load the pipeline to.
  59406. * @param rootUrl The URL of the serialized pipeline.
  59407. * @returns An instantiated pipeline from the serialized object.
  59408. */
  59409. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59410. }
  59411. }
  59412. declare module BABYLON {
  59413. /** @hidden */
  59414. export var lensHighlightsPixelShader: {
  59415. name: string;
  59416. shader: string;
  59417. };
  59418. }
  59419. declare module BABYLON {
  59420. /** @hidden */
  59421. export var depthOfFieldPixelShader: {
  59422. name: string;
  59423. shader: string;
  59424. };
  59425. }
  59426. declare module BABYLON {
  59427. /**
  59428. * BABYLON.JS Chromatic Aberration GLSL Shader
  59429. * Author: Olivier Guyot
  59430. * Separates very slightly R, G and B colors on the edges of the screen
  59431. * Inspired by Francois Tarlier & Martins Upitis
  59432. */
  59433. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59434. /**
  59435. * @ignore
  59436. * The chromatic aberration PostProcess id in the pipeline
  59437. */
  59438. LensChromaticAberrationEffect: string;
  59439. /**
  59440. * @ignore
  59441. * The highlights enhancing PostProcess id in the pipeline
  59442. */
  59443. HighlightsEnhancingEffect: string;
  59444. /**
  59445. * @ignore
  59446. * The depth-of-field PostProcess id in the pipeline
  59447. */
  59448. LensDepthOfFieldEffect: string;
  59449. private _scene;
  59450. private _depthTexture;
  59451. private _grainTexture;
  59452. private _chromaticAberrationPostProcess;
  59453. private _highlightsPostProcess;
  59454. private _depthOfFieldPostProcess;
  59455. private _edgeBlur;
  59456. private _grainAmount;
  59457. private _chromaticAberration;
  59458. private _distortion;
  59459. private _highlightsGain;
  59460. private _highlightsThreshold;
  59461. private _dofDistance;
  59462. private _dofAperture;
  59463. private _dofDarken;
  59464. private _dofPentagon;
  59465. private _blurNoise;
  59466. /**
  59467. * @constructor
  59468. *
  59469. * Effect parameters are as follow:
  59470. * {
  59471. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59472. * edge_blur: number; // from 0 to x (1 for realism)
  59473. * distortion: number; // from 0 to x (1 for realism)
  59474. * grain_amount: number; // from 0 to 1
  59475. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59476. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59477. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59478. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59479. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59480. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59481. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59482. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59483. * }
  59484. * Note: if an effect parameter is unset, effect is disabled
  59485. *
  59486. * @param name The rendering pipeline name
  59487. * @param parameters - An object containing all parameters (see above)
  59488. * @param scene The scene linked to this pipeline
  59489. * @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)
  59490. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59491. */
  59492. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59493. /**
  59494. * Get the class name
  59495. * @returns "LensRenderingPipeline"
  59496. */
  59497. getClassName(): string;
  59498. /**
  59499. * Gets associated scene
  59500. */
  59501. readonly scene: Scene;
  59502. /**
  59503. * Gets or sets the edge blur
  59504. */
  59505. edgeBlur: number;
  59506. /**
  59507. * Gets or sets the grain amount
  59508. */
  59509. grainAmount: number;
  59510. /**
  59511. * Gets or sets the chromatic aberration amount
  59512. */
  59513. chromaticAberration: number;
  59514. /**
  59515. * Gets or sets the depth of field aperture
  59516. */
  59517. dofAperture: number;
  59518. /**
  59519. * Gets or sets the edge distortion
  59520. */
  59521. edgeDistortion: number;
  59522. /**
  59523. * Gets or sets the depth of field distortion
  59524. */
  59525. dofDistortion: number;
  59526. /**
  59527. * Gets or sets the darken out of focus amount
  59528. */
  59529. darkenOutOfFocus: number;
  59530. /**
  59531. * Gets or sets a boolean indicating if blur noise is enabled
  59532. */
  59533. blurNoise: boolean;
  59534. /**
  59535. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59536. */
  59537. pentagonBokeh: boolean;
  59538. /**
  59539. * Gets or sets the highlight grain amount
  59540. */
  59541. highlightsGain: number;
  59542. /**
  59543. * Gets or sets the highlight threshold
  59544. */
  59545. highlightsThreshold: number;
  59546. /**
  59547. * Sets the amount of blur at the edges
  59548. * @param amount blur amount
  59549. */
  59550. setEdgeBlur(amount: number): void;
  59551. /**
  59552. * Sets edge blur to 0
  59553. */
  59554. disableEdgeBlur(): void;
  59555. /**
  59556. * Sets the amout of grain
  59557. * @param amount Amount of grain
  59558. */
  59559. setGrainAmount(amount: number): void;
  59560. /**
  59561. * Set grain amount to 0
  59562. */
  59563. disableGrain(): void;
  59564. /**
  59565. * Sets the chromatic aberration amount
  59566. * @param amount amount of chromatic aberration
  59567. */
  59568. setChromaticAberration(amount: number): void;
  59569. /**
  59570. * Sets chromatic aberration amount to 0
  59571. */
  59572. disableChromaticAberration(): void;
  59573. /**
  59574. * Sets the EdgeDistortion amount
  59575. * @param amount amount of EdgeDistortion
  59576. */
  59577. setEdgeDistortion(amount: number): void;
  59578. /**
  59579. * Sets edge distortion to 0
  59580. */
  59581. disableEdgeDistortion(): void;
  59582. /**
  59583. * Sets the FocusDistance amount
  59584. * @param amount amount of FocusDistance
  59585. */
  59586. setFocusDistance(amount: number): void;
  59587. /**
  59588. * Disables depth of field
  59589. */
  59590. disableDepthOfField(): void;
  59591. /**
  59592. * Sets the Aperture amount
  59593. * @param amount amount of Aperture
  59594. */
  59595. setAperture(amount: number): void;
  59596. /**
  59597. * Sets the DarkenOutOfFocus amount
  59598. * @param amount amount of DarkenOutOfFocus
  59599. */
  59600. setDarkenOutOfFocus(amount: number): void;
  59601. private _pentagonBokehIsEnabled;
  59602. /**
  59603. * Creates a pentagon bokeh effect
  59604. */
  59605. enablePentagonBokeh(): void;
  59606. /**
  59607. * Disables the pentagon bokeh effect
  59608. */
  59609. disablePentagonBokeh(): void;
  59610. /**
  59611. * Enables noise blur
  59612. */
  59613. enableNoiseBlur(): void;
  59614. /**
  59615. * Disables noise blur
  59616. */
  59617. disableNoiseBlur(): void;
  59618. /**
  59619. * Sets the HighlightsGain amount
  59620. * @param amount amount of HighlightsGain
  59621. */
  59622. setHighlightsGain(amount: number): void;
  59623. /**
  59624. * Sets the HighlightsThreshold amount
  59625. * @param amount amount of HighlightsThreshold
  59626. */
  59627. setHighlightsThreshold(amount: number): void;
  59628. /**
  59629. * Disables highlights
  59630. */
  59631. disableHighlights(): void;
  59632. /**
  59633. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59634. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59635. */
  59636. dispose(disableDepthRender?: boolean): void;
  59637. private _createChromaticAberrationPostProcess;
  59638. private _createHighlightsPostProcess;
  59639. private _createDepthOfFieldPostProcess;
  59640. private _createGrainTexture;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /** @hidden */
  59645. export var ssao2PixelShader: {
  59646. name: string;
  59647. shader: string;
  59648. };
  59649. }
  59650. declare module BABYLON {
  59651. /** @hidden */
  59652. export var ssaoCombinePixelShader: {
  59653. name: string;
  59654. shader: string;
  59655. };
  59656. }
  59657. declare module BABYLON {
  59658. /**
  59659. * Render pipeline to produce ssao effect
  59660. */
  59661. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59662. /**
  59663. * @ignore
  59664. * The PassPostProcess id in the pipeline that contains the original scene color
  59665. */
  59666. SSAOOriginalSceneColorEffect: string;
  59667. /**
  59668. * @ignore
  59669. * The SSAO PostProcess id in the pipeline
  59670. */
  59671. SSAORenderEffect: string;
  59672. /**
  59673. * @ignore
  59674. * The horizontal blur PostProcess id in the pipeline
  59675. */
  59676. SSAOBlurHRenderEffect: string;
  59677. /**
  59678. * @ignore
  59679. * The vertical blur PostProcess id in the pipeline
  59680. */
  59681. SSAOBlurVRenderEffect: string;
  59682. /**
  59683. * @ignore
  59684. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59685. */
  59686. SSAOCombineRenderEffect: string;
  59687. /**
  59688. * The output strength of the SSAO post-process. Default value is 1.0.
  59689. */
  59690. totalStrength: number;
  59691. /**
  59692. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59693. */
  59694. maxZ: number;
  59695. /**
  59696. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59697. */
  59698. minZAspect: number;
  59699. private _samples;
  59700. /**
  59701. * Number of samples used for the SSAO calculations. Default value is 8
  59702. */
  59703. samples: number;
  59704. private _textureSamples;
  59705. /**
  59706. * Number of samples to use for antialiasing
  59707. */
  59708. textureSamples: number;
  59709. /**
  59710. * Ratio object used for SSAO ratio and blur ratio
  59711. */
  59712. private _ratio;
  59713. /**
  59714. * Dynamically generated sphere sampler.
  59715. */
  59716. private _sampleSphere;
  59717. /**
  59718. * Blur filter offsets
  59719. */
  59720. private _samplerOffsets;
  59721. private _expensiveBlur;
  59722. /**
  59723. * If bilateral blur should be used
  59724. */
  59725. expensiveBlur: boolean;
  59726. /**
  59727. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59728. */
  59729. radius: number;
  59730. /**
  59731. * The base color of the SSAO post-process
  59732. * The final result is "base + ssao" between [0, 1]
  59733. */
  59734. base: number;
  59735. /**
  59736. * Support test.
  59737. */
  59738. static readonly IsSupported: boolean;
  59739. private _scene;
  59740. private _depthTexture;
  59741. private _normalTexture;
  59742. private _randomTexture;
  59743. private _originalColorPostProcess;
  59744. private _ssaoPostProcess;
  59745. private _blurHPostProcess;
  59746. private _blurVPostProcess;
  59747. private _ssaoCombinePostProcess;
  59748. private _firstUpdate;
  59749. /**
  59750. * Gets active scene
  59751. */
  59752. readonly scene: Scene;
  59753. /**
  59754. * @constructor
  59755. * @param name The rendering pipeline name
  59756. * @param scene The scene linked to this pipeline
  59757. * @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 }
  59758. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59759. */
  59760. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59761. /**
  59762. * Get the class name
  59763. * @returns "SSAO2RenderingPipeline"
  59764. */
  59765. getClassName(): string;
  59766. /**
  59767. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59768. */
  59769. dispose(disableGeometryBufferRenderer?: boolean): void;
  59770. private _createBlurPostProcess;
  59771. /** @hidden */
  59772. _rebuild(): void;
  59773. private _bits;
  59774. private _radicalInverse_VdC;
  59775. private _hammersley;
  59776. private _hemisphereSample_uniform;
  59777. private _generateHemisphere;
  59778. private _createSSAOPostProcess;
  59779. private _createSSAOCombinePostProcess;
  59780. private _createRandomTexture;
  59781. /**
  59782. * Serialize the rendering pipeline (Used when exporting)
  59783. * @returns the serialized object
  59784. */
  59785. serialize(): any;
  59786. /**
  59787. * Parse the serialized pipeline
  59788. * @param source Source pipeline.
  59789. * @param scene The scene to load the pipeline to.
  59790. * @param rootUrl The URL of the serialized pipeline.
  59791. * @returns An instantiated pipeline from the serialized object.
  59792. */
  59793. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59794. }
  59795. }
  59796. declare module BABYLON {
  59797. /** @hidden */
  59798. export var ssaoPixelShader: {
  59799. name: string;
  59800. shader: string;
  59801. };
  59802. }
  59803. declare module BABYLON {
  59804. /**
  59805. * Render pipeline to produce ssao effect
  59806. */
  59807. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59808. /**
  59809. * @ignore
  59810. * The PassPostProcess id in the pipeline that contains the original scene color
  59811. */
  59812. SSAOOriginalSceneColorEffect: string;
  59813. /**
  59814. * @ignore
  59815. * The SSAO PostProcess id in the pipeline
  59816. */
  59817. SSAORenderEffect: string;
  59818. /**
  59819. * @ignore
  59820. * The horizontal blur PostProcess id in the pipeline
  59821. */
  59822. SSAOBlurHRenderEffect: string;
  59823. /**
  59824. * @ignore
  59825. * The vertical blur PostProcess id in the pipeline
  59826. */
  59827. SSAOBlurVRenderEffect: string;
  59828. /**
  59829. * @ignore
  59830. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59831. */
  59832. SSAOCombineRenderEffect: string;
  59833. /**
  59834. * The output strength of the SSAO post-process. Default value is 1.0.
  59835. */
  59836. totalStrength: number;
  59837. /**
  59838. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59839. */
  59840. radius: number;
  59841. /**
  59842. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59843. * Must not be equal to fallOff and superior to fallOff.
  59844. * Default value is 0.0075
  59845. */
  59846. area: number;
  59847. /**
  59848. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59849. * Must not be equal to area and inferior to area.
  59850. * Default value is 0.000001
  59851. */
  59852. fallOff: number;
  59853. /**
  59854. * The base color of the SSAO post-process
  59855. * The final result is "base + ssao" between [0, 1]
  59856. */
  59857. base: number;
  59858. private _scene;
  59859. private _depthTexture;
  59860. private _randomTexture;
  59861. private _originalColorPostProcess;
  59862. private _ssaoPostProcess;
  59863. private _blurHPostProcess;
  59864. private _blurVPostProcess;
  59865. private _ssaoCombinePostProcess;
  59866. private _firstUpdate;
  59867. /**
  59868. * Gets active scene
  59869. */
  59870. readonly scene: Scene;
  59871. /**
  59872. * @constructor
  59873. * @param name - The rendering pipeline name
  59874. * @param scene - The scene linked to this pipeline
  59875. * @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 }
  59876. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59877. */
  59878. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59879. /**
  59880. * Get the class name
  59881. * @returns "SSAORenderingPipeline"
  59882. */
  59883. getClassName(): string;
  59884. /**
  59885. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59886. */
  59887. dispose(disableDepthRender?: boolean): void;
  59888. private _createBlurPostProcess;
  59889. /** @hidden */
  59890. _rebuild(): void;
  59891. private _createSSAOPostProcess;
  59892. private _createSSAOCombinePostProcess;
  59893. private _createRandomTexture;
  59894. }
  59895. }
  59896. declare module BABYLON {
  59897. /** @hidden */
  59898. export var standardPixelShader: {
  59899. name: string;
  59900. shader: string;
  59901. };
  59902. }
  59903. declare module BABYLON {
  59904. /**
  59905. * Standard rendering pipeline
  59906. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59907. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59908. */
  59909. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59910. /**
  59911. * Public members
  59912. */
  59913. /**
  59914. * Post-process which contains the original scene color before the pipeline applies all the effects
  59915. */
  59916. originalPostProcess: Nullable<PostProcess>;
  59917. /**
  59918. * Post-process used to down scale an image x4
  59919. */
  59920. downSampleX4PostProcess: Nullable<PostProcess>;
  59921. /**
  59922. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59923. */
  59924. brightPassPostProcess: Nullable<PostProcess>;
  59925. /**
  59926. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59927. */
  59928. blurHPostProcesses: PostProcess[];
  59929. /**
  59930. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59931. */
  59932. blurVPostProcesses: PostProcess[];
  59933. /**
  59934. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59935. */
  59936. textureAdderPostProcess: Nullable<PostProcess>;
  59937. /**
  59938. * Post-process used to create volumetric lighting effect
  59939. */
  59940. volumetricLightPostProcess: Nullable<PostProcess>;
  59941. /**
  59942. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59943. */
  59944. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59945. /**
  59946. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59947. */
  59948. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59949. /**
  59950. * Post-process used to merge the volumetric light effect and the real scene color
  59951. */
  59952. volumetricLightMergePostProces: Nullable<PostProcess>;
  59953. /**
  59954. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59955. */
  59956. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59957. /**
  59958. * Base post-process used to calculate the average luminance of the final image for HDR
  59959. */
  59960. luminancePostProcess: Nullable<PostProcess>;
  59961. /**
  59962. * Post-processes used to create down sample post-processes in order to get
  59963. * the average luminance of the final image for HDR
  59964. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59965. */
  59966. luminanceDownSamplePostProcesses: PostProcess[];
  59967. /**
  59968. * Post-process used to create a HDR effect (light adaptation)
  59969. */
  59970. hdrPostProcess: Nullable<PostProcess>;
  59971. /**
  59972. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59973. */
  59974. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59975. /**
  59976. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59977. */
  59978. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59979. /**
  59980. * Post-process used to merge the final HDR post-process and the real scene color
  59981. */
  59982. hdrFinalPostProcess: Nullable<PostProcess>;
  59983. /**
  59984. * Post-process used to create a lens flare effect
  59985. */
  59986. lensFlarePostProcess: Nullable<PostProcess>;
  59987. /**
  59988. * Post-process that merges the result of the lens flare post-process and the real scene color
  59989. */
  59990. lensFlareComposePostProcess: Nullable<PostProcess>;
  59991. /**
  59992. * Post-process used to create a motion blur effect
  59993. */
  59994. motionBlurPostProcess: Nullable<PostProcess>;
  59995. /**
  59996. * Post-process used to create a depth of field effect
  59997. */
  59998. depthOfFieldPostProcess: Nullable<PostProcess>;
  59999. /**
  60000. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60001. */
  60002. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60003. /**
  60004. * Represents the brightness threshold in order to configure the illuminated surfaces
  60005. */
  60006. brightThreshold: number;
  60007. /**
  60008. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60009. */
  60010. blurWidth: number;
  60011. /**
  60012. * Sets if the blur for highlighted surfaces must be only horizontal
  60013. */
  60014. horizontalBlur: boolean;
  60015. /**
  60016. * Gets the overall exposure used by the pipeline
  60017. */
  60018. /**
  60019. * Sets the overall exposure used by the pipeline
  60020. */
  60021. exposure: number;
  60022. /**
  60023. * Texture used typically to simulate "dirty" on camera lens
  60024. */
  60025. lensTexture: Nullable<Texture>;
  60026. /**
  60027. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60028. */
  60029. volumetricLightCoefficient: number;
  60030. /**
  60031. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60032. */
  60033. volumetricLightPower: number;
  60034. /**
  60035. * Used the set the blur intensity to smooth the volumetric lights
  60036. */
  60037. volumetricLightBlurScale: number;
  60038. /**
  60039. * Light (spot or directional) used to generate the volumetric lights rays
  60040. * The source light must have a shadow generate so the pipeline can get its
  60041. * depth map
  60042. */
  60043. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60044. /**
  60045. * For eye adaptation, represents the minimum luminance the eye can see
  60046. */
  60047. hdrMinimumLuminance: number;
  60048. /**
  60049. * For eye adaptation, represents the decrease luminance speed
  60050. */
  60051. hdrDecreaseRate: number;
  60052. /**
  60053. * For eye adaptation, represents the increase luminance speed
  60054. */
  60055. hdrIncreaseRate: number;
  60056. /**
  60057. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60058. */
  60059. /**
  60060. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60061. */
  60062. hdrAutoExposure: boolean;
  60063. /**
  60064. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60065. */
  60066. lensColorTexture: Nullable<Texture>;
  60067. /**
  60068. * The overall strengh for the lens flare effect
  60069. */
  60070. lensFlareStrength: number;
  60071. /**
  60072. * Dispersion coefficient for lens flare ghosts
  60073. */
  60074. lensFlareGhostDispersal: number;
  60075. /**
  60076. * Main lens flare halo width
  60077. */
  60078. lensFlareHaloWidth: number;
  60079. /**
  60080. * Based on the lens distortion effect, defines how much the lens flare result
  60081. * is distorted
  60082. */
  60083. lensFlareDistortionStrength: number;
  60084. /**
  60085. * Configures the blur intensity used for for lens flare (halo)
  60086. */
  60087. lensFlareBlurWidth: number;
  60088. /**
  60089. * Lens star texture must be used to simulate rays on the flares and is available
  60090. * in the documentation
  60091. */
  60092. lensStarTexture: Nullable<Texture>;
  60093. /**
  60094. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60095. * flare effect by taking account of the dirt texture
  60096. */
  60097. lensFlareDirtTexture: Nullable<Texture>;
  60098. /**
  60099. * Represents the focal length for the depth of field effect
  60100. */
  60101. depthOfFieldDistance: number;
  60102. /**
  60103. * Represents the blur intensity for the blurred part of the depth of field effect
  60104. */
  60105. depthOfFieldBlurWidth: number;
  60106. /**
  60107. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60108. */
  60109. /**
  60110. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60111. */
  60112. motionStrength: number;
  60113. /**
  60114. * Gets wether or not the motion blur post-process is object based or screen based.
  60115. */
  60116. /**
  60117. * Sets wether or not the motion blur post-process should be object based or screen based
  60118. */
  60119. objectBasedMotionBlur: boolean;
  60120. /**
  60121. * List of animations for the pipeline (IAnimatable implementation)
  60122. */
  60123. animations: Animation[];
  60124. /**
  60125. * Private members
  60126. */
  60127. private _scene;
  60128. private _currentDepthOfFieldSource;
  60129. private _basePostProcess;
  60130. private _fixedExposure;
  60131. private _currentExposure;
  60132. private _hdrAutoExposure;
  60133. private _hdrCurrentLuminance;
  60134. private _motionStrength;
  60135. private _isObjectBasedMotionBlur;
  60136. private _floatTextureType;
  60137. private _camerasToBeAttached;
  60138. private _ratio;
  60139. private _bloomEnabled;
  60140. private _depthOfFieldEnabled;
  60141. private _vlsEnabled;
  60142. private _lensFlareEnabled;
  60143. private _hdrEnabled;
  60144. private _motionBlurEnabled;
  60145. private _fxaaEnabled;
  60146. private _motionBlurSamples;
  60147. private _volumetricLightStepsCount;
  60148. private _samples;
  60149. /**
  60150. * @ignore
  60151. * Specifies if the bloom pipeline is enabled
  60152. */
  60153. BloomEnabled: boolean;
  60154. /**
  60155. * @ignore
  60156. * Specifies if the depth of field pipeline is enabed
  60157. */
  60158. DepthOfFieldEnabled: boolean;
  60159. /**
  60160. * @ignore
  60161. * Specifies if the lens flare pipeline is enabed
  60162. */
  60163. LensFlareEnabled: boolean;
  60164. /**
  60165. * @ignore
  60166. * Specifies if the HDR pipeline is enabled
  60167. */
  60168. HDREnabled: boolean;
  60169. /**
  60170. * @ignore
  60171. * Specifies if the volumetric lights scattering effect is enabled
  60172. */
  60173. VLSEnabled: boolean;
  60174. /**
  60175. * @ignore
  60176. * Specifies if the motion blur effect is enabled
  60177. */
  60178. MotionBlurEnabled: boolean;
  60179. /**
  60180. * Specifies if anti-aliasing is enabled
  60181. */
  60182. fxaaEnabled: boolean;
  60183. /**
  60184. * Specifies the number of steps used to calculate the volumetric lights
  60185. * Typically in interval [50, 200]
  60186. */
  60187. volumetricLightStepsCount: number;
  60188. /**
  60189. * Specifies the number of samples used for the motion blur effect
  60190. * Typically in interval [16, 64]
  60191. */
  60192. motionBlurSamples: number;
  60193. /**
  60194. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60195. */
  60196. samples: number;
  60197. /**
  60198. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60199. * @constructor
  60200. * @param name The rendering pipeline name
  60201. * @param scene The scene linked to this pipeline
  60202. * @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)
  60203. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60204. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60205. */
  60206. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60207. private _buildPipeline;
  60208. private _createDownSampleX4PostProcess;
  60209. private _createBrightPassPostProcess;
  60210. private _createBlurPostProcesses;
  60211. private _createTextureAdderPostProcess;
  60212. private _createVolumetricLightPostProcess;
  60213. private _createLuminancePostProcesses;
  60214. private _createHdrPostProcess;
  60215. private _createLensFlarePostProcess;
  60216. private _createDepthOfFieldPostProcess;
  60217. private _createMotionBlurPostProcess;
  60218. private _getDepthTexture;
  60219. private _disposePostProcesses;
  60220. /**
  60221. * Dispose of the pipeline and stop all post processes
  60222. */
  60223. dispose(): void;
  60224. /**
  60225. * Serialize the rendering pipeline (Used when exporting)
  60226. * @returns the serialized object
  60227. */
  60228. serialize(): any;
  60229. /**
  60230. * Parse the serialized pipeline
  60231. * @param source Source pipeline.
  60232. * @param scene The scene to load the pipeline to.
  60233. * @param rootUrl The URL of the serialized pipeline.
  60234. * @returns An instantiated pipeline from the serialized object.
  60235. */
  60236. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60237. /**
  60238. * Luminance steps
  60239. */
  60240. static LuminanceSteps: number;
  60241. }
  60242. }
  60243. declare module BABYLON {
  60244. /** @hidden */
  60245. export var tonemapPixelShader: {
  60246. name: string;
  60247. shader: string;
  60248. };
  60249. }
  60250. declare module BABYLON {
  60251. /** Defines operator used for tonemapping */
  60252. export enum TonemappingOperator {
  60253. /** Hable */
  60254. Hable = 0,
  60255. /** Reinhard */
  60256. Reinhard = 1,
  60257. /** HejiDawson */
  60258. HejiDawson = 2,
  60259. /** Photographic */
  60260. Photographic = 3
  60261. }
  60262. /**
  60263. * Defines a post process to apply tone mapping
  60264. */
  60265. export class TonemapPostProcess extends PostProcess {
  60266. private _operator;
  60267. /** Defines the required exposure adjustement */
  60268. exposureAdjustment: number;
  60269. /**
  60270. * Creates a new TonemapPostProcess
  60271. * @param name defines the name of the postprocess
  60272. * @param _operator defines the operator to use
  60273. * @param exposureAdjustment defines the required exposure adjustement
  60274. * @param camera defines the camera to use (can be null)
  60275. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60276. * @param engine defines the hosting engine (can be ignore if camera is set)
  60277. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60278. */
  60279. constructor(name: string, _operator: TonemappingOperator,
  60280. /** Defines the required exposure adjustement */
  60281. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60282. }
  60283. }
  60284. declare module BABYLON {
  60285. /** @hidden */
  60286. export var depthVertexShader: {
  60287. name: string;
  60288. shader: string;
  60289. };
  60290. }
  60291. declare module BABYLON {
  60292. /** @hidden */
  60293. export var volumetricLightScatteringPixelShader: {
  60294. name: string;
  60295. shader: string;
  60296. };
  60297. }
  60298. declare module BABYLON {
  60299. /** @hidden */
  60300. export var volumetricLightScatteringPassVertexShader: {
  60301. name: string;
  60302. shader: string;
  60303. };
  60304. }
  60305. declare module BABYLON {
  60306. /** @hidden */
  60307. export var volumetricLightScatteringPassPixelShader: {
  60308. name: string;
  60309. shader: string;
  60310. };
  60311. }
  60312. declare module BABYLON {
  60313. /**
  60314. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60315. */
  60316. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60317. private _volumetricLightScatteringPass;
  60318. private _volumetricLightScatteringRTT;
  60319. private _viewPort;
  60320. private _screenCoordinates;
  60321. private _cachedDefines;
  60322. /**
  60323. * If not undefined, the mesh position is computed from the attached node position
  60324. */
  60325. attachedNode: {
  60326. position: Vector3;
  60327. };
  60328. /**
  60329. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60330. */
  60331. customMeshPosition: Vector3;
  60332. /**
  60333. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60334. */
  60335. useCustomMeshPosition: boolean;
  60336. /**
  60337. * If the post-process should inverse the light scattering direction
  60338. */
  60339. invert: boolean;
  60340. /**
  60341. * The internal mesh used by the post-process
  60342. */
  60343. mesh: Mesh;
  60344. /**
  60345. * @hidden
  60346. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60347. */
  60348. useDiffuseColor: boolean;
  60349. /**
  60350. * Array containing the excluded meshes not rendered in the internal pass
  60351. */
  60352. excludedMeshes: AbstractMesh[];
  60353. /**
  60354. * Controls the overall intensity of the post-process
  60355. */
  60356. exposure: number;
  60357. /**
  60358. * Dissipates each sample's contribution in range [0, 1]
  60359. */
  60360. decay: number;
  60361. /**
  60362. * Controls the overall intensity of each sample
  60363. */
  60364. weight: number;
  60365. /**
  60366. * Controls the density of each sample
  60367. */
  60368. density: number;
  60369. /**
  60370. * @constructor
  60371. * @param name The post-process name
  60372. * @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)
  60373. * @param camera The camera that the post-process will be attached to
  60374. * @param mesh The mesh used to create the light scattering
  60375. * @param samples The post-process quality, default 100
  60376. * @param samplingModeThe post-process filtering mode
  60377. * @param engine The babylon engine
  60378. * @param reusable If the post-process is reusable
  60379. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60380. */
  60381. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60382. /**
  60383. * Returns the string "VolumetricLightScatteringPostProcess"
  60384. * @returns "VolumetricLightScatteringPostProcess"
  60385. */
  60386. getClassName(): string;
  60387. private _isReady;
  60388. /**
  60389. * Sets the new light position for light scattering effect
  60390. * @param position The new custom light position
  60391. */
  60392. setCustomMeshPosition(position: Vector3): void;
  60393. /**
  60394. * Returns the light position for light scattering effect
  60395. * @return Vector3 The custom light position
  60396. */
  60397. getCustomMeshPosition(): Vector3;
  60398. /**
  60399. * Disposes the internal assets and detaches the post-process from the camera
  60400. */
  60401. dispose(camera: Camera): void;
  60402. /**
  60403. * Returns the render target texture used by the post-process
  60404. * @return the render target texture used by the post-process
  60405. */
  60406. getPass(): RenderTargetTexture;
  60407. private _meshExcluded;
  60408. private _createPass;
  60409. private _updateMeshScreenCoordinates;
  60410. /**
  60411. * Creates a default mesh for the Volumeric Light Scattering post-process
  60412. * @param name The mesh name
  60413. * @param scene The scene where to create the mesh
  60414. * @return the default mesh
  60415. */
  60416. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60417. }
  60418. }
  60419. declare module BABYLON {
  60420. interface Scene {
  60421. /** @hidden (Backing field) */
  60422. _boundingBoxRenderer: BoundingBoxRenderer;
  60423. /** @hidden (Backing field) */
  60424. _forceShowBoundingBoxes: boolean;
  60425. /**
  60426. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60427. */
  60428. forceShowBoundingBoxes: boolean;
  60429. /**
  60430. * Gets the bounding box renderer associated with the scene
  60431. * @returns a BoundingBoxRenderer
  60432. */
  60433. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60434. }
  60435. interface AbstractMesh {
  60436. /** @hidden (Backing field) */
  60437. _showBoundingBox: boolean;
  60438. /**
  60439. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60440. */
  60441. showBoundingBox: boolean;
  60442. }
  60443. /**
  60444. * Component responsible of rendering the bounding box of the meshes in a scene.
  60445. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60446. */
  60447. export class BoundingBoxRenderer implements ISceneComponent {
  60448. /**
  60449. * The component name helpfull to identify the component in the list of scene components.
  60450. */
  60451. readonly name: string;
  60452. /**
  60453. * The scene the component belongs to.
  60454. */
  60455. scene: Scene;
  60456. /**
  60457. * Color of the bounding box lines placed in front of an object
  60458. */
  60459. frontColor: Color3;
  60460. /**
  60461. * Color of the bounding box lines placed behind an object
  60462. */
  60463. backColor: Color3;
  60464. /**
  60465. * Defines if the renderer should show the back lines or not
  60466. */
  60467. showBackLines: boolean;
  60468. /**
  60469. * @hidden
  60470. */
  60471. renderList: SmartArray<BoundingBox>;
  60472. private _colorShader;
  60473. private _vertexBuffers;
  60474. private _indexBuffer;
  60475. private _fillIndexBuffer;
  60476. private _fillIndexData;
  60477. /**
  60478. * Instantiates a new bounding box renderer in a scene.
  60479. * @param scene the scene the renderer renders in
  60480. */
  60481. constructor(scene: Scene);
  60482. /**
  60483. * Registers the component in a given scene
  60484. */
  60485. register(): void;
  60486. private _evaluateSubMesh;
  60487. private _activeMesh;
  60488. private _prepareRessources;
  60489. private _createIndexBuffer;
  60490. /**
  60491. * Rebuilds the elements related to this component in case of
  60492. * context lost for instance.
  60493. */
  60494. rebuild(): void;
  60495. /**
  60496. * @hidden
  60497. */
  60498. reset(): void;
  60499. /**
  60500. * Render the bounding boxes of a specific rendering group
  60501. * @param renderingGroupId defines the rendering group to render
  60502. */
  60503. render(renderingGroupId: number): void;
  60504. /**
  60505. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60506. * @param mesh Define the mesh to render the occlusion bounding box for
  60507. */
  60508. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60509. /**
  60510. * Dispose and release the resources attached to this renderer.
  60511. */
  60512. dispose(): void;
  60513. }
  60514. }
  60515. declare module BABYLON {
  60516. /** @hidden */
  60517. export var depthPixelShader: {
  60518. name: string;
  60519. shader: string;
  60520. };
  60521. }
  60522. declare module BABYLON {
  60523. /**
  60524. * This represents a depth renderer in Babylon.
  60525. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60526. */
  60527. export class DepthRenderer {
  60528. private _scene;
  60529. private _depthMap;
  60530. private _effect;
  60531. private readonly _storeNonLinearDepth;
  60532. private readonly _clearColor;
  60533. /** Get if the depth renderer is using packed depth or not */
  60534. readonly isPacked: boolean;
  60535. private _cachedDefines;
  60536. private _camera;
  60537. /**
  60538. * Specifiess that the depth renderer will only be used within
  60539. * the camera it is created for.
  60540. * This can help forcing its rendering during the camera processing.
  60541. */
  60542. useOnlyInActiveCamera: boolean;
  60543. /** @hidden */
  60544. static _SceneComponentInitialization: (scene: Scene) => void;
  60545. /**
  60546. * Instantiates a depth renderer
  60547. * @param scene The scene the renderer belongs to
  60548. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60549. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60550. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60551. */
  60552. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60553. /**
  60554. * Creates the depth rendering effect and checks if the effect is ready.
  60555. * @param subMesh The submesh to be used to render the depth map of
  60556. * @param useInstances If multiple world instances should be used
  60557. * @returns if the depth renderer is ready to render the depth map
  60558. */
  60559. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60560. /**
  60561. * Gets the texture which the depth map will be written to.
  60562. * @returns The depth map texture
  60563. */
  60564. getDepthMap(): RenderTargetTexture;
  60565. /**
  60566. * Disposes of the depth renderer.
  60567. */
  60568. dispose(): void;
  60569. }
  60570. }
  60571. declare module BABYLON {
  60572. interface Scene {
  60573. /** @hidden (Backing field) */
  60574. _depthRenderer: {
  60575. [id: string]: DepthRenderer;
  60576. };
  60577. /**
  60578. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60579. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60580. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60581. * @returns the created depth renderer
  60582. */
  60583. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60584. /**
  60585. * Disables a depth renderer for a given camera
  60586. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60587. */
  60588. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60589. }
  60590. /**
  60591. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60592. * in several rendering techniques.
  60593. */
  60594. export class DepthRendererSceneComponent implements ISceneComponent {
  60595. /**
  60596. * The component name helpfull to identify the component in the list of scene components.
  60597. */
  60598. readonly name: string;
  60599. /**
  60600. * The scene the component belongs to.
  60601. */
  60602. scene: Scene;
  60603. /**
  60604. * Creates a new instance of the component for the given scene
  60605. * @param scene Defines the scene to register the component in
  60606. */
  60607. constructor(scene: Scene);
  60608. /**
  60609. * Registers the component in a given scene
  60610. */
  60611. register(): void;
  60612. /**
  60613. * Rebuilds the elements related to this component in case of
  60614. * context lost for instance.
  60615. */
  60616. rebuild(): void;
  60617. /**
  60618. * Disposes the component and the associated ressources
  60619. */
  60620. dispose(): void;
  60621. private _gatherRenderTargets;
  60622. private _gatherActiveCameraRenderTargets;
  60623. }
  60624. }
  60625. declare module BABYLON {
  60626. /** @hidden */
  60627. export var outlinePixelShader: {
  60628. name: string;
  60629. shader: string;
  60630. };
  60631. }
  60632. declare module BABYLON {
  60633. /** @hidden */
  60634. export var outlineVertexShader: {
  60635. name: string;
  60636. shader: string;
  60637. };
  60638. }
  60639. declare module BABYLON {
  60640. interface Scene {
  60641. /** @hidden */
  60642. _outlineRenderer: OutlineRenderer;
  60643. /**
  60644. * Gets the outline renderer associated with the scene
  60645. * @returns a OutlineRenderer
  60646. */
  60647. getOutlineRenderer(): OutlineRenderer;
  60648. }
  60649. interface AbstractMesh {
  60650. /** @hidden (Backing field) */
  60651. _renderOutline: boolean;
  60652. /**
  60653. * Gets or sets a boolean indicating if the outline must be rendered as well
  60654. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60655. */
  60656. renderOutline: boolean;
  60657. /** @hidden (Backing field) */
  60658. _renderOverlay: boolean;
  60659. /**
  60660. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60661. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60662. */
  60663. renderOverlay: boolean;
  60664. }
  60665. /**
  60666. * This class is responsible to draw bothe outline/overlay of meshes.
  60667. * It should not be used directly but through the available method on mesh.
  60668. */
  60669. export class OutlineRenderer implements ISceneComponent {
  60670. /**
  60671. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60672. */
  60673. private static _StencilReference;
  60674. /**
  60675. * The name of the component. Each component must have a unique name.
  60676. */
  60677. name: string;
  60678. /**
  60679. * The scene the component belongs to.
  60680. */
  60681. scene: Scene;
  60682. /**
  60683. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60684. */
  60685. zOffset: number;
  60686. private _engine;
  60687. private _effect;
  60688. private _cachedDefines;
  60689. private _savedDepthWrite;
  60690. /**
  60691. * Instantiates a new outline renderer. (There could be only one per scene).
  60692. * @param scene Defines the scene it belongs to
  60693. */
  60694. constructor(scene: Scene);
  60695. /**
  60696. * Register the component to one instance of a scene.
  60697. */
  60698. register(): void;
  60699. /**
  60700. * Rebuilds the elements related to this component in case of
  60701. * context lost for instance.
  60702. */
  60703. rebuild(): void;
  60704. /**
  60705. * Disposes the component and the associated ressources.
  60706. */
  60707. dispose(): void;
  60708. /**
  60709. * Renders the outline in the canvas.
  60710. * @param subMesh Defines the sumesh to render
  60711. * @param batch Defines the batch of meshes in case of instances
  60712. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60713. */
  60714. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60715. /**
  60716. * Returns whether or not the outline renderer is ready for a given submesh.
  60717. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60718. * @param subMesh Defines the submesh to check readyness for
  60719. * @param useInstances Defines wheter wee are trying to render instances or not
  60720. * @returns true if ready otherwise false
  60721. */
  60722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60723. private _beforeRenderingMesh;
  60724. private _afterRenderingMesh;
  60725. }
  60726. }
  60727. declare module BABYLON {
  60728. /**
  60729. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60730. * @see http://doc.babylonjs.com/babylon101/sprites
  60731. */
  60732. export class SpritePackedManager extends SpriteManager {
  60733. /** defines the packed manager's name */
  60734. name: string;
  60735. /**
  60736. * Creates a new sprite manager from a packed sprite sheet
  60737. * @param name defines the manager's name
  60738. * @param imgUrl defines the sprite sheet url
  60739. * @param capacity defines the maximum allowed number of sprites
  60740. * @param scene defines the hosting scene
  60741. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60742. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60743. * @param samplingMode defines the smapling mode to use with spritesheet
  60744. * @param fromPacked set to true; do not alter
  60745. */
  60746. constructor(
  60747. /** defines the packed manager's name */
  60748. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60749. }
  60750. }
  60751. declare module BABYLON {
  60752. /**
  60753. * Defines the list of states available for a task inside a AssetsManager
  60754. */
  60755. export enum AssetTaskState {
  60756. /**
  60757. * Initialization
  60758. */
  60759. INIT = 0,
  60760. /**
  60761. * Running
  60762. */
  60763. RUNNING = 1,
  60764. /**
  60765. * Done
  60766. */
  60767. DONE = 2,
  60768. /**
  60769. * Error
  60770. */
  60771. ERROR = 3
  60772. }
  60773. /**
  60774. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60775. */
  60776. export abstract class AbstractAssetTask {
  60777. /**
  60778. * Task name
  60779. */ name: string;
  60780. /**
  60781. * Callback called when the task is successful
  60782. */
  60783. onSuccess: (task: any) => void;
  60784. /**
  60785. * Callback called when the task is not successful
  60786. */
  60787. onError: (task: any, message?: string, exception?: any) => void;
  60788. /**
  60789. * Creates a new AssetsManager
  60790. * @param name defines the name of the task
  60791. */
  60792. constructor(
  60793. /**
  60794. * Task name
  60795. */ name: string);
  60796. private _isCompleted;
  60797. private _taskState;
  60798. private _errorObject;
  60799. /**
  60800. * Get if the task is completed
  60801. */
  60802. readonly isCompleted: boolean;
  60803. /**
  60804. * Gets the current state of the task
  60805. */
  60806. readonly taskState: AssetTaskState;
  60807. /**
  60808. * Gets the current error object (if task is in error)
  60809. */
  60810. readonly errorObject: {
  60811. message?: string;
  60812. exception?: any;
  60813. };
  60814. /**
  60815. * Internal only
  60816. * @hidden
  60817. */
  60818. _setErrorObject(message?: string, exception?: any): void;
  60819. /**
  60820. * Execute the current task
  60821. * @param scene defines the scene where you want your assets to be loaded
  60822. * @param onSuccess is a callback called when the task is successfully executed
  60823. * @param onError is a callback called if an error occurs
  60824. */
  60825. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60826. /**
  60827. * Execute the current task
  60828. * @param scene defines the scene where you want your assets to be loaded
  60829. * @param onSuccess is a callback called when the task is successfully executed
  60830. * @param onError is a callback called if an error occurs
  60831. */
  60832. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60833. /**
  60834. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60835. * This can be used with failed tasks that have the reason for failure fixed.
  60836. */
  60837. reset(): void;
  60838. private onErrorCallback;
  60839. private onDoneCallback;
  60840. }
  60841. /**
  60842. * Define the interface used by progress events raised during assets loading
  60843. */
  60844. export interface IAssetsProgressEvent {
  60845. /**
  60846. * Defines the number of remaining tasks to process
  60847. */
  60848. remainingCount: number;
  60849. /**
  60850. * Defines the total number of tasks
  60851. */
  60852. totalCount: number;
  60853. /**
  60854. * Defines the task that was just processed
  60855. */
  60856. task: AbstractAssetTask;
  60857. }
  60858. /**
  60859. * Class used to share progress information about assets loading
  60860. */
  60861. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60862. /**
  60863. * Defines the number of remaining tasks to process
  60864. */
  60865. remainingCount: number;
  60866. /**
  60867. * Defines the total number of tasks
  60868. */
  60869. totalCount: number;
  60870. /**
  60871. * Defines the task that was just processed
  60872. */
  60873. task: AbstractAssetTask;
  60874. /**
  60875. * Creates a AssetsProgressEvent
  60876. * @param remainingCount defines the number of remaining tasks to process
  60877. * @param totalCount defines the total number of tasks
  60878. * @param task defines the task that was just processed
  60879. */
  60880. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60881. }
  60882. /**
  60883. * Define a task used by AssetsManager to load meshes
  60884. */
  60885. export class MeshAssetTask extends AbstractAssetTask {
  60886. /**
  60887. * Defines the name of the task
  60888. */
  60889. name: string;
  60890. /**
  60891. * Defines the list of mesh's names you want to load
  60892. */
  60893. meshesNames: any;
  60894. /**
  60895. * Defines the root url to use as a base to load your meshes and associated resources
  60896. */
  60897. rootUrl: string;
  60898. /**
  60899. * Defines the filename of the scene to load from
  60900. */
  60901. sceneFilename: string;
  60902. /**
  60903. * Gets the list of loaded meshes
  60904. */
  60905. loadedMeshes: Array<AbstractMesh>;
  60906. /**
  60907. * Gets the list of loaded particle systems
  60908. */
  60909. loadedParticleSystems: Array<IParticleSystem>;
  60910. /**
  60911. * Gets the list of loaded skeletons
  60912. */
  60913. loadedSkeletons: Array<Skeleton>;
  60914. /**
  60915. * Gets the list of loaded animation groups
  60916. */
  60917. loadedAnimationGroups: Array<AnimationGroup>;
  60918. /**
  60919. * Callback called when the task is successful
  60920. */
  60921. onSuccess: (task: MeshAssetTask) => void;
  60922. /**
  60923. * Callback called when the task is successful
  60924. */
  60925. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60926. /**
  60927. * Creates a new MeshAssetTask
  60928. * @param name defines the name of the task
  60929. * @param meshesNames defines the list of mesh's names you want to load
  60930. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60931. * @param sceneFilename defines the filename of the scene to load from
  60932. */
  60933. constructor(
  60934. /**
  60935. * Defines the name of the task
  60936. */
  60937. name: string,
  60938. /**
  60939. * Defines the list of mesh's names you want to load
  60940. */
  60941. meshesNames: any,
  60942. /**
  60943. * Defines the root url to use as a base to load your meshes and associated resources
  60944. */
  60945. rootUrl: string,
  60946. /**
  60947. * Defines the filename of the scene to load from
  60948. */
  60949. sceneFilename: string);
  60950. /**
  60951. * Execute the current task
  60952. * @param scene defines the scene where you want your assets to be loaded
  60953. * @param onSuccess is a callback called when the task is successfully executed
  60954. * @param onError is a callback called if an error occurs
  60955. */
  60956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60957. }
  60958. /**
  60959. * Define a task used by AssetsManager to load text content
  60960. */
  60961. export class TextFileAssetTask extends AbstractAssetTask {
  60962. /**
  60963. * Defines the name of the task
  60964. */
  60965. name: string;
  60966. /**
  60967. * Defines the location of the file to load
  60968. */
  60969. url: string;
  60970. /**
  60971. * Gets the loaded text string
  60972. */
  60973. text: string;
  60974. /**
  60975. * Callback called when the task is successful
  60976. */
  60977. onSuccess: (task: TextFileAssetTask) => void;
  60978. /**
  60979. * Callback called when the task is successful
  60980. */
  60981. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60982. /**
  60983. * Creates a new TextFileAssetTask object
  60984. * @param name defines the name of the task
  60985. * @param url defines the location of the file to load
  60986. */
  60987. constructor(
  60988. /**
  60989. * Defines the name of the task
  60990. */
  60991. name: string,
  60992. /**
  60993. * Defines the location of the file to load
  60994. */
  60995. url: string);
  60996. /**
  60997. * Execute the current task
  60998. * @param scene defines the scene where you want your assets to be loaded
  60999. * @param onSuccess is a callback called when the task is successfully executed
  61000. * @param onError is a callback called if an error occurs
  61001. */
  61002. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61003. }
  61004. /**
  61005. * Define a task used by AssetsManager to load binary data
  61006. */
  61007. export class BinaryFileAssetTask extends AbstractAssetTask {
  61008. /**
  61009. * Defines the name of the task
  61010. */
  61011. name: string;
  61012. /**
  61013. * Defines the location of the file to load
  61014. */
  61015. url: string;
  61016. /**
  61017. * Gets the lodaded data (as an array buffer)
  61018. */
  61019. data: ArrayBuffer;
  61020. /**
  61021. * Callback called when the task is successful
  61022. */
  61023. onSuccess: (task: BinaryFileAssetTask) => void;
  61024. /**
  61025. * Callback called when the task is successful
  61026. */
  61027. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61028. /**
  61029. * Creates a new BinaryFileAssetTask object
  61030. * @param name defines the name of the new task
  61031. * @param url defines the location of the file to load
  61032. */
  61033. constructor(
  61034. /**
  61035. * Defines the name of the task
  61036. */
  61037. name: string,
  61038. /**
  61039. * Defines the location of the file to load
  61040. */
  61041. url: string);
  61042. /**
  61043. * Execute the current task
  61044. * @param scene defines the scene where you want your assets to be loaded
  61045. * @param onSuccess is a callback called when the task is successfully executed
  61046. * @param onError is a callback called if an error occurs
  61047. */
  61048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61049. }
  61050. /**
  61051. * Define a task used by AssetsManager to load images
  61052. */
  61053. export class ImageAssetTask extends AbstractAssetTask {
  61054. /**
  61055. * Defines the name of the task
  61056. */
  61057. name: string;
  61058. /**
  61059. * Defines the location of the image to load
  61060. */
  61061. url: string;
  61062. /**
  61063. * Gets the loaded images
  61064. */
  61065. image: HTMLImageElement;
  61066. /**
  61067. * Callback called when the task is successful
  61068. */
  61069. onSuccess: (task: ImageAssetTask) => void;
  61070. /**
  61071. * Callback called when the task is successful
  61072. */
  61073. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61074. /**
  61075. * Creates a new ImageAssetTask
  61076. * @param name defines the name of the task
  61077. * @param url defines the location of the image to load
  61078. */
  61079. constructor(
  61080. /**
  61081. * Defines the name of the task
  61082. */
  61083. name: string,
  61084. /**
  61085. * Defines the location of the image to load
  61086. */
  61087. url: string);
  61088. /**
  61089. * Execute the current task
  61090. * @param scene defines the scene where you want your assets to be loaded
  61091. * @param onSuccess is a callback called when the task is successfully executed
  61092. * @param onError is a callback called if an error occurs
  61093. */
  61094. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61095. }
  61096. /**
  61097. * Defines the interface used by texture loading tasks
  61098. */
  61099. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61100. /**
  61101. * Gets the loaded texture
  61102. */
  61103. texture: TEX;
  61104. }
  61105. /**
  61106. * Define a task used by AssetsManager to load 2D textures
  61107. */
  61108. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61109. /**
  61110. * Defines the name of the task
  61111. */
  61112. name: string;
  61113. /**
  61114. * Defines the location of the file to load
  61115. */
  61116. url: string;
  61117. /**
  61118. * Defines if mipmap should not be generated (default is false)
  61119. */
  61120. noMipmap?: boolean | undefined;
  61121. /**
  61122. * Defines if texture must be inverted on Y axis (default is false)
  61123. */
  61124. invertY?: boolean | undefined;
  61125. /**
  61126. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61127. */
  61128. samplingMode: number;
  61129. /**
  61130. * Gets the loaded texture
  61131. */
  61132. texture: Texture;
  61133. /**
  61134. * Callback called when the task is successful
  61135. */
  61136. onSuccess: (task: TextureAssetTask) => void;
  61137. /**
  61138. * Callback called when the task is successful
  61139. */
  61140. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61141. /**
  61142. * Creates a new TextureAssetTask object
  61143. * @param name defines the name of the task
  61144. * @param url defines the location of the file to load
  61145. * @param noMipmap defines if mipmap should not be generated (default is false)
  61146. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61147. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61148. */
  61149. constructor(
  61150. /**
  61151. * Defines the name of the task
  61152. */
  61153. name: string,
  61154. /**
  61155. * Defines the location of the file to load
  61156. */
  61157. url: string,
  61158. /**
  61159. * Defines if mipmap should not be generated (default is false)
  61160. */
  61161. noMipmap?: boolean | undefined,
  61162. /**
  61163. * Defines if texture must be inverted on Y axis (default is false)
  61164. */
  61165. invertY?: boolean | undefined,
  61166. /**
  61167. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61168. */
  61169. samplingMode?: number);
  61170. /**
  61171. * Execute the current task
  61172. * @param scene defines the scene where you want your assets to be loaded
  61173. * @param onSuccess is a callback called when the task is successfully executed
  61174. * @param onError is a callback called if an error occurs
  61175. */
  61176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61177. }
  61178. /**
  61179. * Define a task used by AssetsManager to load cube textures
  61180. */
  61181. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61182. /**
  61183. * Defines the name of the task
  61184. */
  61185. name: string;
  61186. /**
  61187. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61188. */
  61189. url: string;
  61190. /**
  61191. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61192. */
  61193. extensions?: string[] | undefined;
  61194. /**
  61195. * Defines if mipmaps should not be generated (default is false)
  61196. */
  61197. noMipmap?: boolean | undefined;
  61198. /**
  61199. * Defines the explicit list of files (undefined by default)
  61200. */
  61201. files?: string[] | undefined;
  61202. /**
  61203. * Gets the loaded texture
  61204. */
  61205. texture: CubeTexture;
  61206. /**
  61207. * Callback called when the task is successful
  61208. */
  61209. onSuccess: (task: CubeTextureAssetTask) => void;
  61210. /**
  61211. * Callback called when the task is successful
  61212. */
  61213. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61214. /**
  61215. * Creates a new CubeTextureAssetTask
  61216. * @param name defines the name of the task
  61217. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61218. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61219. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61220. * @param files defines the explicit list of files (undefined by default)
  61221. */
  61222. constructor(
  61223. /**
  61224. * Defines the name of the task
  61225. */
  61226. name: string,
  61227. /**
  61228. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61229. */
  61230. url: string,
  61231. /**
  61232. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61233. */
  61234. extensions?: string[] | undefined,
  61235. /**
  61236. * Defines if mipmaps should not be generated (default is false)
  61237. */
  61238. noMipmap?: boolean | undefined,
  61239. /**
  61240. * Defines the explicit list of files (undefined by default)
  61241. */
  61242. files?: string[] | undefined);
  61243. /**
  61244. * Execute the current task
  61245. * @param scene defines the scene where you want your assets to be loaded
  61246. * @param onSuccess is a callback called when the task is successfully executed
  61247. * @param onError is a callback called if an error occurs
  61248. */
  61249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61250. }
  61251. /**
  61252. * Define a task used by AssetsManager to load HDR cube textures
  61253. */
  61254. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61255. /**
  61256. * Defines the name of the task
  61257. */
  61258. name: string;
  61259. /**
  61260. * Defines the location of the file to load
  61261. */
  61262. url: string;
  61263. /**
  61264. * Defines the desired size (the more it increases the longer the generation will be)
  61265. */
  61266. size: number;
  61267. /**
  61268. * Defines if mipmaps should not be generated (default is false)
  61269. */
  61270. noMipmap: boolean;
  61271. /**
  61272. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61273. */
  61274. generateHarmonics: boolean;
  61275. /**
  61276. * 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)
  61277. */
  61278. gammaSpace: boolean;
  61279. /**
  61280. * Internal Use Only
  61281. */
  61282. reserved: boolean;
  61283. /**
  61284. * Gets the loaded texture
  61285. */
  61286. texture: HDRCubeTexture;
  61287. /**
  61288. * Callback called when the task is successful
  61289. */
  61290. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61291. /**
  61292. * Callback called when the task is successful
  61293. */
  61294. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61295. /**
  61296. * Creates a new HDRCubeTextureAssetTask object
  61297. * @param name defines the name of the task
  61298. * @param url defines the location of the file to load
  61299. * @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.
  61300. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61301. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61302. * @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)
  61303. * @param reserved Internal use only
  61304. */
  61305. constructor(
  61306. /**
  61307. * Defines the name of the task
  61308. */
  61309. name: string,
  61310. /**
  61311. * Defines the location of the file to load
  61312. */
  61313. url: string,
  61314. /**
  61315. * Defines the desired size (the more it increases the longer the generation will be)
  61316. */
  61317. size: number,
  61318. /**
  61319. * Defines if mipmaps should not be generated (default is false)
  61320. */
  61321. noMipmap?: boolean,
  61322. /**
  61323. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61324. */
  61325. generateHarmonics?: boolean,
  61326. /**
  61327. * 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)
  61328. */
  61329. gammaSpace?: boolean,
  61330. /**
  61331. * Internal Use Only
  61332. */
  61333. reserved?: boolean);
  61334. /**
  61335. * Execute the current task
  61336. * @param scene defines the scene where you want your assets to be loaded
  61337. * @param onSuccess is a callback called when the task is successfully executed
  61338. * @param onError is a callback called if an error occurs
  61339. */
  61340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61341. }
  61342. /**
  61343. * Define a task used by AssetsManager to load Equirectangular cube textures
  61344. */
  61345. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61346. /**
  61347. * Defines the name of the task
  61348. */
  61349. name: string;
  61350. /**
  61351. * Defines the location of the file to load
  61352. */
  61353. url: string;
  61354. /**
  61355. * Defines the desired size (the more it increases the longer the generation will be)
  61356. */
  61357. size: number;
  61358. /**
  61359. * Defines if mipmaps should not be generated (default is false)
  61360. */
  61361. noMipmap: boolean;
  61362. /**
  61363. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61364. * but the standard material would require them in Gamma space) (default is true)
  61365. */
  61366. gammaSpace: boolean;
  61367. /**
  61368. * Gets the loaded texture
  61369. */
  61370. texture: EquiRectangularCubeTexture;
  61371. /**
  61372. * Callback called when the task is successful
  61373. */
  61374. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61375. /**
  61376. * Callback called when the task is successful
  61377. */
  61378. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61379. /**
  61380. * Creates a new EquiRectangularCubeTextureAssetTask object
  61381. * @param name defines the name of the task
  61382. * @param url defines the location of the file to load
  61383. * @param size defines the desired size (the more it increases the longer the generation will be)
  61384. * If the size is omitted this implies you are using a preprocessed cubemap.
  61385. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61386. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61387. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61388. * (default is true)
  61389. */
  61390. constructor(
  61391. /**
  61392. * Defines the name of the task
  61393. */
  61394. name: string,
  61395. /**
  61396. * Defines the location of the file to load
  61397. */
  61398. url: string,
  61399. /**
  61400. * Defines the desired size (the more it increases the longer the generation will be)
  61401. */
  61402. size: number,
  61403. /**
  61404. * Defines if mipmaps should not be generated (default is false)
  61405. */
  61406. noMipmap?: boolean,
  61407. /**
  61408. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61409. * but the standard material would require them in Gamma space) (default is true)
  61410. */
  61411. gammaSpace?: boolean);
  61412. /**
  61413. * Execute the current task
  61414. * @param scene defines the scene where you want your assets to be loaded
  61415. * @param onSuccess is a callback called when the task is successfully executed
  61416. * @param onError is a callback called if an error occurs
  61417. */
  61418. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61419. }
  61420. /**
  61421. * This class can be used to easily import assets into a scene
  61422. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61423. */
  61424. export class AssetsManager {
  61425. private _scene;
  61426. private _isLoading;
  61427. protected _tasks: AbstractAssetTask[];
  61428. protected _waitingTasksCount: number;
  61429. protected _totalTasksCount: number;
  61430. /**
  61431. * Callback called when all tasks are processed
  61432. */
  61433. onFinish: (tasks: AbstractAssetTask[]) => void;
  61434. /**
  61435. * Callback called when a task is successful
  61436. */
  61437. onTaskSuccess: (task: AbstractAssetTask) => void;
  61438. /**
  61439. * Callback called when a task had an error
  61440. */
  61441. onTaskError: (task: AbstractAssetTask) => void;
  61442. /**
  61443. * Callback called when a task is done (whatever the result is)
  61444. */
  61445. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61446. /**
  61447. * Observable called when all tasks are processed
  61448. */
  61449. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61450. /**
  61451. * Observable called when a task had an error
  61452. */
  61453. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61454. /**
  61455. * Observable called when all tasks were executed
  61456. */
  61457. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61458. /**
  61459. * Observable called when a task is done (whatever the result is)
  61460. */
  61461. onProgressObservable: Observable<IAssetsProgressEvent>;
  61462. /**
  61463. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61465. */
  61466. useDefaultLoadingScreen: boolean;
  61467. /**
  61468. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61469. * when all assets have been downloaded.
  61470. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61471. */
  61472. autoHideLoadingUI: boolean;
  61473. /**
  61474. * Creates a new AssetsManager
  61475. * @param scene defines the scene to work on
  61476. */
  61477. constructor(scene: Scene);
  61478. /**
  61479. * Add a MeshAssetTask to the list of active tasks
  61480. * @param taskName defines the name of the new task
  61481. * @param meshesNames defines the name of meshes to load
  61482. * @param rootUrl defines the root url to use to locate files
  61483. * @param sceneFilename defines the filename of the scene file
  61484. * @returns a new MeshAssetTask object
  61485. */
  61486. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61487. /**
  61488. * Add a TextFileAssetTask to the list of active tasks
  61489. * @param taskName defines the name of the new task
  61490. * @param url defines the url of the file to load
  61491. * @returns a new TextFileAssetTask object
  61492. */
  61493. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61494. /**
  61495. * Add a BinaryFileAssetTask to the list of active tasks
  61496. * @param taskName defines the name of the new task
  61497. * @param url defines the url of the file to load
  61498. * @returns a new BinaryFileAssetTask object
  61499. */
  61500. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61501. /**
  61502. * Add a ImageAssetTask to the list of active tasks
  61503. * @param taskName defines the name of the new task
  61504. * @param url defines the url of the file to load
  61505. * @returns a new ImageAssetTask object
  61506. */
  61507. addImageTask(taskName: string, url: string): ImageAssetTask;
  61508. /**
  61509. * Add a TextureAssetTask to the list of active tasks
  61510. * @param taskName defines the name of the new task
  61511. * @param url defines the url of the file to load
  61512. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61513. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61514. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61515. * @returns a new TextureAssetTask object
  61516. */
  61517. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61518. /**
  61519. * Add a CubeTextureAssetTask to the list of active tasks
  61520. * @param taskName defines the name of the new task
  61521. * @param url defines the url of the file to load
  61522. * @param extensions defines the extension to use to load the cube map (can be null)
  61523. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61524. * @param files defines the list of files to load (can be null)
  61525. * @returns a new CubeTextureAssetTask object
  61526. */
  61527. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61528. /**
  61529. *
  61530. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61531. * @param taskName defines the name of the new task
  61532. * @param url defines the url of the file to load
  61533. * @param size defines the size you want for the cubemap (can be null)
  61534. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61535. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61536. * @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)
  61537. * @param reserved Internal use only
  61538. * @returns a new HDRCubeTextureAssetTask object
  61539. */
  61540. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61541. /**
  61542. *
  61543. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61544. * @param taskName defines the name of the new task
  61545. * @param url defines the url of the file to load
  61546. * @param size defines the size you want for the cubemap (can be null)
  61547. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61548. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61549. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61550. * @returns a new EquiRectangularCubeTextureAssetTask object
  61551. */
  61552. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61553. /**
  61554. * Remove a task from the assets manager.
  61555. * @param task the task to remove
  61556. */
  61557. removeTask(task: AbstractAssetTask): void;
  61558. private _decreaseWaitingTasksCount;
  61559. private _runTask;
  61560. /**
  61561. * Reset the AssetsManager and remove all tasks
  61562. * @return the current instance of the AssetsManager
  61563. */
  61564. reset(): AssetsManager;
  61565. /**
  61566. * Start the loading process
  61567. * @return the current instance of the AssetsManager
  61568. */
  61569. load(): AssetsManager;
  61570. /**
  61571. * Start the loading process as an async operation
  61572. * @return a promise returning the list of failed tasks
  61573. */
  61574. loadAsync(): Promise<void>;
  61575. }
  61576. }
  61577. declare module BABYLON {
  61578. /**
  61579. * Wrapper class for promise with external resolve and reject.
  61580. */
  61581. export class Deferred<T> {
  61582. /**
  61583. * The promise associated with this deferred object.
  61584. */
  61585. readonly promise: Promise<T>;
  61586. private _resolve;
  61587. private _reject;
  61588. /**
  61589. * The resolve method of the promise associated with this deferred object.
  61590. */
  61591. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61592. /**
  61593. * The reject method of the promise associated with this deferred object.
  61594. */
  61595. readonly reject: (reason?: any) => void;
  61596. /**
  61597. * Constructor for this deferred object.
  61598. */
  61599. constructor();
  61600. }
  61601. }
  61602. declare module BABYLON {
  61603. /**
  61604. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61605. */
  61606. export class MeshExploder {
  61607. private _centerMesh;
  61608. private _meshes;
  61609. private _meshesOrigins;
  61610. private _toCenterVectors;
  61611. private _scaledDirection;
  61612. private _newPosition;
  61613. private _centerPosition;
  61614. /**
  61615. * Explodes meshes from a center mesh.
  61616. * @param meshes The meshes to explode.
  61617. * @param centerMesh The mesh to be center of explosion.
  61618. */
  61619. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61620. private _setCenterMesh;
  61621. /**
  61622. * Get class name
  61623. * @returns "MeshExploder"
  61624. */
  61625. getClassName(): string;
  61626. /**
  61627. * "Exploded meshes"
  61628. * @returns Array of meshes with the centerMesh at index 0.
  61629. */
  61630. getMeshes(): Array<Mesh>;
  61631. /**
  61632. * Explodes meshes giving a specific direction
  61633. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61634. */
  61635. explode(direction?: number): void;
  61636. }
  61637. }
  61638. declare module BABYLON {
  61639. /**
  61640. * Class used to help managing file picking and drag'n'drop
  61641. */
  61642. export class FilesInput {
  61643. /**
  61644. * List of files ready to be loaded
  61645. */
  61646. static readonly FilesToLoad: {
  61647. [key: string]: File;
  61648. };
  61649. /**
  61650. * Callback called when a file is processed
  61651. */
  61652. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61653. private _engine;
  61654. private _currentScene;
  61655. private _sceneLoadedCallback;
  61656. private _progressCallback;
  61657. private _additionalRenderLoopLogicCallback;
  61658. private _textureLoadingCallback;
  61659. private _startingProcessingFilesCallback;
  61660. private _onReloadCallback;
  61661. private _errorCallback;
  61662. private _elementToMonitor;
  61663. private _sceneFileToLoad;
  61664. private _filesToLoad;
  61665. /**
  61666. * Creates a new FilesInput
  61667. * @param engine defines the rendering engine
  61668. * @param scene defines the hosting scene
  61669. * @param sceneLoadedCallback callback called when scene is loaded
  61670. * @param progressCallback callback called to track progress
  61671. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61672. * @param textureLoadingCallback callback called when a texture is loading
  61673. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61674. * @param onReloadCallback callback called when a reload is requested
  61675. * @param errorCallback callback call if an error occurs
  61676. */
  61677. 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);
  61678. private _dragEnterHandler;
  61679. private _dragOverHandler;
  61680. private _dropHandler;
  61681. /**
  61682. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61683. * @param elementToMonitor defines the DOM element to track
  61684. */
  61685. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61686. /**
  61687. * Release all associated resources
  61688. */
  61689. dispose(): void;
  61690. private renderFunction;
  61691. private drag;
  61692. private drop;
  61693. private _traverseFolder;
  61694. private _processFiles;
  61695. /**
  61696. * Load files from a drop event
  61697. * @param event defines the drop event to use as source
  61698. */
  61699. loadFiles(event: any): void;
  61700. private _processReload;
  61701. /**
  61702. * Reload the current scene from the loaded files
  61703. */
  61704. reload(): void;
  61705. }
  61706. }
  61707. declare module BABYLON {
  61708. /**
  61709. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61711. */
  61712. export class SceneOptimization {
  61713. /**
  61714. * Defines the priority of this optimization (0 by default which means first in the list)
  61715. */
  61716. priority: number;
  61717. /**
  61718. * Gets a string describing the action executed by the current optimization
  61719. * @returns description string
  61720. */
  61721. getDescription(): string;
  61722. /**
  61723. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61724. * @param scene defines the current scene where to apply this optimization
  61725. * @param optimizer defines the current optimizer
  61726. * @returns true if everything that can be done was applied
  61727. */
  61728. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61729. /**
  61730. * Creates the SceneOptimization object
  61731. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61732. * @param desc defines the description associated with the optimization
  61733. */
  61734. constructor(
  61735. /**
  61736. * Defines the priority of this optimization (0 by default which means first in the list)
  61737. */
  61738. priority?: number);
  61739. }
  61740. /**
  61741. * Defines an optimization used to reduce the size of render target textures
  61742. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61743. */
  61744. export class TextureOptimization extends SceneOptimization {
  61745. /**
  61746. * Defines the priority of this optimization (0 by default which means first in the list)
  61747. */
  61748. priority: number;
  61749. /**
  61750. * 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
  61751. */
  61752. maximumSize: number;
  61753. /**
  61754. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61755. */
  61756. step: number;
  61757. /**
  61758. * Gets a string describing the action executed by the current optimization
  61759. * @returns description string
  61760. */
  61761. getDescription(): string;
  61762. /**
  61763. * Creates the TextureOptimization object
  61764. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61765. * @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
  61766. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61767. */
  61768. constructor(
  61769. /**
  61770. * Defines the priority of this optimization (0 by default which means first in the list)
  61771. */
  61772. priority?: number,
  61773. /**
  61774. * 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
  61775. */
  61776. maximumSize?: number,
  61777. /**
  61778. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61779. */
  61780. step?: number);
  61781. /**
  61782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61783. * @param scene defines the current scene where to apply this optimization
  61784. * @param optimizer defines the current optimizer
  61785. * @returns true if everything that can be done was applied
  61786. */
  61787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61788. }
  61789. /**
  61790. * Defines an optimization used to increase or decrease the rendering resolution
  61791. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61792. */
  61793. export class HardwareScalingOptimization extends SceneOptimization {
  61794. /**
  61795. * Defines the priority of this optimization (0 by default which means first in the list)
  61796. */
  61797. priority: number;
  61798. /**
  61799. * Defines the maximum scale to use (2 by default)
  61800. */
  61801. maximumScale: number;
  61802. /**
  61803. * Defines the step to use between two passes (0.5 by default)
  61804. */
  61805. step: number;
  61806. private _currentScale;
  61807. private _directionOffset;
  61808. /**
  61809. * Gets a string describing the action executed by the current optimization
  61810. * @return description string
  61811. */
  61812. getDescription(): string;
  61813. /**
  61814. * Creates the HardwareScalingOptimization object
  61815. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61816. * @param maximumScale defines the maximum scale to use (2 by default)
  61817. * @param step defines the step to use between two passes (0.5 by default)
  61818. */
  61819. constructor(
  61820. /**
  61821. * Defines the priority of this optimization (0 by default which means first in the list)
  61822. */
  61823. priority?: number,
  61824. /**
  61825. * Defines the maximum scale to use (2 by default)
  61826. */
  61827. maximumScale?: number,
  61828. /**
  61829. * Defines the step to use between two passes (0.5 by default)
  61830. */
  61831. step?: number);
  61832. /**
  61833. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61834. * @param scene defines the current scene where to apply this optimization
  61835. * @param optimizer defines the current optimizer
  61836. * @returns true if everything that can be done was applied
  61837. */
  61838. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61839. }
  61840. /**
  61841. * Defines an optimization used to remove shadows
  61842. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61843. */
  61844. export class ShadowsOptimization extends SceneOptimization {
  61845. /**
  61846. * Gets a string describing the action executed by the current optimization
  61847. * @return description string
  61848. */
  61849. getDescription(): string;
  61850. /**
  61851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61852. * @param scene defines the current scene where to apply this optimization
  61853. * @param optimizer defines the current optimizer
  61854. * @returns true if everything that can be done was applied
  61855. */
  61856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61857. }
  61858. /**
  61859. * Defines an optimization used to turn post-processes off
  61860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61861. */
  61862. export class PostProcessesOptimization extends SceneOptimization {
  61863. /**
  61864. * Gets a string describing the action executed by the current optimization
  61865. * @return description string
  61866. */
  61867. getDescription(): string;
  61868. /**
  61869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61870. * @param scene defines the current scene where to apply this optimization
  61871. * @param optimizer defines the current optimizer
  61872. * @returns true if everything that can be done was applied
  61873. */
  61874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61875. }
  61876. /**
  61877. * Defines an optimization used to turn lens flares off
  61878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61879. */
  61880. export class LensFlaresOptimization extends SceneOptimization {
  61881. /**
  61882. * Gets a string describing the action executed by the current optimization
  61883. * @return description string
  61884. */
  61885. getDescription(): string;
  61886. /**
  61887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61888. * @param scene defines the current scene where to apply this optimization
  61889. * @param optimizer defines the current optimizer
  61890. * @returns true if everything that can be done was applied
  61891. */
  61892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61893. }
  61894. /**
  61895. * Defines an optimization based on user defined callback.
  61896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61897. */
  61898. export class CustomOptimization extends SceneOptimization {
  61899. /**
  61900. * Callback called to apply the custom optimization.
  61901. */
  61902. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61903. /**
  61904. * Callback called to get custom description
  61905. */
  61906. onGetDescription: () => string;
  61907. /**
  61908. * Gets a string describing the action executed by the current optimization
  61909. * @returns description string
  61910. */
  61911. getDescription(): string;
  61912. /**
  61913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61914. * @param scene defines the current scene where to apply this optimization
  61915. * @param optimizer defines the current optimizer
  61916. * @returns true if everything that can be done was applied
  61917. */
  61918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61919. }
  61920. /**
  61921. * Defines an optimization used to turn particles off
  61922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61923. */
  61924. export class ParticlesOptimization extends SceneOptimization {
  61925. /**
  61926. * Gets a string describing the action executed by the current optimization
  61927. * @return description string
  61928. */
  61929. getDescription(): string;
  61930. /**
  61931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61932. * @param scene defines the current scene where to apply this optimization
  61933. * @param optimizer defines the current optimizer
  61934. * @returns true if everything that can be done was applied
  61935. */
  61936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61937. }
  61938. /**
  61939. * Defines an optimization used to turn render targets off
  61940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61941. */
  61942. export class RenderTargetsOptimization extends SceneOptimization {
  61943. /**
  61944. * Gets a string describing the action executed by the current optimization
  61945. * @return description string
  61946. */
  61947. getDescription(): string;
  61948. /**
  61949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61950. * @param scene defines the current scene where to apply this optimization
  61951. * @param optimizer defines the current optimizer
  61952. * @returns true if everything that can be done was applied
  61953. */
  61954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61955. }
  61956. /**
  61957. * Defines an optimization used to merge meshes with compatible materials
  61958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61959. */
  61960. export class MergeMeshesOptimization extends SceneOptimization {
  61961. private static _UpdateSelectionTree;
  61962. /**
  61963. * Gets or sets a boolean which defines if optimization octree has to be updated
  61964. */
  61965. /**
  61966. * Gets or sets a boolean which defines if optimization octree has to be updated
  61967. */
  61968. static UpdateSelectionTree: boolean;
  61969. /**
  61970. * Gets a string describing the action executed by the current optimization
  61971. * @return description string
  61972. */
  61973. getDescription(): string;
  61974. private _canBeMerged;
  61975. /**
  61976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61977. * @param scene defines the current scene where to apply this optimization
  61978. * @param optimizer defines the current optimizer
  61979. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61980. * @returns true if everything that can be done was applied
  61981. */
  61982. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61983. }
  61984. /**
  61985. * Defines a list of options used by SceneOptimizer
  61986. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61987. */
  61988. export class SceneOptimizerOptions {
  61989. /**
  61990. * Defines the target frame rate to reach (60 by default)
  61991. */
  61992. targetFrameRate: number;
  61993. /**
  61994. * Defines the interval between two checkes (2000ms by default)
  61995. */
  61996. trackerDuration: number;
  61997. /**
  61998. * Gets the list of optimizations to apply
  61999. */
  62000. optimizations: SceneOptimization[];
  62001. /**
  62002. * Creates a new list of options used by SceneOptimizer
  62003. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62004. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62005. */
  62006. constructor(
  62007. /**
  62008. * Defines the target frame rate to reach (60 by default)
  62009. */
  62010. targetFrameRate?: number,
  62011. /**
  62012. * Defines the interval between two checkes (2000ms by default)
  62013. */
  62014. trackerDuration?: number);
  62015. /**
  62016. * Add a new optimization
  62017. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62018. * @returns the current SceneOptimizerOptions
  62019. */
  62020. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62021. /**
  62022. * Add a new custom optimization
  62023. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62024. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62025. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62026. * @returns the current SceneOptimizerOptions
  62027. */
  62028. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62029. /**
  62030. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62031. * @param targetFrameRate defines the target frame rate (60 by default)
  62032. * @returns a SceneOptimizerOptions object
  62033. */
  62034. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62035. /**
  62036. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62037. * @param targetFrameRate defines the target frame rate (60 by default)
  62038. * @returns a SceneOptimizerOptions object
  62039. */
  62040. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62041. /**
  62042. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62043. * @param targetFrameRate defines the target frame rate (60 by default)
  62044. * @returns a SceneOptimizerOptions object
  62045. */
  62046. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62047. }
  62048. /**
  62049. * Class used to run optimizations in order to reach a target frame rate
  62050. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62051. */
  62052. export class SceneOptimizer implements IDisposable {
  62053. private _isRunning;
  62054. private _options;
  62055. private _scene;
  62056. private _currentPriorityLevel;
  62057. private _targetFrameRate;
  62058. private _trackerDuration;
  62059. private _currentFrameRate;
  62060. private _sceneDisposeObserver;
  62061. private _improvementMode;
  62062. /**
  62063. * Defines an observable called when the optimizer reaches the target frame rate
  62064. */
  62065. onSuccessObservable: Observable<SceneOptimizer>;
  62066. /**
  62067. * Defines an observable called when the optimizer enables an optimization
  62068. */
  62069. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62070. /**
  62071. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62072. */
  62073. onFailureObservable: Observable<SceneOptimizer>;
  62074. /**
  62075. * Gets a boolean indicating if the optimizer is in improvement mode
  62076. */
  62077. readonly isInImprovementMode: boolean;
  62078. /**
  62079. * Gets the current priority level (0 at start)
  62080. */
  62081. readonly currentPriorityLevel: number;
  62082. /**
  62083. * Gets the current frame rate checked by the SceneOptimizer
  62084. */
  62085. readonly currentFrameRate: number;
  62086. /**
  62087. * Gets or sets the current target frame rate (60 by default)
  62088. */
  62089. /**
  62090. * Gets or sets the current target frame rate (60 by default)
  62091. */
  62092. targetFrameRate: number;
  62093. /**
  62094. * Gets or sets the current interval between two checks (every 2000ms by default)
  62095. */
  62096. /**
  62097. * Gets or sets the current interval between two checks (every 2000ms by default)
  62098. */
  62099. trackerDuration: number;
  62100. /**
  62101. * Gets the list of active optimizations
  62102. */
  62103. readonly optimizations: SceneOptimization[];
  62104. /**
  62105. * Creates a new SceneOptimizer
  62106. * @param scene defines the scene to work on
  62107. * @param options defines the options to use with the SceneOptimizer
  62108. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62109. * @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)
  62110. */
  62111. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62112. /**
  62113. * Stops the current optimizer
  62114. */
  62115. stop(): void;
  62116. /**
  62117. * Reset the optimizer to initial step (current priority level = 0)
  62118. */
  62119. reset(): void;
  62120. /**
  62121. * Start the optimizer. By default it will try to reach a specific framerate
  62122. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62123. */
  62124. start(): void;
  62125. private _checkCurrentState;
  62126. /**
  62127. * Release all resources
  62128. */
  62129. dispose(): void;
  62130. /**
  62131. * Helper function to create a SceneOptimizer with one single line of code
  62132. * @param scene defines the scene to work on
  62133. * @param options defines the options to use with the SceneOptimizer
  62134. * @param onSuccess defines a callback to call on success
  62135. * @param onFailure defines a callback to call on failure
  62136. * @returns the new SceneOptimizer object
  62137. */
  62138. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Class used to serialize a scene into a string
  62144. */
  62145. export class SceneSerializer {
  62146. /**
  62147. * Clear cache used by a previous serialization
  62148. */
  62149. static ClearCache(): void;
  62150. /**
  62151. * Serialize a scene into a JSON compatible object
  62152. * @param scene defines the scene to serialize
  62153. * @returns a JSON compatible object
  62154. */
  62155. static Serialize(scene: Scene): any;
  62156. /**
  62157. * Serialize a mesh into a JSON compatible object
  62158. * @param toSerialize defines the mesh to serialize
  62159. * @param withParents defines if parents must be serialized as well
  62160. * @param withChildren defines if children must be serialized as well
  62161. * @returns a JSON compatible object
  62162. */
  62163. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62164. }
  62165. }
  62166. declare module BABYLON {
  62167. /**
  62168. * Class used to host texture specific utilities
  62169. */
  62170. export class TextureTools {
  62171. /**
  62172. * Uses the GPU to create a copy texture rescaled at a given size
  62173. * @param texture Texture to copy from
  62174. * @param width defines the desired width
  62175. * @param height defines the desired height
  62176. * @param useBilinearMode defines if bilinear mode has to be used
  62177. * @return the generated texture
  62178. */
  62179. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62180. }
  62181. }
  62182. declare module BABYLON {
  62183. /**
  62184. * This represents the different options available for the video capture.
  62185. */
  62186. export interface VideoRecorderOptions {
  62187. /** Defines the mime type of the video. */
  62188. mimeType: string;
  62189. /** Defines the FPS the video should be recorded at. */
  62190. fps: number;
  62191. /** Defines the chunk size for the recording data. */
  62192. recordChunckSize: number;
  62193. /** The audio tracks to attach to the recording. */
  62194. audioTracks?: MediaStreamTrack[];
  62195. }
  62196. /**
  62197. * This can help with recording videos from BabylonJS.
  62198. * This is based on the available WebRTC functionalities of the browser.
  62199. *
  62200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62201. */
  62202. export class VideoRecorder {
  62203. private static readonly _defaultOptions;
  62204. /**
  62205. * Returns whether or not the VideoRecorder is available in your browser.
  62206. * @param engine Defines the Babylon Engine.
  62207. * @returns true if supported otherwise false.
  62208. */
  62209. static IsSupported(engine: Engine): boolean;
  62210. private readonly _options;
  62211. private _canvas;
  62212. private _mediaRecorder;
  62213. private _recordedChunks;
  62214. private _fileName;
  62215. private _resolve;
  62216. private _reject;
  62217. /**
  62218. * True when a recording is already in progress.
  62219. */
  62220. readonly isRecording: boolean;
  62221. /**
  62222. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62223. * @param engine Defines the BabylonJS Engine you wish to record.
  62224. * @param options Defines options that can be used to customize the capture.
  62225. */
  62226. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62227. /**
  62228. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62229. */
  62230. stopRecording(): void;
  62231. /**
  62232. * Starts recording the canvas for a max duration specified in parameters.
  62233. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62234. * If null no automatic download will start and you can rely on the promise to get the data back.
  62235. * @param maxDuration Defines the maximum recording time in seconds.
  62236. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62237. * @return A promise callback at the end of the recording with the video data in Blob.
  62238. */
  62239. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62240. /**
  62241. * Releases internal resources used during the recording.
  62242. */
  62243. dispose(): void;
  62244. private _handleDataAvailable;
  62245. private _handleError;
  62246. private _handleStop;
  62247. }
  62248. }
  62249. declare module BABYLON {
  62250. /**
  62251. * Class containing a set of static utilities functions for screenshots
  62252. */
  62253. export class ScreenshotTools {
  62254. /**
  62255. * Captures a screenshot of the current rendering
  62256. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62257. * @param engine defines the rendering engine
  62258. * @param camera defines the source camera
  62259. * @param size This parameter can be set to a single number or to an object with the
  62260. * following (optional) properties: precision, width, height. If a single number is passed,
  62261. * it will be used for both width and height. If an object is passed, the screenshot size
  62262. * will be derived from the parameters. The precision property is a multiplier allowing
  62263. * rendering at a higher or lower resolution
  62264. * @param successCallback defines the callback receives a single parameter which contains the
  62265. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62266. * src parameter of an <img> to display it
  62267. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62268. * Check your browser for supported MIME types
  62269. */
  62270. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62271. /**
  62272. * Captures a screenshot of the current rendering
  62273. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62274. * @param engine defines the rendering engine
  62275. * @param camera defines the source camera
  62276. * @param size This parameter can be set to a single number or to an object with the
  62277. * following (optional) properties: precision, width, height. If a single number is passed,
  62278. * it will be used for both width and height. If an object is passed, the screenshot size
  62279. * will be derived from the parameters. The precision property is a multiplier allowing
  62280. * rendering at a higher or lower resolution
  62281. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62282. * Check your browser for supported MIME types
  62283. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62284. * to the src parameter of an <img> to display it
  62285. */
  62286. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62287. /**
  62288. * Generates an image screenshot from the specified camera.
  62289. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62290. * @param engine The engine to use for rendering
  62291. * @param camera The camera to use for rendering
  62292. * @param size This parameter can be set to a single number or to an object with the
  62293. * following (optional) properties: precision, width, height. If a single number is passed,
  62294. * it will be used for both width and height. If an object is passed, the screenshot size
  62295. * will be derived from the parameters. The precision property is a multiplier allowing
  62296. * rendering at a higher or lower resolution
  62297. * @param successCallback The callback receives a single parameter which contains the
  62298. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62299. * src parameter of an <img> to display it
  62300. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62301. * Check your browser for supported MIME types
  62302. * @param samples Texture samples (default: 1)
  62303. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62304. * @param fileName A name for for the downloaded file.
  62305. */
  62306. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62307. /**
  62308. * Generates an image screenshot from the specified camera.
  62309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62310. * @param engine The engine to use for rendering
  62311. * @param camera The camera to use for rendering
  62312. * @param size This parameter can be set to a single number or to an object with the
  62313. * following (optional) properties: precision, width, height. If a single number is passed,
  62314. * it will be used for both width and height. If an object is passed, the screenshot size
  62315. * will be derived from the parameters. The precision property is a multiplier allowing
  62316. * rendering at a higher or lower resolution
  62317. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62318. * Check your browser for supported MIME types
  62319. * @param samples Texture samples (default: 1)
  62320. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62321. * @param fileName A name for for the downloaded file.
  62322. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62323. * to the src parameter of an <img> to display it
  62324. */
  62325. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62326. /**
  62327. * Gets height and width for screenshot size
  62328. * @private
  62329. */
  62330. private static _getScreenshotSize;
  62331. }
  62332. }
  62333. declare module BABYLON {
  62334. /**
  62335. * A cursor which tracks a point on a path
  62336. */
  62337. export class PathCursor {
  62338. private path;
  62339. /**
  62340. * Stores path cursor callbacks for when an onchange event is triggered
  62341. */
  62342. private _onchange;
  62343. /**
  62344. * The value of the path cursor
  62345. */
  62346. value: number;
  62347. /**
  62348. * The animation array of the path cursor
  62349. */
  62350. animations: Animation[];
  62351. /**
  62352. * Initializes the path cursor
  62353. * @param path The path to track
  62354. */
  62355. constructor(path: Path2);
  62356. /**
  62357. * Gets the cursor point on the path
  62358. * @returns A point on the path cursor at the cursor location
  62359. */
  62360. getPoint(): Vector3;
  62361. /**
  62362. * Moves the cursor ahead by the step amount
  62363. * @param step The amount to move the cursor forward
  62364. * @returns This path cursor
  62365. */
  62366. moveAhead(step?: number): PathCursor;
  62367. /**
  62368. * Moves the cursor behind by the step amount
  62369. * @param step The amount to move the cursor back
  62370. * @returns This path cursor
  62371. */
  62372. moveBack(step?: number): PathCursor;
  62373. /**
  62374. * Moves the cursor by the step amount
  62375. * If the step amount is greater than one, an exception is thrown
  62376. * @param step The amount to move the cursor
  62377. * @returns This path cursor
  62378. */
  62379. move(step: number): PathCursor;
  62380. /**
  62381. * Ensures that the value is limited between zero and one
  62382. * @returns This path cursor
  62383. */
  62384. private ensureLimits;
  62385. /**
  62386. * Runs onchange callbacks on change (used by the animation engine)
  62387. * @returns This path cursor
  62388. */
  62389. private raiseOnChange;
  62390. /**
  62391. * Executes a function on change
  62392. * @param f A path cursor onchange callback
  62393. * @returns This path cursor
  62394. */
  62395. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62396. }
  62397. }
  62398. declare module BABYLON {
  62399. /** @hidden */
  62400. export var blurPixelShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module BABYLON {
  62406. /** @hidden */
  62407. export var pointCloudVertexDeclaration: {
  62408. name: string;
  62409. shader: string;
  62410. };
  62411. }
  62412. // Mixins
  62413. interface Window {
  62414. mozIndexedDB: IDBFactory;
  62415. webkitIndexedDB: IDBFactory;
  62416. msIndexedDB: IDBFactory;
  62417. webkitURL: typeof URL;
  62418. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62419. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62420. WebGLRenderingContext: WebGLRenderingContext;
  62421. MSGesture: MSGesture;
  62422. CANNON: any;
  62423. AudioContext: AudioContext;
  62424. webkitAudioContext: AudioContext;
  62425. PointerEvent: any;
  62426. Math: Math;
  62427. Uint8Array: Uint8ArrayConstructor;
  62428. Float32Array: Float32ArrayConstructor;
  62429. mozURL: typeof URL;
  62430. msURL: typeof URL;
  62431. VRFrameData: any; // WebVR, from specs 1.1
  62432. DracoDecoderModule: any;
  62433. setImmediate(handler: (...args: any[]) => void): number;
  62434. }
  62435. interface HTMLCanvasElement {
  62436. requestPointerLock(): void;
  62437. msRequestPointerLock?(): void;
  62438. mozRequestPointerLock?(): void;
  62439. webkitRequestPointerLock?(): void;
  62440. /** Track wether a record is in progress */
  62441. isRecording: boolean;
  62442. /** Capture Stream method defined by some browsers */
  62443. captureStream(fps?: number): MediaStream;
  62444. }
  62445. interface CanvasRenderingContext2D {
  62446. msImageSmoothingEnabled: boolean;
  62447. }
  62448. interface MouseEvent {
  62449. mozMovementX: number;
  62450. mozMovementY: number;
  62451. webkitMovementX: number;
  62452. webkitMovementY: number;
  62453. msMovementX: number;
  62454. msMovementY: number;
  62455. }
  62456. interface Navigator {
  62457. mozGetVRDevices: (any: any) => any;
  62458. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62459. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62460. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62461. webkitGetGamepads(): Gamepad[];
  62462. msGetGamepads(): Gamepad[];
  62463. webkitGamepads(): Gamepad[];
  62464. }
  62465. interface HTMLVideoElement {
  62466. mozSrcObject: any;
  62467. }
  62468. interface Math {
  62469. fround(x: number): number;
  62470. imul(a: number, b: number): number;
  62471. }
  62472. interface WebGLRenderingContext {
  62473. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62474. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62475. vertexAttribDivisor(index: number, divisor: number): void;
  62476. createVertexArray(): any;
  62477. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62478. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62479. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62480. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62481. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62482. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62483. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62484. // Queries
  62485. createQuery(): WebGLQuery;
  62486. deleteQuery(query: WebGLQuery): void;
  62487. beginQuery(target: number, query: WebGLQuery): void;
  62488. endQuery(target: number): void;
  62489. getQueryParameter(query: WebGLQuery, pname: number): any;
  62490. getQuery(target: number, pname: number): any;
  62491. MAX_SAMPLES: number;
  62492. RGBA8: number;
  62493. READ_FRAMEBUFFER: number;
  62494. DRAW_FRAMEBUFFER: number;
  62495. UNIFORM_BUFFER: number;
  62496. HALF_FLOAT_OES: number;
  62497. RGBA16F: number;
  62498. RGBA32F: number;
  62499. R32F: number;
  62500. RG32F: number;
  62501. RGB32F: number;
  62502. R16F: number;
  62503. RG16F: number;
  62504. RGB16F: number;
  62505. RED: number;
  62506. RG: number;
  62507. R8: number;
  62508. RG8: number;
  62509. UNSIGNED_INT_24_8: number;
  62510. DEPTH24_STENCIL8: number;
  62511. MIN: number;
  62512. MAX: number;
  62513. /* Multiple Render Targets */
  62514. drawBuffers(buffers: number[]): void;
  62515. readBuffer(src: number): void;
  62516. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62517. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62518. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62519. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62520. // Occlusion Query
  62521. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62522. ANY_SAMPLES_PASSED: number;
  62523. QUERY_RESULT_AVAILABLE: number;
  62524. QUERY_RESULT: number;
  62525. }
  62526. interface WebGLProgram {
  62527. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62528. }
  62529. interface EXT_disjoint_timer_query {
  62530. QUERY_COUNTER_BITS_EXT: number;
  62531. TIME_ELAPSED_EXT: number;
  62532. TIMESTAMP_EXT: number;
  62533. GPU_DISJOINT_EXT: number;
  62534. QUERY_RESULT_EXT: number;
  62535. QUERY_RESULT_AVAILABLE_EXT: number;
  62536. queryCounterEXT(query: WebGLQuery, target: number): void;
  62537. createQueryEXT(): WebGLQuery;
  62538. beginQueryEXT(target: number, query: WebGLQuery): void;
  62539. endQueryEXT(target: number): void;
  62540. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62541. deleteQueryEXT(query: WebGLQuery): void;
  62542. }
  62543. interface WebGLUniformLocation {
  62544. _currentState: any;
  62545. }
  62546. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62547. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62548. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62549. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62550. interface WebGLRenderingContext {
  62551. readonly RASTERIZER_DISCARD: number;
  62552. readonly DEPTH_COMPONENT24: number;
  62553. readonly TEXTURE_3D: number;
  62554. readonly TEXTURE_2D_ARRAY: number;
  62555. readonly TEXTURE_COMPARE_FUNC: number;
  62556. readonly TEXTURE_COMPARE_MODE: number;
  62557. readonly COMPARE_REF_TO_TEXTURE: number;
  62558. readonly TEXTURE_WRAP_R: number;
  62559. readonly HALF_FLOAT: number;
  62560. readonly RGB8: number;
  62561. readonly RED_INTEGER: number;
  62562. readonly RG_INTEGER: number;
  62563. readonly RGB_INTEGER: number;
  62564. readonly RGBA_INTEGER: number;
  62565. readonly R8_SNORM: number;
  62566. readonly RG8_SNORM: number;
  62567. readonly RGB8_SNORM: number;
  62568. readonly RGBA8_SNORM: number;
  62569. readonly R8I: number;
  62570. readonly RG8I: number;
  62571. readonly RGB8I: number;
  62572. readonly RGBA8I: number;
  62573. readonly R8UI: number;
  62574. readonly RG8UI: number;
  62575. readonly RGB8UI: number;
  62576. readonly RGBA8UI: number;
  62577. readonly R16I: number;
  62578. readonly RG16I: number;
  62579. readonly RGB16I: number;
  62580. readonly RGBA16I: number;
  62581. readonly R16UI: number;
  62582. readonly RG16UI: number;
  62583. readonly RGB16UI: number;
  62584. readonly RGBA16UI: number;
  62585. readonly R32I: number;
  62586. readonly RG32I: number;
  62587. readonly RGB32I: number;
  62588. readonly RGBA32I: number;
  62589. readonly R32UI: number;
  62590. readonly RG32UI: number;
  62591. readonly RGB32UI: number;
  62592. readonly RGBA32UI: number;
  62593. readonly RGB10_A2UI: number;
  62594. readonly R11F_G11F_B10F: number;
  62595. readonly RGB9_E5: number;
  62596. readonly RGB10_A2: number;
  62597. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62598. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62599. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62600. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62601. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62602. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62603. 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;
  62604. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62605. readonly TRANSFORM_FEEDBACK: number;
  62606. readonly INTERLEAVED_ATTRIBS: number;
  62607. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62608. createTransformFeedback(): WebGLTransformFeedback;
  62609. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62610. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62611. beginTransformFeedback(primitiveMode: number): void;
  62612. endTransformFeedback(): void;
  62613. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62614. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62615. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62616. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62617. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62618. }
  62619. interface ImageBitmap {
  62620. readonly width: number;
  62621. readonly height: number;
  62622. close(): void;
  62623. }
  62624. interface WebGLQuery extends WebGLObject {
  62625. }
  62626. declare var WebGLQuery: {
  62627. prototype: WebGLQuery;
  62628. new(): WebGLQuery;
  62629. };
  62630. interface WebGLSampler extends WebGLObject {
  62631. }
  62632. declare var WebGLSampler: {
  62633. prototype: WebGLSampler;
  62634. new(): WebGLSampler;
  62635. };
  62636. interface WebGLSync extends WebGLObject {
  62637. }
  62638. declare var WebGLSync: {
  62639. prototype: WebGLSync;
  62640. new(): WebGLSync;
  62641. };
  62642. interface WebGLTransformFeedback extends WebGLObject {
  62643. }
  62644. declare var WebGLTransformFeedback: {
  62645. prototype: WebGLTransformFeedback;
  62646. new(): WebGLTransformFeedback;
  62647. };
  62648. interface WebGLVertexArrayObject extends WebGLObject {
  62649. }
  62650. declare var WebGLVertexArrayObject: {
  62651. prototype: WebGLVertexArrayObject;
  62652. new(): WebGLVertexArrayObject;
  62653. };
  62654. // Type definitions for WebVR API
  62655. // Project: https://w3c.github.io/webvr/
  62656. // Definitions by: six a <https://github.com/lostfictions>
  62657. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62658. interface VRDisplay extends EventTarget {
  62659. /**
  62660. * Dictionary of capabilities describing the VRDisplay.
  62661. */
  62662. readonly capabilities: VRDisplayCapabilities;
  62663. /**
  62664. * z-depth defining the far plane of the eye view frustum
  62665. * enables mapping of values in the render target depth
  62666. * attachment to scene coordinates. Initially set to 10000.0.
  62667. */
  62668. depthFar: number;
  62669. /**
  62670. * z-depth defining the near plane of the eye view frustum
  62671. * enables mapping of values in the render target depth
  62672. * attachment to scene coordinates. Initially set to 0.01.
  62673. */
  62674. depthNear: number;
  62675. /**
  62676. * An identifier for this distinct VRDisplay. Used as an
  62677. * association point in the Gamepad API.
  62678. */
  62679. readonly displayId: number;
  62680. /**
  62681. * A display name, a user-readable name identifying it.
  62682. */
  62683. readonly displayName: string;
  62684. readonly isConnected: boolean;
  62685. readonly isPresenting: boolean;
  62686. /**
  62687. * If this VRDisplay supports room-scale experiences, the optional
  62688. * stage attribute contains details on the room-scale parameters.
  62689. */
  62690. readonly stageParameters: VRStageParameters | null;
  62691. /**
  62692. * Passing the value returned by `requestAnimationFrame` to
  62693. * `cancelAnimationFrame` will unregister the callback.
  62694. * @param handle Define the hanle of the request to cancel
  62695. */
  62696. cancelAnimationFrame(handle: number): void;
  62697. /**
  62698. * Stops presenting to the VRDisplay.
  62699. * @returns a promise to know when it stopped
  62700. */
  62701. exitPresent(): Promise<void>;
  62702. /**
  62703. * Return the current VREyeParameters for the given eye.
  62704. * @param whichEye Define the eye we want the parameter for
  62705. * @returns the eye parameters
  62706. */
  62707. getEyeParameters(whichEye: string): VREyeParameters;
  62708. /**
  62709. * Populates the passed VRFrameData with the information required to render
  62710. * the current frame.
  62711. * @param frameData Define the data structure to populate
  62712. * @returns true if ok otherwise false
  62713. */
  62714. getFrameData(frameData: VRFrameData): boolean;
  62715. /**
  62716. * Get the layers currently being presented.
  62717. * @returns the list of VR layers
  62718. */
  62719. getLayers(): VRLayer[];
  62720. /**
  62721. * Return a VRPose containing the future predicted pose of the VRDisplay
  62722. * when the current frame will be presented. The value returned will not
  62723. * change until JavaScript has returned control to the browser.
  62724. *
  62725. * The VRPose will contain the position, orientation, velocity,
  62726. * and acceleration of each of these properties.
  62727. * @returns the pose object
  62728. */
  62729. getPose(): VRPose;
  62730. /**
  62731. * Return the current instantaneous pose of the VRDisplay, with no
  62732. * prediction applied.
  62733. * @returns the current instantaneous pose
  62734. */
  62735. getImmediatePose(): VRPose;
  62736. /**
  62737. * The callback passed to `requestAnimationFrame` will be called
  62738. * any time a new frame should be rendered. When the VRDisplay is
  62739. * presenting the callback will be called at the native refresh
  62740. * rate of the HMD. When not presenting this function acts
  62741. * identically to how window.requestAnimationFrame acts. Content should
  62742. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62743. * asynchronously from other displays and at differing refresh rates.
  62744. * @param callback Define the eaction to run next frame
  62745. * @returns the request handle it
  62746. */
  62747. requestAnimationFrame(callback: FrameRequestCallback): number;
  62748. /**
  62749. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62750. * Repeat calls while already presenting will update the VRLayers being displayed.
  62751. * @param layers Define the list of layer to present
  62752. * @returns a promise to know when the request has been fulfilled
  62753. */
  62754. requestPresent(layers: VRLayer[]): Promise<void>;
  62755. /**
  62756. * Reset the pose for this display, treating its current position and
  62757. * orientation as the "origin/zero" values. VRPose.position,
  62758. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62759. * updated when calling resetPose(). This should be called in only
  62760. * sitting-space experiences.
  62761. */
  62762. resetPose(): void;
  62763. /**
  62764. * The VRLayer provided to the VRDisplay will be captured and presented
  62765. * in the HMD. Calling this function has the same effect on the source
  62766. * canvas as any other operation that uses its source image, and canvases
  62767. * created without preserveDrawingBuffer set to true will be cleared.
  62768. * @param pose Define the pose to submit
  62769. */
  62770. submitFrame(pose?: VRPose): void;
  62771. }
  62772. declare var VRDisplay: {
  62773. prototype: VRDisplay;
  62774. new(): VRDisplay;
  62775. };
  62776. interface VRLayer {
  62777. leftBounds?: number[] | Float32Array | null;
  62778. rightBounds?: number[] | Float32Array | null;
  62779. source?: HTMLCanvasElement | null;
  62780. }
  62781. interface VRDisplayCapabilities {
  62782. readonly canPresent: boolean;
  62783. readonly hasExternalDisplay: boolean;
  62784. readonly hasOrientation: boolean;
  62785. readonly hasPosition: boolean;
  62786. readonly maxLayers: number;
  62787. }
  62788. interface VREyeParameters {
  62789. /** @deprecated */
  62790. readonly fieldOfView: VRFieldOfView;
  62791. readonly offset: Float32Array;
  62792. readonly renderHeight: number;
  62793. readonly renderWidth: number;
  62794. }
  62795. interface VRFieldOfView {
  62796. readonly downDegrees: number;
  62797. readonly leftDegrees: number;
  62798. readonly rightDegrees: number;
  62799. readonly upDegrees: number;
  62800. }
  62801. interface VRFrameData {
  62802. readonly leftProjectionMatrix: Float32Array;
  62803. readonly leftViewMatrix: Float32Array;
  62804. readonly pose: VRPose;
  62805. readonly rightProjectionMatrix: Float32Array;
  62806. readonly rightViewMatrix: Float32Array;
  62807. readonly timestamp: number;
  62808. }
  62809. interface VRPose {
  62810. readonly angularAcceleration: Float32Array | null;
  62811. readonly angularVelocity: Float32Array | null;
  62812. readonly linearAcceleration: Float32Array | null;
  62813. readonly linearVelocity: Float32Array | null;
  62814. readonly orientation: Float32Array | null;
  62815. readonly position: Float32Array | null;
  62816. readonly timestamp: number;
  62817. }
  62818. interface VRStageParameters {
  62819. sittingToStandingTransform?: Float32Array;
  62820. sizeX?: number;
  62821. sizeY?: number;
  62822. }
  62823. interface Navigator {
  62824. getVRDisplays(): Promise<VRDisplay[]>;
  62825. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62826. }
  62827. interface Window {
  62828. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62829. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62830. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62831. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62832. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62833. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62834. }
  62835. interface Gamepad {
  62836. readonly displayId: number;
  62837. }
  62838. type XRSessionMode =
  62839. | "inline"
  62840. | "immersive-vr"
  62841. | "immersive-ar";
  62842. type XRReferenceSpaceType =
  62843. | "viewer"
  62844. | "local"
  62845. | "local-floor"
  62846. | "bounded-floor"
  62847. | "unbounded";
  62848. type XREnvironmentBlendMode =
  62849. | "opaque"
  62850. | "additive"
  62851. | "alpha-blend";
  62852. type XRVisibilityState =
  62853. | "visible"
  62854. | "visible-blurred"
  62855. | "hidden";
  62856. type XRHandedness =
  62857. | "none"
  62858. | "left"
  62859. | "right";
  62860. type XRTargetRayMode =
  62861. | "gaze"
  62862. | "tracked-pointer"
  62863. | "screen";
  62864. type XREye =
  62865. | "none"
  62866. | "left"
  62867. | "right";
  62868. interface XRSpace extends EventTarget {
  62869. }
  62870. interface XRRenderState {
  62871. depthNear?: number;
  62872. depthFar?: number;
  62873. inlineVerticalFieldOfView?: number;
  62874. baseLayer?: XRWebGLLayer;
  62875. }
  62876. interface XRInputSource {
  62877. handedness: XRHandedness;
  62878. targetRayMode: XRTargetRayMode;
  62879. targetRaySpace: XRSpace;
  62880. gripSpace: XRSpace | undefined;
  62881. gamepad: Gamepad | undefined;
  62882. profiles: Array<string>;
  62883. }
  62884. interface XRSession {
  62885. addEventListener: Function;
  62886. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62887. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62888. requestAnimationFrame: Function;
  62889. end(): Promise<void>;
  62890. renderState: XRRenderState;
  62891. inputSources: Array<XRInputSource>;
  62892. }
  62893. interface XRReferenceSpace extends XRSpace {
  62894. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62895. onreset: any;
  62896. }
  62897. interface XRFrame {
  62898. session: XRSession;
  62899. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62900. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62901. }
  62902. interface XRViewerPose extends XRPose {
  62903. views: Array<XRView>;
  62904. }
  62905. interface XRPose {
  62906. transform: XRRigidTransform;
  62907. emulatedPosition: boolean;
  62908. }
  62909. declare var XRWebGLLayer: {
  62910. prototype: XRWebGLLayer;
  62911. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62912. };
  62913. interface XRWebGLLayer {
  62914. framebuffer: WebGLFramebuffer;
  62915. framebufferWidth: number;
  62916. framebufferHeight: number;
  62917. getViewport: Function;
  62918. }
  62919. interface XRRigidTransform {
  62920. position: DOMPointReadOnly;
  62921. orientation: DOMPointReadOnly;
  62922. matrix: Float32Array;
  62923. inverse: XRRigidTransform;
  62924. }
  62925. interface XRView {
  62926. eye: XREye;
  62927. projectionMatrix: Float32Array;
  62928. transform: XRRigidTransform;
  62929. }
  62930. interface XRInputSourceChangeEvent {
  62931. session: XRSession;
  62932. removed: Array<XRInputSource>;
  62933. added: Array<XRInputSource>;
  62934. }
  62935. /**
  62936. * @ignore
  62937. */
  62938. declare module BABYLON.GLTF2.Exporter {
  62939. }
  62940. /**
  62941. * @ignore
  62942. */
  62943. declare module BABYLON.GLTF1 {
  62944. }
  62945. declare module BABYLON.GUI {
  62946. /**
  62947. * Class used to specific a value and its associated unit
  62948. */
  62949. export class ValueAndUnit {
  62950. /** defines the unit to store */
  62951. unit: number;
  62952. /** defines a boolean indicating if the value can be negative */
  62953. negativeValueAllowed: boolean;
  62954. private _value;
  62955. private _originalUnit;
  62956. /**
  62957. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62958. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62959. */
  62960. ignoreAdaptiveScaling: boolean;
  62961. /**
  62962. * Creates a new ValueAndUnit
  62963. * @param value defines the value to store
  62964. * @param unit defines the unit to store
  62965. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62966. */
  62967. constructor(value: number,
  62968. /** defines the unit to store */
  62969. unit?: number,
  62970. /** defines a boolean indicating if the value can be negative */
  62971. negativeValueAllowed?: boolean);
  62972. /** Gets a boolean indicating if the value is a percentage */
  62973. readonly isPercentage: boolean;
  62974. /** Gets a boolean indicating if the value is store as pixel */
  62975. readonly isPixel: boolean;
  62976. /** Gets direct internal value */
  62977. readonly internalValue: number;
  62978. /**
  62979. * Gets value as pixel
  62980. * @param host defines the root host
  62981. * @param refValue defines the reference value for percentages
  62982. * @returns the value as pixel
  62983. */
  62984. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62985. /**
  62986. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62987. * @param value defines the value to store
  62988. * @param unit defines the unit to store
  62989. * @returns the current ValueAndUnit
  62990. */
  62991. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62992. /**
  62993. * Gets the value accordingly to its unit
  62994. * @param host defines the root host
  62995. * @returns the value
  62996. */
  62997. getValue(host: AdvancedDynamicTexture): number;
  62998. /**
  62999. * Gets a string representation of the value
  63000. * @param host defines the root host
  63001. * @param decimals defines an optional number of decimals to display
  63002. * @returns a string
  63003. */
  63004. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63005. /**
  63006. * Store a value parsed from a string
  63007. * @param source defines the source string
  63008. * @returns true if the value was successfully parsed
  63009. */
  63010. fromString(source: string | number): boolean;
  63011. private static _Regex;
  63012. private static _UNITMODE_PERCENTAGE;
  63013. private static _UNITMODE_PIXEL;
  63014. /** UNITMODE_PERCENTAGE */
  63015. static readonly UNITMODE_PERCENTAGE: number;
  63016. /** UNITMODE_PIXEL */
  63017. static readonly UNITMODE_PIXEL: number;
  63018. }
  63019. }
  63020. declare module BABYLON.GUI {
  63021. /**
  63022. * Define a style used by control to automatically setup properties based on a template.
  63023. * Only support font related properties so far
  63024. */
  63025. export class Style implements BABYLON.IDisposable {
  63026. private _fontFamily;
  63027. private _fontStyle;
  63028. private _fontWeight;
  63029. /** @hidden */
  63030. _host: AdvancedDynamicTexture;
  63031. /** @hidden */
  63032. _fontSize: ValueAndUnit;
  63033. /**
  63034. * BABYLON.Observable raised when the style values are changed
  63035. */
  63036. onChangedObservable: BABYLON.Observable<Style>;
  63037. /**
  63038. * Creates a new style object
  63039. * @param host defines the AdvancedDynamicTexture which hosts this style
  63040. */
  63041. constructor(host: AdvancedDynamicTexture);
  63042. /**
  63043. * Gets or sets the font size
  63044. */
  63045. fontSize: string | number;
  63046. /**
  63047. * Gets or sets the font family
  63048. */
  63049. fontFamily: string;
  63050. /**
  63051. * Gets or sets the font style
  63052. */
  63053. fontStyle: string;
  63054. /** Gets or sets font weight */
  63055. fontWeight: string;
  63056. /** Dispose all associated resources */
  63057. dispose(): void;
  63058. }
  63059. }
  63060. declare module BABYLON.GUI {
  63061. /**
  63062. * Class used to transport BABYLON.Vector2 information for pointer events
  63063. */
  63064. export class Vector2WithInfo extends BABYLON.Vector2 {
  63065. /** defines the current mouse button index */
  63066. buttonIndex: number;
  63067. /**
  63068. * Creates a new Vector2WithInfo
  63069. * @param source defines the vector2 data to transport
  63070. * @param buttonIndex defines the current mouse button index
  63071. */
  63072. constructor(source: BABYLON.Vector2,
  63073. /** defines the current mouse button index */
  63074. buttonIndex?: number);
  63075. }
  63076. /** Class used to provide 2D matrix features */
  63077. export class Matrix2D {
  63078. /** Gets the internal array of 6 floats used to store matrix data */
  63079. m: Float32Array;
  63080. /**
  63081. * Creates a new matrix
  63082. * @param m00 defines value for (0, 0)
  63083. * @param m01 defines value for (0, 1)
  63084. * @param m10 defines value for (1, 0)
  63085. * @param m11 defines value for (1, 1)
  63086. * @param m20 defines value for (2, 0)
  63087. * @param m21 defines value for (2, 1)
  63088. */
  63089. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63090. /**
  63091. * Fills the matrix from direct values
  63092. * @param m00 defines value for (0, 0)
  63093. * @param m01 defines value for (0, 1)
  63094. * @param m10 defines value for (1, 0)
  63095. * @param m11 defines value for (1, 1)
  63096. * @param m20 defines value for (2, 0)
  63097. * @param m21 defines value for (2, 1)
  63098. * @returns the current modified matrix
  63099. */
  63100. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63101. /**
  63102. * Gets matrix determinant
  63103. * @returns the determinant
  63104. */
  63105. determinant(): number;
  63106. /**
  63107. * Inverses the matrix and stores it in a target matrix
  63108. * @param result defines the target matrix
  63109. * @returns the current matrix
  63110. */
  63111. invertToRef(result: Matrix2D): Matrix2D;
  63112. /**
  63113. * Multiplies the current matrix with another one
  63114. * @param other defines the second operand
  63115. * @param result defines the target matrix
  63116. * @returns the current matrix
  63117. */
  63118. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63119. /**
  63120. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63121. * @param x defines the x coordinate to transform
  63122. * @param y defines the x coordinate to transform
  63123. * @param result defines the target vector2
  63124. * @returns the current matrix
  63125. */
  63126. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63127. /**
  63128. * Creates an identity matrix
  63129. * @returns a new matrix
  63130. */
  63131. static Identity(): Matrix2D;
  63132. /**
  63133. * Creates a translation matrix and stores it in a target matrix
  63134. * @param x defines the x coordinate of the translation
  63135. * @param y defines the y coordinate of the translation
  63136. * @param result defines the target matrix
  63137. */
  63138. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63139. /**
  63140. * Creates a scaling matrix and stores it in a target matrix
  63141. * @param x defines the x coordinate of the scaling
  63142. * @param y defines the y coordinate of the scaling
  63143. * @param result defines the target matrix
  63144. */
  63145. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63146. /**
  63147. * Creates a rotation matrix and stores it in a target matrix
  63148. * @param angle defines the rotation angle
  63149. * @param result defines the target matrix
  63150. */
  63151. static RotationToRef(angle: number, result: Matrix2D): void;
  63152. private static _TempPreTranslationMatrix;
  63153. private static _TempPostTranslationMatrix;
  63154. private static _TempRotationMatrix;
  63155. private static _TempScalingMatrix;
  63156. private static _TempCompose0;
  63157. private static _TempCompose1;
  63158. private static _TempCompose2;
  63159. /**
  63160. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63161. * @param tx defines the x coordinate of the translation
  63162. * @param ty defines the y coordinate of the translation
  63163. * @param angle defines the rotation angle
  63164. * @param scaleX defines the x coordinate of the scaling
  63165. * @param scaleY defines the y coordinate of the scaling
  63166. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63167. * @param result defines the target matrix
  63168. */
  63169. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63170. }
  63171. }
  63172. declare module BABYLON.GUI {
  63173. /**
  63174. * Class used to store 2D control sizes
  63175. */
  63176. export class Measure {
  63177. /** defines left coordinate */
  63178. left: number;
  63179. /** defines top coordinate */
  63180. top: number;
  63181. /** defines width dimension */
  63182. width: number;
  63183. /** defines height dimension */
  63184. height: number;
  63185. /**
  63186. * Creates a new measure
  63187. * @param left defines left coordinate
  63188. * @param top defines top coordinate
  63189. * @param width defines width dimension
  63190. * @param height defines height dimension
  63191. */
  63192. constructor(
  63193. /** defines left coordinate */
  63194. left: number,
  63195. /** defines top coordinate */
  63196. top: number,
  63197. /** defines width dimension */
  63198. width: number,
  63199. /** defines height dimension */
  63200. height: number);
  63201. /**
  63202. * Copy from another measure
  63203. * @param other defines the other measure to copy from
  63204. */
  63205. copyFrom(other: Measure): void;
  63206. /**
  63207. * Copy from a group of 4 floats
  63208. * @param left defines left coordinate
  63209. * @param top defines top coordinate
  63210. * @param width defines width dimension
  63211. * @param height defines height dimension
  63212. */
  63213. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63214. /**
  63215. * Computes the axis aligned bounding box measure for two given measures
  63216. * @param a Input measure
  63217. * @param b Input measure
  63218. * @param result the resulting bounding measure
  63219. */
  63220. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63221. /**
  63222. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63223. * @param transform the matrix to transform the measure before computing the AABB
  63224. * @param result the resulting AABB
  63225. */
  63226. transformToRef(transform: Matrix2D, result: Measure): void;
  63227. /**
  63228. * Check equality between this measure and another one
  63229. * @param other defines the other measures
  63230. * @returns true if both measures are equals
  63231. */
  63232. isEqualsTo(other: Measure): boolean;
  63233. /**
  63234. * Creates an empty measure
  63235. * @returns a new measure
  63236. */
  63237. static Empty(): Measure;
  63238. }
  63239. }
  63240. declare module BABYLON.GUI {
  63241. /**
  63242. * Interface used to define a control that can receive focus
  63243. */
  63244. export interface IFocusableControl {
  63245. /**
  63246. * Function called when the control receives the focus
  63247. */
  63248. onFocus(): void;
  63249. /**
  63250. * Function called when the control loses the focus
  63251. */
  63252. onBlur(): void;
  63253. /**
  63254. * Function called to let the control handle keyboard events
  63255. * @param evt defines the current keyboard event
  63256. */
  63257. processKeyboard(evt: KeyboardEvent): void;
  63258. /**
  63259. * Function called to get the list of controls that should not steal the focus from this control
  63260. * @returns an array of controls
  63261. */
  63262. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63263. }
  63264. /**
  63265. * Class used to create texture to support 2D GUI elements
  63266. * @see http://doc.babylonjs.com/how_to/gui
  63267. */
  63268. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63269. private _isDirty;
  63270. private _renderObserver;
  63271. private _resizeObserver;
  63272. private _preKeyboardObserver;
  63273. private _pointerMoveObserver;
  63274. private _pointerObserver;
  63275. private _canvasPointerOutObserver;
  63276. private _background;
  63277. /** @hidden */
  63278. _rootContainer: Container;
  63279. /** @hidden */
  63280. _lastPickedControl: Control;
  63281. /** @hidden */
  63282. _lastControlOver: {
  63283. [pointerId: number]: Control;
  63284. };
  63285. /** @hidden */
  63286. _lastControlDown: {
  63287. [pointerId: number]: Control;
  63288. };
  63289. /** @hidden */
  63290. _capturingControl: {
  63291. [pointerId: number]: Control;
  63292. };
  63293. /** @hidden */
  63294. _shouldBlockPointer: boolean;
  63295. /** @hidden */
  63296. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63297. /** @hidden */
  63298. _linkedControls: Control[];
  63299. private _isFullscreen;
  63300. private _fullscreenViewport;
  63301. private _idealWidth;
  63302. private _idealHeight;
  63303. private _useSmallestIdeal;
  63304. private _renderAtIdealSize;
  63305. private _focusedControl;
  63306. private _blockNextFocusCheck;
  63307. private _renderScale;
  63308. private _rootCanvas;
  63309. private _cursorChanged;
  63310. /**
  63311. * Define type to string to ensure compatibility across browsers
  63312. * Safari doesn't support DataTransfer constructor
  63313. */
  63314. private _clipboardData;
  63315. /**
  63316. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63317. */
  63318. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63319. /**
  63320. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63321. */
  63322. onControlPickedObservable: BABYLON.Observable<Control>;
  63323. /**
  63324. * BABYLON.Observable event triggered before layout is evaluated
  63325. */
  63326. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63327. /**
  63328. * BABYLON.Observable event triggered after the layout was evaluated
  63329. */
  63330. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63331. /**
  63332. * BABYLON.Observable event triggered before the texture is rendered
  63333. */
  63334. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63335. /**
  63336. * BABYLON.Observable event triggered after the texture was rendered
  63337. */
  63338. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63339. /**
  63340. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63341. */
  63342. premulAlpha: boolean;
  63343. /**
  63344. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63345. * Useful when you want more antialiasing
  63346. */
  63347. renderScale: number;
  63348. /** Gets or sets the background color */
  63349. background: string;
  63350. /**
  63351. * Gets or sets the ideal width used to design controls.
  63352. * The GUI will then rescale everything accordingly
  63353. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63354. */
  63355. idealWidth: number;
  63356. /**
  63357. * Gets or sets the ideal height used to design controls.
  63358. * The GUI will then rescale everything accordingly
  63359. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63360. */
  63361. idealHeight: number;
  63362. /**
  63363. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63364. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63365. */
  63366. useSmallestIdeal: boolean;
  63367. /**
  63368. * Gets or sets a boolean indicating if adaptive scaling must be used
  63369. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63370. */
  63371. renderAtIdealSize: boolean;
  63372. /**
  63373. * Gets the underlying layer used to render the texture when in fullscreen mode
  63374. */
  63375. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63376. /**
  63377. * Gets the root container control
  63378. */
  63379. readonly rootContainer: Container;
  63380. /**
  63381. * Returns an array containing the root container.
  63382. * This is mostly used to let the Inspector introspects the ADT
  63383. * @returns an array containing the rootContainer
  63384. */
  63385. getChildren(): Array<Container>;
  63386. /**
  63387. * Will return all controls that are inside this texture
  63388. * @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
  63389. * @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
  63390. * @return all child controls
  63391. */
  63392. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63393. /**
  63394. * Gets or sets the current focused control
  63395. */
  63396. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63397. /**
  63398. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63399. */
  63400. isForeground: boolean;
  63401. /**
  63402. * Gets or set information about clipboardData
  63403. */
  63404. clipboardData: string;
  63405. /**
  63406. * Creates a new AdvancedDynamicTexture
  63407. * @param name defines the name of the texture
  63408. * @param width defines the width of the texture
  63409. * @param height defines the height of the texture
  63410. * @param scene defines the hosting scene
  63411. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63412. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63413. */
  63414. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63415. /**
  63416. * Get the current class name of the texture useful for serialization or dynamic coding.
  63417. * @returns "AdvancedDynamicTexture"
  63418. */
  63419. getClassName(): string;
  63420. /**
  63421. * Function used to execute a function on all controls
  63422. * @param func defines the function to execute
  63423. * @param container defines the container where controls belong. If null the root container will be used
  63424. */
  63425. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63426. private _useInvalidateRectOptimization;
  63427. /**
  63428. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63429. */
  63430. useInvalidateRectOptimization: boolean;
  63431. private _invalidatedRectangle;
  63432. /**
  63433. * Invalidates a rectangle area on the gui texture
  63434. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63435. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63436. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63437. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63438. */
  63439. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63440. /**
  63441. * Marks the texture as dirty forcing a complete update
  63442. */
  63443. markAsDirty(): void;
  63444. /**
  63445. * Helper function used to create a new style
  63446. * @returns a new style
  63447. * @see http://doc.babylonjs.com/how_to/gui#styles
  63448. */
  63449. createStyle(): Style;
  63450. /**
  63451. * Adds a new control to the root container
  63452. * @param control defines the control to add
  63453. * @returns the current texture
  63454. */
  63455. addControl(control: Control): AdvancedDynamicTexture;
  63456. /**
  63457. * Removes a control from the root container
  63458. * @param control defines the control to remove
  63459. * @returns the current texture
  63460. */
  63461. removeControl(control: Control): AdvancedDynamicTexture;
  63462. /**
  63463. * Release all resources
  63464. */
  63465. dispose(): void;
  63466. private _onResize;
  63467. /** @hidden */
  63468. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63469. /**
  63470. * Get screen coordinates for a vector3
  63471. * @param position defines the position to project
  63472. * @param worldMatrix defines the world matrix to use
  63473. * @returns the projected position
  63474. */
  63475. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63476. private _checkUpdate;
  63477. private _clearMeasure;
  63478. private _render;
  63479. /** @hidden */
  63480. _changeCursor(cursor: string): void;
  63481. /** @hidden */
  63482. _registerLastControlDown(control: Control, pointerId: number): void;
  63483. private _doPicking;
  63484. /** @hidden */
  63485. _cleanControlAfterRemovalFromList(list: {
  63486. [pointerId: number]: Control;
  63487. }, control: Control): void;
  63488. /** @hidden */
  63489. _cleanControlAfterRemoval(control: Control): void;
  63490. /** Attach to all scene events required to support pointer events */
  63491. attach(): void;
  63492. /** @hidden */
  63493. private onClipboardCopy;
  63494. /** @hidden */
  63495. private onClipboardCut;
  63496. /** @hidden */
  63497. private onClipboardPaste;
  63498. /**
  63499. * Register the clipboard Events onto the canvas
  63500. */
  63501. registerClipboardEvents(): void;
  63502. /**
  63503. * Unregister the clipboard Events from the canvas
  63504. */
  63505. unRegisterClipboardEvents(): void;
  63506. /**
  63507. * Connect the texture to a hosting mesh to enable interactions
  63508. * @param mesh defines the mesh to attach to
  63509. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63510. */
  63511. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63512. /**
  63513. * Move the focus to a specific control
  63514. * @param control defines the control which will receive the focus
  63515. */
  63516. moveFocusToControl(control: IFocusableControl): void;
  63517. private _manageFocus;
  63518. private _attachToOnPointerOut;
  63519. /**
  63520. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63521. * @param mesh defines the mesh which will receive the texture
  63522. * @param width defines the texture width (1024 by default)
  63523. * @param height defines the texture height (1024 by default)
  63524. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63525. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63526. * @returns a new AdvancedDynamicTexture
  63527. */
  63528. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63529. /**
  63530. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63531. * In this mode the texture will rely on a layer for its rendering.
  63532. * This allows it to be treated like any other layer.
  63533. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63534. * LayerMask is set through advancedTexture.layer.layerMask
  63535. * @param name defines name for the texture
  63536. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63537. * @param scene defines the hsoting scene
  63538. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63539. * @returns a new AdvancedDynamicTexture
  63540. */
  63541. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63542. }
  63543. }
  63544. declare module BABYLON.GUI {
  63545. /**
  63546. * Root class used for all 2D controls
  63547. * @see http://doc.babylonjs.com/how_to/gui#controls
  63548. */
  63549. export class Control {
  63550. /** defines the name of the control */
  63551. name?: string | undefined;
  63552. /**
  63553. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63554. */
  63555. static AllowAlphaInheritance: boolean;
  63556. private _alpha;
  63557. private _alphaSet;
  63558. private _zIndex;
  63559. /** @hidden */
  63560. _host: AdvancedDynamicTexture;
  63561. /** Gets or sets the control parent */
  63562. parent: BABYLON.Nullable<Container>;
  63563. /** @hidden */
  63564. _currentMeasure: Measure;
  63565. private _fontFamily;
  63566. private _fontStyle;
  63567. private _fontWeight;
  63568. private _fontSize;
  63569. private _font;
  63570. /** @hidden */
  63571. _width: ValueAndUnit;
  63572. /** @hidden */
  63573. _height: ValueAndUnit;
  63574. /** @hidden */
  63575. protected _fontOffset: {
  63576. ascent: number;
  63577. height: number;
  63578. descent: number;
  63579. };
  63580. private _color;
  63581. private _style;
  63582. private _styleObserver;
  63583. /** @hidden */
  63584. protected _horizontalAlignment: number;
  63585. /** @hidden */
  63586. protected _verticalAlignment: number;
  63587. /** @hidden */
  63588. protected _isDirty: boolean;
  63589. /** @hidden */
  63590. protected _wasDirty: boolean;
  63591. /** @hidden */
  63592. _tempParentMeasure: Measure;
  63593. /** @hidden */
  63594. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63595. /** @hidden */
  63596. protected _cachedParentMeasure: Measure;
  63597. private _paddingLeft;
  63598. private _paddingRight;
  63599. private _paddingTop;
  63600. private _paddingBottom;
  63601. /** @hidden */
  63602. _left: ValueAndUnit;
  63603. /** @hidden */
  63604. _top: ValueAndUnit;
  63605. private _scaleX;
  63606. private _scaleY;
  63607. private _rotation;
  63608. private _transformCenterX;
  63609. private _transformCenterY;
  63610. /** @hidden */
  63611. _transformMatrix: Matrix2D;
  63612. /** @hidden */
  63613. protected _invertTransformMatrix: Matrix2D;
  63614. /** @hidden */
  63615. protected _transformedPosition: BABYLON.Vector2;
  63616. private _isMatrixDirty;
  63617. private _cachedOffsetX;
  63618. private _cachedOffsetY;
  63619. private _isVisible;
  63620. private _isHighlighted;
  63621. /** @hidden */
  63622. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63623. private _fontSet;
  63624. private _dummyVector2;
  63625. private _downCount;
  63626. private _enterCount;
  63627. private _doNotRender;
  63628. private _downPointerIds;
  63629. protected _isEnabled: boolean;
  63630. protected _disabledColor: string;
  63631. /** @hidden */
  63632. protected _rebuildLayout: boolean;
  63633. /** @hidden */
  63634. _isClipped: boolean;
  63635. /** @hidden */
  63636. _tag: any;
  63637. /**
  63638. * 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
  63639. */
  63640. uniqueId: number;
  63641. /**
  63642. * Gets or sets an object used to store user defined information for the node
  63643. */
  63644. metadata: any;
  63645. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63646. isHitTestVisible: boolean;
  63647. /** Gets or sets a boolean indicating if the control can block pointer events */
  63648. isPointerBlocker: boolean;
  63649. /** Gets or sets a boolean indicating if the control can be focusable */
  63650. isFocusInvisible: boolean;
  63651. /**
  63652. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63653. * 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
  63654. */
  63655. clipChildren: boolean;
  63656. /**
  63657. * Gets or sets a boolean indicating that control content must be clipped
  63658. * 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
  63659. */
  63660. clipContent: boolean;
  63661. /**
  63662. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63663. */
  63664. useBitmapCache: boolean;
  63665. private _cacheData;
  63666. private _shadowOffsetX;
  63667. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63668. shadowOffsetX: number;
  63669. private _shadowOffsetY;
  63670. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63671. shadowOffsetY: number;
  63672. private _shadowBlur;
  63673. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63674. shadowBlur: number;
  63675. private _shadowColor;
  63676. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63677. shadowColor: string;
  63678. /** Gets or sets the cursor to use when the control is hovered */
  63679. hoverCursor: string;
  63680. /** @hidden */
  63681. protected _linkOffsetX: ValueAndUnit;
  63682. /** @hidden */
  63683. protected _linkOffsetY: ValueAndUnit;
  63684. /** Gets the control type name */
  63685. readonly typeName: string;
  63686. /**
  63687. * Get the current class name of the control.
  63688. * @returns current class name
  63689. */
  63690. getClassName(): string;
  63691. /**
  63692. * An event triggered when the pointer move over the control.
  63693. */
  63694. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63695. /**
  63696. * An event triggered when the pointer move out of the control.
  63697. */
  63698. onPointerOutObservable: BABYLON.Observable<Control>;
  63699. /**
  63700. * An event triggered when the pointer taps the control
  63701. */
  63702. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63703. /**
  63704. * An event triggered when pointer up
  63705. */
  63706. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63707. /**
  63708. * An event triggered when a control is clicked on
  63709. */
  63710. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63711. /**
  63712. * An event triggered when pointer enters the control
  63713. */
  63714. onPointerEnterObservable: BABYLON.Observable<Control>;
  63715. /**
  63716. * An event triggered when the control is marked as dirty
  63717. */
  63718. onDirtyObservable: BABYLON.Observable<Control>;
  63719. /**
  63720. * An event triggered before drawing the control
  63721. */
  63722. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63723. /**
  63724. * An event triggered after the control was drawn
  63725. */
  63726. onAfterDrawObservable: BABYLON.Observable<Control>;
  63727. /**
  63728. * Get the hosting AdvancedDynamicTexture
  63729. */
  63730. readonly host: AdvancedDynamicTexture;
  63731. /** Gets or set information about font offsets (used to render and align text) */
  63732. fontOffset: {
  63733. ascent: number;
  63734. height: number;
  63735. descent: number;
  63736. };
  63737. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63738. alpha: number;
  63739. /**
  63740. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63741. */
  63742. isHighlighted: boolean;
  63743. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63744. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63745. */
  63746. scaleX: number;
  63747. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63748. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63749. */
  63750. scaleY: number;
  63751. /** Gets or sets the rotation angle (0 by default)
  63752. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63753. */
  63754. rotation: number;
  63755. /** Gets or sets the transformation center on Y axis (0 by default)
  63756. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63757. */
  63758. transformCenterY: number;
  63759. /** Gets or sets the transformation center on X axis (0 by default)
  63760. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63761. */
  63762. transformCenterX: number;
  63763. /**
  63764. * Gets or sets the horizontal alignment
  63765. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63766. */
  63767. horizontalAlignment: number;
  63768. /**
  63769. * Gets or sets the vertical alignment
  63770. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63771. */
  63772. verticalAlignment: number;
  63773. /**
  63774. * Gets or sets control width
  63775. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63776. */
  63777. width: string | number;
  63778. /**
  63779. * Gets or sets the control width in pixel
  63780. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63781. */
  63782. widthInPixels: number;
  63783. /**
  63784. * Gets or sets control height
  63785. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63786. */
  63787. height: string | number;
  63788. /**
  63789. * Gets or sets control height in pixel
  63790. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63791. */
  63792. heightInPixels: number;
  63793. /** Gets or set font family */
  63794. fontFamily: string;
  63795. /** Gets or sets font style */
  63796. fontStyle: string;
  63797. /** Gets or sets font weight */
  63798. fontWeight: string;
  63799. /**
  63800. * Gets or sets style
  63801. * @see http://doc.babylonjs.com/how_to/gui#styles
  63802. */
  63803. style: BABYLON.Nullable<Style>;
  63804. /** @hidden */
  63805. readonly _isFontSizeInPercentage: boolean;
  63806. /** Gets or sets font size in pixels */
  63807. fontSizeInPixels: number;
  63808. /** Gets or sets font size */
  63809. fontSize: string | number;
  63810. /** Gets or sets foreground color */
  63811. color: string;
  63812. /** Gets or sets z index which is used to reorder controls on the z axis */
  63813. zIndex: number;
  63814. /** Gets or sets a boolean indicating if the control can be rendered */
  63815. notRenderable: boolean;
  63816. /** Gets or sets a boolean indicating if the control is visible */
  63817. isVisible: boolean;
  63818. /** Gets a boolean indicating that the control needs to update its rendering */
  63819. readonly isDirty: boolean;
  63820. /**
  63821. * Gets the current linked mesh (or null if none)
  63822. */
  63823. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63824. /**
  63825. * Gets or sets a value indicating the padding to use on the left of the control
  63826. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63827. */
  63828. paddingLeft: string | number;
  63829. /**
  63830. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63831. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63832. */
  63833. paddingLeftInPixels: number;
  63834. /**
  63835. * Gets or sets a value indicating the padding to use on the right of the control
  63836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63837. */
  63838. paddingRight: string | number;
  63839. /**
  63840. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63842. */
  63843. paddingRightInPixels: number;
  63844. /**
  63845. * Gets or sets a value indicating the padding to use on the top of the control
  63846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63847. */
  63848. paddingTop: string | number;
  63849. /**
  63850. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63851. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63852. */
  63853. paddingTopInPixels: number;
  63854. /**
  63855. * Gets or sets a value indicating the padding to use on the bottom of the control
  63856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63857. */
  63858. paddingBottom: string | number;
  63859. /**
  63860. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63861. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63862. */
  63863. paddingBottomInPixels: number;
  63864. /**
  63865. * Gets or sets a value indicating the left coordinate of the control
  63866. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63867. */
  63868. left: string | number;
  63869. /**
  63870. * Gets or sets a value indicating the left coordinate in pixels of the control
  63871. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63872. */
  63873. leftInPixels: number;
  63874. /**
  63875. * Gets or sets a value indicating the top coordinate of the control
  63876. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63877. */
  63878. top: string | number;
  63879. /**
  63880. * Gets or sets a value indicating the top coordinate in pixels of the control
  63881. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63882. */
  63883. topInPixels: number;
  63884. /**
  63885. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63886. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63887. */
  63888. linkOffsetX: string | number;
  63889. /**
  63890. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63891. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63892. */
  63893. linkOffsetXInPixels: number;
  63894. /**
  63895. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63896. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63897. */
  63898. linkOffsetY: string | number;
  63899. /**
  63900. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63901. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63902. */
  63903. linkOffsetYInPixels: number;
  63904. /** Gets the center coordinate on X axis */
  63905. readonly centerX: number;
  63906. /** Gets the center coordinate on Y axis */
  63907. readonly centerY: number;
  63908. /** Gets or sets if control is Enabled*/
  63909. isEnabled: boolean;
  63910. /** Gets or sets background color of control if it's disabled*/
  63911. disabledColor: string;
  63912. /**
  63913. * Creates a new control
  63914. * @param name defines the name of the control
  63915. */
  63916. constructor(
  63917. /** defines the name of the control */
  63918. name?: string | undefined);
  63919. /** @hidden */
  63920. protected _getTypeName(): string;
  63921. /**
  63922. * Gets the first ascendant in the hierarchy of the given type
  63923. * @param className defines the required type
  63924. * @returns the ascendant or null if not found
  63925. */
  63926. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63927. /** @hidden */
  63928. _resetFontCache(): void;
  63929. /**
  63930. * Determines if a container is an ascendant of the current control
  63931. * @param container defines the container to look for
  63932. * @returns true if the container is one of the ascendant of the control
  63933. */
  63934. isAscendant(container: Control): boolean;
  63935. /**
  63936. * Gets coordinates in local control space
  63937. * @param globalCoordinates defines the coordinates to transform
  63938. * @returns the new coordinates in local space
  63939. */
  63940. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63941. /**
  63942. * Gets coordinates in local control space
  63943. * @param globalCoordinates defines the coordinates to transform
  63944. * @param result defines the target vector2 where to store the result
  63945. * @returns the current control
  63946. */
  63947. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63948. /**
  63949. * Gets coordinates in parent local control space
  63950. * @param globalCoordinates defines the coordinates to transform
  63951. * @returns the new coordinates in parent local space
  63952. */
  63953. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63954. /**
  63955. * Move the current control to a vector3 position projected onto the screen.
  63956. * @param position defines the target position
  63957. * @param scene defines the hosting scene
  63958. */
  63959. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63960. /** @hidden */
  63961. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63962. /**
  63963. * Will return all controls that have this control as ascendant
  63964. * @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
  63965. * @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
  63966. * @return all child controls
  63967. */
  63968. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63969. /**
  63970. * Link current control with a target mesh
  63971. * @param mesh defines the mesh to link with
  63972. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63973. */
  63974. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63975. /** @hidden */
  63976. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63977. /** @hidden */
  63978. _offsetLeft(offset: number): void;
  63979. /** @hidden */
  63980. _offsetTop(offset: number): void;
  63981. /** @hidden */
  63982. _markMatrixAsDirty(): void;
  63983. /** @hidden */
  63984. _flagDescendantsAsMatrixDirty(): void;
  63985. /** @hidden */
  63986. _intersectsRect(rect: Measure): boolean;
  63987. /** @hidden */
  63988. protected invalidateRect(): void;
  63989. /** @hidden */
  63990. _markAsDirty(force?: boolean): void;
  63991. /** @hidden */
  63992. _markAllAsDirty(): void;
  63993. /** @hidden */
  63994. _link(host: AdvancedDynamicTexture): void;
  63995. /** @hidden */
  63996. protected _transform(context?: CanvasRenderingContext2D): void;
  63997. /** @hidden */
  63998. _renderHighlight(context: CanvasRenderingContext2D): void;
  63999. /** @hidden */
  64000. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64001. /** @hidden */
  64002. protected _applyStates(context: CanvasRenderingContext2D): void;
  64003. /** @hidden */
  64004. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64005. /** @hidden */
  64006. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64007. protected _evaluateClippingState(parentMeasure: Measure): void;
  64008. /** @hidden */
  64009. _measure(): void;
  64010. /** @hidden */
  64011. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64012. /** @hidden */
  64013. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64014. /** @hidden */
  64015. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64016. /** @hidden */
  64017. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64018. private static _ClipMeasure;
  64019. private _tmpMeasureA;
  64020. private _clip;
  64021. /** @hidden */
  64022. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64023. /** @hidden */
  64024. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64025. /**
  64026. * Tests if a given coordinates belong to the current control
  64027. * @param x defines x coordinate to test
  64028. * @param y defines y coordinate to test
  64029. * @returns true if the coordinates are inside the control
  64030. */
  64031. contains(x: number, y: number): boolean;
  64032. /** @hidden */
  64033. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64034. /** @hidden */
  64035. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64036. /** @hidden */
  64037. _onPointerEnter(target: Control): boolean;
  64038. /** @hidden */
  64039. _onPointerOut(target: Control, force?: boolean): void;
  64040. /** @hidden */
  64041. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64042. /** @hidden */
  64043. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64044. /** @hidden */
  64045. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64046. /** @hidden */
  64047. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64048. private _prepareFont;
  64049. /** Releases associated resources */
  64050. dispose(): void;
  64051. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64052. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64053. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64054. private static _VERTICAL_ALIGNMENT_TOP;
  64055. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64056. private static _VERTICAL_ALIGNMENT_CENTER;
  64057. /** HORIZONTAL_ALIGNMENT_LEFT */
  64058. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64059. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64060. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64061. /** HORIZONTAL_ALIGNMENT_CENTER */
  64062. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64063. /** VERTICAL_ALIGNMENT_TOP */
  64064. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64065. /** VERTICAL_ALIGNMENT_BOTTOM */
  64066. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64067. /** VERTICAL_ALIGNMENT_CENTER */
  64068. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64069. private static _FontHeightSizes;
  64070. /** @hidden */
  64071. static _GetFontOffset(font: string): {
  64072. ascent: number;
  64073. height: number;
  64074. descent: number;
  64075. };
  64076. /**
  64077. * Creates a stack panel that can be used to render headers
  64078. * @param control defines the control to associate with the header
  64079. * @param text defines the text of the header
  64080. * @param size defines the size of the header
  64081. * @param options defines options used to configure the header
  64082. * @returns a new StackPanel
  64083. * @ignore
  64084. * @hidden
  64085. */
  64086. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64087. isHorizontal: boolean;
  64088. controlFirst: boolean;
  64089. }) => any;
  64090. /** @hidden */
  64091. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64092. }
  64093. }
  64094. declare module BABYLON.GUI {
  64095. /**
  64096. * Root class for 2D containers
  64097. * @see http://doc.babylonjs.com/how_to/gui#containers
  64098. */
  64099. export class Container extends Control {
  64100. name?: string | undefined;
  64101. /** @hidden */
  64102. protected _children: Control[];
  64103. /** @hidden */
  64104. protected _measureForChildren: Measure;
  64105. /** @hidden */
  64106. protected _background: string;
  64107. /** @hidden */
  64108. protected _adaptWidthToChildren: boolean;
  64109. /** @hidden */
  64110. protected _adaptHeightToChildren: boolean;
  64111. /**
  64112. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64113. */
  64114. logLayoutCycleErrors: boolean;
  64115. /**
  64116. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64117. */
  64118. maxLayoutCycle: number;
  64119. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64120. adaptHeightToChildren: boolean;
  64121. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64122. adaptWidthToChildren: boolean;
  64123. /** Gets or sets background color */
  64124. background: string;
  64125. /** Gets the list of children */
  64126. readonly children: Control[];
  64127. /**
  64128. * Creates a new Container
  64129. * @param name defines the name of the container
  64130. */
  64131. constructor(name?: string | undefined);
  64132. protected _getTypeName(): string;
  64133. _flagDescendantsAsMatrixDirty(): void;
  64134. /**
  64135. * Gets a child using its name
  64136. * @param name defines the child name to look for
  64137. * @returns the child control if found
  64138. */
  64139. getChildByName(name: string): BABYLON.Nullable<Control>;
  64140. /**
  64141. * Gets a child using its type and its name
  64142. * @param name defines the child name to look for
  64143. * @param type defines the child type to look for
  64144. * @returns the child control if found
  64145. */
  64146. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64147. /**
  64148. * Search for a specific control in children
  64149. * @param control defines the control to look for
  64150. * @returns true if the control is in child list
  64151. */
  64152. containsControl(control: Control): boolean;
  64153. /**
  64154. * Adds a new control to the current container
  64155. * @param control defines the control to add
  64156. * @returns the current container
  64157. */
  64158. addControl(control: BABYLON.Nullable<Control>): Container;
  64159. /**
  64160. * Removes all controls from the current container
  64161. * @returns the current container
  64162. */
  64163. clearControls(): Container;
  64164. /**
  64165. * Removes a control from the current container
  64166. * @param control defines the control to remove
  64167. * @returns the current container
  64168. */
  64169. removeControl(control: Control): Container;
  64170. /** @hidden */
  64171. _reOrderControl(control: Control): void;
  64172. /** @hidden */
  64173. _offsetLeft(offset: number): void;
  64174. /** @hidden */
  64175. _offsetTop(offset: number): void;
  64176. /** @hidden */
  64177. _markAllAsDirty(): void;
  64178. /** @hidden */
  64179. protected _localDraw(context: CanvasRenderingContext2D): void;
  64180. /** @hidden */
  64181. _link(host: AdvancedDynamicTexture): void;
  64182. /** @hidden */
  64183. protected _beforeLayout(): void;
  64184. /** @hidden */
  64185. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64186. /** @hidden */
  64187. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64188. protected _postMeasure(): void;
  64189. /** @hidden */
  64190. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64191. /** @hidden */
  64192. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64193. /** @hidden */
  64194. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64195. /** @hidden */
  64196. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64197. /** Releases associated resources */
  64198. dispose(): void;
  64199. }
  64200. }
  64201. declare module BABYLON.GUI {
  64202. /** Class used to create rectangle container */
  64203. export class Rectangle extends Container {
  64204. name?: string | undefined;
  64205. private _thickness;
  64206. private _cornerRadius;
  64207. /** Gets or sets border thickness */
  64208. thickness: number;
  64209. /** Gets or sets the corner radius angle */
  64210. cornerRadius: number;
  64211. /**
  64212. * Creates a new Rectangle
  64213. * @param name defines the control name
  64214. */
  64215. constructor(name?: string | undefined);
  64216. protected _getTypeName(): string;
  64217. protected _localDraw(context: CanvasRenderingContext2D): void;
  64218. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64219. private _drawRoundedRect;
  64220. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64221. }
  64222. }
  64223. declare module BABYLON.GUI {
  64224. /**
  64225. * Enum that determines the text-wrapping mode to use.
  64226. */
  64227. export enum TextWrapping {
  64228. /**
  64229. * Clip the text when it's larger than Control.width; this is the default mode.
  64230. */
  64231. Clip = 0,
  64232. /**
  64233. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64234. */
  64235. WordWrap = 1,
  64236. /**
  64237. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64238. */
  64239. Ellipsis = 2
  64240. }
  64241. /**
  64242. * Class used to create text block control
  64243. */
  64244. export class TextBlock extends Control {
  64245. /**
  64246. * Defines the name of the control
  64247. */
  64248. name?: string | undefined;
  64249. private _text;
  64250. private _textWrapping;
  64251. private _textHorizontalAlignment;
  64252. private _textVerticalAlignment;
  64253. private _lines;
  64254. private _resizeToFit;
  64255. private _lineSpacing;
  64256. private _outlineWidth;
  64257. private _outlineColor;
  64258. /**
  64259. * An event triggered after the text is changed
  64260. */
  64261. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64262. /**
  64263. * An event triggered after the text was broken up into lines
  64264. */
  64265. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64266. /**
  64267. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64268. */
  64269. readonly lines: any[];
  64270. /**
  64271. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64272. */
  64273. /**
  64274. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64275. */
  64276. resizeToFit: boolean;
  64277. /**
  64278. * Gets or sets a boolean indicating if text must be wrapped
  64279. */
  64280. /**
  64281. * Gets or sets a boolean indicating if text must be wrapped
  64282. */
  64283. textWrapping: TextWrapping | boolean;
  64284. /**
  64285. * Gets or sets text to display
  64286. */
  64287. /**
  64288. * Gets or sets text to display
  64289. */
  64290. text: string;
  64291. /**
  64292. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64293. */
  64294. /**
  64295. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64296. */
  64297. textHorizontalAlignment: number;
  64298. /**
  64299. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64300. */
  64301. /**
  64302. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64303. */
  64304. textVerticalAlignment: number;
  64305. /**
  64306. * Gets or sets line spacing value
  64307. */
  64308. /**
  64309. * Gets or sets line spacing value
  64310. */
  64311. lineSpacing: string | number;
  64312. /**
  64313. * Gets or sets outlineWidth of the text to display
  64314. */
  64315. /**
  64316. * Gets or sets outlineWidth of the text to display
  64317. */
  64318. outlineWidth: number;
  64319. /**
  64320. * Gets or sets outlineColor of the text to display
  64321. */
  64322. /**
  64323. * Gets or sets outlineColor of the text to display
  64324. */
  64325. outlineColor: string;
  64326. /**
  64327. * Creates a new TextBlock object
  64328. * @param name defines the name of the control
  64329. * @param text defines the text to display (emptry string by default)
  64330. */
  64331. constructor(
  64332. /**
  64333. * Defines the name of the control
  64334. */
  64335. name?: string | undefined, text?: string);
  64336. protected _getTypeName(): string;
  64337. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64338. private _drawText;
  64339. /** @hidden */
  64340. _draw(context: CanvasRenderingContext2D): void;
  64341. protected _applyStates(context: CanvasRenderingContext2D): void;
  64342. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64343. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64344. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64345. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64346. protected _renderLines(context: CanvasRenderingContext2D): void;
  64347. /**
  64348. * Given a width constraint applied on the text block, find the expected height
  64349. * @returns expected height
  64350. */
  64351. computeExpectedHeight(): number;
  64352. dispose(): void;
  64353. }
  64354. }
  64355. declare module BABYLON.GUI {
  64356. /**
  64357. * Class used to create 2D images
  64358. */
  64359. export class Image extends Control {
  64360. name?: string | undefined;
  64361. private static _WorkingCanvas;
  64362. private _domImage;
  64363. private _imageWidth;
  64364. private _imageHeight;
  64365. private _loaded;
  64366. private _stretch;
  64367. private _source;
  64368. private _autoScale;
  64369. private _sourceLeft;
  64370. private _sourceTop;
  64371. private _sourceWidth;
  64372. private _sourceHeight;
  64373. private _cellWidth;
  64374. private _cellHeight;
  64375. private _cellId;
  64376. private _populateNinePatchSlicesFromImage;
  64377. private _sliceLeft;
  64378. private _sliceRight;
  64379. private _sliceTop;
  64380. private _sliceBottom;
  64381. private _detectPointerOnOpaqueOnly;
  64382. /**
  64383. * BABYLON.Observable notified when the content is loaded
  64384. */
  64385. onImageLoadedObservable: BABYLON.Observable<Image>;
  64386. /**
  64387. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64388. */
  64389. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64390. /**
  64391. * Gets a boolean indicating that the content is loaded
  64392. */
  64393. readonly isLoaded: boolean;
  64394. /**
  64395. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64396. */
  64397. populateNinePatchSlicesFromImage: boolean;
  64398. /**
  64399. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64400. * Beware using this as this will comsume more memory as the image has to be stored twice
  64401. */
  64402. detectPointerOnOpaqueOnly: boolean;
  64403. /**
  64404. * Gets or sets the left value for slicing (9-patch)
  64405. */
  64406. sliceLeft: number;
  64407. /**
  64408. * Gets or sets the right value for slicing (9-patch)
  64409. */
  64410. sliceRight: number;
  64411. /**
  64412. * Gets or sets the top value for slicing (9-patch)
  64413. */
  64414. sliceTop: number;
  64415. /**
  64416. * Gets or sets the bottom value for slicing (9-patch)
  64417. */
  64418. sliceBottom: number;
  64419. /**
  64420. * Gets or sets the left coordinate in the source image
  64421. */
  64422. sourceLeft: number;
  64423. /**
  64424. * Gets or sets the top coordinate in the source image
  64425. */
  64426. sourceTop: number;
  64427. /**
  64428. * Gets or sets the width to capture in the source image
  64429. */
  64430. sourceWidth: number;
  64431. /**
  64432. * Gets or sets the height to capture in the source image
  64433. */
  64434. sourceHeight: number;
  64435. /**
  64436. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64437. * @see http://doc.babylonjs.com/how_to/gui#image
  64438. */
  64439. autoScale: boolean;
  64440. /** Gets or sets the streching mode used by the image */
  64441. stretch: number;
  64442. /**
  64443. * Gets or sets the internal DOM image used to render the control
  64444. */
  64445. domImage: HTMLImageElement;
  64446. private _onImageLoaded;
  64447. private _extractNinePatchSliceDataFromImage;
  64448. /**
  64449. * Gets or sets image source url
  64450. */
  64451. source: BABYLON.Nullable<string>;
  64452. /**
  64453. * Checks for svg document with icon id present
  64454. */
  64455. private _svgCheck;
  64456. /**
  64457. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64458. * given external svg file and icon id
  64459. */
  64460. private _getSVGAttribs;
  64461. /**
  64462. * Gets or sets the cell width to use when animation sheet is enabled
  64463. * @see http://doc.babylonjs.com/how_to/gui#image
  64464. */
  64465. cellWidth: number;
  64466. /**
  64467. * Gets or sets the cell height to use when animation sheet is enabled
  64468. * @see http://doc.babylonjs.com/how_to/gui#image
  64469. */
  64470. cellHeight: number;
  64471. /**
  64472. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64473. * @see http://doc.babylonjs.com/how_to/gui#image
  64474. */
  64475. cellId: number;
  64476. /**
  64477. * Creates a new Image
  64478. * @param name defines the control name
  64479. * @param url defines the image url
  64480. */
  64481. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64482. /**
  64483. * Tests if a given coordinates belong to the current control
  64484. * @param x defines x coordinate to test
  64485. * @param y defines y coordinate to test
  64486. * @returns true if the coordinates are inside the control
  64487. */
  64488. contains(x: number, y: number): boolean;
  64489. protected _getTypeName(): string;
  64490. /** Force the control to synchronize with its content */
  64491. synchronizeSizeWithContent(): void;
  64492. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64493. private _prepareWorkingCanvasForOpaqueDetection;
  64494. private _drawImage;
  64495. _draw(context: CanvasRenderingContext2D): void;
  64496. private _renderCornerPatch;
  64497. private _renderNinePatch;
  64498. dispose(): void;
  64499. /** STRETCH_NONE */
  64500. static readonly STRETCH_NONE: number;
  64501. /** STRETCH_FILL */
  64502. static readonly STRETCH_FILL: number;
  64503. /** STRETCH_UNIFORM */
  64504. static readonly STRETCH_UNIFORM: number;
  64505. /** STRETCH_EXTEND */
  64506. static readonly STRETCH_EXTEND: number;
  64507. /** NINE_PATCH */
  64508. static readonly STRETCH_NINE_PATCH: number;
  64509. }
  64510. }
  64511. declare module BABYLON.GUI {
  64512. /**
  64513. * Class used to create 2D buttons
  64514. */
  64515. export class Button extends Rectangle {
  64516. name?: string | undefined;
  64517. /**
  64518. * Function called to generate a pointer enter animation
  64519. */
  64520. pointerEnterAnimation: () => void;
  64521. /**
  64522. * Function called to generate a pointer out animation
  64523. */
  64524. pointerOutAnimation: () => void;
  64525. /**
  64526. * Function called to generate a pointer down animation
  64527. */
  64528. pointerDownAnimation: () => void;
  64529. /**
  64530. * Function called to generate a pointer up animation
  64531. */
  64532. pointerUpAnimation: () => void;
  64533. /**
  64534. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64535. */
  64536. delegatePickingToChildren: boolean;
  64537. private _image;
  64538. /**
  64539. * Returns the image part of the button (if any)
  64540. */
  64541. readonly image: BABYLON.Nullable<Image>;
  64542. private _textBlock;
  64543. /**
  64544. * Returns the image part of the button (if any)
  64545. */
  64546. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64547. /**
  64548. * Creates a new Button
  64549. * @param name defines the name of the button
  64550. */
  64551. constructor(name?: string | undefined);
  64552. protected _getTypeName(): string;
  64553. /** @hidden */
  64554. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64555. /** @hidden */
  64556. _onPointerEnter(target: Control): boolean;
  64557. /** @hidden */
  64558. _onPointerOut(target: Control, force?: boolean): void;
  64559. /** @hidden */
  64560. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64561. /** @hidden */
  64562. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64563. /**
  64564. * Creates a new button made with an image and a text
  64565. * @param name defines the name of the button
  64566. * @param text defines the text of the button
  64567. * @param imageUrl defines the url of the image
  64568. * @returns a new Button
  64569. */
  64570. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64571. /**
  64572. * Creates a new button made with an image
  64573. * @param name defines the name of the button
  64574. * @param imageUrl defines the url of the image
  64575. * @returns a new Button
  64576. */
  64577. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64578. /**
  64579. * Creates a new button made with a text
  64580. * @param name defines the name of the button
  64581. * @param text defines the text of the button
  64582. * @returns a new Button
  64583. */
  64584. static CreateSimpleButton(name: string, text: string): Button;
  64585. /**
  64586. * Creates a new button made with an image and a centered text
  64587. * @param name defines the name of the button
  64588. * @param text defines the text of the button
  64589. * @param imageUrl defines the url of the image
  64590. * @returns a new Button
  64591. */
  64592. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64593. }
  64594. }
  64595. declare module BABYLON.GUI {
  64596. /**
  64597. * Class used to create a 2D stack panel container
  64598. */
  64599. export class StackPanel extends Container {
  64600. name?: string | undefined;
  64601. private _isVertical;
  64602. private _manualWidth;
  64603. private _manualHeight;
  64604. private _doNotTrackManualChanges;
  64605. /**
  64606. * Gets or sets a boolean indicating that layou warnings should be ignored
  64607. */
  64608. ignoreLayoutWarnings: boolean;
  64609. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64610. isVertical: boolean;
  64611. /**
  64612. * Gets or sets panel width.
  64613. * This value should not be set when in horizontal mode as it will be computed automatically
  64614. */
  64615. width: string | number;
  64616. /**
  64617. * Gets or sets panel height.
  64618. * This value should not be set when in vertical mode as it will be computed automatically
  64619. */
  64620. height: string | number;
  64621. /**
  64622. * Creates a new StackPanel
  64623. * @param name defines control name
  64624. */
  64625. constructor(name?: string | undefined);
  64626. protected _getTypeName(): string;
  64627. /** @hidden */
  64628. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64629. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64630. protected _postMeasure(): void;
  64631. }
  64632. }
  64633. declare module BABYLON.GUI {
  64634. /**
  64635. * Class used to represent a 2D checkbox
  64636. */
  64637. export class Checkbox extends Control {
  64638. name?: string | undefined;
  64639. private _isChecked;
  64640. private _background;
  64641. private _checkSizeRatio;
  64642. private _thickness;
  64643. /** Gets or sets border thickness */
  64644. thickness: number;
  64645. /**
  64646. * BABYLON.Observable raised when isChecked property changes
  64647. */
  64648. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64649. /** Gets or sets a value indicating the ratio between overall size and check size */
  64650. checkSizeRatio: number;
  64651. /** Gets or sets background color */
  64652. background: string;
  64653. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64654. isChecked: boolean;
  64655. /**
  64656. * Creates a new CheckBox
  64657. * @param name defines the control name
  64658. */
  64659. constructor(name?: string | undefined);
  64660. protected _getTypeName(): string;
  64661. /** @hidden */
  64662. _draw(context: CanvasRenderingContext2D): void;
  64663. /** @hidden */
  64664. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64665. /**
  64666. * Utility function to easily create a checkbox with a header
  64667. * @param title defines the label to use for the header
  64668. * @param onValueChanged defines the callback to call when value changes
  64669. * @returns a StackPanel containing the checkbox and a textBlock
  64670. */
  64671. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64672. }
  64673. }
  64674. declare module BABYLON.GUI {
  64675. /**
  64676. * Class used to store key control properties
  64677. */
  64678. export class KeyPropertySet {
  64679. /** Width */
  64680. width?: string;
  64681. /** Height */
  64682. height?: string;
  64683. /** Left padding */
  64684. paddingLeft?: string;
  64685. /** Right padding */
  64686. paddingRight?: string;
  64687. /** Top padding */
  64688. paddingTop?: string;
  64689. /** Bottom padding */
  64690. paddingBottom?: string;
  64691. /** Foreground color */
  64692. color?: string;
  64693. /** Background color */
  64694. background?: string;
  64695. }
  64696. /**
  64697. * Class used to create virtual keyboard
  64698. */
  64699. export class VirtualKeyboard extends StackPanel {
  64700. /** BABYLON.Observable raised when a key is pressed */
  64701. onKeyPressObservable: BABYLON.Observable<string>;
  64702. /** Gets or sets default key button width */
  64703. defaultButtonWidth: string;
  64704. /** Gets or sets default key button height */
  64705. defaultButtonHeight: string;
  64706. /** Gets or sets default key button left padding */
  64707. defaultButtonPaddingLeft: string;
  64708. /** Gets or sets default key button right padding */
  64709. defaultButtonPaddingRight: string;
  64710. /** Gets or sets default key button top padding */
  64711. defaultButtonPaddingTop: string;
  64712. /** Gets or sets default key button bottom padding */
  64713. defaultButtonPaddingBottom: string;
  64714. /** Gets or sets default key button foreground color */
  64715. defaultButtonColor: string;
  64716. /** Gets or sets default key button background color */
  64717. defaultButtonBackground: string;
  64718. /** Gets or sets shift button foreground color */
  64719. shiftButtonColor: string;
  64720. /** Gets or sets shift button thickness*/
  64721. selectedShiftThickness: number;
  64722. /** Gets shift key state */
  64723. shiftState: number;
  64724. protected _getTypeName(): string;
  64725. private _createKey;
  64726. /**
  64727. * Adds a new row of keys
  64728. * @param keys defines the list of keys to add
  64729. * @param propertySets defines the associated property sets
  64730. */
  64731. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64732. /**
  64733. * Set the shift key to a specific state
  64734. * @param shiftState defines the new shift state
  64735. */
  64736. applyShiftState(shiftState: number): void;
  64737. private _currentlyConnectedInputText;
  64738. private _connectedInputTexts;
  64739. private _onKeyPressObserver;
  64740. /** Gets the input text control currently attached to the keyboard */
  64741. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64742. /**
  64743. * Connects the keyboard with an input text control
  64744. *
  64745. * @param input defines the target control
  64746. */
  64747. connect(input: InputText): void;
  64748. /**
  64749. * Disconnects the keyboard from connected InputText controls
  64750. *
  64751. * @param input optionally defines a target control, otherwise all are disconnected
  64752. */
  64753. disconnect(input?: InputText): void;
  64754. private _removeConnectedInputObservables;
  64755. /**
  64756. * Release all resources
  64757. */
  64758. dispose(): void;
  64759. /**
  64760. * Creates a new keyboard using a default layout
  64761. *
  64762. * @param name defines control name
  64763. * @returns a new VirtualKeyboard
  64764. */
  64765. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64766. }
  64767. }
  64768. declare module BABYLON.GUI {
  64769. /**
  64770. * Class used to create input text control
  64771. */
  64772. export class InputText extends Control implements IFocusableControl {
  64773. name?: string | undefined;
  64774. private _text;
  64775. private _placeholderText;
  64776. private _background;
  64777. private _focusedBackground;
  64778. private _focusedColor;
  64779. private _placeholderColor;
  64780. private _thickness;
  64781. private _margin;
  64782. private _autoStretchWidth;
  64783. private _maxWidth;
  64784. private _isFocused;
  64785. private _blinkTimeout;
  64786. private _blinkIsEven;
  64787. private _cursorOffset;
  64788. private _scrollLeft;
  64789. private _textWidth;
  64790. private _clickedCoordinate;
  64791. private _deadKey;
  64792. private _addKey;
  64793. private _currentKey;
  64794. private _isTextHighlightOn;
  64795. private _textHighlightColor;
  64796. private _highligherOpacity;
  64797. private _highlightedText;
  64798. private _startHighlightIndex;
  64799. private _endHighlightIndex;
  64800. private _cursorIndex;
  64801. private _onFocusSelectAll;
  64802. private _isPointerDown;
  64803. private _onClipboardObserver;
  64804. private _onPointerDblTapObserver;
  64805. /** @hidden */
  64806. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64807. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64808. promptMessage: string;
  64809. /** Force disable prompt on mobile device */
  64810. disableMobilePrompt: boolean;
  64811. /** BABYLON.Observable raised when the text changes */
  64812. onTextChangedObservable: BABYLON.Observable<InputText>;
  64813. /** BABYLON.Observable raised just before an entered character is to be added */
  64814. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64815. /** BABYLON.Observable raised when the control gets the focus */
  64816. onFocusObservable: BABYLON.Observable<InputText>;
  64817. /** BABYLON.Observable raised when the control loses the focus */
  64818. onBlurObservable: BABYLON.Observable<InputText>;
  64819. /**Observable raised when the text is highlighted */
  64820. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64821. /**Observable raised when copy event is triggered */
  64822. onTextCopyObservable: BABYLON.Observable<InputText>;
  64823. /** BABYLON.Observable raised when cut event is triggered */
  64824. onTextCutObservable: BABYLON.Observable<InputText>;
  64825. /** BABYLON.Observable raised when paste event is triggered */
  64826. onTextPasteObservable: BABYLON.Observable<InputText>;
  64827. /** BABYLON.Observable raised when a key event was processed */
  64828. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64829. /** Gets or sets the maximum width allowed by the control */
  64830. maxWidth: string | number;
  64831. /** Gets the maximum width allowed by the control in pixels */
  64832. readonly maxWidthInPixels: number;
  64833. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64834. highligherOpacity: number;
  64835. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64836. onFocusSelectAll: boolean;
  64837. /** Gets or sets the text hightlight color */
  64838. textHighlightColor: string;
  64839. /** Gets or sets control margin */
  64840. margin: string;
  64841. /** Gets control margin in pixels */
  64842. readonly marginInPixels: number;
  64843. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64844. autoStretchWidth: boolean;
  64845. /** Gets or sets border thickness */
  64846. thickness: number;
  64847. /** Gets or sets the background color when focused */
  64848. focusedBackground: string;
  64849. /** Gets or sets the background color when focused */
  64850. focusedColor: string;
  64851. /** Gets or sets the background color */
  64852. background: string;
  64853. /** Gets or sets the placeholder color */
  64854. placeholderColor: string;
  64855. /** Gets or sets the text displayed when the control is empty */
  64856. placeholderText: string;
  64857. /** Gets or sets the dead key flag */
  64858. deadKey: boolean;
  64859. /** Gets or sets the highlight text */
  64860. highlightedText: string;
  64861. /** Gets or sets if the current key should be added */
  64862. addKey: boolean;
  64863. /** Gets or sets the value of the current key being entered */
  64864. currentKey: string;
  64865. /** Gets or sets the text displayed in the control */
  64866. text: string;
  64867. /** Gets or sets control width */
  64868. width: string | number;
  64869. /**
  64870. * Creates a new InputText
  64871. * @param name defines the control name
  64872. * @param text defines the text of the control
  64873. */
  64874. constructor(name?: string | undefined, text?: string);
  64875. /** @hidden */
  64876. onBlur(): void;
  64877. /** @hidden */
  64878. onFocus(): void;
  64879. protected _getTypeName(): string;
  64880. /**
  64881. * Function called to get the list of controls that should not steal the focus from this control
  64882. * @returns an array of controls
  64883. */
  64884. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64885. /** @hidden */
  64886. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64887. /** @hidden */
  64888. private _updateValueFromCursorIndex;
  64889. /** @hidden */
  64890. private _processDblClick;
  64891. /** @hidden */
  64892. private _selectAllText;
  64893. /**
  64894. * Handles the keyboard event
  64895. * @param evt Defines the KeyboardEvent
  64896. */
  64897. processKeyboard(evt: KeyboardEvent): void;
  64898. /** @hidden */
  64899. private _onCopyText;
  64900. /** @hidden */
  64901. private _onCutText;
  64902. /** @hidden */
  64903. private _onPasteText;
  64904. _draw(context: CanvasRenderingContext2D): void;
  64905. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64906. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64907. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64908. protected _beforeRenderText(text: string): string;
  64909. dispose(): void;
  64910. }
  64911. }
  64912. declare module BABYLON.GUI {
  64913. /**
  64914. * Class used to create a 2D grid container
  64915. */
  64916. export class Grid extends Container {
  64917. name?: string | undefined;
  64918. private _rowDefinitions;
  64919. private _columnDefinitions;
  64920. private _cells;
  64921. private _childControls;
  64922. /**
  64923. * Gets the number of columns
  64924. */
  64925. readonly columnCount: number;
  64926. /**
  64927. * Gets the number of rows
  64928. */
  64929. readonly rowCount: number;
  64930. /** Gets the list of children */
  64931. readonly children: Control[];
  64932. /** Gets the list of cells (e.g. the containers) */
  64933. readonly cells: {
  64934. [key: string]: Container;
  64935. };
  64936. /**
  64937. * Gets the definition of a specific row
  64938. * @param index defines the index of the row
  64939. * @returns the row definition
  64940. */
  64941. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64942. /**
  64943. * Gets the definition of a specific column
  64944. * @param index defines the index of the column
  64945. * @returns the column definition
  64946. */
  64947. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64948. /**
  64949. * Adds a new row to the grid
  64950. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64951. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64952. * @returns the current grid
  64953. */
  64954. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64955. /**
  64956. * Adds a new column to the grid
  64957. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64958. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64959. * @returns the current grid
  64960. */
  64961. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64962. /**
  64963. * Update a row definition
  64964. * @param index defines the index of the row to update
  64965. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64966. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64967. * @returns the current grid
  64968. */
  64969. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64970. /**
  64971. * Update a column definition
  64972. * @param index defines the index of the column to update
  64973. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64974. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64975. * @returns the current grid
  64976. */
  64977. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64978. /**
  64979. * Gets the list of children stored in a specific cell
  64980. * @param row defines the row to check
  64981. * @param column defines the column to check
  64982. * @returns the list of controls
  64983. */
  64984. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64985. /**
  64986. * Gets a string representing the child cell info (row x column)
  64987. * @param child defines the control to get info from
  64988. * @returns a string containing the child cell info (row x column)
  64989. */
  64990. getChildCellInfo(child: Control): string;
  64991. private _removeCell;
  64992. private _offsetCell;
  64993. /**
  64994. * Remove a column definition at specified index
  64995. * @param index defines the index of the column to remove
  64996. * @returns the current grid
  64997. */
  64998. removeColumnDefinition(index: number): Grid;
  64999. /**
  65000. * Remove a row definition at specified index
  65001. * @param index defines the index of the row to remove
  65002. * @returns the current grid
  65003. */
  65004. removeRowDefinition(index: number): Grid;
  65005. /**
  65006. * Adds a new control to the current grid
  65007. * @param control defines the control to add
  65008. * @param row defines the row where to add the control (0 by default)
  65009. * @param column defines the column where to add the control (0 by default)
  65010. * @returns the current grid
  65011. */
  65012. addControl(control: Control, row?: number, column?: number): Grid;
  65013. /**
  65014. * Removes a control from the current container
  65015. * @param control defines the control to remove
  65016. * @returns the current container
  65017. */
  65018. removeControl(control: Control): Container;
  65019. /**
  65020. * Creates a new Grid
  65021. * @param name defines control name
  65022. */
  65023. constructor(name?: string | undefined);
  65024. protected _getTypeName(): string;
  65025. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65026. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65027. _flagDescendantsAsMatrixDirty(): void;
  65028. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65029. /** Releases associated resources */
  65030. dispose(): void;
  65031. }
  65032. }
  65033. declare module BABYLON.GUI {
  65034. /** Class used to create color pickers */
  65035. export class ColorPicker extends Control {
  65036. name?: string | undefined;
  65037. private static _Epsilon;
  65038. private _colorWheelCanvas;
  65039. private _value;
  65040. private _tmpColor;
  65041. private _pointerStartedOnSquare;
  65042. private _pointerStartedOnWheel;
  65043. private _squareLeft;
  65044. private _squareTop;
  65045. private _squareSize;
  65046. private _h;
  65047. private _s;
  65048. private _v;
  65049. private _lastPointerDownID;
  65050. /**
  65051. * BABYLON.Observable raised when the value changes
  65052. */
  65053. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65054. /** Gets or sets the color of the color picker */
  65055. value: BABYLON.Color3;
  65056. /**
  65057. * Gets or sets control width
  65058. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65059. */
  65060. width: string | number;
  65061. /**
  65062. * Gets or sets control height
  65063. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65064. */
  65065. /** Gets or sets control height */
  65066. height: string | number;
  65067. /** Gets or sets control size */
  65068. size: string | number;
  65069. /**
  65070. * Creates a new ColorPicker
  65071. * @param name defines the control name
  65072. */
  65073. constructor(name?: string | undefined);
  65074. protected _getTypeName(): string;
  65075. /** @hidden */
  65076. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65077. private _updateSquareProps;
  65078. private _drawGradientSquare;
  65079. private _drawCircle;
  65080. private _createColorWheelCanvas;
  65081. /** @hidden */
  65082. _draw(context: CanvasRenderingContext2D): void;
  65083. private _pointerIsDown;
  65084. private _updateValueFromPointer;
  65085. private _isPointOnSquare;
  65086. private _isPointOnWheel;
  65087. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65088. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65089. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65090. /**
  65091. * This function expands the color picker by creating a color picker dialog with manual
  65092. * color value input and the ability to save colors into an array to be used later in
  65093. * subsequent launches of the dialogue.
  65094. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65095. * @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.
  65096. * @returns picked color as a hex string and the saved colors array as hex strings.
  65097. */
  65098. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65099. pickerWidth?: string;
  65100. pickerHeight?: string;
  65101. headerHeight?: string;
  65102. lastColor?: string;
  65103. swatchLimit?: number;
  65104. numSwatchesPerLine?: number;
  65105. savedColors?: Array<string>;
  65106. }): Promise<{
  65107. savedColors?: string[];
  65108. pickedColor: string;
  65109. }>;
  65110. }
  65111. }
  65112. declare module BABYLON.GUI {
  65113. /** Class used to create 2D ellipse containers */
  65114. export class Ellipse extends Container {
  65115. name?: string | undefined;
  65116. private _thickness;
  65117. /** Gets or sets border thickness */
  65118. thickness: number;
  65119. /**
  65120. * Creates a new Ellipse
  65121. * @param name defines the control name
  65122. */
  65123. constructor(name?: string | undefined);
  65124. protected _getTypeName(): string;
  65125. protected _localDraw(context: CanvasRenderingContext2D): void;
  65126. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65127. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65128. }
  65129. }
  65130. declare module BABYLON.GUI {
  65131. /**
  65132. * Class used to create a password control
  65133. */
  65134. export class InputPassword extends InputText {
  65135. protected _beforeRenderText(text: string): string;
  65136. }
  65137. }
  65138. declare module BABYLON.GUI {
  65139. /** Class used to render 2D lines */
  65140. export class Line extends Control {
  65141. name?: string | undefined;
  65142. private _lineWidth;
  65143. private _x1;
  65144. private _y1;
  65145. private _x2;
  65146. private _y2;
  65147. private _dash;
  65148. private _connectedControl;
  65149. private _connectedControlDirtyObserver;
  65150. /** Gets or sets the dash pattern */
  65151. dash: Array<number>;
  65152. /** Gets or sets the control connected with the line end */
  65153. connectedControl: Control;
  65154. /** Gets or sets start coordinates on X axis */
  65155. x1: string | number;
  65156. /** Gets or sets start coordinates on Y axis */
  65157. y1: string | number;
  65158. /** Gets or sets end coordinates on X axis */
  65159. x2: string | number;
  65160. /** Gets or sets end coordinates on Y axis */
  65161. y2: string | number;
  65162. /** Gets or sets line width */
  65163. lineWidth: number;
  65164. /** Gets or sets horizontal alignment */
  65165. horizontalAlignment: number;
  65166. /** Gets or sets vertical alignment */
  65167. verticalAlignment: number;
  65168. private readonly _effectiveX2;
  65169. private readonly _effectiveY2;
  65170. /**
  65171. * Creates a new Line
  65172. * @param name defines the control name
  65173. */
  65174. constructor(name?: string | undefined);
  65175. protected _getTypeName(): string;
  65176. _draw(context: CanvasRenderingContext2D): void;
  65177. _measure(): void;
  65178. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65179. /**
  65180. * Move one end of the line given 3D cartesian coordinates.
  65181. * @param position Targeted world position
  65182. * @param scene BABYLON.Scene
  65183. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65184. */
  65185. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65186. /**
  65187. * Move one end of the line to a position in screen absolute space.
  65188. * @param projectedPosition Position in screen absolute space (X, Y)
  65189. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65190. */
  65191. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65192. }
  65193. }
  65194. declare module BABYLON.GUI {
  65195. /**
  65196. * Class used to store a point for a MultiLine object.
  65197. * The point can be pure 2D coordinates, a mesh or a control
  65198. */
  65199. export class MultiLinePoint {
  65200. private _multiLine;
  65201. private _x;
  65202. private _y;
  65203. private _control;
  65204. private _mesh;
  65205. private _controlObserver;
  65206. private _meshObserver;
  65207. /** @hidden */
  65208. _point: BABYLON.Vector2;
  65209. /**
  65210. * Creates a new MultiLinePoint
  65211. * @param multiLine defines the source MultiLine object
  65212. */
  65213. constructor(multiLine: MultiLine);
  65214. /** Gets or sets x coordinate */
  65215. x: string | number;
  65216. /** Gets or sets y coordinate */
  65217. y: string | number;
  65218. /** Gets or sets the control associated with this point */
  65219. control: BABYLON.Nullable<Control>;
  65220. /** Gets or sets the mesh associated with this point */
  65221. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65222. /** Resets links */
  65223. resetLinks(): void;
  65224. /**
  65225. * Gets a translation vector
  65226. * @returns the translation vector
  65227. */
  65228. translate(): BABYLON.Vector2;
  65229. private _translatePoint;
  65230. /** Release associated resources */
  65231. dispose(): void;
  65232. }
  65233. }
  65234. declare module BABYLON.GUI {
  65235. /**
  65236. * Class used to create multi line control
  65237. */
  65238. export class MultiLine extends Control {
  65239. name?: string | undefined;
  65240. private _lineWidth;
  65241. private _dash;
  65242. private _points;
  65243. private _minX;
  65244. private _minY;
  65245. private _maxX;
  65246. private _maxY;
  65247. /**
  65248. * Creates a new MultiLine
  65249. * @param name defines the control name
  65250. */
  65251. constructor(name?: string | undefined);
  65252. /** Gets or sets dash pattern */
  65253. dash: Array<number>;
  65254. /**
  65255. * Gets point stored at specified index
  65256. * @param index defines the index to look for
  65257. * @returns the requested point if found
  65258. */
  65259. getAt(index: number): MultiLinePoint;
  65260. /** Function called when a point is updated */
  65261. onPointUpdate: () => void;
  65262. /**
  65263. * Adds new points to the point collection
  65264. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65265. * @returns the list of created MultiLinePoint
  65266. */
  65267. add(...items: (AbstractMesh | Control | {
  65268. x: string | number;
  65269. y: string | number;
  65270. })[]): MultiLinePoint[];
  65271. /**
  65272. * Adds a new point to the point collection
  65273. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65274. * @returns the created MultiLinePoint
  65275. */
  65276. push(item?: (AbstractMesh | Control | {
  65277. x: string | number;
  65278. y: string | number;
  65279. })): MultiLinePoint;
  65280. /**
  65281. * Remove a specific value or point from the active point collection
  65282. * @param value defines the value or point to remove
  65283. */
  65284. remove(value: number | MultiLinePoint): void;
  65285. /**
  65286. * Resets this object to initial state (no point)
  65287. */
  65288. reset(): void;
  65289. /**
  65290. * Resets all links
  65291. */
  65292. resetLinks(): void;
  65293. /** Gets or sets line width */
  65294. lineWidth: number;
  65295. horizontalAlignment: number;
  65296. verticalAlignment: number;
  65297. protected _getTypeName(): string;
  65298. _draw(context: CanvasRenderingContext2D): void;
  65299. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65300. _measure(): void;
  65301. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65302. dispose(): void;
  65303. }
  65304. }
  65305. declare module BABYLON.GUI {
  65306. /**
  65307. * Class used to create radio button controls
  65308. */
  65309. export class RadioButton extends Control {
  65310. name?: string | undefined;
  65311. private _isChecked;
  65312. private _background;
  65313. private _checkSizeRatio;
  65314. private _thickness;
  65315. /** Gets or sets border thickness */
  65316. thickness: number;
  65317. /** Gets or sets group name */
  65318. group: string;
  65319. /** BABYLON.Observable raised when isChecked is changed */
  65320. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65321. /** Gets or sets a value indicating the ratio between overall size and check size */
  65322. checkSizeRatio: number;
  65323. /** Gets or sets background color */
  65324. background: string;
  65325. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65326. isChecked: boolean;
  65327. /**
  65328. * Creates a new RadioButton
  65329. * @param name defines the control name
  65330. */
  65331. constructor(name?: string | undefined);
  65332. protected _getTypeName(): string;
  65333. _draw(context: CanvasRenderingContext2D): void;
  65334. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65335. /**
  65336. * Utility function to easily create a radio button with a header
  65337. * @param title defines the label to use for the header
  65338. * @param group defines the group to use for the radio button
  65339. * @param isChecked defines the initial state of the radio button
  65340. * @param onValueChanged defines the callback to call when value changes
  65341. * @returns a StackPanel containing the radio button and a textBlock
  65342. */
  65343. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65344. }
  65345. }
  65346. declare module BABYLON.GUI {
  65347. /**
  65348. * Class used to create slider controls
  65349. */
  65350. export class BaseSlider extends Control {
  65351. name?: string | undefined;
  65352. protected _thumbWidth: ValueAndUnit;
  65353. private _minimum;
  65354. private _maximum;
  65355. private _value;
  65356. private _isVertical;
  65357. protected _barOffset: ValueAndUnit;
  65358. private _isThumbClamped;
  65359. protected _displayThumb: boolean;
  65360. private _step;
  65361. private _lastPointerDownID;
  65362. protected _effectiveBarOffset: number;
  65363. protected _renderLeft: number;
  65364. protected _renderTop: number;
  65365. protected _renderWidth: number;
  65366. protected _renderHeight: number;
  65367. protected _backgroundBoxLength: number;
  65368. protected _backgroundBoxThickness: number;
  65369. protected _effectiveThumbThickness: number;
  65370. /** BABYLON.Observable raised when the sldier value changes */
  65371. onValueChangedObservable: BABYLON.Observable<number>;
  65372. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65373. displayThumb: boolean;
  65374. /** Gets or sets a step to apply to values (0 by default) */
  65375. step: number;
  65376. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65377. barOffset: string | number;
  65378. /** Gets main bar offset in pixels*/
  65379. readonly barOffsetInPixels: number;
  65380. /** Gets or sets thumb width */
  65381. thumbWidth: string | number;
  65382. /** Gets thumb width in pixels */
  65383. readonly thumbWidthInPixels: number;
  65384. /** Gets or sets minimum value */
  65385. minimum: number;
  65386. /** Gets or sets maximum value */
  65387. maximum: number;
  65388. /** Gets or sets current value */
  65389. value: number;
  65390. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65391. isVertical: boolean;
  65392. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65393. isThumbClamped: boolean;
  65394. /**
  65395. * Creates a new BaseSlider
  65396. * @param name defines the control name
  65397. */
  65398. constructor(name?: string | undefined);
  65399. protected _getTypeName(): string;
  65400. protected _getThumbPosition(): number;
  65401. protected _getThumbThickness(type: string): number;
  65402. protected _prepareRenderingData(type: string): void;
  65403. private _pointerIsDown;
  65404. /** @hidden */
  65405. protected _updateValueFromPointer(x: number, y: number): void;
  65406. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65407. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65408. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65409. }
  65410. }
  65411. declare module BABYLON.GUI {
  65412. /**
  65413. * Class used to create slider controls
  65414. */
  65415. export class Slider extends BaseSlider {
  65416. name?: string | undefined;
  65417. private _background;
  65418. private _borderColor;
  65419. private _isThumbCircle;
  65420. protected _displayValueBar: boolean;
  65421. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65422. displayValueBar: boolean;
  65423. /** Gets or sets border color */
  65424. borderColor: string;
  65425. /** Gets or sets background color */
  65426. background: string;
  65427. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65428. isThumbCircle: boolean;
  65429. /**
  65430. * Creates a new Slider
  65431. * @param name defines the control name
  65432. */
  65433. constructor(name?: string | undefined);
  65434. protected _getTypeName(): string;
  65435. _draw(context: CanvasRenderingContext2D): void;
  65436. }
  65437. }
  65438. declare module BABYLON.GUI {
  65439. /** Class used to create a RadioGroup
  65440. * which contains groups of radio buttons
  65441. */
  65442. export class SelectorGroup {
  65443. /** name of SelectorGroup */
  65444. name: string;
  65445. private _groupPanel;
  65446. private _selectors;
  65447. private _groupHeader;
  65448. /**
  65449. * Creates a new SelectorGroup
  65450. * @param name of group, used as a group heading
  65451. */
  65452. constructor(
  65453. /** name of SelectorGroup */
  65454. name: string);
  65455. /** Gets the groupPanel of the SelectorGroup */
  65456. readonly groupPanel: StackPanel;
  65457. /** Gets the selectors array */
  65458. readonly selectors: StackPanel[];
  65459. /** Gets and sets the group header */
  65460. header: string;
  65461. /** @hidden */
  65462. private _addGroupHeader;
  65463. /** @hidden*/
  65464. _getSelector(selectorNb: number): StackPanel | undefined;
  65465. /** Removes the selector at the given position
  65466. * @param selectorNb the position of the selector within the group
  65467. */
  65468. removeSelector(selectorNb: number): void;
  65469. }
  65470. /** Class used to create a CheckboxGroup
  65471. * which contains groups of checkbox buttons
  65472. */
  65473. export class CheckboxGroup extends SelectorGroup {
  65474. /** Adds a checkbox as a control
  65475. * @param text is the label for the selector
  65476. * @param func is the function called when the Selector is checked
  65477. * @param checked is true when Selector is checked
  65478. */
  65479. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65480. /** @hidden */
  65481. _setSelectorLabel(selectorNb: number, label: string): void;
  65482. /** @hidden */
  65483. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65484. /** @hidden */
  65485. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65486. /** @hidden */
  65487. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65488. }
  65489. /** Class used to create a RadioGroup
  65490. * which contains groups of radio buttons
  65491. */
  65492. export class RadioGroup extends SelectorGroup {
  65493. private _selectNb;
  65494. /** Adds a radio button as a control
  65495. * @param label is the label for the selector
  65496. * @param func is the function called when the Selector is checked
  65497. * @param checked is true when Selector is checked
  65498. */
  65499. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65500. /** @hidden */
  65501. _setSelectorLabel(selectorNb: number, label: string): void;
  65502. /** @hidden */
  65503. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65504. /** @hidden */
  65505. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65506. /** @hidden */
  65507. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65508. }
  65509. /** Class used to create a SliderGroup
  65510. * which contains groups of slider buttons
  65511. */
  65512. export class SliderGroup extends SelectorGroup {
  65513. /**
  65514. * Adds a slider to the SelectorGroup
  65515. * @param label is the label for the SliderBar
  65516. * @param func is the function called when the Slider moves
  65517. * @param unit is a string describing the units used, eg degrees or metres
  65518. * @param min is the minimum value for the Slider
  65519. * @param max is the maximum value for the Slider
  65520. * @param value is the start value for the Slider between min and max
  65521. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65522. */
  65523. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65524. /** @hidden */
  65525. _setSelectorLabel(selectorNb: number, label: string): void;
  65526. /** @hidden */
  65527. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65528. /** @hidden */
  65529. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65530. /** @hidden */
  65531. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65532. }
  65533. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65534. * @see http://doc.babylonjs.com/how_to/selector
  65535. */
  65536. export class SelectionPanel extends Rectangle {
  65537. /** name of SelectionPanel */
  65538. name: string;
  65539. /** an array of SelectionGroups */
  65540. groups: SelectorGroup[];
  65541. private _panel;
  65542. private _buttonColor;
  65543. private _buttonBackground;
  65544. private _headerColor;
  65545. private _barColor;
  65546. private _barHeight;
  65547. private _spacerHeight;
  65548. private _labelColor;
  65549. private _groups;
  65550. private _bars;
  65551. /**
  65552. * Creates a new SelectionPanel
  65553. * @param name of SelectionPanel
  65554. * @param groups is an array of SelectionGroups
  65555. */
  65556. constructor(
  65557. /** name of SelectionPanel */
  65558. name: string,
  65559. /** an array of SelectionGroups */
  65560. groups?: SelectorGroup[]);
  65561. protected _getTypeName(): string;
  65562. /** Gets or sets the headerColor */
  65563. headerColor: string;
  65564. private _setHeaderColor;
  65565. /** Gets or sets the button color */
  65566. buttonColor: string;
  65567. private _setbuttonColor;
  65568. /** Gets or sets the label color */
  65569. labelColor: string;
  65570. private _setLabelColor;
  65571. /** Gets or sets the button background */
  65572. buttonBackground: string;
  65573. private _setButtonBackground;
  65574. /** Gets or sets the color of separator bar */
  65575. barColor: string;
  65576. private _setBarColor;
  65577. /** Gets or sets the height of separator bar */
  65578. barHeight: string;
  65579. private _setBarHeight;
  65580. /** Gets or sets the height of spacers*/
  65581. spacerHeight: string;
  65582. private _setSpacerHeight;
  65583. /** Adds a bar between groups */
  65584. private _addSpacer;
  65585. /** Add a group to the selection panel
  65586. * @param group is the selector group to add
  65587. */
  65588. addGroup(group: SelectorGroup): void;
  65589. /** Remove the group from the given position
  65590. * @param groupNb is the position of the group in the list
  65591. */
  65592. removeGroup(groupNb: number): void;
  65593. /** Change a group header label
  65594. * @param label is the new group header label
  65595. * @param groupNb is the number of the group to relabel
  65596. * */
  65597. setHeaderName(label: string, groupNb: number): void;
  65598. /** Change selector label to the one given
  65599. * @param label is the new selector label
  65600. * @param groupNb is the number of the groupcontaining the selector
  65601. * @param selectorNb is the number of the selector within a group to relabel
  65602. * */
  65603. relabel(label: string, groupNb: number, selectorNb: number): void;
  65604. /** For a given group position remove the selector at the given position
  65605. * @param groupNb is the number of the group to remove the selector from
  65606. * @param selectorNb is the number of the selector within the group
  65607. */
  65608. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65609. /** For a given group position of correct type add a checkbox button
  65610. * @param groupNb is the number of the group to remove the selector from
  65611. * @param label is the label for the selector
  65612. * @param func is the function called when the Selector is checked
  65613. * @param checked is true when Selector is checked
  65614. */
  65615. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65616. /** For a given group position of correct type add a radio button
  65617. * @param groupNb is the number of the group to remove the selector from
  65618. * @param label is the label for the selector
  65619. * @param func is the function called when the Selector is checked
  65620. * @param checked is true when Selector is checked
  65621. */
  65622. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65623. /**
  65624. * For a given slider group add a slider
  65625. * @param groupNb is the number of the group to add the slider to
  65626. * @param label is the label for the Slider
  65627. * @param func is the function called when the Slider moves
  65628. * @param unit is a string describing the units used, eg degrees or metres
  65629. * @param min is the minimum value for the Slider
  65630. * @param max is the maximum value for the Slider
  65631. * @param value is the start value for the Slider between min and max
  65632. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65633. */
  65634. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65635. }
  65636. }
  65637. declare module BABYLON.GUI {
  65638. /**
  65639. * Class used to hold a the container for ScrollViewer
  65640. * @hidden
  65641. */
  65642. export class _ScrollViewerWindow extends Container {
  65643. parentClientWidth: number;
  65644. parentClientHeight: number;
  65645. /**
  65646. * Creates a new ScrollViewerWindow
  65647. * @param name of ScrollViewerWindow
  65648. */
  65649. constructor(name?: string);
  65650. protected _getTypeName(): string;
  65651. /** @hidden */
  65652. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65653. protected _postMeasure(): void;
  65654. }
  65655. }
  65656. declare module BABYLON.GUI {
  65657. /**
  65658. * Class used to create slider controls
  65659. */
  65660. export class ScrollBar extends BaseSlider {
  65661. name?: string | undefined;
  65662. private _background;
  65663. private _borderColor;
  65664. private _thumbMeasure;
  65665. /** Gets or sets border color */
  65666. borderColor: string;
  65667. /** Gets or sets background color */
  65668. background: string;
  65669. /**
  65670. * Creates a new Slider
  65671. * @param name defines the control name
  65672. */
  65673. constructor(name?: string | undefined);
  65674. protected _getTypeName(): string;
  65675. protected _getThumbThickness(): number;
  65676. _draw(context: CanvasRenderingContext2D): void;
  65677. private _first;
  65678. private _originX;
  65679. private _originY;
  65680. /** @hidden */
  65681. protected _updateValueFromPointer(x: number, y: number): void;
  65682. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65683. }
  65684. }
  65685. declare module BABYLON.GUI {
  65686. /**
  65687. * Class used to hold a viewer window and sliders in a grid
  65688. */
  65689. export class ScrollViewer extends Rectangle {
  65690. private _grid;
  65691. private _horizontalBarSpace;
  65692. private _verticalBarSpace;
  65693. private _dragSpace;
  65694. private _horizontalBar;
  65695. private _verticalBar;
  65696. private _barColor;
  65697. private _barBackground;
  65698. private _barSize;
  65699. private _endLeft;
  65700. private _endTop;
  65701. private _window;
  65702. private _pointerIsOver;
  65703. private _wheelPrecision;
  65704. private _onPointerObserver;
  65705. private _clientWidth;
  65706. private _clientHeight;
  65707. /**
  65708. * Gets the horizontal scrollbar
  65709. */
  65710. readonly horizontalBar: ScrollBar;
  65711. /**
  65712. * Gets the vertical scrollbar
  65713. */
  65714. readonly verticalBar: ScrollBar;
  65715. /**
  65716. * Adds a new control to the current container
  65717. * @param control defines the control to add
  65718. * @returns the current container
  65719. */
  65720. addControl(control: BABYLON.Nullable<Control>): Container;
  65721. /**
  65722. * Removes a control from the current container
  65723. * @param control defines the control to remove
  65724. * @returns the current container
  65725. */
  65726. removeControl(control: Control): Container;
  65727. /** Gets the list of children */
  65728. readonly children: Control[];
  65729. _flagDescendantsAsMatrixDirty(): void;
  65730. /**
  65731. * Creates a new ScrollViewer
  65732. * @param name of ScrollViewer
  65733. */
  65734. constructor(name?: string);
  65735. /** Reset the scroll viewer window to initial size */
  65736. resetWindow(): void;
  65737. protected _getTypeName(): string;
  65738. private _buildClientSizes;
  65739. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65740. protected _postMeasure(): void;
  65741. /**
  65742. * Gets or sets the mouse wheel precision
  65743. * from 0 to 1 with a default value of 0.05
  65744. * */
  65745. wheelPrecision: number;
  65746. /** Gets or sets the bar color */
  65747. barColor: string;
  65748. /** Gets or sets the size of the bar */
  65749. barSize: number;
  65750. /** Gets or sets the bar background */
  65751. barBackground: string;
  65752. /** @hidden */
  65753. private _updateScroller;
  65754. _link(host: AdvancedDynamicTexture): void;
  65755. /** @hidden */
  65756. private _attachWheel;
  65757. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65758. /** Releases associated resources */
  65759. dispose(): void;
  65760. }
  65761. }
  65762. declare module BABYLON.GUI {
  65763. /** Class used to render a grid */
  65764. export class DisplayGrid extends Control {
  65765. name?: string | undefined;
  65766. private _cellWidth;
  65767. private _cellHeight;
  65768. private _minorLineTickness;
  65769. private _minorLineColor;
  65770. private _majorLineTickness;
  65771. private _majorLineColor;
  65772. private _majorLineFrequency;
  65773. private _background;
  65774. private _displayMajorLines;
  65775. private _displayMinorLines;
  65776. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65777. displayMinorLines: boolean;
  65778. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65779. displayMajorLines: boolean;
  65780. /** Gets or sets background color (Black by default) */
  65781. background: string;
  65782. /** Gets or sets the width of each cell (20 by default) */
  65783. cellWidth: number;
  65784. /** Gets or sets the height of each cell (20 by default) */
  65785. cellHeight: number;
  65786. /** Gets or sets the tickness of minor lines (1 by default) */
  65787. minorLineTickness: number;
  65788. /** Gets or sets the color of minor lines (DarkGray by default) */
  65789. minorLineColor: string;
  65790. /** Gets or sets the tickness of major lines (2 by default) */
  65791. majorLineTickness: number;
  65792. /** Gets or sets the color of major lines (White by default) */
  65793. majorLineColor: string;
  65794. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65795. majorLineFrequency: number;
  65796. /**
  65797. * Creates a new GridDisplayRectangle
  65798. * @param name defines the control name
  65799. */
  65800. constructor(name?: string | undefined);
  65801. _draw(context: CanvasRenderingContext2D): void;
  65802. protected _getTypeName(): string;
  65803. }
  65804. }
  65805. declare module BABYLON.GUI {
  65806. /**
  65807. * Class used to create slider controls based on images
  65808. */
  65809. export class ImageBasedSlider extends BaseSlider {
  65810. name?: string | undefined;
  65811. private _backgroundImage;
  65812. private _thumbImage;
  65813. private _valueBarImage;
  65814. private _tempMeasure;
  65815. displayThumb: boolean;
  65816. /**
  65817. * Gets or sets the image used to render the background
  65818. */
  65819. backgroundImage: Image;
  65820. /**
  65821. * Gets or sets the image used to render the value bar
  65822. */
  65823. valueBarImage: Image;
  65824. /**
  65825. * Gets or sets the image used to render the thumb
  65826. */
  65827. thumbImage: Image;
  65828. /**
  65829. * Creates a new ImageBasedSlider
  65830. * @param name defines the control name
  65831. */
  65832. constructor(name?: string | undefined);
  65833. protected _getTypeName(): string;
  65834. _draw(context: CanvasRenderingContext2D): void;
  65835. }
  65836. }
  65837. declare module BABYLON.GUI {
  65838. /**
  65839. * Forcing an export so that this code will execute
  65840. * @hidden
  65841. */
  65842. const name = "Statics";
  65843. }
  65844. declare module BABYLON.GUI {
  65845. /**
  65846. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65847. */
  65848. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65849. /**
  65850. * Define the instrumented AdvancedDynamicTexture.
  65851. */
  65852. texture: AdvancedDynamicTexture;
  65853. private _captureRenderTime;
  65854. private _renderTime;
  65855. private _captureLayoutTime;
  65856. private _layoutTime;
  65857. private _onBeginRenderObserver;
  65858. private _onEndRenderObserver;
  65859. private _onBeginLayoutObserver;
  65860. private _onEndLayoutObserver;
  65861. /**
  65862. * Gets the perf counter used to capture render time
  65863. */
  65864. readonly renderTimeCounter: BABYLON.PerfCounter;
  65865. /**
  65866. * Gets the perf counter used to capture layout time
  65867. */
  65868. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65869. /**
  65870. * Enable or disable the render time capture
  65871. */
  65872. captureRenderTime: boolean;
  65873. /**
  65874. * Enable or disable the layout time capture
  65875. */
  65876. captureLayoutTime: boolean;
  65877. /**
  65878. * Instantiates a new advanced dynamic texture instrumentation.
  65879. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65880. * @param texture Defines the AdvancedDynamicTexture to instrument
  65881. */
  65882. constructor(
  65883. /**
  65884. * Define the instrumented AdvancedDynamicTexture.
  65885. */
  65886. texture: AdvancedDynamicTexture);
  65887. /**
  65888. * Dispose and release associated resources.
  65889. */
  65890. dispose(): void;
  65891. }
  65892. }
  65893. declare module BABYLON.GUI {
  65894. /**
  65895. * Class used to create containers for controls
  65896. */
  65897. export class Container3D extends Control3D {
  65898. private _blockLayout;
  65899. /**
  65900. * Gets the list of child controls
  65901. */
  65902. protected _children: Control3D[];
  65903. /**
  65904. * Gets the list of child controls
  65905. */
  65906. readonly children: Array<Control3D>;
  65907. /**
  65908. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65909. * This is helpful to optimize layout operation when adding multiple children in a row
  65910. */
  65911. blockLayout: boolean;
  65912. /**
  65913. * Creates a new container
  65914. * @param name defines the container name
  65915. */
  65916. constructor(name?: string);
  65917. /**
  65918. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65919. * @returns the current container
  65920. */
  65921. updateLayout(): Container3D;
  65922. /**
  65923. * Gets a boolean indicating if the given control is in the children of this control
  65924. * @param control defines the control to check
  65925. * @returns true if the control is in the child list
  65926. */
  65927. containsControl(control: Control3D): boolean;
  65928. /**
  65929. * Adds a control to the children of this control
  65930. * @param control defines the control to add
  65931. * @returns the current container
  65932. */
  65933. addControl(control: Control3D): Container3D;
  65934. /**
  65935. * This function will be called everytime a new control is added
  65936. */
  65937. protected _arrangeChildren(): void;
  65938. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65939. /**
  65940. * Removes a control from the children of this control
  65941. * @param control defines the control to remove
  65942. * @returns the current container
  65943. */
  65944. removeControl(control: Control3D): Container3D;
  65945. protected _getTypeName(): string;
  65946. /**
  65947. * Releases all associated resources
  65948. */
  65949. dispose(): void;
  65950. /** Control rotation will remain unchanged */
  65951. static readonly UNSET_ORIENTATION: number;
  65952. /** Control will rotate to make it look at sphere central axis */
  65953. static readonly FACEORIGIN_ORIENTATION: number;
  65954. /** Control will rotate to make it look back at sphere central axis */
  65955. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65956. /** Control will rotate to look at z axis (0, 0, 1) */
  65957. static readonly FACEFORWARD_ORIENTATION: number;
  65958. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65959. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65960. }
  65961. }
  65962. declare module BABYLON.GUI {
  65963. /**
  65964. * Class used to manage 3D user interface
  65965. * @see http://doc.babylonjs.com/how_to/gui3d
  65966. */
  65967. export class GUI3DManager implements BABYLON.IDisposable {
  65968. private _scene;
  65969. private _sceneDisposeObserver;
  65970. private _utilityLayer;
  65971. private _rootContainer;
  65972. private _pointerObserver;
  65973. private _pointerOutObserver;
  65974. /** @hidden */
  65975. _lastPickedControl: Control3D;
  65976. /** @hidden */
  65977. _lastControlOver: {
  65978. [pointerId: number]: Control3D;
  65979. };
  65980. /** @hidden */
  65981. _lastControlDown: {
  65982. [pointerId: number]: Control3D;
  65983. };
  65984. /**
  65985. * BABYLON.Observable raised when the point picked by the pointer events changed
  65986. */
  65987. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65988. /** @hidden */
  65989. _sharedMaterials: {
  65990. [key: string]: BABYLON.Material;
  65991. };
  65992. /** Gets the hosting scene */
  65993. readonly scene: BABYLON.Scene;
  65994. /** Gets associated utility layer */
  65995. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65996. /**
  65997. * Creates a new GUI3DManager
  65998. * @param scene
  65999. */
  66000. constructor(scene?: BABYLON.Scene);
  66001. private _handlePointerOut;
  66002. private _doPicking;
  66003. /**
  66004. * Gets the root container
  66005. */
  66006. readonly rootContainer: Container3D;
  66007. /**
  66008. * Gets a boolean indicating if the given control is in the root child list
  66009. * @param control defines the control to check
  66010. * @returns true if the control is in the root child list
  66011. */
  66012. containsControl(control: Control3D): boolean;
  66013. /**
  66014. * Adds a control to the root child list
  66015. * @param control defines the control to add
  66016. * @returns the current manager
  66017. */
  66018. addControl(control: Control3D): GUI3DManager;
  66019. /**
  66020. * Removes a control from the root child list
  66021. * @param control defines the control to remove
  66022. * @returns the current container
  66023. */
  66024. removeControl(control: Control3D): GUI3DManager;
  66025. /**
  66026. * Releases all associated resources
  66027. */
  66028. dispose(): void;
  66029. }
  66030. }
  66031. declare module BABYLON.GUI {
  66032. /**
  66033. * Class used to transport BABYLON.Vector3 information for pointer events
  66034. */
  66035. export class Vector3WithInfo extends BABYLON.Vector3 {
  66036. /** defines the current mouse button index */
  66037. buttonIndex: number;
  66038. /**
  66039. * Creates a new Vector3WithInfo
  66040. * @param source defines the vector3 data to transport
  66041. * @param buttonIndex defines the current mouse button index
  66042. */
  66043. constructor(source: BABYLON.Vector3,
  66044. /** defines the current mouse button index */
  66045. buttonIndex?: number);
  66046. }
  66047. }
  66048. declare module BABYLON.GUI {
  66049. /**
  66050. * Class used as base class for controls
  66051. */
  66052. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66053. /** Defines the control name */
  66054. name?: string | undefined;
  66055. /** @hidden */
  66056. _host: GUI3DManager;
  66057. private _node;
  66058. private _downCount;
  66059. private _enterCount;
  66060. private _downPointerIds;
  66061. private _isVisible;
  66062. /** Gets or sets the control position in world space */
  66063. position: BABYLON.Vector3;
  66064. /** Gets or sets the control scaling in world space */
  66065. scaling: BABYLON.Vector3;
  66066. /** Callback used to start pointer enter animation */
  66067. pointerEnterAnimation: () => void;
  66068. /** Callback used to start pointer out animation */
  66069. pointerOutAnimation: () => void;
  66070. /** Callback used to start pointer down animation */
  66071. pointerDownAnimation: () => void;
  66072. /** Callback used to start pointer up animation */
  66073. pointerUpAnimation: () => void;
  66074. /**
  66075. * An event triggered when the pointer move over the control
  66076. */
  66077. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66078. /**
  66079. * An event triggered when the pointer move out of the control
  66080. */
  66081. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66082. /**
  66083. * An event triggered when the pointer taps the control
  66084. */
  66085. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66086. /**
  66087. * An event triggered when pointer is up
  66088. */
  66089. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66090. /**
  66091. * An event triggered when a control is clicked on (with a mouse)
  66092. */
  66093. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66094. /**
  66095. * An event triggered when pointer enters the control
  66096. */
  66097. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66098. /**
  66099. * Gets or sets the parent container
  66100. */
  66101. parent: BABYLON.Nullable<Container3D>;
  66102. private _behaviors;
  66103. /**
  66104. * Gets the list of attached behaviors
  66105. * @see http://doc.babylonjs.com/features/behaviour
  66106. */
  66107. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66108. /**
  66109. * Attach a behavior to the control
  66110. * @see http://doc.babylonjs.com/features/behaviour
  66111. * @param behavior defines the behavior to attach
  66112. * @returns the current control
  66113. */
  66114. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66115. /**
  66116. * Remove an attached behavior
  66117. * @see http://doc.babylonjs.com/features/behaviour
  66118. * @param behavior defines the behavior to attach
  66119. * @returns the current control
  66120. */
  66121. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66122. /**
  66123. * Gets an attached behavior by name
  66124. * @param name defines the name of the behavior to look for
  66125. * @see http://doc.babylonjs.com/features/behaviour
  66126. * @returns null if behavior was not found else the requested behavior
  66127. */
  66128. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66129. /** Gets or sets a boolean indicating if the control is visible */
  66130. isVisible: boolean;
  66131. /**
  66132. * Creates a new control
  66133. * @param name defines the control name
  66134. */
  66135. constructor(
  66136. /** Defines the control name */
  66137. name?: string | undefined);
  66138. /**
  66139. * Gets a string representing the class name
  66140. */
  66141. readonly typeName: string;
  66142. /**
  66143. * Get the current class name of the control.
  66144. * @returns current class name
  66145. */
  66146. getClassName(): string;
  66147. protected _getTypeName(): string;
  66148. /**
  66149. * Gets the transform node used by this control
  66150. */
  66151. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66152. /**
  66153. * Gets the mesh used to render this control
  66154. */
  66155. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66156. /**
  66157. * Link the control as child of the given node
  66158. * @param node defines the node to link to. Use null to unlink the control
  66159. * @returns the current control
  66160. */
  66161. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66162. /** @hidden **/
  66163. _prepareNode(scene: BABYLON.Scene): void;
  66164. /**
  66165. * Node creation.
  66166. * Can be overriden by children
  66167. * @param scene defines the scene where the node must be attached
  66168. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66169. */
  66170. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66171. /**
  66172. * Affect a material to the given mesh
  66173. * @param mesh defines the mesh which will represent the control
  66174. */
  66175. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66176. /** @hidden */
  66177. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66178. /** @hidden */
  66179. _onPointerEnter(target: Control3D): boolean;
  66180. /** @hidden */
  66181. _onPointerOut(target: Control3D): void;
  66182. /** @hidden */
  66183. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66184. /** @hidden */
  66185. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66186. /** @hidden */
  66187. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66188. /** @hidden */
  66189. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66190. /** @hidden */
  66191. _disposeNode(): void;
  66192. /**
  66193. * Releases all associated resources
  66194. */
  66195. dispose(): void;
  66196. }
  66197. }
  66198. declare module BABYLON.GUI {
  66199. /**
  66200. * Class used as a root to all buttons
  66201. */
  66202. export class AbstractButton3D extends Control3D {
  66203. /**
  66204. * Creates a new button
  66205. * @param name defines the control name
  66206. */
  66207. constructor(name?: string);
  66208. protected _getTypeName(): string;
  66209. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66210. }
  66211. }
  66212. declare module BABYLON.GUI {
  66213. /**
  66214. * Class used to create a button in 3D
  66215. */
  66216. export class Button3D extends AbstractButton3D {
  66217. /** @hidden */
  66218. protected _currentMaterial: BABYLON.Material;
  66219. private _facadeTexture;
  66220. private _content;
  66221. private _contentResolution;
  66222. private _contentScaleRatio;
  66223. /**
  66224. * Gets or sets the texture resolution used to render content (512 by default)
  66225. */
  66226. contentResolution: BABYLON.int;
  66227. /**
  66228. * Gets or sets the texture scale ratio used to render content (2 by default)
  66229. */
  66230. contentScaleRatio: number;
  66231. protected _disposeFacadeTexture(): void;
  66232. protected _resetContent(): void;
  66233. /**
  66234. * Creates a new button
  66235. * @param name defines the control name
  66236. */
  66237. constructor(name?: string);
  66238. /**
  66239. * Gets or sets the GUI 2D content used to display the button's facade
  66240. */
  66241. content: Control;
  66242. /**
  66243. * Apply the facade texture (created from the content property).
  66244. * This function can be overloaded by child classes
  66245. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66246. */
  66247. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66248. protected _getTypeName(): string;
  66249. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66250. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66251. /**
  66252. * Releases all associated resources
  66253. */
  66254. dispose(): void;
  66255. }
  66256. }
  66257. declare module BABYLON.GUI {
  66258. /**
  66259. * Abstract class used to create a container panel deployed on the surface of a volume
  66260. */
  66261. export abstract class VolumeBasedPanel extends Container3D {
  66262. private _columns;
  66263. private _rows;
  66264. private _rowThenColum;
  66265. private _orientation;
  66266. protected _cellWidth: number;
  66267. protected _cellHeight: number;
  66268. /**
  66269. * Gets or sets the distance between elements
  66270. */
  66271. margin: number;
  66272. /**
  66273. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66274. * | Value | Type | Description |
  66275. * | ----- | ----------------------------------- | ----------- |
  66276. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66277. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66278. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66279. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66280. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66281. */
  66282. orientation: number;
  66283. /**
  66284. * Gets or sets the number of columns requested (10 by default).
  66285. * The panel will automatically compute the number of rows based on number of child controls.
  66286. */
  66287. columns: BABYLON.int;
  66288. /**
  66289. * Gets or sets a the number of rows requested.
  66290. * The panel will automatically compute the number of columns based on number of child controls.
  66291. */
  66292. rows: BABYLON.int;
  66293. /**
  66294. * Creates new VolumeBasedPanel
  66295. */
  66296. constructor();
  66297. protected _arrangeChildren(): void;
  66298. /** Child classes must implement this function to provide correct control positioning */
  66299. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66300. /** Child classes can implement this function to provide additional processing */
  66301. protected _finalProcessing(): void;
  66302. }
  66303. }
  66304. declare module BABYLON.GUI {
  66305. /**
  66306. * Class used to create a container panel deployed on the surface of a cylinder
  66307. */
  66308. export class CylinderPanel extends VolumeBasedPanel {
  66309. private _radius;
  66310. /**
  66311. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66312. */
  66313. radius: BABYLON.float;
  66314. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66315. private _cylindricalMapping;
  66316. }
  66317. }
  66318. declare module BABYLON.GUI {
  66319. /** @hidden */
  66320. export var fluentVertexShader: {
  66321. name: string;
  66322. shader: string;
  66323. };
  66324. }
  66325. declare module BABYLON.GUI {
  66326. /** @hidden */
  66327. export var fluentPixelShader: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module BABYLON.GUI {
  66333. /** @hidden */
  66334. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66335. INNERGLOW: boolean;
  66336. BORDER: boolean;
  66337. HOVERLIGHT: boolean;
  66338. TEXTURE: boolean;
  66339. constructor();
  66340. }
  66341. /**
  66342. * Class used to render controls with fluent desgin
  66343. */
  66344. export class FluentMaterial extends BABYLON.PushMaterial {
  66345. /**
  66346. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66347. */
  66348. innerGlowColorIntensity: number;
  66349. /**
  66350. * Gets or sets the inner glow color (white by default)
  66351. */
  66352. innerGlowColor: BABYLON.Color3;
  66353. /**
  66354. * Gets or sets alpha value (default is 1.0)
  66355. */
  66356. alpha: number;
  66357. /**
  66358. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66359. */
  66360. albedoColor: BABYLON.Color3;
  66361. /**
  66362. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66363. */
  66364. renderBorders: boolean;
  66365. /**
  66366. * Gets or sets border width (default is 0.5)
  66367. */
  66368. borderWidth: number;
  66369. /**
  66370. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66371. */
  66372. edgeSmoothingValue: number;
  66373. /**
  66374. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66375. */
  66376. borderMinValue: number;
  66377. /**
  66378. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66379. */
  66380. renderHoverLight: boolean;
  66381. /**
  66382. * Gets or sets the radius used to render the hover light (default is 1.0)
  66383. */
  66384. hoverRadius: number;
  66385. /**
  66386. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66387. */
  66388. hoverColor: BABYLON.Color4;
  66389. /**
  66390. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66391. */
  66392. hoverPosition: BABYLON.Vector3;
  66393. private _albedoTexture;
  66394. /** Gets or sets the texture to use for albedo color */
  66395. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66396. /**
  66397. * Creates a new Fluent material
  66398. * @param name defines the name of the material
  66399. * @param scene defines the hosting scene
  66400. */
  66401. constructor(name: string, scene: BABYLON.Scene);
  66402. needAlphaBlending(): boolean;
  66403. needAlphaTesting(): boolean;
  66404. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66405. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66406. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66407. getActiveTextures(): BABYLON.BaseTexture[];
  66408. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66409. dispose(forceDisposeEffect?: boolean): void;
  66410. clone(name: string): FluentMaterial;
  66411. serialize(): any;
  66412. getClassName(): string;
  66413. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66414. }
  66415. }
  66416. declare module BABYLON.GUI {
  66417. /**
  66418. * Class used to create a holographic button in 3D
  66419. */
  66420. export class HolographicButton extends Button3D {
  66421. private _backPlate;
  66422. private _textPlate;
  66423. private _frontPlate;
  66424. private _text;
  66425. private _imageUrl;
  66426. private _shareMaterials;
  66427. private _frontMaterial;
  66428. private _backMaterial;
  66429. private _plateMaterial;
  66430. private _pickedPointObserver;
  66431. private _tooltipFade;
  66432. private _tooltipTextBlock;
  66433. private _tooltipTexture;
  66434. private _tooltipMesh;
  66435. private _tooltipHoverObserver;
  66436. private _tooltipOutObserver;
  66437. private _disposeTooltip;
  66438. /**
  66439. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66440. */
  66441. tooltipText: BABYLON.Nullable<string>;
  66442. /**
  66443. * Gets or sets text for the button
  66444. */
  66445. text: string;
  66446. /**
  66447. * Gets or sets the image url for the button
  66448. */
  66449. imageUrl: string;
  66450. /**
  66451. * Gets the back material used by this button
  66452. */
  66453. readonly backMaterial: FluentMaterial;
  66454. /**
  66455. * Gets the front material used by this button
  66456. */
  66457. readonly frontMaterial: FluentMaterial;
  66458. /**
  66459. * Gets the plate material used by this button
  66460. */
  66461. readonly plateMaterial: BABYLON.StandardMaterial;
  66462. /**
  66463. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66464. */
  66465. readonly shareMaterials: boolean;
  66466. /**
  66467. * Creates a new button
  66468. * @param name defines the control name
  66469. */
  66470. constructor(name?: string, shareMaterials?: boolean);
  66471. protected _getTypeName(): string;
  66472. private _rebuildContent;
  66473. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66474. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66475. private _createBackMaterial;
  66476. private _createFrontMaterial;
  66477. private _createPlateMaterial;
  66478. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66479. /**
  66480. * Releases all associated resources
  66481. */
  66482. dispose(): void;
  66483. }
  66484. }
  66485. declare module BABYLON.GUI {
  66486. /**
  66487. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66488. */
  66489. export class MeshButton3D extends Button3D {
  66490. /** @hidden */
  66491. protected _currentMesh: BABYLON.Mesh;
  66492. /**
  66493. * Creates a new 3D button based on a mesh
  66494. * @param mesh mesh to become a 3D button
  66495. * @param name defines the control name
  66496. */
  66497. constructor(mesh: BABYLON.Mesh, name?: string);
  66498. protected _getTypeName(): string;
  66499. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66500. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66501. }
  66502. }
  66503. declare module BABYLON.GUI {
  66504. /**
  66505. * Class used to create a container panel deployed on the surface of a plane
  66506. */
  66507. export class PlanePanel extends VolumeBasedPanel {
  66508. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66509. }
  66510. }
  66511. declare module BABYLON.GUI {
  66512. /**
  66513. * Class used to create a container panel where items get randomized planar mapping
  66514. */
  66515. export class ScatterPanel extends VolumeBasedPanel {
  66516. private _iteration;
  66517. /**
  66518. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66519. */
  66520. iteration: BABYLON.float;
  66521. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66522. private _scatterMapping;
  66523. protected _finalProcessing(): void;
  66524. }
  66525. }
  66526. declare module BABYLON.GUI {
  66527. /**
  66528. * Class used to create a container panel deployed on the surface of a sphere
  66529. */
  66530. export class SpherePanel extends VolumeBasedPanel {
  66531. private _radius;
  66532. /**
  66533. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66534. */
  66535. radius: BABYLON.float;
  66536. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66537. private _sphericalMapping;
  66538. }
  66539. }
  66540. declare module BABYLON.GUI {
  66541. /**
  66542. * Class used to create a stack panel in 3D on XY plane
  66543. */
  66544. export class StackPanel3D extends Container3D {
  66545. private _isVertical;
  66546. /**
  66547. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66548. */
  66549. isVertical: boolean;
  66550. /**
  66551. * Gets or sets the distance between elements
  66552. */
  66553. margin: number;
  66554. /**
  66555. * Creates new StackPanel
  66556. * @param isVertical
  66557. */
  66558. constructor(isVertical?: boolean);
  66559. protected _arrangeChildren(): void;
  66560. }
  66561. }
  66562. declare module BABYLON {
  66563. /**
  66564. * Mode that determines the coordinate system to use.
  66565. */
  66566. export enum GLTFLoaderCoordinateSystemMode {
  66567. /**
  66568. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66569. */
  66570. AUTO = 0,
  66571. /**
  66572. * Sets the useRightHandedSystem flag on the scene.
  66573. */
  66574. FORCE_RIGHT_HANDED = 1
  66575. }
  66576. /**
  66577. * Mode that determines what animations will start.
  66578. */
  66579. export enum GLTFLoaderAnimationStartMode {
  66580. /**
  66581. * No animation will start.
  66582. */
  66583. NONE = 0,
  66584. /**
  66585. * The first animation will start.
  66586. */
  66587. FIRST = 1,
  66588. /**
  66589. * All animations will start.
  66590. */
  66591. ALL = 2
  66592. }
  66593. /**
  66594. * Interface that contains the data for the glTF asset.
  66595. */
  66596. export interface IGLTFLoaderData {
  66597. /**
  66598. * Object that represents the glTF JSON.
  66599. */
  66600. json: Object;
  66601. /**
  66602. * The BIN chunk of a binary glTF.
  66603. */
  66604. bin: Nullable<ArrayBufferView>;
  66605. }
  66606. /**
  66607. * Interface for extending the loader.
  66608. */
  66609. export interface IGLTFLoaderExtension {
  66610. /**
  66611. * The name of this extension.
  66612. */
  66613. readonly name: string;
  66614. /**
  66615. * Defines whether this extension is enabled.
  66616. */
  66617. enabled: boolean;
  66618. }
  66619. /**
  66620. * Loader state.
  66621. */
  66622. export enum GLTFLoaderState {
  66623. /**
  66624. * The asset is loading.
  66625. */
  66626. LOADING = 0,
  66627. /**
  66628. * The asset is ready for rendering.
  66629. */
  66630. READY = 1,
  66631. /**
  66632. * The asset is completely loaded.
  66633. */
  66634. COMPLETE = 2
  66635. }
  66636. /** @hidden */
  66637. export interface IGLTFLoader extends IDisposable {
  66638. readonly state: Nullable<GLTFLoaderState>;
  66639. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66640. meshes: AbstractMesh[];
  66641. particleSystems: IParticleSystem[];
  66642. skeletons: Skeleton[];
  66643. animationGroups: AnimationGroup[];
  66644. }>;
  66645. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66646. }
  66647. /**
  66648. * File loader for loading glTF files into a scene.
  66649. */
  66650. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66651. /** @hidden */
  66652. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66653. /** @hidden */
  66654. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66655. /**
  66656. * Raised when the asset has been parsed
  66657. */
  66658. onParsedObservable: Observable<IGLTFLoaderData>;
  66659. private _onParsedObserver;
  66660. /**
  66661. * Raised when the asset has been parsed
  66662. */
  66663. onParsed: (loaderData: IGLTFLoaderData) => void;
  66664. /**
  66665. * 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.
  66666. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66667. * Defaults to true.
  66668. * @hidden
  66669. */
  66670. static IncrementalLoading: boolean;
  66671. /**
  66672. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66673. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66674. * @hidden
  66675. */
  66676. static HomogeneousCoordinates: boolean;
  66677. /**
  66678. * The coordinate system mode. Defaults to AUTO.
  66679. */
  66680. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66681. /**
  66682. * The animation start mode. Defaults to FIRST.
  66683. */
  66684. animationStartMode: GLTFLoaderAnimationStartMode;
  66685. /**
  66686. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66687. */
  66688. compileMaterials: boolean;
  66689. /**
  66690. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66691. */
  66692. useClipPlane: boolean;
  66693. /**
  66694. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66695. */
  66696. compileShadowGenerators: boolean;
  66697. /**
  66698. * Defines if the Alpha blended materials are only applied as coverage.
  66699. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66700. * If true, no extra effects are applied to transparent pixels.
  66701. */
  66702. transparencyAsCoverage: boolean;
  66703. /**
  66704. * Function called before loading a url referenced by the asset.
  66705. */
  66706. preprocessUrlAsync: (url: string) => Promise<string>;
  66707. /**
  66708. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66709. */
  66710. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66711. private _onMeshLoadedObserver;
  66712. /**
  66713. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66714. */
  66715. onMeshLoaded: (mesh: AbstractMesh) => void;
  66716. /**
  66717. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66718. */
  66719. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66720. private _onTextureLoadedObserver;
  66721. /**
  66722. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66723. */
  66724. onTextureLoaded: (texture: BaseTexture) => void;
  66725. /**
  66726. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66727. */
  66728. readonly onMaterialLoadedObservable: Observable<Material>;
  66729. private _onMaterialLoadedObserver;
  66730. /**
  66731. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66732. */
  66733. onMaterialLoaded: (material: Material) => void;
  66734. /**
  66735. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66736. */
  66737. readonly onCameraLoadedObservable: Observable<Camera>;
  66738. private _onCameraLoadedObserver;
  66739. /**
  66740. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66741. */
  66742. onCameraLoaded: (camera: Camera) => void;
  66743. /**
  66744. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66745. * For assets with LODs, raised when all of the LODs are complete.
  66746. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66747. */
  66748. readonly onCompleteObservable: Observable<void>;
  66749. private _onCompleteObserver;
  66750. /**
  66751. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66752. * For assets with LODs, raised when all of the LODs are complete.
  66753. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66754. */
  66755. onComplete: () => void;
  66756. /**
  66757. * Observable raised when an error occurs.
  66758. */
  66759. readonly onErrorObservable: Observable<any>;
  66760. private _onErrorObserver;
  66761. /**
  66762. * Callback raised when an error occurs.
  66763. */
  66764. onError: (reason: any) => void;
  66765. /**
  66766. * Observable raised after the loader is disposed.
  66767. */
  66768. readonly onDisposeObservable: Observable<void>;
  66769. private _onDisposeObserver;
  66770. /**
  66771. * Callback raised after the loader is disposed.
  66772. */
  66773. onDispose: () => void;
  66774. /**
  66775. * Observable raised after a loader extension is created.
  66776. * Set additional options for a loader extension in this event.
  66777. */
  66778. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66779. private _onExtensionLoadedObserver;
  66780. /**
  66781. * Callback raised after a loader extension is created.
  66782. */
  66783. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66784. /**
  66785. * Defines if the loader logging is enabled.
  66786. */
  66787. loggingEnabled: boolean;
  66788. /**
  66789. * Defines if the loader should capture performance counters.
  66790. */
  66791. capturePerformanceCounters: boolean;
  66792. /**
  66793. * Defines if the loader should validate the asset.
  66794. */
  66795. validate: boolean;
  66796. /**
  66797. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66798. */
  66799. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66800. private _onValidatedObserver;
  66801. /**
  66802. * Callback raised after a loader extension is created.
  66803. */
  66804. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66805. private _loader;
  66806. /**
  66807. * Name of the loader ("gltf")
  66808. */
  66809. name: string;
  66810. /**
  66811. * Supported file extensions of the loader (.gltf, .glb)
  66812. */
  66813. extensions: ISceneLoaderPluginExtensions;
  66814. /**
  66815. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66816. */
  66817. dispose(): void;
  66818. /** @hidden */
  66819. _clear(): void;
  66820. /**
  66821. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66822. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66823. * @param scene the scene the meshes should be added to
  66824. * @param data the glTF data to load
  66825. * @param rootUrl root url to load from
  66826. * @param onProgress event that fires when loading progress has occured
  66827. * @param fileName Defines the name of the file to load
  66828. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66829. */
  66830. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66831. meshes: AbstractMesh[];
  66832. particleSystems: IParticleSystem[];
  66833. skeletons: Skeleton[];
  66834. animationGroups: AnimationGroup[];
  66835. }>;
  66836. /**
  66837. * Imports all objects from the loaded glTF data and adds them to the scene
  66838. * @param scene the scene the objects should be added to
  66839. * @param data the glTF data to load
  66840. * @param rootUrl root url to load from
  66841. * @param onProgress event that fires when loading progress has occured
  66842. * @param fileName Defines the name of the file to load
  66843. * @returns a promise which completes when objects have been loaded to the scene
  66844. */
  66845. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66846. /**
  66847. * Load into an asset container.
  66848. * @param scene The scene to load into
  66849. * @param data The data to import
  66850. * @param rootUrl The root url for scene and resources
  66851. * @param onProgress The callback when the load progresses
  66852. * @param fileName Defines the name of the file to load
  66853. * @returns The loaded asset container
  66854. */
  66855. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66856. /**
  66857. * If the data string can be loaded directly.
  66858. * @param data string contianing the file data
  66859. * @returns if the data can be loaded directly
  66860. */
  66861. canDirectLoad(data: string): boolean;
  66862. /**
  66863. * Rewrites a url by combining a root url and response url.
  66864. */
  66865. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66866. /**
  66867. * Instantiates a glTF file loader plugin.
  66868. * @returns the created plugin
  66869. */
  66870. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66871. /**
  66872. * The loader state or null if the loader is not active.
  66873. */
  66874. readonly loaderState: Nullable<GLTFLoaderState>;
  66875. /**
  66876. * Returns a promise that resolves when the asset is completely loaded.
  66877. * @returns a promise that resolves when the asset is completely loaded.
  66878. */
  66879. whenCompleteAsync(): Promise<void>;
  66880. private _parseAsync;
  66881. private _validateAsync;
  66882. private _getLoader;
  66883. private _unpackBinary;
  66884. private _unpackBinaryV1;
  66885. private _unpackBinaryV2;
  66886. private static _parseVersion;
  66887. private static _compareVersion;
  66888. private static _decodeBufferToText;
  66889. private static readonly _logSpaces;
  66890. private _logIndentLevel;
  66891. private _loggingEnabled;
  66892. /** @hidden */
  66893. _log: (message: string) => void;
  66894. /** @hidden */
  66895. _logOpen(message: string): void;
  66896. /** @hidden */
  66897. _logClose(): void;
  66898. private _logEnabled;
  66899. private _logDisabled;
  66900. private _capturePerformanceCounters;
  66901. /** @hidden */
  66902. _startPerformanceCounter: (counterName: string) => void;
  66903. /** @hidden */
  66904. _endPerformanceCounter: (counterName: string) => void;
  66905. private _startPerformanceCounterEnabled;
  66906. private _startPerformanceCounterDisabled;
  66907. private _endPerformanceCounterEnabled;
  66908. private _endPerformanceCounterDisabled;
  66909. }
  66910. }
  66911. declare module BABYLON.GLTF1 {
  66912. /**
  66913. * Enums
  66914. * @hidden
  66915. */
  66916. export enum EComponentType {
  66917. BYTE = 5120,
  66918. UNSIGNED_BYTE = 5121,
  66919. SHORT = 5122,
  66920. UNSIGNED_SHORT = 5123,
  66921. FLOAT = 5126
  66922. }
  66923. /** @hidden */
  66924. export enum EShaderType {
  66925. FRAGMENT = 35632,
  66926. VERTEX = 35633
  66927. }
  66928. /** @hidden */
  66929. export enum EParameterType {
  66930. BYTE = 5120,
  66931. UNSIGNED_BYTE = 5121,
  66932. SHORT = 5122,
  66933. UNSIGNED_SHORT = 5123,
  66934. INT = 5124,
  66935. UNSIGNED_INT = 5125,
  66936. FLOAT = 5126,
  66937. FLOAT_VEC2 = 35664,
  66938. FLOAT_VEC3 = 35665,
  66939. FLOAT_VEC4 = 35666,
  66940. INT_VEC2 = 35667,
  66941. INT_VEC3 = 35668,
  66942. INT_VEC4 = 35669,
  66943. BOOL = 35670,
  66944. BOOL_VEC2 = 35671,
  66945. BOOL_VEC3 = 35672,
  66946. BOOL_VEC4 = 35673,
  66947. FLOAT_MAT2 = 35674,
  66948. FLOAT_MAT3 = 35675,
  66949. FLOAT_MAT4 = 35676,
  66950. SAMPLER_2D = 35678
  66951. }
  66952. /** @hidden */
  66953. export enum ETextureWrapMode {
  66954. CLAMP_TO_EDGE = 33071,
  66955. MIRRORED_REPEAT = 33648,
  66956. REPEAT = 10497
  66957. }
  66958. /** @hidden */
  66959. export enum ETextureFilterType {
  66960. NEAREST = 9728,
  66961. LINEAR = 9728,
  66962. NEAREST_MIPMAP_NEAREST = 9984,
  66963. LINEAR_MIPMAP_NEAREST = 9985,
  66964. NEAREST_MIPMAP_LINEAR = 9986,
  66965. LINEAR_MIPMAP_LINEAR = 9987
  66966. }
  66967. /** @hidden */
  66968. export enum ETextureFormat {
  66969. ALPHA = 6406,
  66970. RGB = 6407,
  66971. RGBA = 6408,
  66972. LUMINANCE = 6409,
  66973. LUMINANCE_ALPHA = 6410
  66974. }
  66975. /** @hidden */
  66976. export enum ECullingType {
  66977. FRONT = 1028,
  66978. BACK = 1029,
  66979. FRONT_AND_BACK = 1032
  66980. }
  66981. /** @hidden */
  66982. export enum EBlendingFunction {
  66983. ZERO = 0,
  66984. ONE = 1,
  66985. SRC_COLOR = 768,
  66986. ONE_MINUS_SRC_COLOR = 769,
  66987. DST_COLOR = 774,
  66988. ONE_MINUS_DST_COLOR = 775,
  66989. SRC_ALPHA = 770,
  66990. ONE_MINUS_SRC_ALPHA = 771,
  66991. DST_ALPHA = 772,
  66992. ONE_MINUS_DST_ALPHA = 773,
  66993. CONSTANT_COLOR = 32769,
  66994. ONE_MINUS_CONSTANT_COLOR = 32770,
  66995. CONSTANT_ALPHA = 32771,
  66996. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66997. SRC_ALPHA_SATURATE = 776
  66998. }
  66999. /** @hidden */
  67000. export interface IGLTFProperty {
  67001. extensions?: {
  67002. [key: string]: any;
  67003. };
  67004. extras?: Object;
  67005. }
  67006. /** @hidden */
  67007. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67008. name?: string;
  67009. }
  67010. /** @hidden */
  67011. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67012. bufferView: string;
  67013. byteOffset: number;
  67014. byteStride: number;
  67015. count: number;
  67016. type: string;
  67017. componentType: EComponentType;
  67018. max?: number[];
  67019. min?: number[];
  67020. name?: string;
  67021. }
  67022. /** @hidden */
  67023. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67024. buffer: string;
  67025. byteOffset: number;
  67026. byteLength: number;
  67027. byteStride: number;
  67028. target?: number;
  67029. }
  67030. /** @hidden */
  67031. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67032. uri: string;
  67033. byteLength?: number;
  67034. type?: string;
  67035. }
  67036. /** @hidden */
  67037. export interface IGLTFShader extends IGLTFChildRootProperty {
  67038. uri: string;
  67039. type: EShaderType;
  67040. }
  67041. /** @hidden */
  67042. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67043. attributes: string[];
  67044. fragmentShader: string;
  67045. vertexShader: string;
  67046. }
  67047. /** @hidden */
  67048. export interface IGLTFTechniqueParameter {
  67049. type: number;
  67050. count?: number;
  67051. semantic?: string;
  67052. node?: string;
  67053. value?: number | boolean | string | Array<any>;
  67054. source?: string;
  67055. babylonValue?: any;
  67056. }
  67057. /** @hidden */
  67058. export interface IGLTFTechniqueCommonProfile {
  67059. lightingModel: string;
  67060. texcoordBindings: Object;
  67061. parameters?: Array<any>;
  67062. }
  67063. /** @hidden */
  67064. export interface IGLTFTechniqueStatesFunctions {
  67065. blendColor?: number[];
  67066. blendEquationSeparate?: number[];
  67067. blendFuncSeparate?: number[];
  67068. colorMask: boolean[];
  67069. cullFace: number[];
  67070. }
  67071. /** @hidden */
  67072. export interface IGLTFTechniqueStates {
  67073. enable: number[];
  67074. functions: IGLTFTechniqueStatesFunctions;
  67075. }
  67076. /** @hidden */
  67077. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67078. parameters: {
  67079. [key: string]: IGLTFTechniqueParameter;
  67080. };
  67081. program: string;
  67082. attributes: {
  67083. [key: string]: string;
  67084. };
  67085. uniforms: {
  67086. [key: string]: string;
  67087. };
  67088. states: IGLTFTechniqueStates;
  67089. }
  67090. /** @hidden */
  67091. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67092. technique?: string;
  67093. values: string[];
  67094. }
  67095. /** @hidden */
  67096. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67097. attributes: {
  67098. [key: string]: string;
  67099. };
  67100. indices: string;
  67101. material: string;
  67102. mode?: number;
  67103. }
  67104. /** @hidden */
  67105. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67106. primitives: IGLTFMeshPrimitive[];
  67107. }
  67108. /** @hidden */
  67109. export interface IGLTFImage extends IGLTFChildRootProperty {
  67110. uri: string;
  67111. }
  67112. /** @hidden */
  67113. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67114. magFilter?: number;
  67115. minFilter?: number;
  67116. wrapS?: number;
  67117. wrapT?: number;
  67118. }
  67119. /** @hidden */
  67120. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67121. sampler: string;
  67122. source: string;
  67123. format?: ETextureFormat;
  67124. internalFormat?: ETextureFormat;
  67125. target?: number;
  67126. type?: number;
  67127. babylonTexture?: Texture;
  67128. }
  67129. /** @hidden */
  67130. export interface IGLTFAmbienLight {
  67131. color?: number[];
  67132. }
  67133. /** @hidden */
  67134. export interface IGLTFDirectionalLight {
  67135. color?: number[];
  67136. }
  67137. /** @hidden */
  67138. export interface IGLTFPointLight {
  67139. color?: number[];
  67140. constantAttenuation?: number;
  67141. linearAttenuation?: number;
  67142. quadraticAttenuation?: number;
  67143. }
  67144. /** @hidden */
  67145. export interface IGLTFSpotLight {
  67146. color?: number[];
  67147. constantAttenuation?: number;
  67148. fallOfAngle?: number;
  67149. fallOffExponent?: number;
  67150. linearAttenuation?: number;
  67151. quadraticAttenuation?: number;
  67152. }
  67153. /** @hidden */
  67154. export interface IGLTFLight extends IGLTFChildRootProperty {
  67155. type: string;
  67156. }
  67157. /** @hidden */
  67158. export interface IGLTFCameraOrthographic {
  67159. xmag: number;
  67160. ymag: number;
  67161. zfar: number;
  67162. znear: number;
  67163. }
  67164. /** @hidden */
  67165. export interface IGLTFCameraPerspective {
  67166. aspectRatio: number;
  67167. yfov: number;
  67168. zfar: number;
  67169. znear: number;
  67170. }
  67171. /** @hidden */
  67172. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67173. type: string;
  67174. }
  67175. /** @hidden */
  67176. export interface IGLTFAnimationChannelTarget {
  67177. id: string;
  67178. path: string;
  67179. }
  67180. /** @hidden */
  67181. export interface IGLTFAnimationChannel {
  67182. sampler: string;
  67183. target: IGLTFAnimationChannelTarget;
  67184. }
  67185. /** @hidden */
  67186. export interface IGLTFAnimationSampler {
  67187. input: string;
  67188. output: string;
  67189. interpolation?: string;
  67190. }
  67191. /** @hidden */
  67192. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67193. channels?: IGLTFAnimationChannel[];
  67194. parameters?: {
  67195. [key: string]: string;
  67196. };
  67197. samplers?: {
  67198. [key: string]: IGLTFAnimationSampler;
  67199. };
  67200. }
  67201. /** @hidden */
  67202. export interface IGLTFNodeInstanceSkin {
  67203. skeletons: string[];
  67204. skin: string;
  67205. meshes: string[];
  67206. }
  67207. /** @hidden */
  67208. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67209. bindShapeMatrix: number[];
  67210. inverseBindMatrices: string;
  67211. jointNames: string[];
  67212. babylonSkeleton?: Skeleton;
  67213. }
  67214. /** @hidden */
  67215. export interface IGLTFNode extends IGLTFChildRootProperty {
  67216. camera?: string;
  67217. children: string[];
  67218. skin?: string;
  67219. jointName?: string;
  67220. light?: string;
  67221. matrix: number[];
  67222. mesh?: string;
  67223. meshes?: string[];
  67224. rotation?: number[];
  67225. scale?: number[];
  67226. translation?: number[];
  67227. babylonNode?: Node;
  67228. }
  67229. /** @hidden */
  67230. export interface IGLTFScene extends IGLTFChildRootProperty {
  67231. nodes: string[];
  67232. }
  67233. /** @hidden */
  67234. export interface IGLTFRuntime {
  67235. extensions: {
  67236. [key: string]: any;
  67237. };
  67238. accessors: {
  67239. [key: string]: IGLTFAccessor;
  67240. };
  67241. buffers: {
  67242. [key: string]: IGLTFBuffer;
  67243. };
  67244. bufferViews: {
  67245. [key: string]: IGLTFBufferView;
  67246. };
  67247. meshes: {
  67248. [key: string]: IGLTFMesh;
  67249. };
  67250. lights: {
  67251. [key: string]: IGLTFLight;
  67252. };
  67253. cameras: {
  67254. [key: string]: IGLTFCamera;
  67255. };
  67256. nodes: {
  67257. [key: string]: IGLTFNode;
  67258. };
  67259. images: {
  67260. [key: string]: IGLTFImage;
  67261. };
  67262. textures: {
  67263. [key: string]: IGLTFTexture;
  67264. };
  67265. shaders: {
  67266. [key: string]: IGLTFShader;
  67267. };
  67268. programs: {
  67269. [key: string]: IGLTFProgram;
  67270. };
  67271. samplers: {
  67272. [key: string]: IGLTFSampler;
  67273. };
  67274. techniques: {
  67275. [key: string]: IGLTFTechnique;
  67276. };
  67277. materials: {
  67278. [key: string]: IGLTFMaterial;
  67279. };
  67280. animations: {
  67281. [key: string]: IGLTFAnimation;
  67282. };
  67283. skins: {
  67284. [key: string]: IGLTFSkins;
  67285. };
  67286. currentScene?: Object;
  67287. scenes: {
  67288. [key: string]: IGLTFScene;
  67289. };
  67290. extensionsUsed: string[];
  67291. extensionsRequired?: string[];
  67292. buffersCount: number;
  67293. shaderscount: number;
  67294. scene: Scene;
  67295. rootUrl: string;
  67296. loadedBufferCount: number;
  67297. loadedBufferViews: {
  67298. [name: string]: ArrayBufferView;
  67299. };
  67300. loadedShaderCount: number;
  67301. importOnlyMeshes: boolean;
  67302. importMeshesNames?: string[];
  67303. dummyNodes: Node[];
  67304. }
  67305. /** @hidden */
  67306. export interface INodeToRoot {
  67307. bone: Bone;
  67308. node: IGLTFNode;
  67309. id: string;
  67310. }
  67311. /** @hidden */
  67312. export interface IJointNode {
  67313. node: IGLTFNode;
  67314. id: string;
  67315. }
  67316. }
  67317. declare module BABYLON.GLTF1 {
  67318. /**
  67319. * Utils functions for GLTF
  67320. * @hidden
  67321. */
  67322. export class GLTFUtils {
  67323. /**
  67324. * Sets the given "parameter" matrix
  67325. * @param scene: the Scene object
  67326. * @param source: the source node where to pick the matrix
  67327. * @param parameter: the GLTF technique parameter
  67328. * @param uniformName: the name of the shader's uniform
  67329. * @param shaderMaterial: the shader material
  67330. */
  67331. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67332. /**
  67333. * Sets the given "parameter" matrix
  67334. * @param shaderMaterial: the shader material
  67335. * @param uniform: the name of the shader's uniform
  67336. * @param value: the value of the uniform
  67337. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67338. */
  67339. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67340. /**
  67341. * Returns the wrap mode of the texture
  67342. * @param mode: the mode value
  67343. */
  67344. static GetWrapMode(mode: number): number;
  67345. /**
  67346. * Returns the byte stride giving an accessor
  67347. * @param accessor: the GLTF accessor objet
  67348. */
  67349. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67350. /**
  67351. * Returns the texture filter mode giving a mode value
  67352. * @param mode: the filter mode value
  67353. */
  67354. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67355. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67356. /**
  67357. * Returns a buffer from its accessor
  67358. * @param gltfRuntime: the GLTF runtime
  67359. * @param accessor: the GLTF accessor
  67360. */
  67361. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67362. /**
  67363. * Decodes a buffer view into a string
  67364. * @param view: the buffer view
  67365. */
  67366. static DecodeBufferToText(view: ArrayBufferView): string;
  67367. /**
  67368. * Returns the default material of gltf. Related to
  67369. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67370. * @param scene: the Babylon.js scene
  67371. */
  67372. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67373. private static _DefaultMaterial;
  67374. }
  67375. }
  67376. declare module BABYLON.GLTF1 {
  67377. /**
  67378. * Implementation of the base glTF spec
  67379. * @hidden
  67380. */
  67381. export class GLTFLoaderBase {
  67382. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67383. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67384. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67385. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67386. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67387. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67388. }
  67389. /**
  67390. * glTF V1 Loader
  67391. * @hidden
  67392. */
  67393. export class GLTFLoader implements IGLTFLoader {
  67394. static Extensions: {
  67395. [name: string]: GLTFLoaderExtension;
  67396. };
  67397. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67398. state: Nullable<GLTFLoaderState>;
  67399. dispose(): void;
  67400. private _importMeshAsync;
  67401. /**
  67402. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67403. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67404. * @param scene the scene the meshes should be added to
  67405. * @param data gltf data containing information of the meshes in a loaded file
  67406. * @param rootUrl root url to load from
  67407. * @param onProgress event that fires when loading progress has occured
  67408. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67409. */
  67410. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67411. meshes: AbstractMesh[];
  67412. particleSystems: IParticleSystem[];
  67413. skeletons: Skeleton[];
  67414. animationGroups: AnimationGroup[];
  67415. }>;
  67416. private _loadAsync;
  67417. /**
  67418. * Imports all objects from a loaded gltf file and adds them to the scene
  67419. * @param scene the scene the objects should be added to
  67420. * @param data gltf data containing information of the meshes in a loaded file
  67421. * @param rootUrl root url to load from
  67422. * @param onProgress event that fires when loading progress has occured
  67423. * @returns a promise which completes when objects have been loaded to the scene
  67424. */
  67425. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67426. private _loadShadersAsync;
  67427. private _loadBuffersAsync;
  67428. private _createNodes;
  67429. }
  67430. /** @hidden */
  67431. export abstract class GLTFLoaderExtension {
  67432. private _name;
  67433. constructor(name: string);
  67434. readonly name: string;
  67435. /**
  67436. * Defines an override for loading the runtime
  67437. * Return true to stop further extensions from loading the runtime
  67438. */
  67439. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67440. /**
  67441. * Defines an onverride for creating gltf runtime
  67442. * Return true to stop further extensions from creating the runtime
  67443. */
  67444. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67445. /**
  67446. * Defines an override for loading buffers
  67447. * Return true to stop further extensions from loading this buffer
  67448. */
  67449. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67450. /**
  67451. * Defines an override for loading texture buffers
  67452. * Return true to stop further extensions from loading this texture data
  67453. */
  67454. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67455. /**
  67456. * Defines an override for creating textures
  67457. * Return true to stop further extensions from loading this texture
  67458. */
  67459. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67460. /**
  67461. * Defines an override for loading shader strings
  67462. * Return true to stop further extensions from loading this shader data
  67463. */
  67464. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67465. /**
  67466. * Defines an override for loading materials
  67467. * Return true to stop further extensions from loading this material
  67468. */
  67469. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67470. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67471. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67472. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67473. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67474. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67475. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67476. private static LoadTextureBufferAsync;
  67477. private static CreateTextureAsync;
  67478. private static ApplyExtensions;
  67479. }
  67480. }
  67481. declare module BABYLON.GLTF1 {
  67482. /** @hidden */
  67483. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67484. private _bin;
  67485. constructor();
  67486. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67487. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67488. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67489. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67490. }
  67491. }
  67492. declare module BABYLON.GLTF1 {
  67493. /** @hidden */
  67494. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67495. constructor();
  67496. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67497. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67498. private _loadTexture;
  67499. }
  67500. }
  67501. declare module BABYLON.GLTF2.Loader {
  67502. /**
  67503. * Loader interface with an index field.
  67504. */
  67505. export interface IArrayItem {
  67506. /**
  67507. * The index of this item in the array.
  67508. */
  67509. index: number;
  67510. }
  67511. /**
  67512. * Loader interface with additional members.
  67513. */
  67514. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67515. /** @hidden */
  67516. _data?: Promise<ArrayBufferView>;
  67517. /** @hidden */
  67518. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67519. }
  67520. /**
  67521. * Loader interface with additional members.
  67522. */
  67523. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67524. }
  67525. /** @hidden */
  67526. export interface _IAnimationSamplerData {
  67527. input: Float32Array;
  67528. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67529. output: Float32Array;
  67530. }
  67531. /**
  67532. * Loader interface with additional members.
  67533. */
  67534. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67535. /** @hidden */
  67536. _data?: Promise<_IAnimationSamplerData>;
  67537. }
  67538. /**
  67539. * Loader interface with additional members.
  67540. */
  67541. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67542. channels: IAnimationChannel[];
  67543. samplers: IAnimationSampler[];
  67544. /** @hidden */
  67545. _babylonAnimationGroup?: AnimationGroup;
  67546. }
  67547. /**
  67548. * Loader interface with additional members.
  67549. */
  67550. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67551. /** @hidden */
  67552. _data?: Promise<ArrayBufferView>;
  67553. }
  67554. /**
  67555. * Loader interface with additional members.
  67556. */
  67557. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67558. /** @hidden */
  67559. _data?: Promise<ArrayBufferView>;
  67560. /** @hidden */
  67561. _babylonBuffer?: Promise<Buffer>;
  67562. }
  67563. /**
  67564. * Loader interface with additional members.
  67565. */
  67566. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67567. }
  67568. /**
  67569. * Loader interface with additional members.
  67570. */
  67571. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67572. /** @hidden */
  67573. _data?: Promise<ArrayBufferView>;
  67574. }
  67575. /**
  67576. * Loader interface with additional members.
  67577. */
  67578. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67579. }
  67580. /**
  67581. * Loader interface with additional members.
  67582. */
  67583. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67584. }
  67585. /**
  67586. * Loader interface with additional members.
  67587. */
  67588. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67589. baseColorTexture?: ITextureInfo;
  67590. metallicRoughnessTexture?: ITextureInfo;
  67591. }
  67592. /**
  67593. * Loader interface with additional members.
  67594. */
  67595. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67596. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67597. normalTexture?: IMaterialNormalTextureInfo;
  67598. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67599. emissiveTexture?: ITextureInfo;
  67600. /** @hidden */
  67601. _data?: {
  67602. [babylonDrawMode: number]: {
  67603. babylonMaterial: Material;
  67604. babylonMeshes: AbstractMesh[];
  67605. promise: Promise<void>;
  67606. };
  67607. };
  67608. }
  67609. /**
  67610. * Loader interface with additional members.
  67611. */
  67612. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67613. primitives: IMeshPrimitive[];
  67614. }
  67615. /**
  67616. * Loader interface with additional members.
  67617. */
  67618. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67619. /** @hidden */
  67620. _instanceData?: {
  67621. babylonSourceMesh: Mesh;
  67622. promise: Promise<any>;
  67623. };
  67624. }
  67625. /**
  67626. * Loader interface with additional members.
  67627. */
  67628. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67629. /**
  67630. * The parent glTF node.
  67631. */
  67632. parent?: INode;
  67633. /** @hidden */
  67634. _babylonTransformNode?: TransformNode;
  67635. /** @hidden */
  67636. _primitiveBabylonMeshes?: AbstractMesh[];
  67637. /** @hidden */
  67638. _babylonBones?: Bone[];
  67639. /** @hidden */
  67640. _numMorphTargets?: number;
  67641. }
  67642. /** @hidden */
  67643. export interface _ISamplerData {
  67644. noMipMaps: boolean;
  67645. samplingMode: number;
  67646. wrapU: number;
  67647. wrapV: number;
  67648. }
  67649. /**
  67650. * Loader interface with additional members.
  67651. */
  67652. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67653. /** @hidden */
  67654. _data?: _ISamplerData;
  67655. }
  67656. /**
  67657. * Loader interface with additional members.
  67658. */
  67659. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67660. }
  67661. /**
  67662. * Loader interface with additional members.
  67663. */
  67664. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67665. /** @hidden */
  67666. _data?: {
  67667. babylonSkeleton: Skeleton;
  67668. promise: Promise<void>;
  67669. };
  67670. }
  67671. /**
  67672. * Loader interface with additional members.
  67673. */
  67674. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67675. }
  67676. /**
  67677. * Loader interface with additional members.
  67678. */
  67679. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67680. }
  67681. /**
  67682. * Loader interface with additional members.
  67683. */
  67684. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67685. accessors?: IAccessor[];
  67686. animations?: IAnimation[];
  67687. buffers?: IBuffer[];
  67688. bufferViews?: IBufferView[];
  67689. cameras?: ICamera[];
  67690. images?: IImage[];
  67691. materials?: IMaterial[];
  67692. meshes?: IMesh[];
  67693. nodes?: INode[];
  67694. samplers?: ISampler[];
  67695. scenes?: IScene[];
  67696. skins?: ISkin[];
  67697. textures?: ITexture[];
  67698. }
  67699. }
  67700. declare module BABYLON.GLTF2 {
  67701. /**
  67702. * Interface for a glTF loader extension.
  67703. */
  67704. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67705. /**
  67706. * Called after the loader state changes to LOADING.
  67707. */
  67708. onLoading?(): void;
  67709. /**
  67710. * Called after the loader state changes to READY.
  67711. */
  67712. onReady?(): void;
  67713. /**
  67714. * Define this method to modify the default behavior when loading scenes.
  67715. * @param context The context when loading the asset
  67716. * @param scene The glTF scene property
  67717. * @returns A promise that resolves when the load is complete or null if not handled
  67718. */
  67719. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67720. /**
  67721. * Define this method to modify the default behavior when loading nodes.
  67722. * @param context The context when loading the asset
  67723. * @param node The glTF node property
  67724. * @param assign A function called synchronously after parsing the glTF properties
  67725. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67726. */
  67727. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67728. /**
  67729. * Define this method to modify the default behavior when loading cameras.
  67730. * @param context The context when loading the asset
  67731. * @param camera The glTF camera property
  67732. * @param assign A function called synchronously after parsing the glTF properties
  67733. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67734. */
  67735. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67736. /**
  67737. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67738. * @param context The context when loading the asset
  67739. * @param primitive The glTF mesh primitive property
  67740. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67741. */
  67742. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67743. /**
  67744. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67745. * @param context The context when loading the asset
  67746. * @param name The mesh name when loading the asset
  67747. * @param node The glTF node when loading the asset
  67748. * @param mesh The glTF mesh when loading the asset
  67749. * @param primitive The glTF mesh primitive property
  67750. * @param assign A function called synchronously after parsing the glTF properties
  67751. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67752. */
  67753. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67754. /**
  67755. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67756. * @param context The context when loading the asset
  67757. * @param material The glTF material property
  67758. * @param assign A function called synchronously after parsing the glTF properties
  67759. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67760. */
  67761. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67762. /**
  67763. * Define this method to modify the default behavior when creating materials.
  67764. * @param context The context when loading the asset
  67765. * @param material The glTF material property
  67766. * @param babylonDrawMode The draw mode for the Babylon material
  67767. * @returns The Babylon material or null if not handled
  67768. */
  67769. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67770. /**
  67771. * Define this method to modify the default behavior when loading material properties.
  67772. * @param context The context when loading the asset
  67773. * @param material The glTF material property
  67774. * @param babylonMaterial The Babylon material
  67775. * @returns A promise that resolves when the load is complete or null if not handled
  67776. */
  67777. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67778. /**
  67779. * Define this method to modify the default behavior when loading texture infos.
  67780. * @param context The context when loading the asset
  67781. * @param textureInfo The glTF texture info property
  67782. * @param assign A function called synchronously after parsing the glTF properties
  67783. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67784. */
  67785. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67786. /**
  67787. * Define this method to modify the default behavior when loading animations.
  67788. * @param context The context when loading the asset
  67789. * @param animation The glTF animation property
  67790. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67791. */
  67792. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67793. /**
  67794. * @hidden Define this method to modify the default behavior when loading skins.
  67795. * @param context The context when loading the asset
  67796. * @param node The glTF node property
  67797. * @param skin The glTF skin property
  67798. * @returns A promise that resolves when the load is complete or null if not handled
  67799. */
  67800. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67801. /**
  67802. * @hidden Define this method to modify the default behavior when loading uris.
  67803. * @param context The context when loading the asset
  67804. * @param property The glTF property associated with the uri
  67805. * @param uri The uri to load
  67806. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67807. */
  67808. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67809. }
  67810. }
  67811. declare module BABYLON.GLTF2 {
  67812. /**
  67813. * Helper class for working with arrays when loading the glTF asset
  67814. */
  67815. export class ArrayItem {
  67816. /**
  67817. * Gets an item from the given array.
  67818. * @param context The context when loading the asset
  67819. * @param array The array to get the item from
  67820. * @param index The index to the array
  67821. * @returns The array item
  67822. */
  67823. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67824. /**
  67825. * Assign an `index` field to each item of the given array.
  67826. * @param array The array of items
  67827. */
  67828. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67829. }
  67830. /**
  67831. * The glTF 2.0 loader
  67832. */
  67833. export class GLTFLoader implements IGLTFLoader {
  67834. /** @hidden */
  67835. _completePromises: Promise<any>[];
  67836. private _disposed;
  67837. private _parent;
  67838. private _state;
  67839. private _extensions;
  67840. private _rootUrl;
  67841. private _fileName;
  67842. private _uniqueRootUrl;
  67843. private _gltf;
  67844. private _babylonScene;
  67845. private _rootBabylonMesh;
  67846. private _defaultBabylonMaterialData;
  67847. private _progressCallback?;
  67848. private _requests;
  67849. private static readonly _DefaultSampler;
  67850. private static _ExtensionNames;
  67851. private static _ExtensionFactories;
  67852. /**
  67853. * Registers a loader extension.
  67854. * @param name The name of the loader extension.
  67855. * @param factory The factory function that creates the loader extension.
  67856. */
  67857. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67858. /**
  67859. * Unregisters a loader extension.
  67860. * @param name The name of the loader extenion.
  67861. * @returns A boolean indicating whether the extension has been unregistered
  67862. */
  67863. static UnregisterExtension(name: string): boolean;
  67864. /**
  67865. * Gets the loader state.
  67866. */
  67867. readonly state: Nullable<GLTFLoaderState>;
  67868. /**
  67869. * The glTF object parsed from the JSON.
  67870. */
  67871. readonly gltf: IGLTF;
  67872. /**
  67873. * The Babylon scene when loading the asset.
  67874. */
  67875. readonly babylonScene: Scene;
  67876. /**
  67877. * The root Babylon mesh when loading the asset.
  67878. */
  67879. readonly rootBabylonMesh: Mesh;
  67880. /** @hidden */
  67881. constructor(parent: GLTFFileLoader);
  67882. /** @hidden */
  67883. dispose(): void;
  67884. /** @hidden */
  67885. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67886. meshes: AbstractMesh[];
  67887. particleSystems: IParticleSystem[];
  67888. skeletons: Skeleton[];
  67889. animationGroups: AnimationGroup[];
  67890. }>;
  67891. /** @hidden */
  67892. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67893. private _loadAsync;
  67894. private _loadData;
  67895. private _setupData;
  67896. private _loadExtensions;
  67897. private _checkExtensions;
  67898. private _setState;
  67899. private _createRootNode;
  67900. /**
  67901. * Loads a glTF scene.
  67902. * @param context The context when loading the asset
  67903. * @param scene The glTF scene property
  67904. * @returns A promise that resolves when the load is complete
  67905. */
  67906. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67907. private _forEachPrimitive;
  67908. private _getMeshes;
  67909. private _getSkeletons;
  67910. private _getAnimationGroups;
  67911. private _startAnimations;
  67912. /**
  67913. * Loads a glTF node.
  67914. * @param context The context when loading the asset
  67915. * @param node The glTF node property
  67916. * @param assign A function called synchronously after parsing the glTF properties
  67917. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67918. */
  67919. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67920. private _loadMeshAsync;
  67921. /**
  67922. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67923. * @param context The context when loading the asset
  67924. * @param name The mesh name when loading the asset
  67925. * @param node The glTF node when loading the asset
  67926. * @param mesh The glTF mesh when loading the asset
  67927. * @param primitive The glTF mesh primitive property
  67928. * @param assign A function called synchronously after parsing the glTF properties
  67929. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67930. */
  67931. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67932. private _loadVertexDataAsync;
  67933. private _createMorphTargets;
  67934. private _loadMorphTargetsAsync;
  67935. private _loadMorphTargetVertexDataAsync;
  67936. private static _LoadTransform;
  67937. private _loadSkinAsync;
  67938. private _loadBones;
  67939. private _loadBone;
  67940. private _loadSkinInverseBindMatricesDataAsync;
  67941. private _updateBoneMatrices;
  67942. private _getNodeMatrix;
  67943. /**
  67944. * Loads a glTF camera.
  67945. * @param context The context when loading the asset
  67946. * @param camera The glTF camera property
  67947. * @param assign A function called synchronously after parsing the glTF properties
  67948. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67949. */
  67950. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67951. private _loadAnimationsAsync;
  67952. /**
  67953. * Loads a glTF animation.
  67954. * @param context The context when loading the asset
  67955. * @param animation The glTF animation property
  67956. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67957. */
  67958. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67959. /**
  67960. * @hidden Loads a glTF animation channel.
  67961. * @param context The context when loading the asset
  67962. * @param animationContext The context of the animation when loading the asset
  67963. * @param animation The glTF animation property
  67964. * @param channel The glTF animation channel property
  67965. * @param babylonAnimationGroup The babylon animation group property
  67966. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67967. * @returns A void promise when the channel load is complete
  67968. */
  67969. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67970. private _loadAnimationSamplerAsync;
  67971. private _loadBufferAsync;
  67972. /**
  67973. * Loads a glTF buffer view.
  67974. * @param context The context when loading the asset
  67975. * @param bufferView The glTF buffer view property
  67976. * @returns A promise that resolves with the loaded data when the load is complete
  67977. */
  67978. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67979. private _loadAccessorAsync;
  67980. private _loadFloatAccessorAsync;
  67981. private _loadIndicesAccessorAsync;
  67982. private _loadVertexBufferViewAsync;
  67983. private _loadVertexAccessorAsync;
  67984. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67985. /** @hidden */
  67986. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67987. private _createDefaultMaterial;
  67988. /**
  67989. * Creates a Babylon material from a glTF material.
  67990. * @param context The context when loading the asset
  67991. * @param material The glTF material property
  67992. * @param babylonDrawMode The draw mode for the Babylon material
  67993. * @returns The Babylon material
  67994. */
  67995. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67996. /**
  67997. * Loads properties from a glTF material into a Babylon material.
  67998. * @param context The context when loading the asset
  67999. * @param material The glTF material property
  68000. * @param babylonMaterial The Babylon material
  68001. * @returns A promise that resolves when the load is complete
  68002. */
  68003. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68004. /**
  68005. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68006. * @param context The context when loading the asset
  68007. * @param material The glTF material property
  68008. * @param babylonMaterial The Babylon material
  68009. * @returns A promise that resolves when the load is complete
  68010. */
  68011. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68012. /**
  68013. * Loads the alpha properties from a glTF material into a Babylon material.
  68014. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68015. * @param context The context when loading the asset
  68016. * @param material The glTF material property
  68017. * @param babylonMaterial The Babylon material
  68018. */
  68019. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68020. /**
  68021. * Loads a glTF texture info.
  68022. * @param context The context when loading the asset
  68023. * @param textureInfo The glTF texture info property
  68024. * @param assign A function called synchronously after parsing the glTF properties
  68025. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68026. */
  68027. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68028. private _loadTextureAsync;
  68029. private _loadSampler;
  68030. /**
  68031. * Loads a glTF image.
  68032. * @param context The context when loading the asset
  68033. * @param image The glTF image property
  68034. * @returns A promise that resolves with the loaded data when the load is complete
  68035. */
  68036. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68037. /**
  68038. * Loads a glTF uri.
  68039. * @param context The context when loading the asset
  68040. * @param property The glTF property associated with the uri
  68041. * @param uri The base64 or relative uri
  68042. * @returns A promise that resolves with the loaded data when the load is complete
  68043. */
  68044. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68045. private _onProgress;
  68046. /**
  68047. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68048. * @param babylonObject the Babylon object with metadata
  68049. * @param pointer the JSON pointer
  68050. */
  68051. static AddPointerMetadata(babylonObject: {
  68052. metadata: any;
  68053. }, pointer: string): void;
  68054. private static _GetTextureWrapMode;
  68055. private static _GetTextureSamplingMode;
  68056. private static _GetTypedArrayConstructor;
  68057. private static _GetTypedArray;
  68058. private static _GetNumComponents;
  68059. private static _ValidateUri;
  68060. private static _GetDrawMode;
  68061. private _compileMaterialsAsync;
  68062. private _compileShadowGeneratorsAsync;
  68063. private _forEachExtensions;
  68064. private _applyExtensions;
  68065. private _extensionsOnLoading;
  68066. private _extensionsOnReady;
  68067. private _extensionsLoadSceneAsync;
  68068. private _extensionsLoadNodeAsync;
  68069. private _extensionsLoadCameraAsync;
  68070. private _extensionsLoadVertexDataAsync;
  68071. private _extensionsLoadMeshPrimitiveAsync;
  68072. private _extensionsLoadMaterialAsync;
  68073. private _extensionsCreateMaterial;
  68074. private _extensionsLoadMaterialPropertiesAsync;
  68075. private _extensionsLoadTextureInfoAsync;
  68076. private _extensionsLoadAnimationAsync;
  68077. private _extensionsLoadSkinAsync;
  68078. private _extensionsLoadUriAsync;
  68079. /**
  68080. * Helper method called by a loader extension to load an glTF extension.
  68081. * @param context The context when loading the asset
  68082. * @param property The glTF property to load the extension from
  68083. * @param extensionName The name of the extension to load
  68084. * @param actionAsync The action to run
  68085. * @returns The promise returned by actionAsync or null if the extension does not exist
  68086. */
  68087. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68088. /**
  68089. * Helper method called by a loader extension to load a glTF extra.
  68090. * @param context The context when loading the asset
  68091. * @param property The glTF property to load the extra from
  68092. * @param extensionName The name of the extension to load
  68093. * @param actionAsync The action to run
  68094. * @returns The promise returned by actionAsync or null if the extra does not exist
  68095. */
  68096. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68097. /**
  68098. * Increments the indentation level and logs a message.
  68099. * @param message The message to log
  68100. */
  68101. logOpen(message: string): void;
  68102. /**
  68103. * Decrements the indentation level.
  68104. */
  68105. logClose(): void;
  68106. /**
  68107. * Logs a message
  68108. * @param message The message to log
  68109. */
  68110. log(message: string): void;
  68111. /**
  68112. * Starts a performance counter.
  68113. * @param counterName The name of the performance counter
  68114. */
  68115. startPerformanceCounter(counterName: string): void;
  68116. /**
  68117. * Ends a performance counter.
  68118. * @param counterName The name of the performance counter
  68119. */
  68120. endPerformanceCounter(counterName: string): void;
  68121. }
  68122. }
  68123. declare module BABYLON.GLTF2.Loader.Extensions {
  68124. /**
  68125. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68126. */
  68127. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68128. /** The name of this extension. */
  68129. readonly name: string;
  68130. /** Defines whether this extension is enabled. */
  68131. enabled: boolean;
  68132. private _loader;
  68133. private _lights?;
  68134. /** @hidden */
  68135. constructor(loader: GLTFLoader);
  68136. /** @hidden */
  68137. dispose(): void;
  68138. /** @hidden */
  68139. onLoading(): void;
  68140. /** @hidden */
  68141. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68142. private _loadLightAsync;
  68143. }
  68144. }
  68145. declare module BABYLON.GLTF2.Loader.Extensions {
  68146. /**
  68147. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68148. */
  68149. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68150. /** The name of this extension. */
  68151. readonly name: string;
  68152. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68153. dracoCompression?: DracoCompression;
  68154. /** Defines whether this extension is enabled. */
  68155. enabled: boolean;
  68156. private _loader;
  68157. /** @hidden */
  68158. constructor(loader: GLTFLoader);
  68159. /** @hidden */
  68160. dispose(): void;
  68161. /** @hidden */
  68162. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68163. }
  68164. }
  68165. declare module BABYLON.GLTF2.Loader.Extensions {
  68166. /**
  68167. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68168. */
  68169. export class KHR_lights implements IGLTFLoaderExtension {
  68170. /** The name of this extension. */
  68171. readonly name: string;
  68172. /** Defines whether this extension is enabled. */
  68173. enabled: boolean;
  68174. private _loader;
  68175. private _lights?;
  68176. /** @hidden */
  68177. constructor(loader: GLTFLoader);
  68178. /** @hidden */
  68179. dispose(): void;
  68180. /** @hidden */
  68181. onLoading(): void;
  68182. /** @hidden */
  68183. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68184. }
  68185. }
  68186. declare module BABYLON.GLTF2.Loader.Extensions {
  68187. /**
  68188. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68189. */
  68190. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68191. /** The name of this extension. */
  68192. readonly name: string;
  68193. /** Defines whether this extension is enabled. */
  68194. enabled: boolean;
  68195. private _loader;
  68196. /** @hidden */
  68197. constructor(loader: GLTFLoader);
  68198. /** @hidden */
  68199. dispose(): void;
  68200. /** @hidden */
  68201. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68202. private _loadSpecularGlossinessPropertiesAsync;
  68203. }
  68204. }
  68205. declare module BABYLON.GLTF2.Loader.Extensions {
  68206. /**
  68207. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68208. */
  68209. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68210. /** The name of this extension. */
  68211. readonly name: string;
  68212. /** Defines whether this extension is enabled. */
  68213. enabled: boolean;
  68214. private _loader;
  68215. /** @hidden */
  68216. constructor(loader: GLTFLoader);
  68217. /** @hidden */
  68218. dispose(): void;
  68219. /** @hidden */
  68220. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68221. private _loadUnlitPropertiesAsync;
  68222. }
  68223. }
  68224. declare module BABYLON.GLTF2.Loader.Extensions {
  68225. /**
  68226. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68227. */
  68228. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68229. /** The name of this extension. */
  68230. readonly name: string;
  68231. /** Defines whether this extension is enabled. */
  68232. enabled: boolean;
  68233. private _loader;
  68234. /** @hidden */
  68235. constructor(loader: GLTFLoader);
  68236. /** @hidden */
  68237. dispose(): void;
  68238. /** @hidden */
  68239. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68240. }
  68241. }
  68242. declare module BABYLON.GLTF2.Loader.Extensions {
  68243. /**
  68244. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68245. */
  68246. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68247. /** The name of this extension. */
  68248. readonly name: string;
  68249. /** Defines whether this extension is enabled. */
  68250. enabled: boolean;
  68251. private _loader;
  68252. private _clips;
  68253. private _emitters;
  68254. /** @hidden */
  68255. constructor(loader: GLTFLoader);
  68256. /** @hidden */
  68257. dispose(): void;
  68258. /** @hidden */
  68259. onLoading(): void;
  68260. /** @hidden */
  68261. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68262. /** @hidden */
  68263. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68264. /** @hidden */
  68265. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68266. private _loadClipAsync;
  68267. private _loadEmitterAsync;
  68268. private _getEventAction;
  68269. private _loadAnimationEventAsync;
  68270. }
  68271. }
  68272. declare module BABYLON.GLTF2.Loader.Extensions {
  68273. /**
  68274. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68275. */
  68276. export class MSFT_lod implements IGLTFLoaderExtension {
  68277. /** The name of this extension. */
  68278. readonly name: string;
  68279. /** Defines whether this extension is enabled. */
  68280. enabled: boolean;
  68281. /**
  68282. * Maximum number of LODs to load, starting from the lowest LOD.
  68283. */
  68284. maxLODsToLoad: number;
  68285. /**
  68286. * Observable raised when all node LODs of one level are loaded.
  68287. * The event data is the index of the loaded LOD starting from zero.
  68288. * Dispose the loader to cancel the loading of the next level of LODs.
  68289. */
  68290. onNodeLODsLoadedObservable: Observable<number>;
  68291. /**
  68292. * Observable raised when all material LODs of one level are loaded.
  68293. * The event data is the index of the loaded LOD starting from zero.
  68294. * Dispose the loader to cancel the loading of the next level of LODs.
  68295. */
  68296. onMaterialLODsLoadedObservable: Observable<number>;
  68297. private _loader;
  68298. private _nodeIndexLOD;
  68299. private _nodeSignalLODs;
  68300. private _nodePromiseLODs;
  68301. private _materialIndexLOD;
  68302. private _materialSignalLODs;
  68303. private _materialPromiseLODs;
  68304. /** @hidden */
  68305. constructor(loader: GLTFLoader);
  68306. /** @hidden */
  68307. dispose(): void;
  68308. /** @hidden */
  68309. onReady(): void;
  68310. /** @hidden */
  68311. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68312. /** @hidden */
  68313. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68314. /** @hidden */
  68315. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68316. /**
  68317. * Gets an array of LOD properties from lowest to highest.
  68318. */
  68319. private _getLODs;
  68320. private _disposeUnusedMaterials;
  68321. }
  68322. }
  68323. declare module BABYLON.GLTF2.Loader.Extensions {
  68324. /** @hidden */
  68325. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68326. readonly name: string;
  68327. enabled: boolean;
  68328. private _loader;
  68329. constructor(loader: GLTFLoader);
  68330. dispose(): void;
  68331. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68332. }
  68333. }
  68334. declare module BABYLON.GLTF2.Loader.Extensions {
  68335. /** @hidden */
  68336. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68337. readonly name: string;
  68338. enabled: boolean;
  68339. private _loader;
  68340. constructor(loader: GLTFLoader);
  68341. dispose(): void;
  68342. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68343. }
  68344. }
  68345. declare module BABYLON.GLTF2.Loader.Extensions {
  68346. /**
  68347. * Store glTF extras (if present) in BJS objects' metadata
  68348. */
  68349. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68350. /** The name of this extension. */
  68351. readonly name: string;
  68352. /** Defines whether this extension is enabled. */
  68353. enabled: boolean;
  68354. private _loader;
  68355. private _assignExtras;
  68356. /** @hidden */
  68357. constructor(loader: GLTFLoader);
  68358. /** @hidden */
  68359. dispose(): void;
  68360. /** @hidden */
  68361. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68362. /** @hidden */
  68363. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68364. /** @hidden */
  68365. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68366. }
  68367. }
  68368. declare module BABYLON {
  68369. /**
  68370. * Class reading and parsing the MTL file bundled with the obj file.
  68371. */
  68372. export class MTLFileLoader {
  68373. /**
  68374. * All material loaded from the mtl will be set here
  68375. */
  68376. materials: StandardMaterial[];
  68377. /**
  68378. * This function will read the mtl file and create each material described inside
  68379. * This function could be improve by adding :
  68380. * -some component missing (Ni, Tf...)
  68381. * -including the specific options available
  68382. *
  68383. * @param scene defines the scene the material will be created in
  68384. * @param data defines the mtl data to parse
  68385. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68386. */
  68387. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68388. /**
  68389. * Gets the texture for the material.
  68390. *
  68391. * If the material is imported from input file,
  68392. * We sanitize the url to ensure it takes the textre from aside the material.
  68393. *
  68394. * @param rootUrl The root url to load from
  68395. * @param value The value stored in the mtl
  68396. * @return The Texture
  68397. */
  68398. private static _getTexture;
  68399. }
  68400. /**
  68401. * Options for loading OBJ/MTL files
  68402. */
  68403. type MeshLoadOptions = {
  68404. /**
  68405. * Defines if UVs are optimized by default during load.
  68406. */
  68407. OptimizeWithUV: boolean;
  68408. /**
  68409. * Defines custom scaling of UV coordinates of loaded meshes.
  68410. */
  68411. UVScaling: Vector2;
  68412. /**
  68413. * Invert model on y-axis (does a model scaling inversion)
  68414. */
  68415. InvertY: boolean;
  68416. /**
  68417. * Invert Y-Axis of referenced textures on load
  68418. */
  68419. InvertTextureY: boolean;
  68420. /**
  68421. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68422. */
  68423. ImportVertexColors: boolean;
  68424. /**
  68425. * Compute the normals for the model, even if normals are present in the file.
  68426. */
  68427. ComputeNormals: boolean;
  68428. /**
  68429. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68430. */
  68431. SkipMaterials: boolean;
  68432. /**
  68433. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68434. */
  68435. MaterialLoadingFailsSilently: boolean;
  68436. };
  68437. /**
  68438. * OBJ file type loader.
  68439. * This is a babylon scene loader plugin.
  68440. */
  68441. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68442. /**
  68443. * Defines if UVs are optimized by default during load.
  68444. */
  68445. static OPTIMIZE_WITH_UV: boolean;
  68446. /**
  68447. * Invert model on y-axis (does a model scaling inversion)
  68448. */
  68449. static INVERT_Y: boolean;
  68450. /**
  68451. * Invert Y-Axis of referenced textures on load
  68452. */
  68453. static INVERT_TEXTURE_Y: boolean;
  68454. /**
  68455. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68456. */
  68457. static IMPORT_VERTEX_COLORS: boolean;
  68458. /**
  68459. * Compute the normals for the model, even if normals are present in the file.
  68460. */
  68461. static COMPUTE_NORMALS: boolean;
  68462. /**
  68463. * Defines custom scaling of UV coordinates of loaded meshes.
  68464. */
  68465. static UV_SCALING: Vector2;
  68466. /**
  68467. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68468. */
  68469. static SKIP_MATERIALS: boolean;
  68470. /**
  68471. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68472. *
  68473. * Defaults to true for backwards compatibility.
  68474. */
  68475. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68476. /**
  68477. * Defines the name of the plugin.
  68478. */
  68479. name: string;
  68480. /**
  68481. * Defines the extension the plugin is able to load.
  68482. */
  68483. extensions: string;
  68484. /** @hidden */
  68485. obj: RegExp;
  68486. /** @hidden */
  68487. group: RegExp;
  68488. /** @hidden */
  68489. mtllib: RegExp;
  68490. /** @hidden */
  68491. usemtl: RegExp;
  68492. /** @hidden */
  68493. smooth: RegExp;
  68494. /** @hidden */
  68495. vertexPattern: RegExp;
  68496. /** @hidden */
  68497. normalPattern: RegExp;
  68498. /** @hidden */
  68499. uvPattern: RegExp;
  68500. /** @hidden */
  68501. facePattern1: RegExp;
  68502. /** @hidden */
  68503. facePattern2: RegExp;
  68504. /** @hidden */
  68505. facePattern3: RegExp;
  68506. /** @hidden */
  68507. facePattern4: RegExp;
  68508. /** @hidden */
  68509. facePattern5: RegExp;
  68510. private _meshLoadOptions;
  68511. /**
  68512. * Creates loader for .OBJ files
  68513. *
  68514. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68515. */
  68516. constructor(meshLoadOptions?: MeshLoadOptions);
  68517. private static readonly currentMeshLoadOptions;
  68518. /**
  68519. * Calls synchronously the MTL file attached to this obj.
  68520. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68521. * Without this function materials are not displayed in the first frame (but displayed after).
  68522. * In consequence it is impossible to get material information in your HTML file
  68523. *
  68524. * @param url The URL of the MTL file
  68525. * @param rootUrl
  68526. * @param onSuccess Callback function to be called when the MTL file is loaded
  68527. * @private
  68528. */
  68529. private _loadMTL;
  68530. /**
  68531. * Instantiates a OBJ file loader plugin.
  68532. * @returns the created plugin
  68533. */
  68534. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68535. /**
  68536. * If the data string can be loaded directly.
  68537. *
  68538. * @param data string containing the file data
  68539. * @returns if the data can be loaded directly
  68540. */
  68541. canDirectLoad(data: string): boolean;
  68542. /**
  68543. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68544. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68545. * @param scene the scene the meshes should be added to
  68546. * @param data the OBJ data to load
  68547. * @param rootUrl root url to load from
  68548. * @param onProgress event that fires when loading progress has occured
  68549. * @param fileName Defines the name of the file to load
  68550. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68551. */
  68552. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68553. meshes: AbstractMesh[];
  68554. particleSystems: IParticleSystem[];
  68555. skeletons: Skeleton[];
  68556. animationGroups: AnimationGroup[];
  68557. }>;
  68558. /**
  68559. * Imports all objects from the loaded OBJ data and adds them to the scene
  68560. * @param scene the scene the objects should be added to
  68561. * @param data the OBJ data to load
  68562. * @param rootUrl root url to load from
  68563. * @param onProgress event that fires when loading progress has occured
  68564. * @param fileName Defines the name of the file to load
  68565. * @returns a promise which completes when objects have been loaded to the scene
  68566. */
  68567. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68568. /**
  68569. * Load into an asset container.
  68570. * @param scene The scene to load into
  68571. * @param data The data to import
  68572. * @param rootUrl The root url for scene and resources
  68573. * @param onProgress The callback when the load progresses
  68574. * @param fileName Defines the name of the file to load
  68575. * @returns The loaded asset container
  68576. */
  68577. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68578. /**
  68579. * Read the OBJ file and create an Array of meshes.
  68580. * Each mesh contains all information given by the OBJ and the MTL file.
  68581. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68582. *
  68583. * @param meshesNames
  68584. * @param scene Scene The scene where are displayed the data
  68585. * @param data String The content of the obj file
  68586. * @param rootUrl String The path to the folder
  68587. * @returns Array<AbstractMesh>
  68588. * @private
  68589. */
  68590. private _parseSolid;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * STL file type loader.
  68596. * This is a babylon scene loader plugin.
  68597. */
  68598. export class STLFileLoader implements ISceneLoaderPlugin {
  68599. /** @hidden */
  68600. solidPattern: RegExp;
  68601. /** @hidden */
  68602. facetsPattern: RegExp;
  68603. /** @hidden */
  68604. normalPattern: RegExp;
  68605. /** @hidden */
  68606. vertexPattern: RegExp;
  68607. /**
  68608. * Defines the name of the plugin.
  68609. */
  68610. name: string;
  68611. /**
  68612. * Defines the extensions the stl loader is able to load.
  68613. * force data to come in as an ArrayBuffer
  68614. * we'll convert to string if it looks like it's an ASCII .stl
  68615. */
  68616. extensions: ISceneLoaderPluginExtensions;
  68617. /**
  68618. * Import meshes into a scene.
  68619. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68620. * @param scene The scene to import into
  68621. * @param data The data to import
  68622. * @param rootUrl The root url for scene and resources
  68623. * @param meshes The meshes array to import into
  68624. * @param particleSystems The particle systems array to import into
  68625. * @param skeletons The skeletons array to import into
  68626. * @param onError The callback when import fails
  68627. * @returns True if successful or false otherwise
  68628. */
  68629. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68630. /**
  68631. * Load into a scene.
  68632. * @param scene The scene to load into
  68633. * @param data The data to import
  68634. * @param rootUrl The root url for scene and resources
  68635. * @param onError The callback when import fails
  68636. * @returns true if successful or false otherwise
  68637. */
  68638. load(scene: Scene, data: any, rootUrl: string): boolean;
  68639. /**
  68640. * Load into an asset container.
  68641. * @param scene The scene to load into
  68642. * @param data The data to import
  68643. * @param rootUrl The root url for scene and resources
  68644. * @param onError The callback when import fails
  68645. * @returns The loaded asset container
  68646. */
  68647. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68648. private _isBinary;
  68649. private _parseBinary;
  68650. private _parseASCII;
  68651. }
  68652. }
  68653. declare module BABYLON {
  68654. /**
  68655. * Class for generating OBJ data from a Babylon scene.
  68656. */
  68657. export class OBJExport {
  68658. /**
  68659. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68660. * @param mesh defines the list of meshes to serialize
  68661. * @param materials defines if materials should be exported
  68662. * @param matlibname defines the name of the associated mtl file
  68663. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68664. * @returns the OBJ content
  68665. */
  68666. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68667. /**
  68668. * Exports the material(s) of a mesh in .MTL file format (text)
  68669. * @param mesh defines the mesh to extract the material from
  68670. * @returns the mtl content
  68671. */
  68672. static MTL(mesh: Mesh): string;
  68673. }
  68674. }
  68675. declare module BABYLON {
  68676. /** @hidden */
  68677. export var __IGLTFExporterExtension: number;
  68678. /**
  68679. * Interface for extending the exporter
  68680. * @hidden
  68681. */
  68682. export interface IGLTFExporterExtension {
  68683. /**
  68684. * The name of this extension
  68685. */
  68686. readonly name: string;
  68687. /**
  68688. * Defines whether this extension is enabled
  68689. */
  68690. enabled: boolean;
  68691. /**
  68692. * Defines whether this extension is required
  68693. */
  68694. required: boolean;
  68695. }
  68696. }
  68697. declare module BABYLON.GLTF2.Exporter {
  68698. /** @hidden */
  68699. export var __IGLTFExporterExtensionV2: number;
  68700. /**
  68701. * Interface for a glTF exporter extension
  68702. * @hidden
  68703. */
  68704. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68705. /**
  68706. * Define this method to modify the default behavior before exporting a texture
  68707. * @param context The context when loading the asset
  68708. * @param babylonTexture The glTF texture info property
  68709. * @param mimeType The mime-type of the generated image
  68710. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68711. */
  68712. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68713. /**
  68714. * Define this method to modify the default behavior when exporting texture info
  68715. * @param context The context when loading the asset
  68716. * @param meshPrimitive glTF mesh primitive
  68717. * @param babylonSubMesh Babylon submesh
  68718. * @param binaryWriter glTF serializer binary writer instance
  68719. * @returns nullable IMeshPrimitive promise
  68720. */
  68721. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68722. /**
  68723. * Define this method to modify the default behavior when exporting a node
  68724. * @param context The context when exporting the node
  68725. * @param node glTF node
  68726. * @param babylonNode BabylonJS node
  68727. * @returns nullable INode promise
  68728. */
  68729. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68730. /**
  68731. * Called after the exporter state changes to EXPORTING
  68732. */
  68733. onExporting?(): void;
  68734. }
  68735. }
  68736. declare module BABYLON.GLTF2.Exporter {
  68737. /**
  68738. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68739. * @hidden
  68740. */
  68741. export class _GLTFMaterialExporter {
  68742. /**
  68743. * Represents the dielectric specular values for R, G and B
  68744. */
  68745. private static readonly _DielectricSpecular;
  68746. /**
  68747. * Allows the maximum specular power to be defined for material calculations
  68748. */
  68749. private static readonly _MaxSpecularPower;
  68750. /**
  68751. * Mapping to store textures
  68752. */
  68753. private _textureMap;
  68754. /**
  68755. * Numeric tolerance value
  68756. */
  68757. private static readonly _Epsilon;
  68758. /**
  68759. * Reference to the glTF Exporter
  68760. */
  68761. private _exporter;
  68762. constructor(exporter: _Exporter);
  68763. /**
  68764. * Specifies if two colors are approximately equal in value
  68765. * @param color1 first color to compare to
  68766. * @param color2 second color to compare to
  68767. * @param epsilon threshold value
  68768. */
  68769. private static FuzzyEquals;
  68770. /**
  68771. * Gets the materials from a Babylon scene and converts them to glTF materials
  68772. * @param scene babylonjs scene
  68773. * @param mimeType texture mime type
  68774. * @param images array of images
  68775. * @param textures array of textures
  68776. * @param materials array of materials
  68777. * @param imageData mapping of texture names to base64 textures
  68778. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68779. */
  68780. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68781. /**
  68782. * Makes a copy of the glTF material without the texture parameters
  68783. * @param originalMaterial original glTF material
  68784. * @returns glTF material without texture parameters
  68785. */
  68786. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68787. /**
  68788. * Specifies if the material has any texture parameters present
  68789. * @param material glTF Material
  68790. * @returns boolean specifying if texture parameters are present
  68791. */
  68792. _hasTexturesPresent(material: IMaterial): boolean;
  68793. /**
  68794. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68795. * @param babylonStandardMaterial
  68796. * @returns glTF Metallic Roughness Material representation
  68797. */
  68798. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68799. /**
  68800. * Computes the metallic factor
  68801. * @param diffuse diffused value
  68802. * @param specular specular value
  68803. * @param oneMinusSpecularStrength one minus the specular strength
  68804. * @returns metallic value
  68805. */
  68806. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68807. /**
  68808. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68809. * @param glTFMaterial glTF material
  68810. * @param babylonMaterial Babylon material
  68811. */
  68812. private static _SetAlphaMode;
  68813. /**
  68814. * Converts a Babylon Standard Material to a glTF Material
  68815. * @param babylonStandardMaterial BJS Standard Material
  68816. * @param mimeType mime type to use for the textures
  68817. * @param images array of glTF image interfaces
  68818. * @param textures array of glTF texture interfaces
  68819. * @param materials array of glTF material interfaces
  68820. * @param imageData map of image file name to data
  68821. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68822. */
  68823. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68824. /**
  68825. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68826. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68827. * @param mimeType mime type to use for the textures
  68828. * @param images array of glTF image interfaces
  68829. * @param textures array of glTF texture interfaces
  68830. * @param materials array of glTF material interfaces
  68831. * @param imageData map of image file name to data
  68832. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68833. */
  68834. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68835. /**
  68836. * Converts an image typed array buffer to a base64 image
  68837. * @param buffer typed array buffer
  68838. * @param width width of the image
  68839. * @param height height of the image
  68840. * @param mimeType mimetype of the image
  68841. * @returns base64 image string
  68842. */
  68843. private _createBase64FromCanvasAsync;
  68844. /**
  68845. * Generates a white texture based on the specified width and height
  68846. * @param width width of the texture in pixels
  68847. * @param height height of the texture in pixels
  68848. * @param scene babylonjs scene
  68849. * @returns white texture
  68850. */
  68851. private _createWhiteTexture;
  68852. /**
  68853. * 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
  68854. * @param texture1 first texture to resize
  68855. * @param texture2 second texture to resize
  68856. * @param scene babylonjs scene
  68857. * @returns resized textures or null
  68858. */
  68859. private _resizeTexturesToSameDimensions;
  68860. /**
  68861. * Converts an array of pixels to a Float32Array
  68862. * Throws an error if the pixel format is not supported
  68863. * @param pixels - array buffer containing pixel values
  68864. * @returns Float32 of pixels
  68865. */
  68866. private _convertPixelArrayToFloat32;
  68867. /**
  68868. * Convert Specular Glossiness Textures to Metallic Roughness
  68869. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68870. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68871. * @param diffuseTexture texture used to store diffuse information
  68872. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68873. * @param factors specular glossiness material factors
  68874. * @param mimeType the mime type to use for the texture
  68875. * @returns pbr metallic roughness interface or null
  68876. */
  68877. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68878. /**
  68879. * Converts specular glossiness material properties to metallic roughness
  68880. * @param specularGlossiness interface with specular glossiness material properties
  68881. * @returns interface with metallic roughness material properties
  68882. */
  68883. private _convertSpecularGlossinessToMetallicRoughness;
  68884. /**
  68885. * Calculates the surface reflectance, independent of lighting conditions
  68886. * @param color Color source to calculate brightness from
  68887. * @returns number representing the perceived brightness, or zero if color is undefined
  68888. */
  68889. private _getPerceivedBrightness;
  68890. /**
  68891. * Returns the maximum color component value
  68892. * @param color
  68893. * @returns maximum color component value, or zero if color is null or undefined
  68894. */
  68895. private _getMaxComponent;
  68896. /**
  68897. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68898. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68899. * @param mimeType mime type to use for the textures
  68900. * @param images array of glTF image interfaces
  68901. * @param textures array of glTF texture interfaces
  68902. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68903. * @param imageData map of image file name to data
  68904. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68905. * @returns glTF PBR Metallic Roughness factors
  68906. */
  68907. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68908. private _getGLTFTextureSampler;
  68909. private _getGLTFTextureWrapMode;
  68910. private _getGLTFTextureWrapModesSampler;
  68911. /**
  68912. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68913. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68914. * @param mimeType mime type to use for the textures
  68915. * @param images array of glTF image interfaces
  68916. * @param textures array of glTF texture interfaces
  68917. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68918. * @param imageData map of image file name to data
  68919. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68920. * @returns glTF PBR Metallic Roughness factors
  68921. */
  68922. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68923. /**
  68924. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68925. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68926. * @param mimeType mime type to use for the textures
  68927. * @param images array of glTF image interfaces
  68928. * @param textures array of glTF texture interfaces
  68929. * @param materials array of glTF material interfaces
  68930. * @param imageData map of image file name to data
  68931. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68932. */
  68933. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68934. private setMetallicRoughnessPbrMaterial;
  68935. private getPixelsFromTexture;
  68936. /**
  68937. * Extracts a texture from a Babylon texture into file data and glTF data
  68938. * @param babylonTexture Babylon texture to extract
  68939. * @param mimeType Mime Type of the babylonTexture
  68940. * @return glTF texture info, or null if the texture format is not supported
  68941. */
  68942. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68943. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68944. /**
  68945. * Builds a texture from base64 string
  68946. * @param base64Texture base64 texture string
  68947. * @param baseTextureName Name to use for the texture
  68948. * @param mimeType image mime type for the texture
  68949. * @param images array of images
  68950. * @param textures array of textures
  68951. * @param imageData map of image data
  68952. * @returns glTF texture info, or null if the texture format is not supported
  68953. */
  68954. private _getTextureInfoFromBase64;
  68955. }
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * Class for holding and downloading glTF file data
  68960. */
  68961. export class GLTFData {
  68962. /**
  68963. * Object which contains the file name as the key and its data as the value
  68964. */
  68965. glTFFiles: {
  68966. [fileName: string]: string | Blob;
  68967. };
  68968. /**
  68969. * Initializes the glTF file object
  68970. */
  68971. constructor();
  68972. /**
  68973. * Downloads the glTF data as files based on their names and data
  68974. */
  68975. downloadFiles(): void;
  68976. }
  68977. }
  68978. declare module BABYLON {
  68979. /**
  68980. * Holds a collection of exporter options and parameters
  68981. */
  68982. export interface IExportOptions {
  68983. /**
  68984. * Function which indicates whether a babylon node should be exported or not
  68985. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68986. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68987. */
  68988. shouldExportNode?(node: Node): boolean;
  68989. /**
  68990. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68991. * @param metadata source metadata to read from
  68992. * @returns the data to store to glTF node extras
  68993. */
  68994. metadataSelector?(metadata: any): any;
  68995. /**
  68996. * The sample rate to bake animation curves
  68997. */
  68998. animationSampleRate?: number;
  68999. /**
  69000. * Begin serialization without waiting for the scene to be ready
  69001. */
  69002. exportWithoutWaitingForScene?: boolean;
  69003. }
  69004. /**
  69005. * Class for generating glTF data from a Babylon scene.
  69006. */
  69007. export class GLTF2Export {
  69008. /**
  69009. * Exports the geometry of the scene to .gltf file format asynchronously
  69010. * @param scene Babylon scene with scene hierarchy information
  69011. * @param filePrefix File prefix to use when generating the glTF file
  69012. * @param options Exporter options
  69013. * @returns Returns an object with a .gltf file and associates texture names
  69014. * as keys and their data and paths as values
  69015. */
  69016. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69017. private static _PreExportAsync;
  69018. private static _PostExportAsync;
  69019. /**
  69020. * Exports the geometry of the scene to .glb file format asychronously
  69021. * @param scene Babylon scene with scene hierarchy information
  69022. * @param filePrefix File prefix to use when generating glb file
  69023. * @param options Exporter options
  69024. * @returns Returns an object with a .glb filename as key and data as value
  69025. */
  69026. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69027. }
  69028. }
  69029. declare module BABYLON.GLTF2.Exporter {
  69030. /**
  69031. * @hidden
  69032. */
  69033. export class _GLTFUtilities {
  69034. /**
  69035. * Creates a buffer view based on the supplied arguments
  69036. * @param bufferIndex index value of the specified buffer
  69037. * @param byteOffset byte offset value
  69038. * @param byteLength byte length of the bufferView
  69039. * @param byteStride byte distance between conequential elements
  69040. * @param name name of the buffer view
  69041. * @returns bufferView for glTF
  69042. */
  69043. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69044. /**
  69045. * Creates an accessor based on the supplied arguments
  69046. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69047. * @param name The name of the accessor
  69048. * @param type The type of the accessor
  69049. * @param componentType The datatype of components in the attribute
  69050. * @param count The number of attributes referenced by this accessor
  69051. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69052. * @param min Minimum value of each component in this attribute
  69053. * @param max Maximum value of each component in this attribute
  69054. * @returns accessor for glTF
  69055. */
  69056. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69057. /**
  69058. * Calculates the minimum and maximum values of an array of position floats
  69059. * @param positions Positions array of a mesh
  69060. * @param vertexStart Starting vertex offset to calculate min and max values
  69061. * @param vertexCount Number of vertices to check for min and max values
  69062. * @returns min number array and max number array
  69063. */
  69064. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69065. min: number[];
  69066. max: number[];
  69067. };
  69068. /**
  69069. * Converts a new right-handed Vector3
  69070. * @param vector vector3 array
  69071. * @returns right-handed Vector3
  69072. */
  69073. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69074. /**
  69075. * Converts a Vector3 to right-handed
  69076. * @param vector Vector3 to convert to right-handed
  69077. */
  69078. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69079. /**
  69080. * Converts a three element number array to right-handed
  69081. * @param vector number array to convert to right-handed
  69082. */
  69083. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69084. /**
  69085. * Converts a new right-handed Vector3
  69086. * @param vector vector3 array
  69087. * @returns right-handed Vector3
  69088. */
  69089. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69090. /**
  69091. * Converts a Vector3 to right-handed
  69092. * @param vector Vector3 to convert to right-handed
  69093. */
  69094. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69095. /**
  69096. * Converts a three element number array to right-handed
  69097. * @param vector number array to convert to right-handed
  69098. */
  69099. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69100. /**
  69101. * Converts a Vector4 to right-handed
  69102. * @param vector Vector4 to convert to right-handed
  69103. */
  69104. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69105. /**
  69106. * Converts a Vector4 to right-handed
  69107. * @param vector Vector4 to convert to right-handed
  69108. */
  69109. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69110. /**
  69111. * Converts a Quaternion to right-handed
  69112. * @param quaternion Source quaternion to convert to right-handed
  69113. */
  69114. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69115. /**
  69116. * Converts a Quaternion to right-handed
  69117. * @param quaternion Source quaternion to convert to right-handed
  69118. */
  69119. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69120. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69121. }
  69122. }
  69123. declare module BABYLON.GLTF2.Exporter {
  69124. /**
  69125. * Converts Babylon Scene into glTF 2.0.
  69126. * @hidden
  69127. */
  69128. export class _Exporter {
  69129. /**
  69130. * Stores the glTF to export
  69131. */
  69132. _glTF: IGLTF;
  69133. /**
  69134. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69135. */
  69136. _bufferViews: IBufferView[];
  69137. /**
  69138. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69139. */
  69140. _accessors: IAccessor[];
  69141. /**
  69142. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69143. */
  69144. private _nodes;
  69145. /**
  69146. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69147. */
  69148. private _scenes;
  69149. /**
  69150. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69151. */
  69152. private _meshes;
  69153. /**
  69154. * Stores all the generated material information, which represents the appearance of each primitive
  69155. */
  69156. _materials: IMaterial[];
  69157. _materialMap: {
  69158. [materialID: number]: number;
  69159. };
  69160. /**
  69161. * Stores all the generated texture information, which is referenced by glTF materials
  69162. */
  69163. _textures: ITexture[];
  69164. /**
  69165. * Stores all the generated image information, which is referenced by glTF textures
  69166. */
  69167. _images: IImage[];
  69168. /**
  69169. * Stores all the texture samplers
  69170. */
  69171. _samplers: ISampler[];
  69172. /**
  69173. * Stores all the generated animation samplers, which is referenced by glTF animations
  69174. */
  69175. /**
  69176. * Stores the animations for glTF models
  69177. */
  69178. private _animations;
  69179. /**
  69180. * Stores the total amount of bytes stored in the glTF buffer
  69181. */
  69182. private _totalByteLength;
  69183. /**
  69184. * Stores a reference to the Babylon scene containing the source geometry and material information
  69185. */
  69186. _babylonScene: Scene;
  69187. /**
  69188. * Stores a map of the image data, where the key is the file name and the value
  69189. * is the image data
  69190. */
  69191. _imageData: {
  69192. [fileName: string]: {
  69193. data: Uint8Array;
  69194. mimeType: ImageMimeType;
  69195. };
  69196. };
  69197. /**
  69198. * Stores a map of the unique id of a node to its index in the node array
  69199. */
  69200. private _nodeMap;
  69201. /**
  69202. * Specifies if the Babylon scene should be converted to right-handed on export
  69203. */
  69204. _convertToRightHandedSystem: boolean;
  69205. /**
  69206. * Baked animation sample rate
  69207. */
  69208. private _animationSampleRate;
  69209. private _options;
  69210. private _localEngine;
  69211. _glTFMaterialExporter: _GLTFMaterialExporter;
  69212. private _extensions;
  69213. private static _ExtensionNames;
  69214. private static _ExtensionFactories;
  69215. private _applyExtensions;
  69216. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69217. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69218. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69219. private _forEachExtensions;
  69220. private _extensionsOnExporting;
  69221. /**
  69222. * Load glTF serializer extensions
  69223. */
  69224. private _loadExtensions;
  69225. /**
  69226. * Creates a glTF Exporter instance, which can accept optional exporter options
  69227. * @param babylonScene Babylon scene object
  69228. * @param options Options to modify the behavior of the exporter
  69229. */
  69230. constructor(babylonScene: Scene, options?: IExportOptions);
  69231. /**
  69232. * Registers a glTF exporter extension
  69233. * @param name Name of the extension to export
  69234. * @param factory The factory function that creates the exporter extension
  69235. */
  69236. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69237. /**
  69238. * Un-registers an exporter extension
  69239. * @param name The name fo the exporter extension
  69240. * @returns A boolean indicating whether the extension has been un-registered
  69241. */
  69242. static UnregisterExtension(name: string): boolean;
  69243. /**
  69244. * Lazy load a local engine with premultiplied alpha set to false
  69245. */
  69246. _getLocalEngine(): Engine;
  69247. private reorderIndicesBasedOnPrimitiveMode;
  69248. /**
  69249. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69250. * clock-wise during export to glTF
  69251. * @param submesh BabylonJS submesh
  69252. * @param primitiveMode Primitive mode of the mesh
  69253. * @param sideOrientation the winding order of the submesh
  69254. * @param vertexBufferKind The type of vertex attribute
  69255. * @param meshAttributeArray The vertex attribute data
  69256. * @param byteOffset The offset to the binary data
  69257. * @param binaryWriter The binary data for the glTF file
  69258. */
  69259. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69260. /**
  69261. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69262. * clock-wise during export to glTF
  69263. * @param submesh BabylonJS submesh
  69264. * @param primitiveMode Primitive mode of the mesh
  69265. * @param sideOrientation the winding order of the submesh
  69266. * @param vertexBufferKind The type of vertex attribute
  69267. * @param meshAttributeArray The vertex attribute data
  69268. * @param byteOffset The offset to the binary data
  69269. * @param binaryWriter The binary data for the glTF file
  69270. */
  69271. private reorderTriangleFillMode;
  69272. /**
  69273. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69274. * clock-wise during export to glTF
  69275. * @param submesh BabylonJS submesh
  69276. * @param primitiveMode Primitive mode of the mesh
  69277. * @param sideOrientation the winding order of the submesh
  69278. * @param vertexBufferKind The type of vertex attribute
  69279. * @param meshAttributeArray The vertex attribute data
  69280. * @param byteOffset The offset to the binary data
  69281. * @param binaryWriter The binary data for the glTF file
  69282. */
  69283. private reorderTriangleStripDrawMode;
  69284. /**
  69285. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69286. * clock-wise during export to glTF
  69287. * @param submesh BabylonJS submesh
  69288. * @param primitiveMode Primitive mode of the mesh
  69289. * @param sideOrientation the winding order of the submesh
  69290. * @param vertexBufferKind The type of vertex attribute
  69291. * @param meshAttributeArray The vertex attribute data
  69292. * @param byteOffset The offset to the binary data
  69293. * @param binaryWriter The binary data for the glTF file
  69294. */
  69295. private reorderTriangleFanMode;
  69296. /**
  69297. * Writes the vertex attribute data to binary
  69298. * @param vertices The vertices to write to the binary writer
  69299. * @param byteOffset The offset into the binary writer to overwrite binary data
  69300. * @param vertexAttributeKind The vertex attribute type
  69301. * @param meshAttributeArray The vertex attribute data
  69302. * @param binaryWriter The writer containing the binary data
  69303. */
  69304. private writeVertexAttributeData;
  69305. /**
  69306. * Writes mesh attribute data to a data buffer
  69307. * Returns the bytelength of the data
  69308. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69309. * @param meshAttributeArray Array containing the attribute data
  69310. * @param binaryWriter The buffer to write the binary data to
  69311. * @param indices Used to specify the order of the vertex data
  69312. */
  69313. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69314. /**
  69315. * Generates glTF json data
  69316. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69317. * @param glTFPrefix Text to use when prefixing a glTF file
  69318. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69319. * @returns json data as string
  69320. */
  69321. private generateJSON;
  69322. /**
  69323. * Generates data for .gltf and .bin files based on the glTF prefix string
  69324. * @param glTFPrefix Text to use when prefixing a glTF file
  69325. * @returns GLTFData with glTF file data
  69326. */
  69327. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69328. /**
  69329. * Creates a binary buffer for glTF
  69330. * @returns array buffer for binary data
  69331. */
  69332. private _generateBinaryAsync;
  69333. /**
  69334. * Pads the number to a multiple of 4
  69335. * @param num number to pad
  69336. * @returns padded number
  69337. */
  69338. private _getPadding;
  69339. /**
  69340. * Generates a glb file from the json and binary data
  69341. * Returns an object with the glb file name as the key and data as the value
  69342. * @param glTFPrefix
  69343. * @returns object with glb filename as key and data as value
  69344. */
  69345. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69346. /**
  69347. * Sets the TRS for each node
  69348. * @param node glTF Node for storing the transformation data
  69349. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69350. */
  69351. private setNodeTransformation;
  69352. private getVertexBufferFromMesh;
  69353. /**
  69354. * Creates a bufferview based on the vertices type for the Babylon mesh
  69355. * @param kind Indicates the type of vertices data
  69356. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69357. * @param binaryWriter The buffer to write the bufferview data to
  69358. */
  69359. private createBufferViewKind;
  69360. /**
  69361. * The primitive mode of the Babylon mesh
  69362. * @param babylonMesh The BabylonJS mesh
  69363. */
  69364. private getMeshPrimitiveMode;
  69365. /**
  69366. * Sets the primitive mode of the glTF mesh primitive
  69367. * @param meshPrimitive glTF mesh primitive
  69368. * @param primitiveMode The primitive mode
  69369. */
  69370. private setPrimitiveMode;
  69371. /**
  69372. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69373. * @param meshPrimitive glTF mesh primitive
  69374. * @param attributeKind vertex attribute
  69375. * @returns boolean specifying if uv coordinates are present
  69376. */
  69377. private setAttributeKind;
  69378. /**
  69379. * Sets data for the primitive attributes of each submesh
  69380. * @param mesh glTF Mesh object to store the primitive attribute information
  69381. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69382. * @param binaryWriter Buffer to write the attribute data to
  69383. */
  69384. private setPrimitiveAttributesAsync;
  69385. /**
  69386. * Creates a glTF scene based on the array of meshes
  69387. * Returns the the total byte offset
  69388. * @param babylonScene Babylon scene to get the mesh data from
  69389. * @param binaryWriter Buffer to write binary data to
  69390. */
  69391. private createSceneAsync;
  69392. /**
  69393. * Creates a mapping of Node unique id to node index and handles animations
  69394. * @param babylonScene Babylon Scene
  69395. * @param nodes Babylon transform nodes
  69396. * @param binaryWriter Buffer to write binary data to
  69397. * @returns Node mapping of unique id to index
  69398. */
  69399. private createNodeMapAndAnimationsAsync;
  69400. /**
  69401. * Creates a glTF node from a Babylon mesh
  69402. * @param babylonMesh Source Babylon mesh
  69403. * @param binaryWriter Buffer for storing geometry data
  69404. * @returns glTF node
  69405. */
  69406. private createNodeAsync;
  69407. }
  69408. /**
  69409. * @hidden
  69410. *
  69411. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69412. */
  69413. export class _BinaryWriter {
  69414. /**
  69415. * Array buffer which stores all binary data
  69416. */
  69417. private _arrayBuffer;
  69418. /**
  69419. * View of the array buffer
  69420. */
  69421. private _dataView;
  69422. /**
  69423. * byte offset of data in array buffer
  69424. */
  69425. private _byteOffset;
  69426. /**
  69427. * Initialize binary writer with an initial byte length
  69428. * @param byteLength Initial byte length of the array buffer
  69429. */
  69430. constructor(byteLength: number);
  69431. /**
  69432. * Resize the array buffer to the specified byte length
  69433. * @param byteLength
  69434. */
  69435. private resizeBuffer;
  69436. /**
  69437. * Get an array buffer with the length of the byte offset
  69438. * @returns ArrayBuffer resized to the byte offset
  69439. */
  69440. getArrayBuffer(): ArrayBuffer;
  69441. /**
  69442. * Get the byte offset of the array buffer
  69443. * @returns byte offset
  69444. */
  69445. getByteOffset(): number;
  69446. /**
  69447. * Stores an UInt8 in the array buffer
  69448. * @param entry
  69449. * @param byteOffset If defined, specifies where to set the value as an offset.
  69450. */
  69451. setUInt8(entry: number, byteOffset?: number): void;
  69452. /**
  69453. * Gets an UInt32 in the array buffer
  69454. * @param entry
  69455. * @param byteOffset If defined, specifies where to set the value as an offset.
  69456. */
  69457. getUInt32(byteOffset: number): number;
  69458. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69459. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69460. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69461. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69462. /**
  69463. * Stores a Float32 in the array buffer
  69464. * @param entry
  69465. */
  69466. setFloat32(entry: number, byteOffset?: number): void;
  69467. /**
  69468. * Stores an UInt32 in the array buffer
  69469. * @param entry
  69470. * @param byteOffset If defined, specifies where to set the value as an offset.
  69471. */
  69472. setUInt32(entry: number, byteOffset?: number): void;
  69473. }
  69474. }
  69475. declare module BABYLON.GLTF2.Exporter {
  69476. /**
  69477. * @hidden
  69478. * Interface to store animation data.
  69479. */
  69480. export interface _IAnimationData {
  69481. /**
  69482. * Keyframe data.
  69483. */
  69484. inputs: number[];
  69485. /**
  69486. * Value data.
  69487. */
  69488. outputs: number[][];
  69489. /**
  69490. * Animation interpolation data.
  69491. */
  69492. samplerInterpolation: AnimationSamplerInterpolation;
  69493. /**
  69494. * Minimum keyframe value.
  69495. */
  69496. inputsMin: number;
  69497. /**
  69498. * Maximum keyframe value.
  69499. */
  69500. inputsMax: number;
  69501. }
  69502. /**
  69503. * @hidden
  69504. */
  69505. export interface _IAnimationInfo {
  69506. /**
  69507. * The target channel for the animation
  69508. */
  69509. animationChannelTargetPath: AnimationChannelTargetPath;
  69510. /**
  69511. * The glTF accessor type for the data.
  69512. */
  69513. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69514. /**
  69515. * Specifies if quaternions should be used.
  69516. */
  69517. useQuaternion: boolean;
  69518. }
  69519. /**
  69520. * @hidden
  69521. * Utility class for generating glTF animation data from BabylonJS.
  69522. */
  69523. export class _GLTFAnimation {
  69524. /**
  69525. * @ignore
  69526. *
  69527. * Creates glTF channel animation from BabylonJS animation.
  69528. * @param babylonTransformNode - BabylonJS mesh.
  69529. * @param animation - animation.
  69530. * @param animationChannelTargetPath - The target animation channel.
  69531. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69532. * @param useQuaternion - Specifies if quaternions are used.
  69533. * @returns nullable IAnimationData
  69534. */
  69535. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69536. private static _DeduceAnimationInfo;
  69537. /**
  69538. * @ignore
  69539. * Create node animations from the transform node animations
  69540. * @param babylonNode
  69541. * @param runtimeGLTFAnimation
  69542. * @param idleGLTFAnimations
  69543. * @param nodeMap
  69544. * @param nodes
  69545. * @param binaryWriter
  69546. * @param bufferViews
  69547. * @param accessors
  69548. * @param convertToRightHandedSystem
  69549. */
  69550. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69551. [key: number]: number;
  69552. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69553. /**
  69554. * @ignore
  69555. * Create node animations from the animation groups
  69556. * @param babylonScene
  69557. * @param glTFAnimations
  69558. * @param nodeMap
  69559. * @param nodes
  69560. * @param binaryWriter
  69561. * @param bufferViews
  69562. * @param accessors
  69563. * @param convertToRightHandedSystem
  69564. */
  69565. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69566. [key: number]: number;
  69567. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69568. private static AddAnimation;
  69569. /**
  69570. * Create a baked animation
  69571. * @param babylonTransformNode BabylonJS mesh
  69572. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69573. * @param animationChannelTargetPath animation target channel
  69574. * @param minFrame minimum animation frame
  69575. * @param maxFrame maximum animation frame
  69576. * @param fps frames per second of the animation
  69577. * @param inputs input key frames of the animation
  69578. * @param outputs output key frame data of the animation
  69579. * @param convertToRightHandedSystem converts the values to right-handed
  69580. * @param useQuaternion specifies if quaternions should be used
  69581. */
  69582. private static _CreateBakedAnimation;
  69583. private static _ConvertFactorToVector3OrQuaternion;
  69584. private static _SetInterpolatedValue;
  69585. /**
  69586. * Creates linear animation from the animation key frames
  69587. * @param babylonTransformNode BabylonJS mesh
  69588. * @param animation BabylonJS animation
  69589. * @param animationChannelTargetPath The target animation channel
  69590. * @param frameDelta The difference between the last and first frame of the animation
  69591. * @param inputs Array to store the key frame times
  69592. * @param outputs Array to store the key frame data
  69593. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69594. * @param useQuaternion Specifies if quaternions are used in the animation
  69595. */
  69596. private static _CreateLinearOrStepAnimation;
  69597. /**
  69598. * Creates cubic spline animation from the animation key frames
  69599. * @param babylonTransformNode BabylonJS mesh
  69600. * @param animation BabylonJS animation
  69601. * @param animationChannelTargetPath The target animation channel
  69602. * @param frameDelta The difference between the last and first frame of the animation
  69603. * @param inputs Array to store the key frame times
  69604. * @param outputs Array to store the key frame data
  69605. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69606. * @param useQuaternion Specifies if quaternions are used in the animation
  69607. */
  69608. private static _CreateCubicSplineAnimation;
  69609. private static _GetBasePositionRotationOrScale;
  69610. /**
  69611. * Adds a key frame value
  69612. * @param keyFrame
  69613. * @param animation
  69614. * @param outputs
  69615. * @param animationChannelTargetPath
  69616. * @param basePositionRotationOrScale
  69617. * @param convertToRightHandedSystem
  69618. * @param useQuaternion
  69619. */
  69620. private static _AddKeyframeValue;
  69621. /**
  69622. * Determine the interpolation based on the key frames
  69623. * @param keyFrames
  69624. * @param animationChannelTargetPath
  69625. * @param useQuaternion
  69626. */
  69627. private static _DeduceInterpolation;
  69628. /**
  69629. * Adds an input tangent or output tangent to the output data
  69630. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69631. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69632. * @param outputs The animation data by keyframe
  69633. * @param animationChannelTargetPath The target animation channel
  69634. * @param interpolation The interpolation type
  69635. * @param keyFrame The key frame with the animation data
  69636. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69637. * @param useQuaternion Specifies if quaternions are used
  69638. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69639. */
  69640. private static AddSplineTangent;
  69641. /**
  69642. * Get the minimum and maximum key frames' frame values
  69643. * @param keyFrames animation key frames
  69644. * @returns the minimum and maximum key frame value
  69645. */
  69646. private static calculateMinMaxKeyFrames;
  69647. }
  69648. }
  69649. declare module BABYLON.GLTF2.Exporter {
  69650. /** @hidden */
  69651. export var textureTransformPixelShader: {
  69652. name: string;
  69653. shader: string;
  69654. };
  69655. }
  69656. declare module BABYLON.GLTF2.Exporter.Extensions {
  69657. /**
  69658. * @hidden
  69659. */
  69660. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69661. /** Name of this extension */
  69662. readonly name: string;
  69663. /** Defines whether this extension is enabled */
  69664. enabled: boolean;
  69665. /** Defines whether this extension is required */
  69666. required: boolean;
  69667. /** Reference to the glTF exporter */
  69668. private _exporter;
  69669. constructor(exporter: _Exporter);
  69670. dispose(): void;
  69671. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69672. /**
  69673. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69674. * @param babylonTexture
  69675. * @param offset
  69676. * @param rotation
  69677. * @param scale
  69678. * @param scene
  69679. */
  69680. private _textureTransformTextureAsync;
  69681. }
  69682. }
  69683. declare module BABYLON.GLTF2.Exporter.Extensions {
  69684. /**
  69685. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69686. */
  69687. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69688. /** The name of this extension. */
  69689. readonly name: string;
  69690. /** Defines whether this extension is enabled. */
  69691. enabled: boolean;
  69692. /** Defines whether this extension is required */
  69693. required: boolean;
  69694. /** Reference to the glTF exporter */
  69695. private _exporter;
  69696. private _lights;
  69697. /** @hidden */
  69698. constructor(exporter: _Exporter);
  69699. /** @hidden */
  69700. dispose(): void;
  69701. /** @hidden */
  69702. onExporting(): void;
  69703. /**
  69704. * Define this method to modify the default behavior when exporting a node
  69705. * @param context The context when exporting the node
  69706. * @param node glTF node
  69707. * @param babylonNode BabylonJS node
  69708. * @returns nullable INode promise
  69709. */
  69710. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69711. }
  69712. }
  69713. declare module BABYLON {
  69714. /**
  69715. * Class for generating STL data from a Babylon scene.
  69716. */
  69717. export class STLExport {
  69718. /**
  69719. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69720. * @param meshes list defines the mesh to serialize
  69721. * @param download triggers the automatic download of the file.
  69722. * @param fileName changes the downloads fileName.
  69723. * @param binary changes the STL to a binary type.
  69724. * @param isLittleEndian toggle for binary type exporter.
  69725. * @returns the STL as UTF8 string
  69726. */
  69727. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69728. }
  69729. }
  69730. declare module "babylonjs-gltf2interface" {
  69731. export = BABYLON.GLTF2;
  69732. }
  69733. /**
  69734. * Module for glTF 2.0 Interface
  69735. */
  69736. declare module BABYLON.GLTF2 {
  69737. /**
  69738. * The datatype of the components in the attribute
  69739. */
  69740. const enum AccessorComponentType {
  69741. /**
  69742. * Byte
  69743. */
  69744. BYTE = 5120,
  69745. /**
  69746. * Unsigned Byte
  69747. */
  69748. UNSIGNED_BYTE = 5121,
  69749. /**
  69750. * Short
  69751. */
  69752. SHORT = 5122,
  69753. /**
  69754. * Unsigned Short
  69755. */
  69756. UNSIGNED_SHORT = 5123,
  69757. /**
  69758. * Unsigned Int
  69759. */
  69760. UNSIGNED_INT = 5125,
  69761. /**
  69762. * Float
  69763. */
  69764. FLOAT = 5126,
  69765. }
  69766. /**
  69767. * Specifies if the attirbute is a scalar, vector, or matrix
  69768. */
  69769. const enum AccessorType {
  69770. /**
  69771. * Scalar
  69772. */
  69773. SCALAR = "SCALAR",
  69774. /**
  69775. * Vector2
  69776. */
  69777. VEC2 = "VEC2",
  69778. /**
  69779. * Vector3
  69780. */
  69781. VEC3 = "VEC3",
  69782. /**
  69783. * Vector4
  69784. */
  69785. VEC4 = "VEC4",
  69786. /**
  69787. * Matrix2x2
  69788. */
  69789. MAT2 = "MAT2",
  69790. /**
  69791. * Matrix3x3
  69792. */
  69793. MAT3 = "MAT3",
  69794. /**
  69795. * Matrix4x4
  69796. */
  69797. MAT4 = "MAT4",
  69798. }
  69799. /**
  69800. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69801. */
  69802. const enum AnimationChannelTargetPath {
  69803. /**
  69804. * Translation
  69805. */
  69806. TRANSLATION = "translation",
  69807. /**
  69808. * Rotation
  69809. */
  69810. ROTATION = "rotation",
  69811. /**
  69812. * Scale
  69813. */
  69814. SCALE = "scale",
  69815. /**
  69816. * Weights
  69817. */
  69818. WEIGHTS = "weights",
  69819. }
  69820. /**
  69821. * Interpolation algorithm
  69822. */
  69823. const enum AnimationSamplerInterpolation {
  69824. /**
  69825. * The animated values are linearly interpolated between keyframes
  69826. */
  69827. LINEAR = "LINEAR",
  69828. /**
  69829. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69830. */
  69831. STEP = "STEP",
  69832. /**
  69833. * The animation's interpolation is computed using a cubic spline with specified tangents
  69834. */
  69835. CUBICSPLINE = "CUBICSPLINE",
  69836. }
  69837. /**
  69838. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69839. */
  69840. const enum CameraType {
  69841. /**
  69842. * A perspective camera containing properties to create a perspective projection matrix
  69843. */
  69844. PERSPECTIVE = "perspective",
  69845. /**
  69846. * An orthographic camera containing properties to create an orthographic projection matrix
  69847. */
  69848. ORTHOGRAPHIC = "orthographic",
  69849. }
  69850. /**
  69851. * The mime-type of the image
  69852. */
  69853. const enum ImageMimeType {
  69854. /**
  69855. * JPEG Mime-type
  69856. */
  69857. JPEG = "image/jpeg",
  69858. /**
  69859. * PNG Mime-type
  69860. */
  69861. PNG = "image/png",
  69862. }
  69863. /**
  69864. * The alpha rendering mode of the material
  69865. */
  69866. const enum MaterialAlphaMode {
  69867. /**
  69868. * The alpha value is ignored and the rendered output is fully opaque
  69869. */
  69870. OPAQUE = "OPAQUE",
  69871. /**
  69872. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69873. */
  69874. MASK = "MASK",
  69875. /**
  69876. * 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)
  69877. */
  69878. BLEND = "BLEND",
  69879. }
  69880. /**
  69881. * The type of the primitives to render
  69882. */
  69883. const enum MeshPrimitiveMode {
  69884. /**
  69885. * Points
  69886. */
  69887. POINTS = 0,
  69888. /**
  69889. * Lines
  69890. */
  69891. LINES = 1,
  69892. /**
  69893. * Line Loop
  69894. */
  69895. LINE_LOOP = 2,
  69896. /**
  69897. * Line Strip
  69898. */
  69899. LINE_STRIP = 3,
  69900. /**
  69901. * Triangles
  69902. */
  69903. TRIANGLES = 4,
  69904. /**
  69905. * Triangle Strip
  69906. */
  69907. TRIANGLE_STRIP = 5,
  69908. /**
  69909. * Triangle Fan
  69910. */
  69911. TRIANGLE_FAN = 6,
  69912. }
  69913. /**
  69914. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69915. */
  69916. const enum TextureMagFilter {
  69917. /**
  69918. * Nearest
  69919. */
  69920. NEAREST = 9728,
  69921. /**
  69922. * Linear
  69923. */
  69924. LINEAR = 9729,
  69925. }
  69926. /**
  69927. * Minification filter. All valid values correspond to WebGL enums
  69928. */
  69929. const enum TextureMinFilter {
  69930. /**
  69931. * Nearest
  69932. */
  69933. NEAREST = 9728,
  69934. /**
  69935. * Linear
  69936. */
  69937. LINEAR = 9729,
  69938. /**
  69939. * Nearest Mip-Map Nearest
  69940. */
  69941. NEAREST_MIPMAP_NEAREST = 9984,
  69942. /**
  69943. * Linear Mipmap Nearest
  69944. */
  69945. LINEAR_MIPMAP_NEAREST = 9985,
  69946. /**
  69947. * Nearest Mipmap Linear
  69948. */
  69949. NEAREST_MIPMAP_LINEAR = 9986,
  69950. /**
  69951. * Linear Mipmap Linear
  69952. */
  69953. LINEAR_MIPMAP_LINEAR = 9987,
  69954. }
  69955. /**
  69956. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69957. */
  69958. const enum TextureWrapMode {
  69959. /**
  69960. * Clamp to Edge
  69961. */
  69962. CLAMP_TO_EDGE = 33071,
  69963. /**
  69964. * Mirrored Repeat
  69965. */
  69966. MIRRORED_REPEAT = 33648,
  69967. /**
  69968. * Repeat
  69969. */
  69970. REPEAT = 10497,
  69971. }
  69972. /**
  69973. * glTF Property
  69974. */
  69975. interface IProperty {
  69976. /**
  69977. * Dictionary object with extension-specific objects
  69978. */
  69979. extensions?: {
  69980. [key: string]: any;
  69981. };
  69982. /**
  69983. * Application-Specific data
  69984. */
  69985. extras?: any;
  69986. }
  69987. /**
  69988. * glTF Child of Root Property
  69989. */
  69990. interface IChildRootProperty extends IProperty {
  69991. /**
  69992. * The user-defined name of this object
  69993. */
  69994. name?: string;
  69995. }
  69996. /**
  69997. * Indices of those attributes that deviate from their initialization value
  69998. */
  69999. interface IAccessorSparseIndices extends IProperty {
  70000. /**
  70001. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70002. */
  70003. bufferView: number;
  70004. /**
  70005. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70006. */
  70007. byteOffset?: number;
  70008. /**
  70009. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70010. */
  70011. componentType: AccessorComponentType;
  70012. }
  70013. /**
  70014. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70015. */
  70016. interface IAccessorSparseValues extends IProperty {
  70017. /**
  70018. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70019. */
  70020. bufferView: number;
  70021. /**
  70022. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70023. */
  70024. byteOffset?: number;
  70025. }
  70026. /**
  70027. * Sparse storage of attributes that deviate from their initialization value
  70028. */
  70029. interface IAccessorSparse extends IProperty {
  70030. /**
  70031. * The number of attributes encoded in this sparse accessor
  70032. */
  70033. count: number;
  70034. /**
  70035. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70036. */
  70037. indices: IAccessorSparseIndices;
  70038. /**
  70039. * 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
  70040. */
  70041. values: IAccessorSparseValues;
  70042. }
  70043. /**
  70044. * 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
  70045. */
  70046. interface IAccessor extends IChildRootProperty {
  70047. /**
  70048. * The index of the bufferview
  70049. */
  70050. bufferView?: number;
  70051. /**
  70052. * The offset relative to the start of the bufferView in bytes
  70053. */
  70054. byteOffset?: number;
  70055. /**
  70056. * The datatype of components in the attribute
  70057. */
  70058. componentType: AccessorComponentType;
  70059. /**
  70060. * Specifies whether integer data values should be normalized
  70061. */
  70062. normalized?: boolean;
  70063. /**
  70064. * The number of attributes referenced by this accessor
  70065. */
  70066. count: number;
  70067. /**
  70068. * Specifies if the attribute is a scalar, vector, or matrix
  70069. */
  70070. type: AccessorType;
  70071. /**
  70072. * Maximum value of each component in this attribute
  70073. */
  70074. max?: number[];
  70075. /**
  70076. * Minimum value of each component in this attribute
  70077. */
  70078. min?: number[];
  70079. /**
  70080. * Sparse storage of attributes that deviate from their initialization value
  70081. */
  70082. sparse?: IAccessorSparse;
  70083. }
  70084. /**
  70085. * Targets an animation's sampler at a node's property
  70086. */
  70087. interface IAnimationChannel extends IProperty {
  70088. /**
  70089. * The index of a sampler in this animation used to compute the value for the target
  70090. */
  70091. sampler: number;
  70092. /**
  70093. * The index of the node and TRS property to target
  70094. */
  70095. target: IAnimationChannelTarget;
  70096. }
  70097. /**
  70098. * The index of the node and TRS property that an animation channel targets
  70099. */
  70100. interface IAnimationChannelTarget extends IProperty {
  70101. /**
  70102. * The index of the node to target
  70103. */
  70104. node: number;
  70105. /**
  70106. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70107. */
  70108. path: AnimationChannelTargetPath;
  70109. }
  70110. /**
  70111. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70112. */
  70113. interface IAnimationSampler extends IProperty {
  70114. /**
  70115. * The index of an accessor containing keyframe input values, e.g., time
  70116. */
  70117. input: number;
  70118. /**
  70119. * Interpolation algorithm
  70120. */
  70121. interpolation?: AnimationSamplerInterpolation;
  70122. /**
  70123. * The index of an accessor, containing keyframe output values
  70124. */
  70125. output: number;
  70126. }
  70127. /**
  70128. * A keyframe animation
  70129. */
  70130. interface IAnimation extends IChildRootProperty {
  70131. /**
  70132. * An array of channels, each of which targets an animation's sampler at a node's property
  70133. */
  70134. channels: IAnimationChannel[];
  70135. /**
  70136. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70137. */
  70138. samplers: IAnimationSampler[];
  70139. }
  70140. /**
  70141. * Metadata about the glTF asset
  70142. */
  70143. interface IAsset extends IChildRootProperty {
  70144. /**
  70145. * A copyright message suitable for display to credit the content creator
  70146. */
  70147. copyright?: string;
  70148. /**
  70149. * Tool that generated this glTF model. Useful for debugging
  70150. */
  70151. generator?: string;
  70152. /**
  70153. * The glTF version that this asset targets
  70154. */
  70155. version: string;
  70156. /**
  70157. * The minimum glTF version that this asset targets
  70158. */
  70159. minVersion?: string;
  70160. }
  70161. /**
  70162. * A buffer points to binary geometry, animation, or skins
  70163. */
  70164. interface IBuffer extends IChildRootProperty {
  70165. /**
  70166. * 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
  70167. */
  70168. uri?: string;
  70169. /**
  70170. * The length of the buffer in bytes
  70171. */
  70172. byteLength: number;
  70173. }
  70174. /**
  70175. * A view into a buffer generally representing a subset of the buffer
  70176. */
  70177. interface IBufferView extends IChildRootProperty {
  70178. /**
  70179. * The index of the buffer
  70180. */
  70181. buffer: number;
  70182. /**
  70183. * The offset into the buffer in bytes
  70184. */
  70185. byteOffset?: number;
  70186. /**
  70187. * The lenth of the bufferView in bytes
  70188. */
  70189. byteLength: number;
  70190. /**
  70191. * The stride, in bytes
  70192. */
  70193. byteStride?: number;
  70194. }
  70195. /**
  70196. * An orthographic camera containing properties to create an orthographic projection matrix
  70197. */
  70198. interface ICameraOrthographic extends IProperty {
  70199. /**
  70200. * The floating-point horizontal magnification of the view. Must not be zero
  70201. */
  70202. xmag: number;
  70203. /**
  70204. * The floating-point vertical magnification of the view. Must not be zero
  70205. */
  70206. ymag: number;
  70207. /**
  70208. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70209. */
  70210. zfar: number;
  70211. /**
  70212. * The floating-point distance to the near clipping plane
  70213. */
  70214. znear: number;
  70215. }
  70216. /**
  70217. * A perspective camera containing properties to create a perspective projection matrix
  70218. */
  70219. interface ICameraPerspective extends IProperty {
  70220. /**
  70221. * The floating-point aspect ratio of the field of view
  70222. */
  70223. aspectRatio?: number;
  70224. /**
  70225. * The floating-point vertical field of view in radians
  70226. */
  70227. yfov: number;
  70228. /**
  70229. * The floating-point distance to the far clipping plane
  70230. */
  70231. zfar?: number;
  70232. /**
  70233. * The floating-point distance to the near clipping plane
  70234. */
  70235. znear: number;
  70236. }
  70237. /**
  70238. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70239. */
  70240. interface ICamera extends IChildRootProperty {
  70241. /**
  70242. * An orthographic camera containing properties to create an orthographic projection matrix
  70243. */
  70244. orthographic?: ICameraOrthographic;
  70245. /**
  70246. * A perspective camera containing properties to create a perspective projection matrix
  70247. */
  70248. perspective?: ICameraPerspective;
  70249. /**
  70250. * Specifies if the camera uses a perspective or orthographic projection
  70251. */
  70252. type: CameraType;
  70253. }
  70254. /**
  70255. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70256. */
  70257. interface IImage extends IChildRootProperty {
  70258. /**
  70259. * 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
  70260. */
  70261. uri?: string;
  70262. /**
  70263. * The image's MIME type
  70264. */
  70265. mimeType?: ImageMimeType;
  70266. /**
  70267. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70268. */
  70269. bufferView?: number;
  70270. }
  70271. /**
  70272. * Material Normal Texture Info
  70273. */
  70274. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70275. /**
  70276. * The scalar multiplier applied to each normal vector of the normal texture
  70277. */
  70278. scale?: number;
  70279. }
  70280. /**
  70281. * Material Occlusion Texture Info
  70282. */
  70283. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70284. /**
  70285. * A scalar multiplier controlling the amount of occlusion applied
  70286. */
  70287. strength?: number;
  70288. }
  70289. /**
  70290. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70291. */
  70292. interface IMaterialPbrMetallicRoughness {
  70293. /**
  70294. * The material's base color factor
  70295. */
  70296. baseColorFactor?: number[];
  70297. /**
  70298. * The base color texture
  70299. */
  70300. baseColorTexture?: ITextureInfo;
  70301. /**
  70302. * The metalness of the material
  70303. */
  70304. metallicFactor?: number;
  70305. /**
  70306. * The roughness of the material
  70307. */
  70308. roughnessFactor?: number;
  70309. /**
  70310. * The metallic-roughness texture
  70311. */
  70312. metallicRoughnessTexture?: ITextureInfo;
  70313. }
  70314. /**
  70315. * The material appearance of a primitive
  70316. */
  70317. interface IMaterial extends IChildRootProperty {
  70318. /**
  70319. * 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
  70320. */
  70321. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70322. /**
  70323. * The normal map texture
  70324. */
  70325. normalTexture?: IMaterialNormalTextureInfo;
  70326. /**
  70327. * The occlusion map texture
  70328. */
  70329. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70330. /**
  70331. * The emissive map texture
  70332. */
  70333. emissiveTexture?: ITextureInfo;
  70334. /**
  70335. * 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
  70336. */
  70337. emissiveFactor?: number[];
  70338. /**
  70339. * The alpha rendering mode of the material
  70340. */
  70341. alphaMode?: MaterialAlphaMode;
  70342. /**
  70343. * The alpha cutoff value of the material
  70344. */
  70345. alphaCutoff?: number;
  70346. /**
  70347. * Specifies whether the material is double sided
  70348. */
  70349. doubleSided?: boolean;
  70350. }
  70351. /**
  70352. * Geometry to be rendered with the given material
  70353. */
  70354. interface IMeshPrimitive extends IProperty {
  70355. /**
  70356. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70357. */
  70358. attributes: {
  70359. [name: string]: number;
  70360. };
  70361. /**
  70362. * The index of the accessor that contains the indices
  70363. */
  70364. indices?: number;
  70365. /**
  70366. * The index of the material to apply to this primitive when rendering
  70367. */
  70368. material?: number;
  70369. /**
  70370. * The type of primitives to render. All valid values correspond to WebGL enums
  70371. */
  70372. mode?: MeshPrimitiveMode;
  70373. /**
  70374. * 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
  70375. */
  70376. targets?: {
  70377. [name: string]: number;
  70378. }[];
  70379. }
  70380. /**
  70381. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70382. */
  70383. interface IMesh extends IChildRootProperty {
  70384. /**
  70385. * An array of primitives, each defining geometry to be rendered with a material
  70386. */
  70387. primitives: IMeshPrimitive[];
  70388. /**
  70389. * Array of weights to be applied to the Morph Targets
  70390. */
  70391. weights?: number[];
  70392. }
  70393. /**
  70394. * A node in the node hierarchy
  70395. */
  70396. interface INode extends IChildRootProperty {
  70397. /**
  70398. * The index of the camera referenced by this node
  70399. */
  70400. camera?: number;
  70401. /**
  70402. * The indices of this node's children
  70403. */
  70404. children?: number[];
  70405. /**
  70406. * The index of the skin referenced by this node
  70407. */
  70408. skin?: number;
  70409. /**
  70410. * A floating-point 4x4 transformation matrix stored in column-major order
  70411. */
  70412. matrix?: number[];
  70413. /**
  70414. * The index of the mesh in this node
  70415. */
  70416. mesh?: number;
  70417. /**
  70418. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70419. */
  70420. rotation?: number[];
  70421. /**
  70422. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70423. */
  70424. scale?: number[];
  70425. /**
  70426. * The node's translation along the x, y, and z axes
  70427. */
  70428. translation?: number[];
  70429. /**
  70430. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70431. */
  70432. weights?: number[];
  70433. }
  70434. /**
  70435. * Texture sampler properties for filtering and wrapping modes
  70436. */
  70437. interface ISampler extends IChildRootProperty {
  70438. /**
  70439. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70440. */
  70441. magFilter?: TextureMagFilter;
  70442. /**
  70443. * Minification filter. All valid values correspond to WebGL enums
  70444. */
  70445. minFilter?: TextureMinFilter;
  70446. /**
  70447. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70448. */
  70449. wrapS?: TextureWrapMode;
  70450. /**
  70451. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70452. */
  70453. wrapT?: TextureWrapMode;
  70454. }
  70455. /**
  70456. * The root nodes of a scene
  70457. */
  70458. interface IScene extends IChildRootProperty {
  70459. /**
  70460. * The indices of each root node
  70461. */
  70462. nodes: number[];
  70463. }
  70464. /**
  70465. * Joints and matrices defining a skin
  70466. */
  70467. interface ISkin extends IChildRootProperty {
  70468. /**
  70469. * 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
  70470. */
  70471. inverseBindMatrices?: number;
  70472. /**
  70473. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70474. */
  70475. skeleton?: number;
  70476. /**
  70477. * 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)
  70478. */
  70479. joints: number[];
  70480. }
  70481. /**
  70482. * A texture and its sampler
  70483. */
  70484. interface ITexture extends IChildRootProperty {
  70485. /**
  70486. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70487. */
  70488. sampler?: number;
  70489. /**
  70490. * The index of the image used by this texture
  70491. */
  70492. source: number;
  70493. }
  70494. /**
  70495. * Reference to a texture
  70496. */
  70497. interface ITextureInfo extends IProperty {
  70498. /**
  70499. * The index of the texture
  70500. */
  70501. index: number;
  70502. /**
  70503. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70504. */
  70505. texCoord?: number;
  70506. }
  70507. /**
  70508. * The root object for a glTF asset
  70509. */
  70510. interface IGLTF extends IProperty {
  70511. /**
  70512. * An array of accessors. An accessor is a typed view into a bufferView
  70513. */
  70514. accessors?: IAccessor[];
  70515. /**
  70516. * An array of keyframe animations
  70517. */
  70518. animations?: IAnimation[];
  70519. /**
  70520. * Metadata about the glTF asset
  70521. */
  70522. asset: IAsset;
  70523. /**
  70524. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70525. */
  70526. buffers?: IBuffer[];
  70527. /**
  70528. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70529. */
  70530. bufferViews?: IBufferView[];
  70531. /**
  70532. * An array of cameras
  70533. */
  70534. cameras?: ICamera[];
  70535. /**
  70536. * Names of glTF extensions used somewhere in this asset
  70537. */
  70538. extensionsUsed?: string[];
  70539. /**
  70540. * Names of glTF extensions required to properly load this asset
  70541. */
  70542. extensionsRequired?: string[];
  70543. /**
  70544. * An array of images. An image defines data used to create a texture
  70545. */
  70546. images?: IImage[];
  70547. /**
  70548. * An array of materials. A material defines the appearance of a primitive
  70549. */
  70550. materials?: IMaterial[];
  70551. /**
  70552. * An array of meshes. A mesh is a set of primitives to be rendered
  70553. */
  70554. meshes?: IMesh[];
  70555. /**
  70556. * An array of nodes
  70557. */
  70558. nodes?: INode[];
  70559. /**
  70560. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70561. */
  70562. samplers?: ISampler[];
  70563. /**
  70564. * The index of the default scene
  70565. */
  70566. scene?: number;
  70567. /**
  70568. * An array of scenes
  70569. */
  70570. scenes?: IScene[];
  70571. /**
  70572. * An array of skins. A skin is defined by joints and matrices
  70573. */
  70574. skins?: ISkin[];
  70575. /**
  70576. * An array of textures
  70577. */
  70578. textures?: ITexture[];
  70579. }
  70580. /**
  70581. * The glTF validation results
  70582. * @ignore
  70583. */
  70584. interface IGLTFValidationResults {
  70585. info: {
  70586. generator: string;
  70587. hasAnimations: boolean;
  70588. hasDefaultScene: boolean;
  70589. hasMaterials: boolean;
  70590. hasMorphTargets: boolean;
  70591. hasSkins: boolean;
  70592. hasTextures: boolean;
  70593. maxAttributesUsed: number;
  70594. primitivesCount: number
  70595. };
  70596. issues: {
  70597. messages: Array<string>;
  70598. numErrors: number;
  70599. numHints: number;
  70600. numInfos: number;
  70601. numWarnings: number;
  70602. truncated: boolean
  70603. };
  70604. mimeType: string;
  70605. uri: string;
  70606. validatedAt: string;
  70607. validatorVersion: string;
  70608. }
  70609. /**
  70610. * The glTF validation options
  70611. */
  70612. interface IGLTFValidationOptions {
  70613. /** Uri to use */
  70614. uri?: string;
  70615. /** Function used to load external resources */
  70616. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70617. /** Boolean indicating that we need to validate accessor data */
  70618. validateAccessorData?: boolean;
  70619. /** max number of issues allowed */
  70620. maxIssues?: number;
  70621. /** Ignored issues */
  70622. ignoredIssues?: Array<string>;
  70623. /** Value to override severy settings */
  70624. severityOverrides?: Object;
  70625. }
  70626. /**
  70627. * The glTF validator object
  70628. * @ignore
  70629. */
  70630. interface IGLTFValidator {
  70631. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70632. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70633. }
  70634. }
  70635. declare module BABYLON {
  70636. /** @hidden */
  70637. export var cellPixelShader: {
  70638. name: string;
  70639. shader: string;
  70640. };
  70641. }
  70642. declare module BABYLON {
  70643. /** @hidden */
  70644. export var cellVertexShader: {
  70645. name: string;
  70646. shader: string;
  70647. };
  70648. }
  70649. declare module BABYLON {
  70650. export class CellMaterial extends BABYLON.PushMaterial {
  70651. private _diffuseTexture;
  70652. diffuseTexture: BABYLON.BaseTexture;
  70653. diffuseColor: BABYLON.Color3;
  70654. _computeHighLevel: boolean;
  70655. computeHighLevel: boolean;
  70656. private _disableLighting;
  70657. disableLighting: boolean;
  70658. private _maxSimultaneousLights;
  70659. maxSimultaneousLights: number;
  70660. private _renderId;
  70661. constructor(name: string, scene: BABYLON.Scene);
  70662. needAlphaBlending(): boolean;
  70663. needAlphaTesting(): boolean;
  70664. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70665. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70666. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70667. getAnimatables(): BABYLON.IAnimatable[];
  70668. getActiveTextures(): BABYLON.BaseTexture[];
  70669. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70670. dispose(forceDisposeEffect?: boolean): void;
  70671. getClassName(): string;
  70672. clone(name: string): CellMaterial;
  70673. serialize(): any;
  70674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70675. }
  70676. }
  70677. declare module BABYLON {
  70678. export class CustomShaderStructure {
  70679. FragmentStore: string;
  70680. VertexStore: string;
  70681. constructor();
  70682. }
  70683. export class ShaderSpecialParts {
  70684. constructor();
  70685. Fragment_Begin: string;
  70686. Fragment_Definitions: string;
  70687. Fragment_MainBegin: string;
  70688. Fragment_Custom_Diffuse: string;
  70689. Fragment_Before_Lights: string;
  70690. Fragment_Before_Fog: string;
  70691. Fragment_Custom_Alpha: string;
  70692. Fragment_Before_FragColor: string;
  70693. Vertex_Begin: string;
  70694. Vertex_Definitions: string;
  70695. Vertex_MainBegin: string;
  70696. Vertex_Before_PositionUpdated: string;
  70697. Vertex_Before_NormalUpdated: string;
  70698. Vertex_MainEnd: string;
  70699. }
  70700. export class CustomMaterial extends BABYLON.StandardMaterial {
  70701. static ShaderIndexer: number;
  70702. CustomParts: ShaderSpecialParts;
  70703. _isCreatedShader: boolean;
  70704. _createdShaderName: string;
  70705. _customUniform: string[];
  70706. _newUniforms: string[];
  70707. _newUniformInstances: any[];
  70708. _newSamplerInstances: BABYLON.Texture[];
  70709. FragmentShader: string;
  70710. VertexShader: string;
  70711. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70712. ReviewUniform(name: string, arr: string[]): string[];
  70713. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70714. constructor(name: string, scene: BABYLON.Scene);
  70715. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70716. Fragment_Begin(shaderPart: string): CustomMaterial;
  70717. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70718. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70719. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70720. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70721. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70722. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70723. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70724. Vertex_Begin(shaderPart: string): CustomMaterial;
  70725. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70726. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70727. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70728. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70729. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70730. }
  70731. }
  70732. declare module BABYLON {
  70733. export class ShaderAlebdoParts {
  70734. constructor();
  70735. Fragment_Begin: string;
  70736. Fragment_Definitions: string;
  70737. Fragment_MainBegin: string;
  70738. Fragment_Custom_Albedo: string;
  70739. Fragment_Before_Lights: string;
  70740. Fragment_Custom_MetallicRoughness: string;
  70741. Fragment_Custom_MicroSurface: string;
  70742. Fragment_Before_Fog: string;
  70743. Fragment_Custom_Alpha: string;
  70744. Fragment_Before_FragColor: string;
  70745. Vertex_Begin: string;
  70746. Vertex_Definitions: string;
  70747. Vertex_MainBegin: string;
  70748. Vertex_Before_PositionUpdated: string;
  70749. Vertex_Before_NormalUpdated: string;
  70750. Vertex_MainEnd: string;
  70751. }
  70752. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70753. static ShaderIndexer: number;
  70754. CustomParts: ShaderAlebdoParts;
  70755. _isCreatedShader: boolean;
  70756. _createdShaderName: string;
  70757. _customUniform: string[];
  70758. _newUniforms: string[];
  70759. _newUniformInstances: any[];
  70760. _newSamplerInstances: BABYLON.Texture[];
  70761. FragmentShader: string;
  70762. VertexShader: string;
  70763. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70764. ReviewUniform(name: string, arr: string[]): string[];
  70765. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70766. constructor(name: string, scene: BABYLON.Scene);
  70767. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70768. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70769. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70770. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70771. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70772. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70773. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70774. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70775. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70776. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70777. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70778. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70779. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70780. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70781. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70782. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70783. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70784. }
  70785. }
  70786. declare module BABYLON {
  70787. /** @hidden */
  70788. export var firePixelShader: {
  70789. name: string;
  70790. shader: string;
  70791. };
  70792. }
  70793. declare module BABYLON {
  70794. /** @hidden */
  70795. export var fireVertexShader: {
  70796. name: string;
  70797. shader: string;
  70798. };
  70799. }
  70800. declare module BABYLON {
  70801. export class FireMaterial extends BABYLON.PushMaterial {
  70802. private _diffuseTexture;
  70803. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70804. private _distortionTexture;
  70805. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70806. private _opacityTexture;
  70807. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70808. diffuseColor: BABYLON.Color3;
  70809. speed: number;
  70810. private _scaledDiffuse;
  70811. private _renderId;
  70812. private _lastTime;
  70813. constructor(name: string, scene: BABYLON.Scene);
  70814. needAlphaBlending(): boolean;
  70815. needAlphaTesting(): boolean;
  70816. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70817. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70818. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70819. getAnimatables(): BABYLON.IAnimatable[];
  70820. getActiveTextures(): BABYLON.BaseTexture[];
  70821. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70822. getClassName(): string;
  70823. dispose(forceDisposeEffect?: boolean): void;
  70824. clone(name: string): FireMaterial;
  70825. serialize(): any;
  70826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70827. }
  70828. }
  70829. declare module BABYLON {
  70830. /** @hidden */
  70831. export var furPixelShader: {
  70832. name: string;
  70833. shader: string;
  70834. };
  70835. }
  70836. declare module BABYLON {
  70837. /** @hidden */
  70838. export var furVertexShader: {
  70839. name: string;
  70840. shader: string;
  70841. };
  70842. }
  70843. declare module BABYLON {
  70844. export class FurMaterial extends BABYLON.PushMaterial {
  70845. private _diffuseTexture;
  70846. diffuseTexture: BABYLON.BaseTexture;
  70847. private _heightTexture;
  70848. heightTexture: BABYLON.BaseTexture;
  70849. diffuseColor: BABYLON.Color3;
  70850. furLength: number;
  70851. furAngle: number;
  70852. furColor: BABYLON.Color3;
  70853. furOffset: number;
  70854. furSpacing: number;
  70855. furGravity: BABYLON.Vector3;
  70856. furSpeed: number;
  70857. furDensity: number;
  70858. furOcclusion: number;
  70859. furTexture: BABYLON.DynamicTexture;
  70860. private _disableLighting;
  70861. disableLighting: boolean;
  70862. private _maxSimultaneousLights;
  70863. maxSimultaneousLights: number;
  70864. highLevelFur: boolean;
  70865. _meshes: BABYLON.AbstractMesh[];
  70866. private _renderId;
  70867. private _furTime;
  70868. constructor(name: string, scene: BABYLON.Scene);
  70869. furTime: number;
  70870. needAlphaBlending(): boolean;
  70871. needAlphaTesting(): boolean;
  70872. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70873. updateFur(): void;
  70874. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70875. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70876. getAnimatables(): BABYLON.IAnimatable[];
  70877. getActiveTextures(): BABYLON.BaseTexture[];
  70878. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70879. dispose(forceDisposeEffect?: boolean): void;
  70880. clone(name: string): FurMaterial;
  70881. serialize(): any;
  70882. getClassName(): string;
  70883. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70884. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70885. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70886. }
  70887. }
  70888. declare module BABYLON {
  70889. /** @hidden */
  70890. export var gradientPixelShader: {
  70891. name: string;
  70892. shader: string;
  70893. };
  70894. }
  70895. declare module BABYLON {
  70896. /** @hidden */
  70897. export var gradientVertexShader: {
  70898. name: string;
  70899. shader: string;
  70900. };
  70901. }
  70902. declare module BABYLON {
  70903. export class GradientMaterial extends BABYLON.PushMaterial {
  70904. private _maxSimultaneousLights;
  70905. maxSimultaneousLights: number;
  70906. topColor: BABYLON.Color3;
  70907. topColorAlpha: number;
  70908. bottomColor: BABYLON.Color3;
  70909. bottomColorAlpha: number;
  70910. offset: number;
  70911. scale: number;
  70912. smoothness: number;
  70913. private _disableLighting;
  70914. disableLighting: boolean;
  70915. private _renderId;
  70916. constructor(name: string, scene: BABYLON.Scene);
  70917. needAlphaBlending(): boolean;
  70918. needAlphaTesting(): boolean;
  70919. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70922. getAnimatables(): BABYLON.IAnimatable[];
  70923. dispose(forceDisposeEffect?: boolean): void;
  70924. clone(name: string): GradientMaterial;
  70925. serialize(): any;
  70926. getClassName(): string;
  70927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70928. }
  70929. }
  70930. declare module BABYLON {
  70931. /** @hidden */
  70932. export var gridPixelShader: {
  70933. name: string;
  70934. shader: string;
  70935. };
  70936. }
  70937. declare module BABYLON {
  70938. /** @hidden */
  70939. export var gridVertexShader: {
  70940. name: string;
  70941. shader: string;
  70942. };
  70943. }
  70944. declare module BABYLON {
  70945. /**
  70946. * The grid materials allows you to wrap any shape with a grid.
  70947. * Colors are customizable.
  70948. */
  70949. export class GridMaterial extends BABYLON.PushMaterial {
  70950. /**
  70951. * Main color of the grid (e.g. between lines)
  70952. */
  70953. mainColor: BABYLON.Color3;
  70954. /**
  70955. * Color of the grid lines.
  70956. */
  70957. lineColor: BABYLON.Color3;
  70958. /**
  70959. * The scale of the grid compared to unit.
  70960. */
  70961. gridRatio: number;
  70962. /**
  70963. * Allows setting an offset for the grid lines.
  70964. */
  70965. gridOffset: BABYLON.Vector3;
  70966. /**
  70967. * The frequency of thicker lines.
  70968. */
  70969. majorUnitFrequency: number;
  70970. /**
  70971. * The visibility of minor units in the grid.
  70972. */
  70973. minorUnitVisibility: number;
  70974. /**
  70975. * The grid opacity outside of the lines.
  70976. */
  70977. opacity: number;
  70978. /**
  70979. * Determine RBG output is premultiplied by alpha value.
  70980. */
  70981. preMultiplyAlpha: boolean;
  70982. private _opacityTexture;
  70983. opacityTexture: BABYLON.BaseTexture;
  70984. private _gridControl;
  70985. private _renderId;
  70986. /**
  70987. * constructor
  70988. * @param name The name given to the material in order to identify it afterwards.
  70989. * @param scene The scene the material is used in.
  70990. */
  70991. constructor(name: string, scene: BABYLON.Scene);
  70992. /**
  70993. * Returns wehter or not the grid requires alpha blending.
  70994. */
  70995. needAlphaBlending(): boolean;
  70996. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70997. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70998. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70999. /**
  71000. * Dispose the material and its associated resources.
  71001. * @param forceDisposeEffect will also dispose the used effect when true
  71002. */
  71003. dispose(forceDisposeEffect?: boolean): void;
  71004. clone(name: string): GridMaterial;
  71005. serialize(): any;
  71006. getClassName(): string;
  71007. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71008. }
  71009. }
  71010. declare module BABYLON {
  71011. /** @hidden */
  71012. export var lavaPixelShader: {
  71013. name: string;
  71014. shader: string;
  71015. };
  71016. }
  71017. declare module BABYLON {
  71018. /** @hidden */
  71019. export var lavaVertexShader: {
  71020. name: string;
  71021. shader: string;
  71022. };
  71023. }
  71024. declare module BABYLON {
  71025. export class LavaMaterial extends BABYLON.PushMaterial {
  71026. private _diffuseTexture;
  71027. diffuseTexture: BABYLON.BaseTexture;
  71028. noiseTexture: BABYLON.BaseTexture;
  71029. fogColor: BABYLON.Color3;
  71030. speed: number;
  71031. movingSpeed: number;
  71032. lowFrequencySpeed: number;
  71033. fogDensity: number;
  71034. private _lastTime;
  71035. diffuseColor: BABYLON.Color3;
  71036. private _disableLighting;
  71037. disableLighting: boolean;
  71038. private _unlit;
  71039. unlit: boolean;
  71040. private _maxSimultaneousLights;
  71041. maxSimultaneousLights: number;
  71042. private _scaledDiffuse;
  71043. private _renderId;
  71044. constructor(name: string, scene: BABYLON.Scene);
  71045. needAlphaBlending(): boolean;
  71046. needAlphaTesting(): boolean;
  71047. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71048. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71049. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71050. getAnimatables(): BABYLON.IAnimatable[];
  71051. getActiveTextures(): BABYLON.BaseTexture[];
  71052. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71053. dispose(forceDisposeEffect?: boolean): void;
  71054. clone(name: string): LavaMaterial;
  71055. serialize(): any;
  71056. getClassName(): string;
  71057. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71058. }
  71059. }
  71060. declare module BABYLON {
  71061. /** @hidden */
  71062. export var mixPixelShader: {
  71063. name: string;
  71064. shader: string;
  71065. };
  71066. }
  71067. declare module BABYLON {
  71068. /** @hidden */
  71069. export var mixVertexShader: {
  71070. name: string;
  71071. shader: string;
  71072. };
  71073. }
  71074. declare module BABYLON {
  71075. export class MixMaterial extends BABYLON.PushMaterial {
  71076. /**
  71077. * Mix textures
  71078. */
  71079. private _mixTexture1;
  71080. mixTexture1: BABYLON.BaseTexture;
  71081. private _mixTexture2;
  71082. mixTexture2: BABYLON.BaseTexture;
  71083. /**
  71084. * Diffuse textures
  71085. */
  71086. private _diffuseTexture1;
  71087. diffuseTexture1: BABYLON.Texture;
  71088. private _diffuseTexture2;
  71089. diffuseTexture2: BABYLON.Texture;
  71090. private _diffuseTexture3;
  71091. diffuseTexture3: BABYLON.Texture;
  71092. private _diffuseTexture4;
  71093. diffuseTexture4: BABYLON.Texture;
  71094. private _diffuseTexture5;
  71095. diffuseTexture5: BABYLON.Texture;
  71096. private _diffuseTexture6;
  71097. diffuseTexture6: BABYLON.Texture;
  71098. private _diffuseTexture7;
  71099. diffuseTexture7: BABYLON.Texture;
  71100. private _diffuseTexture8;
  71101. diffuseTexture8: BABYLON.Texture;
  71102. /**
  71103. * Uniforms
  71104. */
  71105. diffuseColor: BABYLON.Color3;
  71106. specularColor: BABYLON.Color3;
  71107. specularPower: number;
  71108. private _disableLighting;
  71109. disableLighting: boolean;
  71110. private _maxSimultaneousLights;
  71111. maxSimultaneousLights: number;
  71112. private _renderId;
  71113. constructor(name: string, scene: BABYLON.Scene);
  71114. needAlphaBlending(): boolean;
  71115. needAlphaTesting(): boolean;
  71116. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71117. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71118. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71119. getAnimatables(): BABYLON.IAnimatable[];
  71120. getActiveTextures(): BABYLON.BaseTexture[];
  71121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71122. dispose(forceDisposeEffect?: boolean): void;
  71123. clone(name: string): MixMaterial;
  71124. serialize(): any;
  71125. getClassName(): string;
  71126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71127. }
  71128. }
  71129. declare module BABYLON {
  71130. /** @hidden */
  71131. export var normalPixelShader: {
  71132. name: string;
  71133. shader: string;
  71134. };
  71135. }
  71136. declare module BABYLON {
  71137. /** @hidden */
  71138. export var normalVertexShader: {
  71139. name: string;
  71140. shader: string;
  71141. };
  71142. }
  71143. declare module BABYLON {
  71144. export class NormalMaterial extends BABYLON.PushMaterial {
  71145. private _diffuseTexture;
  71146. diffuseTexture: BABYLON.BaseTexture;
  71147. diffuseColor: BABYLON.Color3;
  71148. private _disableLighting;
  71149. disableLighting: boolean;
  71150. private _maxSimultaneousLights;
  71151. maxSimultaneousLights: number;
  71152. private _renderId;
  71153. constructor(name: string, scene: BABYLON.Scene);
  71154. needAlphaBlending(): boolean;
  71155. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71156. needAlphaTesting(): boolean;
  71157. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71158. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71159. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71160. getAnimatables(): BABYLON.IAnimatable[];
  71161. getActiveTextures(): BABYLON.BaseTexture[];
  71162. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71163. dispose(forceDisposeEffect?: boolean): void;
  71164. clone(name: string): NormalMaterial;
  71165. serialize(): any;
  71166. getClassName(): string;
  71167. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71168. }
  71169. }
  71170. declare module BABYLON {
  71171. /** @hidden */
  71172. export var shadowOnlyPixelShader: {
  71173. name: string;
  71174. shader: string;
  71175. };
  71176. }
  71177. declare module BABYLON {
  71178. /** @hidden */
  71179. export var shadowOnlyVertexShader: {
  71180. name: string;
  71181. shader: string;
  71182. };
  71183. }
  71184. declare module BABYLON {
  71185. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71186. private _renderId;
  71187. private _activeLight;
  71188. constructor(name: string, scene: BABYLON.Scene);
  71189. shadowColor: BABYLON.Color3;
  71190. needAlphaBlending(): boolean;
  71191. needAlphaTesting(): boolean;
  71192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71193. activeLight: BABYLON.IShadowLight;
  71194. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71195. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71196. clone(name: string): ShadowOnlyMaterial;
  71197. serialize(): any;
  71198. getClassName(): string;
  71199. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71200. }
  71201. }
  71202. declare module BABYLON {
  71203. /** @hidden */
  71204. export var simplePixelShader: {
  71205. name: string;
  71206. shader: string;
  71207. };
  71208. }
  71209. declare module BABYLON {
  71210. /** @hidden */
  71211. export var simpleVertexShader: {
  71212. name: string;
  71213. shader: string;
  71214. };
  71215. }
  71216. declare module BABYLON {
  71217. export class SimpleMaterial extends BABYLON.PushMaterial {
  71218. private _diffuseTexture;
  71219. diffuseTexture: BABYLON.BaseTexture;
  71220. diffuseColor: BABYLON.Color3;
  71221. private _disableLighting;
  71222. disableLighting: boolean;
  71223. private _maxSimultaneousLights;
  71224. maxSimultaneousLights: number;
  71225. private _renderId;
  71226. constructor(name: string, scene: BABYLON.Scene);
  71227. needAlphaBlending(): boolean;
  71228. needAlphaTesting(): boolean;
  71229. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71230. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71231. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71232. getAnimatables(): BABYLON.IAnimatable[];
  71233. getActiveTextures(): BABYLON.BaseTexture[];
  71234. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71235. dispose(forceDisposeEffect?: boolean): void;
  71236. clone(name: string): SimpleMaterial;
  71237. serialize(): any;
  71238. getClassName(): string;
  71239. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71240. }
  71241. }
  71242. declare module BABYLON {
  71243. /** @hidden */
  71244. export var skyPixelShader: {
  71245. name: string;
  71246. shader: string;
  71247. };
  71248. }
  71249. declare module BABYLON {
  71250. /** @hidden */
  71251. export var skyVertexShader: {
  71252. name: string;
  71253. shader: string;
  71254. };
  71255. }
  71256. declare module BABYLON {
  71257. /**
  71258. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71259. * @see https://doc.babylonjs.com/extensions/sky
  71260. */
  71261. export class SkyMaterial extends BABYLON.PushMaterial {
  71262. /**
  71263. * Defines the overall luminance of sky in interval ]0, 1[.
  71264. */
  71265. luminance: number;
  71266. /**
  71267. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71268. */
  71269. turbidity: number;
  71270. /**
  71271. * Defines the sky appearance (light intensity).
  71272. */
  71273. rayleigh: number;
  71274. /**
  71275. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71276. */
  71277. mieCoefficient: number;
  71278. /**
  71279. * Defines the amount of haze particles following the Mie scattering theory.
  71280. */
  71281. mieDirectionalG: number;
  71282. /**
  71283. * Defines the distance of the sun according to the active scene camera.
  71284. */
  71285. distance: number;
  71286. /**
  71287. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71288. * "inclined".
  71289. */
  71290. inclination: number;
  71291. /**
  71292. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71293. * an object direction and a reference direction.
  71294. */
  71295. azimuth: number;
  71296. /**
  71297. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71298. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71299. */
  71300. sunPosition: BABYLON.Vector3;
  71301. /**
  71302. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71303. * .sunPosition property.
  71304. */
  71305. useSunPosition: boolean;
  71306. /**
  71307. * Defines an offset vector used to get a horizon offset.
  71308. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71309. */
  71310. cameraOffset: BABYLON.Vector3;
  71311. private _cameraPosition;
  71312. private _renderId;
  71313. /**
  71314. * Instantiates a new sky material.
  71315. * This material allows to create dynamic and texture free
  71316. * effects for skyboxes by taking care of the atmosphere state.
  71317. * @see https://doc.babylonjs.com/extensions/sky
  71318. * @param name Define the name of the material in the scene
  71319. * @param scene Define the scene the material belong to
  71320. */
  71321. constructor(name: string, scene: BABYLON.Scene);
  71322. /**
  71323. * Specifies if the material will require alpha blending
  71324. * @returns a boolean specifying if alpha blending is needed
  71325. */
  71326. needAlphaBlending(): boolean;
  71327. /**
  71328. * Specifies if this material should be rendered in alpha test mode
  71329. * @returns false as the sky material doesn't need alpha testing.
  71330. */
  71331. needAlphaTesting(): boolean;
  71332. /**
  71333. * Get the texture used for alpha test purpose.
  71334. * @returns null as the sky material has no texture.
  71335. */
  71336. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71337. /**
  71338. * Get if the submesh is ready to be used and all its information available.
  71339. * Child classes can use it to update shaders
  71340. * @param mesh defines the mesh to check
  71341. * @param subMesh defines which submesh to check
  71342. * @param useInstances specifies that instances should be used
  71343. * @returns a boolean indicating that the submesh is ready or not
  71344. */
  71345. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71346. /**
  71347. * Binds the submesh to this material by preparing the effect and shader to draw
  71348. * @param world defines the world transformation matrix
  71349. * @param mesh defines the mesh containing the submesh
  71350. * @param subMesh defines the submesh to bind the material to
  71351. */
  71352. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71353. /**
  71354. * Get the list of animatables in the material.
  71355. * @returns the list of animatables object used in the material
  71356. */
  71357. getAnimatables(): BABYLON.IAnimatable[];
  71358. /**
  71359. * Disposes the material
  71360. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71361. */
  71362. dispose(forceDisposeEffect?: boolean): void;
  71363. /**
  71364. * Makes a duplicate of the material, and gives it a new name
  71365. * @param name defines the new name for the duplicated material
  71366. * @returns the cloned material
  71367. */
  71368. clone(name: string): SkyMaterial;
  71369. /**
  71370. * Serializes this material in a JSON representation
  71371. * @returns the serialized material object
  71372. */
  71373. serialize(): any;
  71374. /**
  71375. * Gets the current class name of the material e.g. "SkyMaterial"
  71376. * Mainly use in serialization.
  71377. * @returns the class name
  71378. */
  71379. getClassName(): string;
  71380. /**
  71381. * Creates a sky material from parsed material data
  71382. * @param source defines the JSON representation of the material
  71383. * @param scene defines the hosting scene
  71384. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71385. * @returns a new sky material
  71386. */
  71387. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71388. }
  71389. }
  71390. declare module BABYLON {
  71391. /** @hidden */
  71392. export var terrainPixelShader: {
  71393. name: string;
  71394. shader: string;
  71395. };
  71396. }
  71397. declare module BABYLON {
  71398. /** @hidden */
  71399. export var terrainVertexShader: {
  71400. name: string;
  71401. shader: string;
  71402. };
  71403. }
  71404. declare module BABYLON {
  71405. export class TerrainMaterial extends BABYLON.PushMaterial {
  71406. private _mixTexture;
  71407. mixTexture: BABYLON.BaseTexture;
  71408. private _diffuseTexture1;
  71409. diffuseTexture1: BABYLON.Texture;
  71410. private _diffuseTexture2;
  71411. diffuseTexture2: BABYLON.Texture;
  71412. private _diffuseTexture3;
  71413. diffuseTexture3: BABYLON.Texture;
  71414. private _bumpTexture1;
  71415. bumpTexture1: BABYLON.Texture;
  71416. private _bumpTexture2;
  71417. bumpTexture2: BABYLON.Texture;
  71418. private _bumpTexture3;
  71419. bumpTexture3: BABYLON.Texture;
  71420. diffuseColor: BABYLON.Color3;
  71421. specularColor: BABYLON.Color3;
  71422. specularPower: number;
  71423. private _disableLighting;
  71424. disableLighting: boolean;
  71425. private _maxSimultaneousLights;
  71426. maxSimultaneousLights: number;
  71427. private _renderId;
  71428. constructor(name: string, scene: BABYLON.Scene);
  71429. needAlphaBlending(): boolean;
  71430. needAlphaTesting(): boolean;
  71431. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71432. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71433. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71434. getAnimatables(): BABYLON.IAnimatable[];
  71435. getActiveTextures(): BABYLON.BaseTexture[];
  71436. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71437. dispose(forceDisposeEffect?: boolean): void;
  71438. clone(name: string): TerrainMaterial;
  71439. serialize(): any;
  71440. getClassName(): string;
  71441. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71442. }
  71443. }
  71444. declare module BABYLON {
  71445. /** @hidden */
  71446. export var triplanarPixelShader: {
  71447. name: string;
  71448. shader: string;
  71449. };
  71450. }
  71451. declare module BABYLON {
  71452. /** @hidden */
  71453. export var triplanarVertexShader: {
  71454. name: string;
  71455. shader: string;
  71456. };
  71457. }
  71458. declare module BABYLON {
  71459. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71460. mixTexture: BABYLON.BaseTexture;
  71461. private _diffuseTextureX;
  71462. diffuseTextureX: BABYLON.BaseTexture;
  71463. private _diffuseTextureY;
  71464. diffuseTextureY: BABYLON.BaseTexture;
  71465. private _diffuseTextureZ;
  71466. diffuseTextureZ: BABYLON.BaseTexture;
  71467. private _normalTextureX;
  71468. normalTextureX: BABYLON.BaseTexture;
  71469. private _normalTextureY;
  71470. normalTextureY: BABYLON.BaseTexture;
  71471. private _normalTextureZ;
  71472. normalTextureZ: BABYLON.BaseTexture;
  71473. tileSize: number;
  71474. diffuseColor: BABYLON.Color3;
  71475. specularColor: BABYLON.Color3;
  71476. specularPower: number;
  71477. private _disableLighting;
  71478. disableLighting: boolean;
  71479. private _maxSimultaneousLights;
  71480. maxSimultaneousLights: number;
  71481. private _renderId;
  71482. constructor(name: string, scene: BABYLON.Scene);
  71483. needAlphaBlending(): boolean;
  71484. needAlphaTesting(): boolean;
  71485. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71486. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71487. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71488. getAnimatables(): BABYLON.IAnimatable[];
  71489. getActiveTextures(): BABYLON.BaseTexture[];
  71490. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71491. dispose(forceDisposeEffect?: boolean): void;
  71492. clone(name: string): TriPlanarMaterial;
  71493. serialize(): any;
  71494. getClassName(): string;
  71495. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71496. }
  71497. }
  71498. declare module BABYLON {
  71499. /** @hidden */
  71500. export var waterPixelShader: {
  71501. name: string;
  71502. shader: string;
  71503. };
  71504. }
  71505. declare module BABYLON {
  71506. /** @hidden */
  71507. export var waterVertexShader: {
  71508. name: string;
  71509. shader: string;
  71510. };
  71511. }
  71512. declare module BABYLON {
  71513. export class WaterMaterial extends BABYLON.PushMaterial {
  71514. renderTargetSize: BABYLON.Vector2;
  71515. private _bumpTexture;
  71516. bumpTexture: BABYLON.BaseTexture;
  71517. diffuseColor: BABYLON.Color3;
  71518. specularColor: BABYLON.Color3;
  71519. specularPower: number;
  71520. private _disableLighting;
  71521. disableLighting: boolean;
  71522. private _maxSimultaneousLights;
  71523. maxSimultaneousLights: number;
  71524. /**
  71525. * @param {number}: Represents the wind force
  71526. */
  71527. windForce: number;
  71528. /**
  71529. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71530. */
  71531. windDirection: BABYLON.Vector2;
  71532. /**
  71533. * @param {number}: Wave height, represents the height of the waves
  71534. */
  71535. waveHeight: number;
  71536. /**
  71537. * @param {number}: Bump height, represents the bump height related to the bump map
  71538. */
  71539. bumpHeight: number;
  71540. /**
  71541. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71542. */
  71543. private _bumpSuperimpose;
  71544. bumpSuperimpose: boolean;
  71545. /**
  71546. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71547. */
  71548. private _fresnelSeparate;
  71549. fresnelSeparate: boolean;
  71550. /**
  71551. * @param {boolean}: bump Waves modify the reflection.
  71552. */
  71553. private _bumpAffectsReflection;
  71554. bumpAffectsReflection: boolean;
  71555. /**
  71556. * @param {number}: The water color blended with the refraction (near)
  71557. */
  71558. waterColor: BABYLON.Color3;
  71559. /**
  71560. * @param {number}: The blend factor related to the water color
  71561. */
  71562. colorBlendFactor: number;
  71563. /**
  71564. * @param {number}: The water color blended with the reflection (far)
  71565. */
  71566. waterColor2: BABYLON.Color3;
  71567. /**
  71568. * @param {number}: The blend factor related to the water color (reflection, far)
  71569. */
  71570. colorBlendFactor2: number;
  71571. /**
  71572. * @param {number}: Represents the maximum length of a wave
  71573. */
  71574. waveLength: number;
  71575. /**
  71576. * @param {number}: Defines the waves speed
  71577. */
  71578. waveSpeed: number;
  71579. /**
  71580. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71581. * will avoid calculating useless pixels in the pixel shader of the water material.
  71582. */
  71583. disableClipPlane: boolean;
  71584. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71585. private _mesh;
  71586. private _refractionRTT;
  71587. private _reflectionRTT;
  71588. private _reflectionTransform;
  71589. private _lastTime;
  71590. private _lastDeltaTime;
  71591. private _renderId;
  71592. private _useLogarithmicDepth;
  71593. private _waitingRenderList;
  71594. private _imageProcessingConfiguration;
  71595. private _imageProcessingObserver;
  71596. /**
  71597. * Gets a boolean indicating that current material needs to register RTT
  71598. */
  71599. readonly hasRenderTargetTextures: boolean;
  71600. /**
  71601. * Constructor
  71602. */
  71603. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71604. useLogarithmicDepth: boolean;
  71605. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71606. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71607. addToRenderList(node: any): void;
  71608. enableRenderTargets(enable: boolean): void;
  71609. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71610. readonly renderTargetsEnabled: boolean;
  71611. needAlphaBlending(): boolean;
  71612. needAlphaTesting(): boolean;
  71613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71614. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71615. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71616. private _createRenderTargets;
  71617. getAnimatables(): BABYLON.IAnimatable[];
  71618. getActiveTextures(): BABYLON.BaseTexture[];
  71619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71620. dispose(forceDisposeEffect?: boolean): void;
  71621. clone(name: string): WaterMaterial;
  71622. serialize(): any;
  71623. getClassName(): string;
  71624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71625. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71626. }
  71627. }
  71628. declare module BABYLON {
  71629. /** @hidden */
  71630. export var asciiartPixelShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module BABYLON {
  71636. /**
  71637. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71638. *
  71639. * It basically takes care rendering the font front the given font size to a texture.
  71640. * This is used later on in the postprocess.
  71641. */
  71642. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71643. private _font;
  71644. private _text;
  71645. private _charSize;
  71646. /**
  71647. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71648. */
  71649. readonly charSize: number;
  71650. /**
  71651. * Create a new instance of the Ascii Art FontTexture class
  71652. * @param name the name of the texture
  71653. * @param font the font to use, use the W3C CSS notation
  71654. * @param text the caracter set to use in the rendering.
  71655. * @param scene the scene that owns the texture
  71656. */
  71657. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71658. /**
  71659. * Gets the max char width of a font.
  71660. * @param font the font to use, use the W3C CSS notation
  71661. * @return the max char width
  71662. */
  71663. private getFontWidth;
  71664. /**
  71665. * Gets the max char height of a font.
  71666. * @param font the font to use, use the W3C CSS notation
  71667. * @return the max char height
  71668. */
  71669. private getFontHeight;
  71670. /**
  71671. * Clones the current AsciiArtTexture.
  71672. * @return the clone of the texture.
  71673. */
  71674. clone(): AsciiArtFontTexture;
  71675. /**
  71676. * Parses a json object representing the texture and returns an instance of it.
  71677. * @param source the source JSON representation
  71678. * @param scene the scene to create the texture for
  71679. * @return the parsed texture
  71680. */
  71681. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71682. }
  71683. /**
  71684. * Option available in the Ascii Art Post Process.
  71685. */
  71686. export interface IAsciiArtPostProcessOptions {
  71687. /**
  71688. * The font to use following the w3c font definition.
  71689. */
  71690. font?: string;
  71691. /**
  71692. * The character set to use in the postprocess.
  71693. */
  71694. characterSet?: string;
  71695. /**
  71696. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71697. * This number is defined between 0 and 1;
  71698. */
  71699. mixToTile?: number;
  71700. /**
  71701. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71702. * This number is defined between 0 and 1;
  71703. */
  71704. mixToNormal?: number;
  71705. }
  71706. /**
  71707. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71708. *
  71709. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71710. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71711. */
  71712. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71713. /**
  71714. * The font texture used to render the char in the post process.
  71715. */
  71716. private _asciiArtFontTexture;
  71717. /**
  71718. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71719. * This number is defined between 0 and 1;
  71720. */
  71721. mixToTile: number;
  71722. /**
  71723. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71724. * This number is defined between 0 and 1;
  71725. */
  71726. mixToNormal: number;
  71727. /**
  71728. * Instantiates a new Ascii Art Post Process.
  71729. * @param name the name to give to the postprocess
  71730. * @camera the camera to apply the post process to.
  71731. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71732. */
  71733. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71734. }
  71735. }
  71736. declare module BABYLON {
  71737. /** @hidden */
  71738. export var digitalrainPixelShader: {
  71739. name: string;
  71740. shader: string;
  71741. };
  71742. }
  71743. declare module BABYLON {
  71744. /**
  71745. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71746. *
  71747. * It basically takes care rendering the font front the given font size to a texture.
  71748. * This is used later on in the postprocess.
  71749. */
  71750. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71751. private _font;
  71752. private _text;
  71753. private _charSize;
  71754. /**
  71755. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71756. */
  71757. readonly charSize: number;
  71758. /**
  71759. * Create a new instance of the Digital Rain FontTexture class
  71760. * @param name the name of the texture
  71761. * @param font the font to use, use the W3C CSS notation
  71762. * @param text the caracter set to use in the rendering.
  71763. * @param scene the scene that owns the texture
  71764. */
  71765. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71766. /**
  71767. * Gets the max char width of a font.
  71768. * @param font the font to use, use the W3C CSS notation
  71769. * @return the max char width
  71770. */
  71771. private getFontWidth;
  71772. /**
  71773. * Gets the max char height of a font.
  71774. * @param font the font to use, use the W3C CSS notation
  71775. * @return the max char height
  71776. */
  71777. private getFontHeight;
  71778. /**
  71779. * Clones the current DigitalRainFontTexture.
  71780. * @return the clone of the texture.
  71781. */
  71782. clone(): DigitalRainFontTexture;
  71783. /**
  71784. * Parses a json object representing the texture and returns an instance of it.
  71785. * @param source the source JSON representation
  71786. * @param scene the scene to create the texture for
  71787. * @return the parsed texture
  71788. */
  71789. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71790. }
  71791. /**
  71792. * Option available in the Digital Rain Post Process.
  71793. */
  71794. export interface IDigitalRainPostProcessOptions {
  71795. /**
  71796. * The font to use following the w3c font definition.
  71797. */
  71798. font?: string;
  71799. /**
  71800. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71801. * This number is defined between 0 and 1;
  71802. */
  71803. mixToTile?: number;
  71804. /**
  71805. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71806. * This number is defined between 0 and 1;
  71807. */
  71808. mixToNormal?: number;
  71809. }
  71810. /**
  71811. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71812. *
  71813. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71814. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71815. */
  71816. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71817. /**
  71818. * The font texture used to render the char in the post process.
  71819. */
  71820. private _digitalRainFontTexture;
  71821. /**
  71822. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71823. * This number is defined between 0 and 1;
  71824. */
  71825. mixToTile: number;
  71826. /**
  71827. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71828. * This number is defined between 0 and 1;
  71829. */
  71830. mixToNormal: number;
  71831. /**
  71832. * Instantiates a new Digital Rain Post Process.
  71833. * @param name the name to give to the postprocess
  71834. * @camera the camera to apply the post process to.
  71835. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71836. */
  71837. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71838. }
  71839. }
  71840. declare module BABYLON {
  71841. /** @hidden */
  71842. export var oceanPostProcessPixelShader: {
  71843. name: string;
  71844. shader: string;
  71845. };
  71846. }
  71847. declare module BABYLON {
  71848. /**
  71849. * Option available in the Ocean Post Process.
  71850. */
  71851. export interface IOceanPostProcessOptions {
  71852. /**
  71853. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71854. */
  71855. reflectionSize?: number | {
  71856. width: number;
  71857. height: number;
  71858. } | {
  71859. ratio: number;
  71860. };
  71861. /**
  71862. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71863. */
  71864. refractionSize?: number | {
  71865. width: number;
  71866. height: number;
  71867. } | {
  71868. ratio: number;
  71869. };
  71870. }
  71871. /**
  71872. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71873. *
  71874. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71875. * Example usage:
  71876. * var pp = new OceanPostProcess("myOcean", camera);
  71877. * pp.reflectionEnabled = true;
  71878. * pp.refractionEnabled = true;
  71879. */
  71880. export class OceanPostProcess extends BABYLON.PostProcess {
  71881. /**
  71882. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71883. */
  71884. /**
  71885. * Sets weither or not the real-time reflection is enabled on the ocean.
  71886. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71887. */
  71888. reflectionEnabled: boolean;
  71889. /**
  71890. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71891. */
  71892. /**
  71893. * Sets weither or not the real-time refraction is enabled on the ocean.
  71894. * Is set to true, the refraction render target texture will be used as refraction texture.
  71895. */
  71896. refractionEnabled: boolean;
  71897. /**
  71898. * Gets wether or not the post-processes is supported by the running hardware.
  71899. * This requires draw buffer supports.
  71900. */
  71901. readonly isSupported: boolean;
  71902. /**
  71903. * This is the reflection mirror texture used to display reflections on the ocean.
  71904. * By default, render list is empty.
  71905. */
  71906. reflectionTexture: BABYLON.MirrorTexture;
  71907. /**
  71908. * This is the refraction render target texture used to display refraction on the ocean.
  71909. * By default, render list is empty.
  71910. */
  71911. refractionTexture: BABYLON.RenderTargetTexture;
  71912. private _time;
  71913. private _cameraRotation;
  71914. private _cameraViewMatrix;
  71915. private _reflectionEnabled;
  71916. private _refractionEnabled;
  71917. private _geometryRenderer;
  71918. /**
  71919. * Instantiates a new Ocean Post Process.
  71920. * @param name the name to give to the postprocess.
  71921. * @camera the camera to apply the post process to.
  71922. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71923. */
  71924. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71925. /**
  71926. * Returns the appropriate defines according to the current configuration.
  71927. */
  71928. private _getDefines;
  71929. /**
  71930. * Computes the current camera rotation as the shader requires a camera rotation.
  71931. */
  71932. private _computeCameraRotation;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /** @hidden */
  71937. export var brickProceduralTexturePixelShader: {
  71938. name: string;
  71939. shader: string;
  71940. };
  71941. }
  71942. declare module BABYLON {
  71943. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71944. private _numberOfBricksHeight;
  71945. private _numberOfBricksWidth;
  71946. private _jointColor;
  71947. private _brickColor;
  71948. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71949. updateShaderUniforms(): void;
  71950. numberOfBricksHeight: number;
  71951. numberOfBricksWidth: number;
  71952. jointColor: BABYLON.Color3;
  71953. brickColor: BABYLON.Color3;
  71954. /**
  71955. * Serializes this brick procedural texture
  71956. * @returns a serialized brick procedural texture object
  71957. */
  71958. serialize(): any;
  71959. /**
  71960. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71961. * @param parsedTexture defines parsed texture data
  71962. * @param scene defines the current scene
  71963. * @param rootUrl defines the root URL containing brick procedural texture information
  71964. * @returns a parsed Brick Procedural BABYLON.Texture
  71965. */
  71966. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71967. }
  71968. }
  71969. declare module BABYLON {
  71970. /** @hidden */
  71971. export var cloudProceduralTexturePixelShader: {
  71972. name: string;
  71973. shader: string;
  71974. };
  71975. }
  71976. declare module BABYLON {
  71977. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71978. private _skyColor;
  71979. private _cloudColor;
  71980. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71981. updateShaderUniforms(): void;
  71982. skyColor: BABYLON.Color4;
  71983. cloudColor: BABYLON.Color4;
  71984. /**
  71985. * Serializes this cloud procedural texture
  71986. * @returns a serialized cloud procedural texture object
  71987. */
  71988. serialize(): any;
  71989. /**
  71990. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71991. * @param parsedTexture defines parsed texture data
  71992. * @param scene defines the current scene
  71993. * @param rootUrl defines the root URL containing cloud procedural texture information
  71994. * @returns a parsed Cloud Procedural BABYLON.Texture
  71995. */
  71996. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71997. }
  71998. }
  71999. declare module BABYLON {
  72000. /** @hidden */
  72001. export var fireProceduralTexturePixelShader: {
  72002. name: string;
  72003. shader: string;
  72004. };
  72005. }
  72006. declare module BABYLON {
  72007. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72008. private _time;
  72009. private _speed;
  72010. private _autoGenerateTime;
  72011. private _fireColors;
  72012. private _alphaThreshold;
  72013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72014. updateShaderUniforms(): void;
  72015. render(useCameraPostProcess?: boolean): void;
  72016. static readonly PurpleFireColors: BABYLON.Color3[];
  72017. static readonly GreenFireColors: BABYLON.Color3[];
  72018. static readonly RedFireColors: BABYLON.Color3[];
  72019. static readonly BlueFireColors: BABYLON.Color3[];
  72020. autoGenerateTime: boolean;
  72021. fireColors: BABYLON.Color3[];
  72022. time: number;
  72023. speed: BABYLON.Vector2;
  72024. alphaThreshold: number;
  72025. /**
  72026. * Serializes this fire procedural texture
  72027. * @returns a serialized fire procedural texture object
  72028. */
  72029. serialize(): any;
  72030. /**
  72031. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72032. * @param parsedTexture defines parsed texture data
  72033. * @param scene defines the current scene
  72034. * @param rootUrl defines the root URL containing fire procedural texture information
  72035. * @returns a parsed Fire Procedural BABYLON.Texture
  72036. */
  72037. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72038. }
  72039. }
  72040. declare module BABYLON {
  72041. /** @hidden */
  72042. export var grassProceduralTexturePixelShader: {
  72043. name: string;
  72044. shader: string;
  72045. };
  72046. }
  72047. declare module BABYLON {
  72048. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72049. private _grassColors;
  72050. private _groundColor;
  72051. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72052. updateShaderUniforms(): void;
  72053. grassColors: BABYLON.Color3[];
  72054. groundColor: BABYLON.Color3;
  72055. /**
  72056. * Serializes this grass procedural texture
  72057. * @returns a serialized grass procedural texture object
  72058. */
  72059. serialize(): any;
  72060. /**
  72061. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72062. * @param parsedTexture defines parsed texture data
  72063. * @param scene defines the current scene
  72064. * @param rootUrl defines the root URL containing grass procedural texture information
  72065. * @returns a parsed Grass Procedural BABYLON.Texture
  72066. */
  72067. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72068. }
  72069. }
  72070. declare module BABYLON {
  72071. /** @hidden */
  72072. export var marbleProceduralTexturePixelShader: {
  72073. name: string;
  72074. shader: string;
  72075. };
  72076. }
  72077. declare module BABYLON {
  72078. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72079. private _numberOfTilesHeight;
  72080. private _numberOfTilesWidth;
  72081. private _amplitude;
  72082. private _jointColor;
  72083. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72084. updateShaderUniforms(): void;
  72085. numberOfTilesHeight: number;
  72086. amplitude: number;
  72087. numberOfTilesWidth: number;
  72088. jointColor: BABYLON.Color3;
  72089. /**
  72090. * Serializes this marble procedural texture
  72091. * @returns a serialized marble procedural texture object
  72092. */
  72093. serialize(): any;
  72094. /**
  72095. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72096. * @param parsedTexture defines parsed texture data
  72097. * @param scene defines the current scene
  72098. * @param rootUrl defines the root URL containing marble procedural texture information
  72099. * @returns a parsed Marble Procedural BABYLON.Texture
  72100. */
  72101. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72102. }
  72103. }
  72104. declare module BABYLON {
  72105. /** @hidden */
  72106. export var normalMapProceduralTexturePixelShader: {
  72107. name: string;
  72108. shader: string;
  72109. };
  72110. }
  72111. declare module BABYLON {
  72112. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72113. private _baseTexture;
  72114. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72115. updateShaderUniforms(): void;
  72116. render(useCameraPostProcess?: boolean): void;
  72117. resize(size: any, generateMipMaps: any): void;
  72118. baseTexture: BABYLON.Texture;
  72119. /**
  72120. * Serializes this normal map procedural texture
  72121. * @returns a serialized normal map procedural texture object
  72122. */
  72123. serialize(): any;
  72124. /**
  72125. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72126. * @param parsedTexture defines parsed texture data
  72127. * @param scene defines the current scene
  72128. * @param rootUrl defines the root URL containing normal map procedural texture information
  72129. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72130. */
  72131. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72132. }
  72133. }
  72134. declare module BABYLON {
  72135. /** @hidden */
  72136. export var perlinNoiseProceduralTexturePixelShader: {
  72137. name: string;
  72138. shader: string;
  72139. };
  72140. }
  72141. declare module BABYLON {
  72142. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72143. time: number;
  72144. timeScale: number;
  72145. translationSpeed: number;
  72146. private _currentTranslation;
  72147. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72148. updateShaderUniforms(): void;
  72149. render(useCameraPostProcess?: boolean): void;
  72150. resize(size: any, generateMipMaps: any): void;
  72151. /**
  72152. * Serializes this perlin noise procedural texture
  72153. * @returns a serialized perlin noise procedural texture object
  72154. */
  72155. serialize(): any;
  72156. /**
  72157. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72158. * @param parsedTexture defines parsed texture data
  72159. * @param scene defines the current scene
  72160. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72161. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72162. */
  72163. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72164. }
  72165. }
  72166. declare module BABYLON {
  72167. /** @hidden */
  72168. export var roadProceduralTexturePixelShader: {
  72169. name: string;
  72170. shader: string;
  72171. };
  72172. }
  72173. declare module BABYLON {
  72174. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72175. private _roadColor;
  72176. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72177. updateShaderUniforms(): void;
  72178. roadColor: BABYLON.Color3;
  72179. /**
  72180. * Serializes this road procedural texture
  72181. * @returns a serialized road procedural texture object
  72182. */
  72183. serialize(): any;
  72184. /**
  72185. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72186. * @param parsedTexture defines parsed texture data
  72187. * @param scene defines the current scene
  72188. * @param rootUrl defines the root URL containing road procedural texture information
  72189. * @returns a parsed Road Procedural BABYLON.Texture
  72190. */
  72191. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72192. }
  72193. }
  72194. declare module BABYLON {
  72195. /** @hidden */
  72196. export var starfieldProceduralTexturePixelShader: {
  72197. name: string;
  72198. shader: string;
  72199. };
  72200. }
  72201. declare module BABYLON {
  72202. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72203. private _time;
  72204. private _alpha;
  72205. private _beta;
  72206. private _zoom;
  72207. private _formuparam;
  72208. private _stepsize;
  72209. private _tile;
  72210. private _brightness;
  72211. private _darkmatter;
  72212. private _distfading;
  72213. private _saturation;
  72214. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72215. updateShaderUniforms(): void;
  72216. time: number;
  72217. alpha: number;
  72218. beta: number;
  72219. formuparam: number;
  72220. stepsize: number;
  72221. zoom: number;
  72222. tile: number;
  72223. brightness: number;
  72224. darkmatter: number;
  72225. distfading: number;
  72226. saturation: number;
  72227. /**
  72228. * Serializes this starfield procedural texture
  72229. * @returns a serialized starfield procedural texture object
  72230. */
  72231. serialize(): any;
  72232. /**
  72233. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72234. * @param parsedTexture defines parsed texture data
  72235. * @param scene defines the current scene
  72236. * @param rootUrl defines the root URL containing startfield procedural texture information
  72237. * @returns a parsed Starfield Procedural BABYLON.Texture
  72238. */
  72239. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72240. }
  72241. }
  72242. declare module BABYLON {
  72243. /** @hidden */
  72244. export var woodProceduralTexturePixelShader: {
  72245. name: string;
  72246. shader: string;
  72247. };
  72248. }
  72249. declare module BABYLON {
  72250. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72251. private _ampScale;
  72252. private _woodColor;
  72253. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72254. updateShaderUniforms(): void;
  72255. ampScale: number;
  72256. woodColor: BABYLON.Color3;
  72257. /**
  72258. * Serializes this wood procedural texture
  72259. * @returns a serialized wood procedural texture object
  72260. */
  72261. serialize(): any;
  72262. /**
  72263. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72264. * @param parsedTexture defines parsed texture data
  72265. * @param scene defines the current scene
  72266. * @param rootUrl defines the root URL containing wood procedural texture information
  72267. * @returns a parsed Wood Procedural BABYLON.Texture
  72268. */
  72269. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72270. }
  72271. }